From 2ecd0b397a79471b96cf6c44cc118e550e629e76 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 22 Aug 2017 17:22:04 +0200 Subject: [PATCH 1/5] print() function for Python 3 --- new_units.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/new_units.py b/new_units.py index afe58f27..e0d80118 100644 --- a/new_units.py +++ b/new_units.py @@ -18,10 +18,10 @@ for line in new_units: new_unit_name = line.strip().split(',')[1] if new_unit_name not in UNIT_LOOKUP: - print "{0},{1}".format(new_unit_name,new_unit_name) + print("{0},{1}".format(new_unit_name,new_unit_name)) -print -print +print('') +print('') ABIL_LOOKUP = dict() for entry in pkgutil.get_data('sc2reader.data', 'ability_lookup.csv').split('\n'): @@ -33,4 +33,4 @@ for line in new_abilities: new_ability_name = line.strip().split(',')[1] if new_ability_name not in ABIL_LOOKUP: - print "{0},{1}".format(new_ability_name,new_ability_name) + print("{0},{1}".format(new_ability_name,new_ability_name)) From 0648ba183f923f7a7ac86c6eee30e26351595697 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 22 Aug 2017 17:25:00 +0200 Subject: [PATCH 2/5] Define print() function and raw_input for Python 3 --- examples/sc2autosave.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/examples/sc2autosave.py b/examples/sc2autosave.py index fc40bb98..e5220f38 100755 --- a/examples/sc2autosave.py +++ b/examples/sc2autosave.py @@ -168,6 +168,11 @@ import sc2reader +try: + raw_input # Python 3 +except NameError: + raw_input = input # Python 3 + def run(args): #Reset wipes the destination clean so we can start over. @@ -367,12 +372,12 @@ def reset(args): elif not os.path.isdir(args.dest): exit("Cannot reset, destination must be directory: {0}", args.dest) - print 'About to reset directory: {0}\nAll files and subdirectories will be removed.'.format(args.dest) + print('About to reset directory: {0}\nAll files and subdirectories will be removed.'.format(args.dest)) choice = raw_input('Proceed anyway? (y/n) ') if choice.lower() == 'y': args.log.write('Removing old directory: {0}\n'.format(args.dest)) if not args.dryrun: - print args.dest + print(args.dest) shutil.rmtree(args.dest) else: sys.exit("Script Aborted") @@ -511,7 +516,7 @@ def main(): try: run(parser.parse_args()) except KeyboardInterrupt: - print "\n\nScript Interupted. Process Aborting" + print("\n\nScript Interupted. Process Aborting") if __name__ == '__main__': main() From 8da92252b68a0830a5eb1cd74cacca77ca237fc3 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 22 Aug 2017 17:26:11 +0200 Subject: [PATCH 3/5] Define print() function for Python 3 --- examples/sc2store.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/sc2store.py b/examples/sc2store.py index cb8995c0..55ff22b0 100755 --- a/examples/sc2store.py +++ b/examples/sc2store.py @@ -172,15 +172,15 @@ def main(): for path in args.paths: for file_name in sc2reader.utils.get_files(path, depth=0): - print "CREATING: {0}".format(file_name) + print("CREATING: {0}".format(file_name)) db.add(Game(sc2reader.read_file(file_name), db)) db.commit() - print list(db.query(distinct(Person.name)).all()) + print(list(db.query(distinct(Person.name)).all())) #for row in db.query(distinct(Person.name)).all(): - # print row + # print(row) def load_session(args): From 5f91a2aea9ab30dbbbeb47bdc8b8649ff4ce11d2 Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 22 Aug 2017 17:28:28 +0200 Subject: [PATCH 4/5] Define raw_input for Python 3 --- sc2reader/scripts/sc2attributes.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sc2reader/scripts/sc2attributes.py b/sc2reader/scripts/sc2attributes.py index a318848f..da0160e9 100644 --- a/sc2reader/scripts/sc2attributes.py +++ b/sc2reader/scripts/sc2attributes.py @@ -38,6 +38,11 @@ import sc2reader +try: + raw_input # Python 2 +except NameError: + raw_input = input # Python 3 + decisions = dict() From ad762662e31d20041897f5bcef9ac202b28774bf Mon Sep 17 00:00:00 2001 From: cclauss Date: Tue, 22 Aug 2017 17:29:48 +0200 Subject: [PATCH 5/5] fix typo --- examples/sc2autosave.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/sc2autosave.py b/examples/sc2autosave.py index e5220f38..eb6b48e4 100755 --- a/examples/sc2autosave.py +++ b/examples/sc2autosave.py @@ -169,7 +169,7 @@ import sc2reader try: - raw_input # Python 3 + raw_input # Python 2 except NameError: raw_input = input # Python 3