core/various: python3 compat, prepare for python2 -> python3
see https://review.gluster.org/#/c/19788/, https://review.gluster.org/#/c/19871/, https://review.gluster.org/#/c/19952/, https://review.gluster.org/#/c/20104/, https://review.gluster.org/#/c/20162/, https://review.gluster.org/#/c/20185/, https://review.gluster.org/#/c/20207/, https://review.gluster.org/#/c/20227/, https://review.gluster.org/#/c/20307/, https://review.gluster.org/#/c/20320/, https://review.gluster.org/#/c/20332/, https://review.gluster.org/#/c/20364/, and https://review.gluster.org/#/c/20441/ Fixes some overlooked string.join()s: + AFAICT extras/profiler/glusterfs-profiler, extras/prot_filter.py, extras/rebalance.py, and extras/volfilter.py would only manifest at runtime. + xlators/experimental/fdl/src/gen_recon.py is a build-time error when using python3 during the build, thus was not noticed previously when building with python2. + extras/create_new_xlator/generate_xlator.py seems to be example code and does not affect the build or runtime AFAICT Note: Fedora packaging guidelines and SUSE rpmlint require explicit shebangs; popular practices like #!/usr/bin/env python and #!/usr/bin/python are not allowed; they must be #!/usr/bin/python2 or #!/usr/bin/python3 Note: Selected small fixes from 2to3 utility. Specifically apply, basestring, funcattrs, has_key, idioms, map, numliterals, raise, set_literal, types, urllib, and zip have already been applied. Also version agnostic imports for urllib, cpickle, socketserver, _thread, queue, etc., suggested by Aravinda in https://review.gluster.org/#/c/19767/1 Note: these 2to3 fixes report no changes are necessary: asserts, buffer, exec, execfile, exitfunc, filter, getcwdu, imports2, input, intern, itertools, metaclass, methodattrs, ne, next, nonzero, operator, paren, raw_input, reduce, reload, renames, repr, standarderror, sys_exc, throw, tuple_params, xreadlines. Change-Id: Ia1fe2958d136f4303e30f7e7e86b6fe7d7b52c81 updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
This commit is contained in:
parent
b32ad78516
commit
970ea7a919
@ -38,9 +38,9 @@ def get_param(names, types):
|
||||
# Convert two separate tuples to one of (name, type) sub-tuples.
|
||||
as_tuples = list(zip(types, names))
|
||||
# Convert each sub-tuple into a "type name" string.
|
||||
as_strings = list(map(string.join, as_tuples))
|
||||
as_strings = [' '.join(item) for item in as_tuples]
|
||||
# Join all of those into one big string.
|
||||
return string.join(as_strings, ",\n\t")
|
||||
return ',\n\t'.join(as_strings)
|
||||
|
||||
|
||||
def generate(tmpl, name, table):
|
||||
@ -56,16 +56,16 @@ def generate(tmpl, name, table):
|
||||
sdict = {}
|
||||
#Parameters are (t1, var1), (t2, var2)...
|
||||
#Args are (var1, var2,...)
|
||||
sdict["@WIND_ARGS@"] = string.join(w_arg_names, ", ")
|
||||
sdict["@UNWIND_ARGS@"] = string.join(u_arg_names, ", ")
|
||||
sdict["@ERROR_ARGS@"] = string.join(list(map(get_error_arg, u_arg_types)), ", ")
|
||||
sdict["@WIND_ARGS@"] = ', '.join(w_arg_names)
|
||||
sdict["@UNWIND_ARGS@"] = ', '.join(u_arg_names)
|
||||
sdict["@ERROR_ARGS@"] = ', '.join(list(map(get_error_arg, u_arg_types)))
|
||||
sdict["@WIND_PARAMS@"] = get_param(w_arg_names, w_arg_types)
|
||||
sdict["@UNWIND_PARAMS@"] = get_param(u_arg_names, u_arg_types)
|
||||
sdict["@FUNC_PARAMS@"] = get_param(fn_arg_names, fn_arg_types)
|
||||
sdict["@NAME@"] = name
|
||||
sdict["@FOP_PREFIX@"] = fop_prefix
|
||||
sdict["@RET_TYPE@"] = string.join(ret_type, "")
|
||||
sdict["@RET_VAR@"] = string.join(ret_var, "")
|
||||
sdict["@RET_TYPE@"] = ''.join(ret_type)
|
||||
sdict["@RET_VAR@"] = ''.join(ret_var)
|
||||
|
||||
for old, new in sdict.items():
|
||||
tmpl = tmpl.replace(old, new)
|
||||
|
@ -291,7 +291,7 @@ class Texttable:
|
||||
s = "%s%s%s" % (horiz, [horiz, self._char_corner][self._has_vlines()],
|
||||
horiz)
|
||||
# build the line
|
||||
l = string.join([horiz*n for n in self._width], s)
|
||||
l = s.join([horiz*n for n in self._width])
|
||||
# add border if needed
|
||||
if self._has_border():
|
||||
l = "%s%s%s%s%s\n" % (self._char_corner, horiz, l, horiz,
|
||||
|
@ -67,7 +67,7 @@ def load (path):
|
||||
xlator.xl_type = text[1]
|
||||
continue
|
||||
if text[0] == "option":
|
||||
xlator.opts[text[1]] = string.join(text[2:])
|
||||
xlator.opts[text[1]] = ''.join(text[2:])
|
||||
continue
|
||||
if text[0] == "subvolumes":
|
||||
for sv in text[1:]:
|
||||
@ -94,8 +94,7 @@ def generate (graph, last, stream=sys.stdout):
|
||||
for k, v in last.opts.items():
|
||||
print(" option %s %s" % (k, v), file=stream)
|
||||
if last.subvols:
|
||||
print(" subvolumes %s" % string.join(
|
||||
[ sv.name for sv in last.subvols ]), file=stream)
|
||||
print(" subvolumes %s" % ''.join([ sv.name for sv in last.subvols ]), file=stream)
|
||||
print("end-volume", file=stream)
|
||||
|
||||
def push_filter (graph, old_xl, filt_type, opts={}):
|
||||
|
@ -47,12 +47,12 @@ def generate_stanza (vf, all_xlators, cur_subvol):
|
||||
for sv in cur_subvol.subvols:
|
||||
generate_stanza(vf, all_xlators, sv)
|
||||
sv_list.append(sv.name)
|
||||
vf.write("volume %s\n"%cur_subvol.name)
|
||||
vf.write(" type %s\n"%cur_subvol.type)
|
||||
vf.write("volume %s\n" % cur_subvol.name)
|
||||
vf.write(" type %s\n" % cur_subvol.type)
|
||||
for kvpair in cur_subvol.opts.items():
|
||||
vf.write(" option %s %s\n"%kvpair)
|
||||
vf.write(" option %s %s\n" % kvpair)
|
||||
if sv_list:
|
||||
vf.write(" subvolumes %s\n"%string.join(sv_list))
|
||||
vf.write(" subvolumes %s\n" % ''.join(sv_list))
|
||||
vf.write("end-volume\n\n")
|
||||
|
||||
|
||||
|
@ -108,7 +108,7 @@ def load (path):
|
||||
xlator.type = text[1]
|
||||
continue
|
||||
if text[0] == "option":
|
||||
xlator.opts[text[1]] = string.join(text[2:])
|
||||
xlator.opts[text[1]] = ''.join(text[2:])
|
||||
continue
|
||||
if text[0] == "subvolumes":
|
||||
for sv in text[1:]:
|
||||
@ -135,7 +135,7 @@ def generate (graph, last, stream=sys.stdout):
|
||||
for k, v in last.opts.items():
|
||||
print(" option %s %s" % (k, v), file=stream)
|
||||
if last.subvols:
|
||||
print(" subvolumes %s" % string.join(
|
||||
print(" subvolumes %s" % ''.join(
|
||||
[ sv.name for sv in last.subvols ]), file=stream)
|
||||
print("end-volume", file=stream)
|
||||
|
||||
|
@ -151,7 +151,7 @@ def get_special_subs (name, args, fop_type):
|
||||
elif name == 'fxattrop':
|
||||
s_args_str = 'fd, flags, dict, xdata, NULL'
|
||||
else:
|
||||
s_args_str = string.join (s_args, ", ")
|
||||
s_args_str = ', '.join(s_args)
|
||||
return code, links, s_args_str, cleanups
|
||||
|
||||
# TBD: probably need to generate type-specific cleanup code as well - e.g.
|
||||
|
Loading…
x
Reference in New Issue
Block a user