modhelp.py: Support Python 3 (Bug#24954)

* modules/modhelp.py: 'print' statement was removed in Python
3.  'print' function should be used instead of 'print' statement.
This commit is contained in:
Syohei YOSHIDA 2016-11-16 23:16:15 +09:00 committed by Noam Postavsky
parent afb04f7f3c
commit de68f337e3

View file

@ -45,31 +45,31 @@ def cmd_test(args):
failed = [] failed = []
for m in mods: for m in mods:
print '[*] %s: ------- start -------' % m print('[*] %s: ------- start -------' % m)
print '[*] %s: running make' % m print('[*] %s: running make' % m)
r = sp.call(make_cmd, cwd=m) r = sp.call(make_cmd, cwd=m)
if r != 0: if r != 0:
print '[E] %s: make failed' % m print('[E] %s: make failed' % m)
failed += [m] failed += [m]
continue continue
print '[*] %s: running test' % m print('[*] %s: running test' % m)
testpath = os.path.join(m, 'test.el') testpath = os.path.join(m, 'test.el')
if os.path.isfile(testpath): if os.path.isfile(testpath):
emacs_cmd = [EMACS, '-batch', '-L', '.', '-l', 'ert', emacs_cmd = [EMACS, '-batch', '-L', '.', '-l', 'ert',
'-l', testpath, '-f', 'ert-run-tests-batch-and-exit'] '-l', testpath, '-f', 'ert-run-tests-batch-and-exit']
print ' '.join(emacs_cmd) print(' '.join(emacs_cmd))
r = sp.call(emacs_cmd) r = sp.call(emacs_cmd)
if r != 0: if r != 0:
print '[E] %s: test failed' % m print('[E] %s: test failed' % m)
failed += [m] failed += [m]
continue continue
else: else:
print '[W] %s: no test to run' % m print('[W] %s: no test to run' % m)
print '\n[*] %d/%d MODULES OK' % (len(mods)-len(failed), len(mods)) print('\n[*] %d/%d MODULES OK' % (len(mods)-len(failed), len(mods)))
for m in failed: for m in failed:
print '\tfailed: %s' % m print('\tfailed: %s' % m)
def to_lisp_sym(sym): def to_lisp_sym(sym):
sym = re.sub('[_ ]', '-', sym) sym = re.sub('[_ ]', '-', sym)
@ -81,7 +81,7 @@ def to_c_sym(sym):
def cmd_init(args): def cmd_init(args):
if os.path.exists(args.module): if os.path.exists(args.module):
print "%s: file/dir '%s' already exists" % (__file__, args.module) print("%s: file/dir '%s' already exists" % (__file__, args.module))
return return
os.mkdir(args.module) os.mkdir(args.module)
@ -98,10 +98,10 @@ def cmd_init(args):
if isinstance(path, string.Template): if isinstance(path, string.Template):
path = path.substitute(template_vars) path = path.substitute(template_vars)
path = os.path.join(args.module, path) path = os.path.join(args.module, path)
print "writing %s..." % path print("writing %s..." % path)
with open(path, "w+") as f: with open(path, "w+") as f:
f.write(t.substitute(template_vars)) f.write(t.substitute(template_vars))
print "done! you can run %s test %s" % (__file__, args.module) print("done! you can run %s test %s" % (__file__, args.module))
def main(): def main():