author | Alberto Bertogli
<albertito@blitiri.com.ar> 2023-08-23 16:13:37 UTC |
committer | Alberto Bertogli
<albertito@blitiri.com.ar> 2023-08-23 16:13:37 UTC |
parent | b5db548acdfbb47fe51b4441a06f07a0de7e57f3 |
pygen | +15 | -15 |
diff --git a/pygen b/pygen index fc7dccf..486d55b 100755 --- a/pygen +++ b/pygen @@ -8,8 +8,8 @@ from optparse import OptionParser def printd(*args): for i in args: - print >> sys.stderr, i, - print >> sys.stderr + print(i, end=' ', file=sys.stderr) + print(file=sys.stderr) def is_newer_than(src, dst): """Determine if "src" is newer than "dst".""" @@ -83,21 +83,21 @@ def gen_from(src, dst, environ = None, incpath = None): elif line.startswith('#py '): code = line.split(' ', 1)[1] - exec code in environ + exec(code, environ) elif line.startswith('#py:'): in_python = 1 in_python_code = '' elif line.startswith('#endpy'): - exec in_python_code in environ + exec(in_python_code, environ) in_python = 0 in_python_code = '' elif line.startswith('#print'): s = line.split(' ', 1)[1] s = 'print ' + s - exec s in environ + exec(s, environ) else: dst.write(line) @@ -120,7 +120,7 @@ def autogen(src, dst): tree = os.walk(srcroot) if not os.path.isdir(dst): - print 'mkdir', dst + print('mkdir', dst) os.mkdir(dst) # directories' stats must be updated after we do all the generation, @@ -140,7 +140,7 @@ def autogen(src, dst): files.append(d) continue if not os.path.isdir(p): - print 'mkdir', p + print('mkdir', p) os.mkdir(p) to_update_stat.append((fulld, p)) @@ -153,35 +153,35 @@ def autogen(src, dst): if diff.endswith('.pgh'): # header files are ignored - print 'ignored', diff + print('ignored', diff) continue elif diff.endswith('.pg'): t = os.path.splitext(diff)[0] t = os.path.normpath(dst + '/' + t) if not is_newer_than(fullf, t): - print 'skipped', diff + print('skipped', diff) continue - print diff, '->', t + print(diff, '->', t) gen_from(fullf, t) else: t = os.path.normpath(dst + '/' + diff) if not is_newer_than(fullf, t): - print 'skipped', diff + print('skipped', diff) continue if os.path.islink(fullf): dlink = os.readlink(fullf) - print 'symlink', diff, '->', dlink + print('symlink', diff, '->', dlink) if os.path.exists(t): os.unlink(t) os.symlink(dlink, t) elif os.path.isfile(fullf): - print 'copy', diff + print('copy', diff) shutil.copy2(fullf, t) # second pass to preserve directories' modification time for s, d in to_update_stat: - print 'copystat', d + print('copystat', d) shutil.copystat(s, d) @@ -211,7 +211,7 @@ if __name__ == '__main__': sys.exit(1) for src in args[1:]: dst = os.path.splitext(src)[0] - print src, '->', dst + print(src, '->', dst) gen_from(src, dst) elif action == 'autogen':