Skip to content

Commit 4e65484

Browse files
committed
Python 3 preparation: avoid string.translate() and string.maketrans().
1 parent b21bfb3 commit 4e65484

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

roundup/dist/command/build_scripts.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,13 @@ def copy_scripts(self):
9696
""" Create each script listed in 'self.scripts'
9797
"""
9898

99-
to_module = string.maketrans('-/', '_.')
99+
try:
100+
# Python 3.
101+
maketrans = str.maketrans
102+
except AttributeError:
103+
# Python 2.
104+
maketrans = string.maketrans
105+
to_module = maketrans('-/', '_.')
100106

101107
self.mkpath(self.build_dir)
102108
for script in self.scripts:
@@ -111,7 +117,7 @@ def copy_scripts(self):
111117
continue
112118

113119
module = os.path.splitext(os.path.basename(script))[0]
114-
module = string.translate(module, to_module)
120+
module = module.translate(to_module)
115121
script_vars = {
116122
'python': self.python_executable,
117123
'package': self.package_name,

0 commit comments

Comments
 (0)