summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorKaleb S. KEITHLEY <kkeithle@redhat.com>2018-07-02 08:18:54 -0400
committerAmar Tumballi <amarts@redhat.com>2018-07-09 03:38:36 +0000
commit55d1b0531a0b322a1b851fc921fd6fdf25d26331 (patch)
treef3d8c84e4d27fb8894a9c921a9a4ed06257cf80e /libglusterfs
parentdab12ce093628860bf43c3e0c7eaf9099cf7a78f (diff)
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/, and https://review.gluster.org/#/c/20364/ Fixes glupy.py python2isms, iteritems -> items, and some overlooked print() in georep/peer_mountbroker.in 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: Idda031c1ec975417c79323aea33e7b694e752b2a updates: #411 Signed-off-by: Kaleb S. KEITHLEY <kkeithle@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/gen-defaults.py10
-rwxr-xr-xlibglusterfs/src/generator.py209
2 files changed, 109 insertions, 110 deletions
diff --git a/libglusterfs/src/gen-defaults.py b/libglusterfs/src/gen-defaults.py
index ccd5f5fc6c9..0c96fd0c176 100644
--- a/libglusterfs/src/gen-defaults.py
+++ b/libglusterfs/src/gen-defaults.py
@@ -61,15 +61,15 @@ default_@NAME@ (
"""
def gen_defaults ():
- for name in ops.iterkeys():
+ for name in list(ops.keys()):
print(generate(FAILURE_CBK_TEMPLATE, name, cbk_subs))
- for name in ops.iterkeys():
+ for name in list(ops.keys()):
print(generate(CBK_RESUME_TEMPLATE, name, cbk_subs))
- for name in ops.iterkeys():
+ for name in list(ops.keys()):
print(generate(CBK_TEMPLATE, name, cbk_subs))
- for name in ops.iterkeys():
+ for name in list(ops.keys()):
print(generate(RESUME_TEMPLATE, name, fop_subs))
- for name in ops.iterkeys():
+ for name in list(ops.keys()):
print(generate(FOP_TEMPLATE, name, fop_subs))
for l in open(sys.argv[1], 'r').readlines():
diff --git a/libglusterfs/src/generator.py b/libglusterfs/src/generator.py
index 3b7df986f1f..64db4e8c479 100755
--- a/libglusterfs/src/generator.py
+++ b/libglusterfs/src/generator.py
@@ -543,170 +543,170 @@ ops['getspec'] = (
)
ops['lease'] = (
- ('fop-arg', 'loc', 'loc_t *'),
- ('fop-arg', 'lease', 'struct gf_lease *'),
- ('fop-arg', 'xdata', 'dict_t *'),
- ('cbk-arg', 'lease', 'struct gf_lease *'),
- ('cbk-arg', 'xdata', 'dict_t *'),
+ ('fop-arg', 'loc', 'loc_t *'),
+ ('fop-arg', 'lease', 'struct gf_lease *'),
+ ('fop-arg', 'xdata', 'dict_t *'),
+ ('cbk-arg', 'lease', 'struct gf_lease *'),
+ ('cbk-arg', 'xdata', 'dict_t *'),
)
ops['getactivelk'] = (
- ('fop-arg', 'loc', 'loc_t *'),
- ('fop-arg', 'xdata', 'dict_t *'),
- ('cbk-arg', 'locklist', 'lock_migration_info_t *'),
- ('cbk-arg', 'xdata', 'dict_t *'),
+ ('fop-arg', 'loc', 'loc_t *'),
+ ('fop-arg', 'xdata', 'dict_t *'),
+ ('cbk-arg', 'locklist', 'lock_migration_info_t *'),
+ ('cbk-arg', 'xdata', 'dict_t *'),
)
ops['setactivelk'] = (
- ('fop-arg', 'loc', 'loc_t *'),
- ('fop-arg', 'locklist', 'lock_migration_info_t *'),
- ('fop-arg', 'xdata', 'dict_t *'),
- ('cbk-arg', 'xdata', 'dict_t *'),
+ ('fop-arg', 'loc', 'loc_t *'),
+ ('fop-arg', 'locklist', 'lock_migration_info_t *'),
+ ('fop-arg', 'xdata', 'dict_t *'),
+ ('cbk-arg', 'xdata', 'dict_t *'),
)
ops['put'] = (
- ('fop-arg', 'loc', 'loc_t *', 'loc'),
- ('fop-arg', 'mode', 'mode_t', 'mode'),
- ('fop-arg', 'umask', 'mode_t', 'umask'),
- ('fop-arg', 'flags', 'uint32_t', 'flags'),
- ('fop-arg', 'vector', 'struct iovec *', 'vector'),
- ('fop-arg', 'count', 'int32_t'),
- ('fop-arg', 'off', 'off_t', 'offset'),
- ('fop-arg', 'iobref', 'struct iobref *'),
- ('fop-arg', 'dict', 'dict_t *', 'xattr'),
- ('fop-arg', 'xdata', 'dict_t *', 'xdata'),
- ('cbk-arg', 'inode', 'inode_t *'),
- ('cbk-arg', 'buf', 'struct iatt *'),
- ('cbk-arg', 'preparent', 'struct iatt *'),
- ('cbk-arg', 'postparent', 'struct iatt *'),
- ('cbk-arg', 'xdata', 'dict_t *'),
+ ('fop-arg', 'loc', 'loc_t *', 'loc'),
+ ('fop-arg', 'mode', 'mode_t', 'mode'),
+ ('fop-arg', 'umask', 'mode_t', 'umask'),
+ ('fop-arg', 'flags', 'uint32_t', 'flags'),
+ ('fop-arg', 'vector', 'struct iovec *', 'vector'),
+ ('fop-arg', 'count', 'int32_t'),
+ ('fop-arg', 'off', 'off_t', 'offset'),
+ ('fop-arg', 'iobref', 'struct iobref *'),
+ ('fop-arg', 'dict', 'dict_t *', 'xattr'),
+ ('fop-arg', 'xdata', 'dict_t *', 'xdata'),
+ ('cbk-arg', 'inode', 'inode_t *'),
+ ('cbk-arg', 'buf', 'struct iatt *'),
+ ('cbk-arg', 'preparent', 'struct iatt *'),
+ ('cbk-arg', 'postparent', 'struct iatt *'),
+ ('cbk-arg', 'xdata', 'dict_t *'),
)
ops['icreate'] = (
- ('fop-arg', 'loc', 'loc_t *'),
- ('fop-arg', 'mode', 'mode_t'),
- ('fop-arg', 'xdata', 'dict_t *'),
- ('cbk-arg', 'inode', 'inode_t *'),
- ('cbk-arg', 'buf', 'struct iatt *'),
- ('cbk-arg', 'xdata', 'dict_t *'),
+ ('fop-arg', 'loc', 'loc_t *'),
+ ('fop-arg', 'mode', 'mode_t'),
+ ('fop-arg', 'xdata', 'dict_t *'),
+ ('cbk-arg', 'inode', 'inode_t *'),
+ ('cbk-arg', 'buf', 'struct iatt *'),
+ ('cbk-arg', 'xdata', 'dict_t *'),
)
ops['namelink'] = (
- ('fop-arg', 'loc', 'loc_t *'),
- ('fop-arg', 'xdata', 'dict_t *'),
- ('cbk-arg', 'prebuf', 'struct iatt *'),
- ('cbk-arg', 'postbuf', 'struct iatt *'),
- ('cbk-arg', 'xdata', 'dict_t *'),
+ ('fop-arg', 'loc', 'loc_t *'),
+ ('fop-arg', 'xdata', 'dict_t *'),
+ ('cbk-arg', 'prebuf', 'struct iatt *'),
+ ('cbk-arg', 'postbuf', 'struct iatt *'),
+ ('cbk-arg', 'xdata', 'dict_t *'),
)
#####################################################################
xlator_cbks['forget'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'inode', 'inode_t *'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'inode', 'inode_t *'),
('ret-val', 'int32_t', '0'),
)
xlator_cbks['release'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'fd', 'fd_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'fd', 'fd_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_cbks['releasedir'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'fd', 'fd_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'fd', 'fd_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_cbks['invalidate'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'inode', 'inode_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'inode', 'inode_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_cbks['client_destroy'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'client', 'client_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'client', 'client_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_cbks['client_disconnect'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'client', 'client_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'client', 'client_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_cbks['ictxmerge'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'fd', 'fd_t *'),
- ('fn-arg', 'inode', 'inode_t *'),
- ('fn-arg', 'linked_inode', 'inode_t *'),
- ('ret-val', 'void', ''),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'fd', 'fd_t *'),
+ ('fn-arg', 'inode', 'inode_t *'),
+ ('fn-arg', 'linked_inode', 'inode_t *'),
+ ('ret-val', 'void', ''),
)
#####################################################################
xlator_dumpops['priv'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['inode'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['fd'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['inodectx'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'ino', 'inode_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'ino', 'inode_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['fdctx'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'fd', 'fd_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'fd', 'fd_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['priv_to_dict'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'dict', 'dict_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'dict', 'dict_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['inode_to_dict'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'dict', 'dict_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'dict', 'dict_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['fd_to_dict'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'dict', 'dict_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'dict', 'dict_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['inodectx_to_dict'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'ino', 'inode_t *'),
- ('fn-arg', 'dict', 'dict_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'ino', 'inode_t *'),
+ ('fn-arg', 'dict', 'dict_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['fdctx_to_dict'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('fn-arg', 'fd', 'fd_t *'),
- ('fn-arg', 'dict', 'dict_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('fn-arg', 'fd', 'fd_t *'),
+ ('fn-arg', 'dict', 'dict_t *'),
+ ('ret-val', 'int32_t', '0'),
)
xlator_dumpops['history'] = (
- ('fn-arg', 'this', 'xlator_t *'),
- ('ret-val', 'int32_t', '0'),
+ ('fn-arg', 'this', 'xlator_t *'),
+ ('ret-val', 'int32_t', '0'),
)
def get_error_arg (type_str):
@@ -716,18 +716,17 @@ def get_error_arg (type_str):
def get_subs (names, types, cbktypes=None):
sdict = {}
- sdict["@SHORT_ARGS@"] = string.join(names, ", ")
+ sdict["@SHORT_ARGS@"] = ', '.join(names)
# 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.
- sdict["@LONG_ARGS@"] = string.join(as_strings, ",\n\t")
+ sdict["@LONG_ARGS@"] = ',\n\t'.join(as_strings)
# So much more readable than string.join(map(string.join,zip(...))))
- sdict["@ERROR_ARGS@"] = string.join(list(map(get_error_arg, types)), ", ")
- if cbktypes is not None:
- sdict["@CBK_ERROR_ARGS@"] = string.join(list(map(
- get_error_arg, cbktypes)), ", ")
+ sdict["@ERROR_ARGS@"] = ', '.join(list(map(get_error_arg, types)))
+ if cbktypes is not None:
+ sdict["@CBK_ERROR_ARGS@"] = ', '.join(list(map(get_error_arg, cbktypes)))
return sdict
def generate (tmpl, name, subs):
@@ -735,24 +734,24 @@ def generate (tmpl, name, subs):
if name == "writev":
# More spurious inconsistency.
text = text.replace("@UPNAME@", "WRITE")
- elif name == "readv":
- text = text.replace("@UPNAME@", "READ")
+ elif name == "readv":
+ text = text.replace("@UPNAME@", "READ")
else:
text = text.replace("@UPNAME@", name.upper())
- for old, new in subs[name].iteritems():
+ for old, new in subs[name].items():
text = text.replace(old, new)
# TBD: reindent/reformat the result for maximum readability.
- return text
+ return text
fop_subs = {}
cbk_subs = {}
-for name, args in ops.iteritems():
+for name, args in ops.items():
# Create the necessary substitution strings for fops.
arg_names = [ a[1] for a in args if a[0] == 'fop-arg']
arg_types = [ a[2] for a in args if a[0] == 'fop-arg']
- cbk_types = [ a[2] for a in args if a[0] == 'cbk-arg']
+ cbk_types = [ a[2] for a in args if a[0] == 'cbk-arg']
fop_subs[name] = get_subs(arg_names, arg_types, cbk_types)
# Same thing for callbacks.