summaryrefslogtreecommitdiffstats
path: root/ext/python
diff options
context:
space:
mode:
authorChristoph Erhardt <kolab@sicherha.de>2021-06-04 16:50:46 +0200
committerChristoph Erhardt <kolab@sicherha.de>2022-01-10 20:42:16 +0100
commitd0579b7e5da331576b80b9d35eb62994075bc939 (patch)
treee925558aabd8a69217e828c46eb4111d16f00fd4 /ext/python
parent7750671314e6da19f65aaa95bb1095963fdc175a (diff)
downloadpykolab-d0579b7e5da331576b80b9d35eb62994075bc939.tar.gz
[Python 3] Use print() as function instead of statement
Summary: print() has been a function since Python 2.6; the old behaviour was dropped in Python 3.0. To use the named file argument in Python 2, we need to import print_function from the __future__ module. Reviewers: machniak, mollekopf Reviewed By: mollekopf Differential Revision: https://git.kolab.org/D3229
Diffstat (limited to 'ext/python')
-rwxr-xr-xext/python/Tools/freeze/freeze.py18
-rw-r--r--ext/python/Tools/freeze/hello.py2
-rw-r--r--ext/python/Tools/freeze/makeconfig.py4
-rw-r--r--ext/python/Tools/freeze/makefreeze.py4
-rw-r--r--ext/python/Tools/freeze/parsesetup.py12
-rw-r--r--ext/python/Tools/freeze/winmakemakefile.py124
6 files changed, 82 insertions, 82 deletions
diff --git a/ext/python/Tools/freeze/freeze.py b/ext/python/Tools/freeze/freeze.py
index 46bfd90..daa345b 100755
--- a/ext/python/Tools/freeze/freeze.py
+++ b/ext/python/Tools/freeze/freeze.py
@@ -162,7 +162,7 @@ def main():
# process option arguments
for o, a in opts:
if o == '-h':
- print __doc__
+ print(__doc__)
return
if o == '-b':
binlib = a
@@ -224,7 +224,7 @@ def main():
if win:
extensions_c = 'frozen_extensions.c'
if ishome:
- print "(Using Python source directory)"
+ print("(Using Python source directory)")
binlib = exec_prefix
incldir = os.path.join(prefix, 'Include')
config_h_dir = exec_prefix
@@ -316,7 +316,7 @@ def main():
if odir and not os.path.isdir(odir):
try:
os.mkdir(odir)
- print "Created output directory", odir
+ print("Created output directory", odir)
except os.error, msg:
usage('%s: mkdir failed (%s)' % (odir, str(msg)))
base = ''
@@ -377,7 +377,7 @@ def main():
if debug > 0:
mf.report()
- print
+ print()
dict = mf.modules
if error_if_any_missing:
@@ -485,18 +485,18 @@ def main():
# Done!
if odir:
- print 'Now run "make" in', odir,
- print 'to build the target:', base_target
+ print('Now run "make" in', odir, end=' ')
+ print('to build the target:', base_target)
else:
- print 'Now run "make" to build the target:', base_target
+ print('Now run "make" to build the target:', base_target)
# Print usage message and exit
def usage(msg):
sys.stdout = sys.stderr
- print "Error:", msg
- print "Use ``%s -h'' for help" % sys.argv[0]
+ print("Error:", msg)
+ print("Use ``%s -h'' for help" % sys.argv[0])
sys.exit(2)
diff --git a/ext/python/Tools/freeze/hello.py b/ext/python/Tools/freeze/hello.py
index f978acc..d7a3729 100644
--- a/ext/python/Tools/freeze/hello.py
+++ b/ext/python/Tools/freeze/hello.py
@@ -1 +1 @@
-print 'Hello world...'
+print('Hello world...')
diff --git a/ext/python/Tools/freeze/makeconfig.py b/ext/python/Tools/freeze/makeconfig.py
index b9bfd08..8aba55e 100644
--- a/ext/python/Tools/freeze/makeconfig.py
+++ b/ext/python/Tools/freeze/makeconfig.py
@@ -40,8 +40,8 @@ def makeconfig(infp, outfp, modules, with_ifdef=0):
def test():
import sys
if not sys.argv[3:]:
- print 'usage: python makeconfig.py config.c.in outputfile',
- print 'modulename ...'
+ print('usage: python makeconfig.py config.c.in outputfile', end=' ')
+ print('modulename ...')
sys.exit(2)
if sys.argv[1] == '-':
infp = sys.stdin
diff --git a/ext/python/Tools/freeze/makefreeze.py b/ext/python/Tools/freeze/makefreeze.py
index 1208b67..e359db9 100644
--- a/ext/python/Tools/freeze/makefreeze.py
+++ b/ext/python/Tools/freeze/makefreeze.py
@@ -43,7 +43,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
outfp = bkfile.open(base + file, 'w')
files.append(file)
if debug:
- print "freezing", mod, "..."
+ print("freezing", mod, "...")
str = marshal.dumps(m.__code__)
size = len(str)
if m.__path__:
@@ -53,7 +53,7 @@ def makefreeze(base, dict, debug=0, entry_point=None, fail_import=()):
writecode(outfp, mangled, str)
outfp.close()
if debug:
- print "generating table of frozen modules"
+ print("generating table of frozen modules")
outfp = bkfile.open(base + 'frozen.c', 'w')
for mod, mangled, size in done:
outfp.write('extern unsigned char M_%s[];\n' % mangled)
diff --git a/ext/python/Tools/freeze/parsesetup.py b/ext/python/Tools/freeze/parsesetup.py
index 856234d..ae0bc43 100644
--- a/ext/python/Tools/freeze/parsesetup.py
+++ b/ext/python/Tools/freeze/parsesetup.py
@@ -84,29 +84,29 @@ def test():
import sys
import os
if not sys.argv[1:]:
- print 'usage: python parsesetup.py Makefile*|Setup* ...'
+ print('usage: python parsesetup.py Makefile*|Setup* ...')
sys.exit(2)
for arg in sys.argv[1:]:
base = os.path.basename(arg)
if base[:8] == 'Makefile':
- print 'Make style parsing:', arg
+ print('Make style parsing:', arg)
v = getmakevars(arg)
prdict(v)
elif base[:5] == 'Setup':
- print 'Setup style parsing:', arg
+ print('Setup style parsing:', arg)
m, v = getsetupinfo(arg)
prdict(m)
prdict(v)
else:
- print arg, 'is neither a Makefile nor a Setup file'
- print '(name must begin with "Makefile" or "Setup")'
+ print(arg, 'is neither a Makefile nor a Setup file')
+ print('(name must begin with "Makefile" or "Setup")')
def prdict(d):
keys = d.keys()
keys.sort()
for key in keys:
value = d[key]
- print "%-15s" % key, str(value)
+ print("%-15s" % key, str(value))
if __name__ == '__main__':
test()
diff --git a/ext/python/Tools/freeze/winmakemakefile.py b/ext/python/Tools/freeze/winmakemakefile.py
index 8570f3d..e473fed 100644
--- a/ext/python/Tools/freeze/winmakemakefile.py
+++ b/ext/python/Tools/freeze/winmakemakefile.py
@@ -52,29 +52,29 @@ def makemakefile(outfp, vars, files, target):
def realwork(vars, moddefns, target):
version_suffix = "%r%r" % sys.version_info[:2]
- print "# Makefile for Microsoft Visual C++ generated by freeze.py script"
- print
- print 'target = %s' % target
- print 'pythonhome = %s' % vars['prefix']
- print
- print 'DEBUG=0 # Set to 1 to use the _d versions of Python.'
- print '!IF $(DEBUG)'
- print 'debug_suffix=_d'
- print 'c_debug=/Zi /Od /DDEBUG /D_DEBUG'
- print 'l_debug=/DEBUG'
- print 'temp_dir=Build\\Debug'
- print '!ELSE'
- print 'debug_suffix='
- print 'c_debug=/Ox'
- print 'l_debug='
- print 'temp_dir=Build\\Release'
- print '!ENDIF'
- print
-
- print '# The following line assumes you have built Python using the standard instructions'
- print '# Otherwise fix the following line to point to the library.'
- print 'pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix
- print
+ print("# Makefile for Microsoft Visual C++ generated by freeze.py script")
+ print()
+ print('target = %s' % target)
+ print('pythonhome = %s' % vars['prefix'])
+ print()
+ print('DEBUG=0 # Set to 1 to use the _d versions of Python.')
+ print('!IF $(DEBUG)')
+ print('debug_suffix=_d')
+ print('c_debug=/Zi /Od /DDEBUG /D_DEBUG')
+ print('l_debug=/DEBUG')
+ print('temp_dir=Build\\Debug')
+ print('!ELSE')
+ print('debug_suffix=')
+ print('c_debug=/Ox')
+ print('l_debug=')
+ print('temp_dir=Build\\Release')
+ print('!ENDIF')
+ print()
+
+ print('# The following line assumes you have built Python using the standard instructions')
+ print('# Otherwise fix the following line to point to the library.')
+ print('pythonlib = "$(pythonhome)/pcbuild/python%s$(debug_suffix).lib"' % version_suffix)
+ print()
# We only ever write one "entry point" symbol - either
# "main" or "WinMain". Therefore, there is no need to
@@ -88,59 +88,59 @@ def realwork(vars, moddefns, target):
target_ext = ".dll"
- print "# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix
- print "cdl = /MD"
- print
- print "all: $(target)$(debug_suffix)%s" % (target_ext)
- print
+ print("# As the target uses Python%s.dll, we must use this compiler option!" % version_suffix)
+ print("cdl = /MD")
+ print()
+ print("all: $(target)$(debug_suffix)%s" % (target_ext))
+ print()
- print '$(temp_dir):'
- print ' if not exist $(temp_dir)\. mkdir $(temp_dir)'
- print
+ print('$(temp_dir):')
+ print(' if not exist $(temp_dir)\. mkdir $(temp_dir)')
+ print()
objects = []
libs = ["shell32.lib", "comdlg32.lib", "wsock32.lib", "user32.lib", "oleaut32.lib"]
for moddefn in moddefns:
- print "# Module", moddefn.name
+ print("# Module", moddefn.name)
for file in moddefn.sourceFiles:
base = os.path.basename(file)
base, ext = os.path.splitext(base)
objects.append(base + ".obj")
- print '$(temp_dir)\%s.obj: "%s"' % (base, file)
- print "\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE",
- print '"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\'
- print "\t\t$(cflags) $(cdebug) $(cinclude) \\"
+ print('$(temp_dir)\%s.obj: "%s"' % (base, file))
+ print("\t@$(CC) -c -nologo /Fo$* $(cdl) $(c_debug) /D BUILD_FREEZE", end=' ')
+ print('"-I$(pythonhome)/Include" "-I$(pythonhome)/PC" \\')
+ print("\t\t$(cflags) $(cdebug) $(cinclude) \\")
extra = moddefn.GetCompilerOptions()
if extra:
- print "\t\t%s \\" % (' '.join(extra),)
- print '\t\t"%s"' % file
- print
+ print("\t\t%s \\" % (' '.join(extra),))
+ print('\t\t"%s"' % file)
+ print()
# Add .lib files this module needs
for modlib in moddefn.GetLinkerLibs():
if modlib not in libs:
libs.append(modlib)
- print "ADDN_LINK_FILES=",
- for addn in vars['addn_link']: print '"%s"' % (addn),
- print ; print
-
- print "OBJS=",
- for obj in objects: print '"$(temp_dir)\%s"' % (obj),
- print ; print
-
- print "LIBS=",
- for lib in libs: print '"%s"' % (lib),
- print ; print
-
- print "$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext)
- print "\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags),
- print "\t$(OBJS) \\"
- print "\t$(LIBS) \\"
- print "\t$(ADDN_LINK_FILES) \\"
- print "\t$(pythonlib) $(lcustom) $(l_debug)\\"
- print "\t$(resources)"
- print
- print "clean:"
- print "\t-rm -f *.obj"
- print "\t-rm -f $(target).exe"
+ print("ADDN_LINK_FILES=", end=' ')
+ for addn in vars['addn_link']: print('"%s"' % (addn), end=' ')
+ print() ; print()
+
+ print("OBJS=", end=' ')
+ for obj in objects: print('"$(temp_dir)\%s"' % (obj), end=' ')
+ print() ; print()
+
+ print("LIBS=", end=' ')
+ for lib in libs: print('"%s"' % (lib), end=' ')
+ print() ; print()
+
+ print("$(target)$(debug_suffix)%s: $(temp_dir) $(OBJS)" % (target_ext))
+ print("\tlink -out:$(target)$(debug_suffix)%s %s" % (target_ext, target_link_flags), end=' ')
+ print("\t$(OBJS) \\")
+ print("\t$(LIBS) \\")
+ print("\t$(ADDN_LINK_FILES) \\")
+ print("\t$(pythonlib) $(lcustom) $(l_debug)\\")
+ print("\t$(resources)")
+ print()
+ print("clean:")
+ print("\t-rm -f *.obj")
+ print("\t-rm -f $(target).exe")