本文整理匯總了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