當前位置: 首頁>>代碼示例>>Python>>正文


Python first_line_re.pattern方法代碼示例

本文整理匯總了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 
開發者ID:MayOneUS,項目名稱:pledgeservice,代碼行數:18,代碼來源:easy_install.py

示例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()) 
開發者ID:jpush,項目名稱:jbox,代碼行數:12,代碼來源:easy_install.py

示例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 
開發者ID:jpush,項目名稱:jbox,代碼行數:14,代碼來源:easy_install.py


注:本文中的distutils.command.build_scripts.first_line_re.pattern方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。