Skip to content

Commit caeefd0

Browse files
simonlindholmaustrin
authored andcommitted
Use Python3 print syntax
1 parent ead5396 commit caeefd0

File tree

5 files changed

+19
-14
lines changed

5 files changed

+19
-14
lines changed

problemtools/problem2html.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env python2
22
# -*- coding: utf-8 -*-
3+
from __future__ import print_function
34
import re
45
import os.path
56
import sys
@@ -54,7 +55,7 @@ def convert(problem, options=None):
5455
renderer = ProblemRenderer()
5556

5657
if not options.quiet:
57-
print 'Parsing TeX source...'
58+
print('Parsing TeX source...')
5859
doc = tex.parse()
5960

6061
# Go to destdir
@@ -65,7 +66,7 @@ def convert(problem, options=None):
6566

6667
try:
6768
if not options.quiet:
68-
print 'Rendering!'
69+
print('Rendering!')
6970
renderer.render(doc)
7071

7172
# Annoying: I have not figured out any way of stopping the plasTeX

problemtools/run/program.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""Abstract base class for programs.
22
"""
3+
from __future__ import print_function
34
import os
45
import limit
56
import resource
@@ -82,8 +83,8 @@ def __run_wait(argv, infile, outfile, errfile, timelim, memlim):
8283
os.O_WRONLY | os.O_CREAT | os.O_TRUNC)
8384
os.execvp(argv[0], argv)
8485
except Exception as exc:
85-
print "Oops. Fatal error in child process:"
86-
print exc
86+
print("Oops. Fatal error in child process:")
87+
print(exc)
8788
os.kill(os.getpid(), signal.SIGTERM)
8889
# Unreachable
8990
logging.error("Unreachable part of run_wait reached")

problemtools/template.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import print_function
12
import os
23
import re
34
import os.path
@@ -60,7 +61,7 @@ def __init__(self, problemdir, language='',
6061
timelim = 1 # Legacy for compatibility with v0.1
6162
version = detect_version(problemdir, problemtex)
6263
if version != '':
63-
print 'Note: problem is in an old version (%s) of problem format, you should consider updating it' % version
64+
print('Note: problem is in an old version (%s) of problem format, you should consider updating it' % version)
6465
templatefile = 'template_%s.tex' % version
6566
clsfile = 'problemset_%s.cls' % version
6667

@@ -82,7 +83,7 @@ def __init__(self, problemdir, language='',
8283
self.problemset_cls = os.path.join(basedir, 'problemset.cls')
8384

8485
if os.path.isfile(self.problemset_cls) and not force_copy_cls:
85-
print '%s exists, will not copy it -- in case of weirdness this is likely culprit' % self.problemset_cls
86+
print('%s exists, will not copy it -- in case of weirdness this is likely culprit' % self.problemset_cls)
8687
self.copy_cls = False
8788

8889
if self.copy_cls:

problemtools/update_from_old_problemformat.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# -*- coding: utf-8 -*-
22

3+
from __future__ import print_function
34
from optparse import OptionParser
45
import glob
56
import os
@@ -17,12 +18,12 @@ def update(problemdir):
1718
yaml_changed = False
1819

1920
if 'name' in config:
20-
print 'Move problem name "%s" to these problem statement files: %s' % (config['name'], stmts)
21+
print('Move problem name "%s" to these problem statement files: %s' % (config['name'], stmts))
2122

2223
for f in stmts:
2324
stmt = open(f, 'r').read()
2425
if stmt.find('\\problemname{') != -1:
25-
print ' Statement %s already has a problemname, skipping' % f
26+
print(' Statement %s already has a problemname, skipping' % f)
2627
continue
2728
newstmt = '\problemname{%s}\n\n%s' % (config['name'], stmt)
2829
open(f, 'w').write(newstmt)
@@ -36,7 +37,7 @@ def update(problemdir):
3637
validation = 'custom'
3738
validator_flags = validator_flags[1:]
3839
validator_flags = ' '.join(validator_flags)
39-
print 'Old validator option exists, moving to validation: %s, validator_flags: %s' % (validation, validator_flags)
40+
print('Old validator option exists, moving to validation: %s, validator_flags: %s' % (validation, validator_flags))
4041
config['validation'] = validation
4142
if validator_flags != '':
4243
config['validator_flags'] = validator_flags
@@ -55,8 +56,8 @@ def update(problemdir):
5556

5657
for dir in args:
5758
try:
58-
print 'Updating %s' % dir
59+
print('Updating %s' % dir)
5960
update(dir)
6061
except Exception as e:
61-
print 'Update FAILED: %s' % e
62+
print('Update FAILED: %s' % e)
6263

problemtools/verifyproblem.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#! /usr/bin/env python2
22
# -*- coding: utf-8 -*-
3+
from __future__ import print_function
34
import glob
45
import string
56
import hashlib
@@ -89,7 +90,7 @@ def warning(self, msg):
8990
logging.warning('in %s: %s', self, msg)
9091

9192
def msg(self, msg):
92-
print msg
93+
print(msg)
9394

9495
def info(self, msg):
9596
logging.info(': %s', msg)
@@ -1272,12 +1273,12 @@ def main():
12721273
format=fmt,
12731274
level=eval("logging." + args.loglevel.upper()))
12741275

1275-
print 'Loading problem %s' % os.path.basename(os.path.realpath(args.problemdir))
1276+
print('Loading problem %s' % os.path.basename(os.path.realpath(args.problemdir)))
12761277
with Problem(args.problemdir) as prob:
12771278
[errors, warnings] = prob.check(args)
12781279
def p(x):
12791280
return '' if x == 1 else 's'
1280-
print "%s tested: %d error%s, %d warning%s" % (prob.shortname, errors, p(errors), warnings, p(warnings))
1281+
print("%s tested: %d error%s, %d warning%s" % (prob.shortname, errors, p(errors), warnings, p(warnings)))
12811282

12821283
sys.exit(1 if errors > 0 else 0)
12831284

0 commit comments

Comments
 (0)