本文整理汇总了Python中distutils.command.build_scripts.first_line_re.pattern方法的典型用法代码示例。如果您正苦于以下问题:Python first_line_re.pattern方法的具体用法?Python first_line_re.pattern怎么用?Python first_line_re.pattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类distutils.command.build_scripts.first_line_re
的用法示例。
在下文中一共展示了first_line_re.pattern方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _adjust_header
# 需要导入模块: from distutils.command.build_scripts import first_line_re [as 别名]
# 或者: from distutils.command.build_scripts.first_line_re import pattern [as 别名]
def _adjust_header(type_, orig_header):
"""
Make sure 'pythonw' is used for gui and and 'python' is used for
console (regardless of what sys.executable is).
"""
pattern = 'pythonw.exe'
repl = 'python.exe'
if type_ == 'gui':
pattern, repl = repl, pattern
pattern_ob = re.compile(re.escape(pattern), re.IGNORECASE)
new_header = pattern_ob.sub(string=orig_header, repl=repl)
clean_header = new_header[2:-1].strip('"')
if sys.platform == 'win32' and not os.path.exists(clean_header):
# the adjusted version doesn't exist, so return the original
return orig_header
return new_header
示例2: _first_line_re
# 需要导入模块: from distutils.command.build_scripts import first_line_re [as 别名]
# 或者: from distutils.command.build_scripts.first_line_re import pattern [as 别名]
def _first_line_re():
"""
Return a regular expression based on first_line_re suitable for matching
strings.
"""
if isinstance(first_line_re.pattern, str):
return first_line_re
# first_line_re in Python >=3.1.4 and >=3.2.1 is a bytes pattern.
return re.compile(first_line_re.pattern.decode())
示例3: _adjust_header
# 需要导入模块: from distutils.command.build_scripts import first_line_re [as 别名]
# 或者: from distutils.command.build_scripts.first_line_re import pattern [as 别名]
def _adjust_header(cls, type_, orig_header):
"""
Make sure 'pythonw' is used for gui and and 'python' is used for
console (regardless of what sys.executable is).
"""
pattern = 'pythonw.exe'
repl = 'python.exe'
if type_ == 'gui':
pattern, repl = repl, pattern
pattern_ob = re.compile(re.escape(pattern), re.IGNORECASE)
new_header = pattern_ob.sub(string=orig_header, repl=repl)
return new_header if cls._use_header(new_header) else orig_header