# HG changeset patch # User Jeff Hammel # Date 1606252230 28800 # Node ID c280a43ac4423df776dd240d7cc1b6d431d871d0 # Parent 1c6dbeb4ddab3cf06f09c578177265293b362da4 py3 diff -r 1c6dbeb4ddab -r c280a43ac442 toolbox/model.py --- a/toolbox/model.py Tue Nov 24 13:07:43 2020 -0800 +++ b/toolbox/model.py Tue Nov 24 13:10:30 2020 -0800 @@ -246,12 +246,11 @@ filename = filename.encode('ascii', 'ignore') filename = os.path.join(self.directory, filename) try: - f = file(filename, 'w') - except Exception, e: - print filename, repr(filename) + with open(filename, 'w') as f: + f.write(json.dumps(project)) + except Exception as e: + print('{} {}'.format(filename, repr(filename))) raise - f.write(json.dumps(project)) - f.close() class ElasticSearchCache(MemoryCache): @@ -402,7 +401,7 @@ # process global options if options.list_models: for name in sorted(models.keys()): - print name # could conceivably print docstring + print(name) parser.exit() if options.list_args: if not options.list_args in models: @@ -414,9 +413,9 @@ for index, value in enumerate(reversed(argspec.defaults), 1): defaults[-index][-1] = value defaults = [[i,j] for i, j in defaults if i != 'fields'] - print '%s arguments:' % options.list_args + print('%s arguments:' % options.list_args) for arg, value in defaults: - print ' -%s %s' % (arg, value or '') + print(' -%s %s' % (arg, value or '')) parser.exit() # parse models and their ctor args