Skip to content

Commit 211e23c

Browse files
authored
Merge pull request #32 from cclauss/patch-1
Define print() function and raw_input for Python 3
2 parents 9a68777 + ad76266 commit 211e23c

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

examples/sc2autosave.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@
168168

169169
import sc2reader
170170

171+
try:
172+
raw_input # Python 2
173+
except NameError:
174+
raw_input = input # Python 3
175+
171176

172177
def run(args):
173178
#Reset wipes the destination clean so we can start over.
@@ -367,12 +372,12 @@ def reset(args):
367372
elif not os.path.isdir(args.dest):
368373
exit("Cannot reset, destination must be directory: {0}", args.dest)
369374

370-
print 'About to reset directory: {0}\nAll files and subdirectories will be removed.'.format(args.dest)
375+
print('About to reset directory: {0}\nAll files and subdirectories will be removed.'.format(args.dest))
371376
choice = raw_input('Proceed anyway? (y/n) ')
372377
if choice.lower() == 'y':
373378
args.log.write('Removing old directory: {0}\n'.format(args.dest))
374379
if not args.dryrun:
375-
print args.dest
380+
print(args.dest)
376381
shutil.rmtree(args.dest)
377382
else:
378383
sys.exit("Script Aborted")
@@ -511,7 +516,7 @@ def main():
511516
try:
512517
run(parser.parse_args())
513518
except KeyboardInterrupt:
514-
print "\n\nScript Interupted. Process Aborting"
519+
print("\n\nScript Interupted. Process Aborting")
515520

516521
if __name__ == '__main__':
517522
main()

examples/sc2store.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,15 @@ def main():
172172

173173
for path in args.paths:
174174
for file_name in sc2reader.utils.get_files(path, depth=0):
175-
print "CREATING: {0}".format(file_name)
175+
print("CREATING: {0}".format(file_name))
176176
db.add(Game(sc2reader.read_file(file_name), db))
177177

178178
db.commit()
179179

180-
print list(db.query(distinct(Person.name)).all())
180+
print(list(db.query(distinct(Person.name)).all()))
181181

182182
#for row in db.query(distinct(Person.name)).all():
183-
# print row
183+
# print(row)
184184

185185

186186
def load_session(args):

new_units.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@
1818
for line in new_units:
1919
new_unit_name = line.strip().split(',')[1]
2020
if new_unit_name not in UNIT_LOOKUP:
21-
print "{0},{1}".format(new_unit_name,new_unit_name)
21+
print("{0},{1}".format(new_unit_name,new_unit_name))
2222

23-
print
24-
print
23+
print('')
24+
print('')
2525

2626
ABIL_LOOKUP = dict()
2727
for entry in pkgutil.get_data('sc2reader.data', 'ability_lookup.csv').split('\n'):
@@ -33,4 +33,4 @@
3333
for line in new_abilities:
3434
new_ability_name = line.strip().split(',')[1]
3535
if new_ability_name not in ABIL_LOOKUP:
36-
print "{0},{1}".format(new_ability_name,new_ability_name)
36+
print("{0},{1}".format(new_ability_name,new_ability_name))

sc2reader/scripts/sc2attributes.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,11 @@
3838

3939
import sc2reader
4040

41+
try:
42+
raw_input # Python 2
43+
except NameError:
44+
raw_input = input # Python 3
45+
4146
decisions = dict()
4247

4348

0 commit comments

Comments
 (0)