Mercurial > hg > toolbox
changeset 12:c280a43ac442
py3
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Tue, 24 Nov 2020 13:10:30 -0800 |
parents | 1c6dbeb4ddab |
children | 2d05ad362637 |
files | toolbox/model.py |
diffstat | 1 files changed, 7 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- 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