Mercurial > p > roundup > code
diff tools/migrate-queries.py @ 5376:64b05e24dbd8
Python 3 preparation: convert print to a function.
Tool-assisted patch. It is possible that some "from __future__ import
print_function" are not in fact needed, if a file only uses print()
with a single string as an argument and so would work fine in Python 2
without that import.
| author | Joseph Myers <jsm@polyomino.org.uk> |
|---|---|
| date | Tue, 24 Jul 2018 09:54:52 +0000 |
| parents | 6e9b9743de89 |
| children | fed0f839c260 |
line wrap: on
line diff
--- a/tools/migrate-queries.py Sat Jul 21 23:07:16 2018 +1000 +++ b/tools/migrate-queries.py Tue Jul 24 09:54:52 2018 +0000 @@ -7,13 +7,14 @@ leading ?; it is added by the 0.6.0 templating, so old queries lead to query URLs with a double leading ?? and a consequent 404 Not Found. ''' +from __future__ import print_function __author__ = 'James Kew <jkew@mediabright.co.uk>' import sys import roundup.instance if len(sys.argv) == 1: - print __doc__ + print(__doc__) sys.exit(1) # Iterate over all instance homes specified in argv. @@ -22,20 +23,20 @@ try: instance = roundup.instance.open(home) except: - print 'Cannot open instance home directory %s!' % home + print('Cannot open instance home directory %s!' % home) continue db = instance.open('admin') db.tx_Source = "cli" - print 'Migrating active queries in %s (%s):'%( - instance.config.TRACKER_NAME, home) + print('Migrating active queries in %s (%s):'%( + instance.config.TRACKER_NAME, home)) for query in db.query.list(): url = db.query.get(query, 'url') if url[0] == '?': url = url[1:] - print ' Migrating query%s (%s)'%(query, - db.query.get(query, 'name')) + print(' Migrating query%s (%s)'%(query, + db.query.get(query, 'name'))) db.query.set(query, url=url) db.commit()
