diff options
author | cclauss <cclauss@me.com> | 2020-01-28 01:38:54 +0100 |
---|---|---|
committer | cclauss <cclauss@me.com> | 2020-01-28 01:38:54 +0100 |
commit | 3208a74f906c116e93074c6ed0559df1cbfe58d1 (patch) | |
tree | c43d03841d5c29d4a8fc29793ef71eebc065d989 /scripts/codegen/makedesc.py | |
parent | aba31e2187808257b250bf469895330f273d7746 (diff) | |
download | tor-3208a74f906c116e93074c6ed0559df1cbfe58d1.tar.gz tor-3208a74f906c116e93074c6ed0559df1cbfe58d1.zip |
Use print() function in both Python 2 and Python 3
Diffstat (limited to 'scripts/codegen/makedesc.py')
-rw-r--r-- | scripts/codegen/makedesc.py | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/scripts/codegen/makedesc.py b/scripts/codegen/makedesc.py index 7d8177f469..4c3cfdb078 100644 --- a/scripts/codegen/makedesc.py +++ b/scripts/codegen/makedesc.py @@ -30,6 +30,11 @@ import slow_ed25519 import slownacl_curve25519 import ed25519_exts_ref +try: + xrange # Python 2 +except NameError: + xrange = range # Python 3 + # Pull in the openssl stuff we need. crypt = ctypes.CDLL(ctypes.util.find_library('crypto')) @@ -303,10 +308,10 @@ def signdesc(body, args_out=None): return body.rstrip() def print_c_string(ident, body): - print "static const char %s[] =" % ident + print("static const char %s[] =" % ident) for line in body.split("\n"): - print ' "%s\\n"' %(line) - print " ;" + print(' "%s\\n"' %(line)) + print(" ;") def emit_ri(name, body): info = OnDemandKeys() @@ -320,8 +325,8 @@ def emit_ei(name, body): body = info.sign_desc(body) print_c_string("EX_EI_%s"%name.upper(), body) - print 'const char EX_EI_{NAME}_FP[] = "{d.RSA_FINGERPRINT_NOSPACE}";'.format( - d=info, NAME=name.upper()) + print('const char EX_EI_{NAME}_FP[] = "{d.RSA_FINGERPRINT_NOSPACE}";'.format( + d=info, NAME=name.upper())) print_c_string("EX_EI_%s_KEY"%name.upper(), info.RSA_IDENTITY) def analyze(s): |