changeset 5435:12baa5b9b597

Python 3 preparation: avoid string.translate() and string.maketrans().
author Joseph Myers <jsm@polyomino.org.uk>
date Wed, 25 Jul 2018 10:44:30 +0000
parents 1ab2c81a64df
children e70fe1d1215b
files roundup/dist/command/build_scripts.py
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/roundup/dist/command/build_scripts.py	Wed Jul 25 10:43:40 2018 +0000
+++ b/roundup/dist/command/build_scripts.py	Wed Jul 25 10:44:30 2018 +0000
@@ -96,7 +96,13 @@
         """ Create each script listed in 'self.scripts'
         """
 
-        to_module = string.maketrans('-/', '_.')
+        try:
+            # Python 3.
+            maketrans = str.maketrans
+        except AttributeError:
+            # Python 2.
+            maketrans = string.maketrans
+        to_module = maketrans('-/', '_.')
 
         self.mkpath(self.build_dir)
         for script in self.scripts:
@@ -111,7 +117,7 @@
                 continue
 
             module = os.path.splitext(os.path.basename(script))[0]
-            module = string.translate(module, to_module)
+            module = module.translate(to_module)
             script_vars = {
                 'python': self.python_executable,
                 'package': self.package_name,

Roundup Issue Tracker: http://roundup-tracker.org/