aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason R. Coombs <jaraco@jaraco.com>2014-06-15 12:37:52 -0400
committerJason R. Coombs <jaraco@jaraco.com>2014-06-15 12:37:52 -0400
commit0a366602272433293a0b12d895bddac999540563 (patch)
treeff1842ce77153f21f2658eb2cf849ef131314520
parentca7d4bdf5a89e04565923c387cc28c15ddc37e5a (diff)
parent99475b7b9ca2650e265fb1d889710865f1fa35f2 (diff)
downloadexternal_python_setuptools-0a366602272433293a0b12d895bddac999540563.tar.gz
external_python_setuptools-0a366602272433293a0b12d895bddac999540563.tar.bz2
external_python_setuptools-0a366602272433293a0b12d895bddac999540563.zip
Merge template loader refactoring
-rwxr-xr-xsetuptools/command/easy_install.py30
1 files changed, 16 insertions, 14 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py
index 325e3c34..2f476fed 100755
--- a/setuptools/command/easy_install.py
+++ b/setuptools/command/easy_install.py
@@ -732,24 +732,26 @@ Please make the appropriate changes for your system and try again.
spec = str(dist.as_requirement())
is_script = is_python_script(script_text, script_name)
- def get_template(filename):
- """
- There are a couple of template scripts in the package. This
- function loads one of them and prepares it for use.
- """
- raw_bytes = resource_string('setuptools', template_name)
- return raw_bytes.decode('utf-8')
-
if is_script:
- # See https://bitbucket.org/pypa/setuptools/issue/134 for info
- # on script file naming and downstream issues with SVR4
- template_name = 'script.tmpl'
- if dev_path:
- template_name = template_name.replace('.tmpl', ' (dev).tmpl')
script_text = (get_script_header(script_text) +
- get_template(template_name) % locals())
+ self._load_template(dev_path) % locals())
self.write_script(script_name, _to_ascii(script_text), 'b')
+ @staticmethod
+ def _load_template(dev_path):
+ """
+ There are a couple of template scripts in the package. This
+ function loads one of them and prepares it for use.
+ """
+ # See https://bitbucket.org/pypa/setuptools/issue/134 for info
+ # on script file naming and downstream issues with SVR4
+ name = 'script.tmpl'
+ if dev_path:
+ name = name.replace('.tmpl', ' (dev).tmpl')
+
+ raw_bytes = resource_string('setuptools', name)
+ return raw_bytes.decode('utf-8')
+
def write_script(self, script_name, contents, mode="t", blockers=()):
"""Write an executable file to the scripts directory"""
self.delete_blockers( # clean up old .py/.pyw w/o a script