X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=clientbin%2FgetNodes.py;h=69abf484d5f410a955d74063a7754b1f5e5bc23d;hb=HEAD;hp=89689a5b8a020d4f2a0c3eb65ba0e23566e18250;hpb=8e558be62ca1e048cedb76d6036d1acbfa827bd4;p=sfa.git diff --git a/clientbin/getNodes.py b/clientbin/getNodes.py index 89689a5b..69abf484 100644 --- a/clientbin/getNodes.py +++ b/clientbin/getNodes.py @@ -1,13 +1,10 @@ -#!/usr/bin/python +#!/usr/bin/env python3 import sys import os from optparse import OptionParser from pprint import pprint -from sfa.util.py23 import StringType - - def create_parser(): command = sys.argv[0] argv = sys.argv[1:] @@ -36,10 +33,10 @@ def print_dict(rdict, options, counter=1): if not isinstance(rdict, dict): raise "%s not a dict" % rdict - for (key, value) in rdict.iteritems(): - if isinstance(value, StringType): + for (key, value) in rdict.items(): + if isinstance(value, str): if (attributes and key in attributes) or not attributes: - print tab * counter + "%s: %s" % (key, value) + print(tab * counter + "%s: %s" % (key, value)) elif isinstance(value, list): for listitem in value: if isinstance(listitem, dict): @@ -50,12 +47,12 @@ def print_dict(rdict, options, counter=1): if counter == 1 or print_children: for (key, listitem) in lists: if isinstance(listitem, dict): - print tab * (counter - 1) + key + print(tab * (counter - 1) + key) print_dict(listitem, options, counter + 1) elif not attributes or (attributes and 'children' in attributes): keys = set([key for (key, listitem) in lists]) if keys: - print tab * (counter) + "(children: %s)" % (",".join(keys)) + print(tab * (counter) + "(children: %s)" % (",".join(keys))) # @@ -67,14 +64,14 @@ def main(): parser = create_parser() (options, args) = parser.parse_args() if not options.infile: - print "RSpec file not specified" + print("RSpec file not specified") return rspec = RSpec() try: rspec.parseFile(options.infile) except: - print "Error reading rspec file" + print("Error reading rspec file") if options.tag: tag_name = options.tag @@ -92,4 +89,4 @@ if __name__ == '__main__': main() except Exception as e: raise - print e + print(e)