diff options
author | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-04 17:20:15 -0500 |
---|---|---|
committer | Jason R. Coombs <jaraco@jaraco.com> | 2015-01-04 17:20:15 -0500 |
commit | 3c78eb2348dff5d493d0cd5a34aef812db8385ef (patch) | |
tree | b17dad26efdd6d65bafff24d2d3676294aa41f8c /setuptools/command/easy_install.py | |
parent | 261d57232c74954468688a76aab2caea80ed42fc (diff) | |
download | external_python_setuptools-3c78eb2348dff5d493d0cd5a34aef812db8385ef.tar.gz external_python_setuptools-3c78eb2348dff5d493d0cd5a34aef812db8385ef.tar.bz2 external_python_setuptools-3c78eb2348dff5d493d0cd5a34aef812db8385ef.zip |
Extract method for parsing options.
Diffstat (limited to 'setuptools/command/easy_install.py')
-rwxr-xr-x | setuptools/command/easy_install.py | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/setuptools/command/easy_install.py b/setuptools/command/easy_install.py index 5c50dbe2..6ec96564 100755 --- a/setuptools/command/easy_install.py +++ b/setuptools/command/easy_install.py @@ -1920,13 +1920,9 @@ class ScriptWriter(object): """Create a #! line, getting options (if any) from script_text""" if executable is None: executable = nt_quote_arg(sys_executable) - first = (script_text + '\n').splitlines()[0] - match = _first_line_re().match(first) - options = '' - if match: - options = match.group(1) or '' - if options: - options = ' ' + options + + options = cls._extract_options(script_text) + hdr = "#!%(executable)s%(options)s\n" % locals() if not isascii(hdr): # Non-ascii path to sys.executable, use -x to prevent warnings @@ -1940,6 +1936,20 @@ class ScriptWriter(object): hdr = "#!%(executable)s%(options)s\n" % locals() return hdr + @classmethod + def _extract_options(cls, orig_script): + """ + Extract any options from the first line of the script. + """ + first = (orig_script + '\n').splitlines()[0] + match = _first_line_re().match(first) + options = '' + if match: + options = match.group(1) or '' + if options: + options = ' ' + options + return options + class WindowsScriptWriter(ScriptWriter): @classmethod |