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


Python compat.WINDOWS屬性代碼示例

本文整理匯總了Python中pip._internal.compat.WINDOWS屬性的典型用法代碼示例。如果您正苦於以下問題:Python compat.WINDOWS屬性的具體用法?Python compat.WINDOWS怎麽用?Python compat.WINDOWS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在pip._internal.compat的用法示例。


在下文中一共展示了compat.WINDOWS屬性的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from pip._internal import compat [as 別名]
# 或者: from pip._internal.compat import WINDOWS [as 別名]
def __init__(self, *args, **kwargs):
        # The Windows terminal does not support the hide/show cursor ANSI codes
        # even with colorama. So we'll ensure that hide_cursor is False on
        # Windows.
        # This call neds to go before the super() call, so that hide_cursor
        # is set in time. The base progress bar class writes the "hide cursor"
        # code to the terminal in its init, so if we don't set this soon
        # enough, we get a "hide" with no corresponding "show"...
        if WINDOWS and self.hide_cursor:
            self.hide_cursor = False

        super(WindowsMixin, self).__init__(*args, **kwargs)

        # Check if we are running on Windows and we have the colorama module,
        # if we do then wrap our file with it.
        if WINDOWS and colorama:
            self.file = colorama.AnsiToWin32(self.file)
            # The progress code expects to be able to call self.file.isatty()
            # but the colorama.AnsiToWin32() object doesn't have that, so we'll
            # add it.
            self.file.isatty = lambda: self.file.wrapped.isatty()
            # The progress code expects to be able to call self.file.flush()
            # but the colorama.AnsiToWin32() object doesn't have that, so we'll
            # add it.
            self.file.flush = lambda: self.file.wrapped.flush() 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:27,代碼來源:ui.py

示例2: hidden_cursor

# 需要導入模塊: from pip._internal import compat [as 別名]
# 或者: from pip._internal.compat import WINDOWS [as 別名]
def hidden_cursor(file):
    # The Windows terminal does not support the hide/show cursor ANSI codes,
    # even via colorama. So don't even try.
    if WINDOWS:
        yield
    # We don't want to clutter the output with control characters if we're
    # writing to a file, or if the user is running with --quiet.
    # See https://github.com/pypa/pip/issues/3418
    elif not file.isatty() or logger.getEffectiveLevel() > logging.INFO:
        yield
    else:
        file.write(HIDE_CURSOR)
        try:
            yield
        finally:
            file.write(SHOW_CURSOR) 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:18,代碼來源:ui.py

示例3: _script_names

# 需要導入模塊: from pip._internal import compat [as 別名]
# 或者: from pip._internal.compat import WINDOWS [as 別名]
def _script_names(dist, script_name, is_gui):
    """Create the fully qualified name of the files created by
    {console,gui}_scripts for the given ``dist``.
    Returns the list of file names
    """
    if dist_in_usersite(dist):
        bin_dir = bin_user
    else:
        bin_dir = bin_py
    exe_name = os.path.join(bin_dir, script_name)
    paths_to_remove = [exe_name]
    if WINDOWS:
        paths_to_remove.append(exe_name + '.exe')
        paths_to_remove.append(exe_name + '.exe.manifest')
        if is_gui:
            paths_to_remove.append(exe_name + '-script.pyw')
        else:
            paths_to_remove.append(exe_name + '-script.py')
    return paths_to_remove 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:21,代碼來源:req_uninstall.py

示例4: user_config_dir

# 需要導入模塊: from pip._internal import compat [as 別名]
# 或者: from pip._internal.compat import WINDOWS [as 別名]
def user_config_dir(appname, roaming=True):
    """Return full path to the user-specific config dir for this application.

        "appname" is the name of application.
            If None, just the system directory is returned.
        "roaming" (boolean, default True) can be set False to not use the
            Windows roaming appdata directory. That means that for users on a
            Windows network setup for roaming profiles, this user data will be
            sync'd on login. See
            <http://technet.microsoft.com/en-us/library/cc766489(WS.10).aspx>
            for a discussion of issues.

    Typical user data directories are:
        macOS:                  same as user_data_dir
        Unix:                   ~/.config/<AppName>
        Win *:                  same as user_data_dir

    For Unix, we follow the XDG spec and support $XDG_CONFIG_HOME.
    That means, by default "~/.config/<AppName>".
    """
    if WINDOWS:
        path = user_data_dir(appname, roaming=roaming)
    elif sys.platform == "darwin":
        path = user_data_dir(appname)
    else:
        path = os.getenv('XDG_CONFIG_HOME', expanduser("~/.config"))
        path = os.path.join(path, appname)

    return path


# for the discussion regarding site_config_dirs locations
# see <https://github.com/pypa/pip/issues/1733> 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:35,代碼來源:appdirs.py

示例5: __init__

# 需要導入模塊: from pip._internal import compat [as 別名]
# 或者: from pip._internal.compat import WINDOWS [as 別名]
def __init__(self, stream=None, no_color=None):
        logging.StreamHandler.__init__(self, stream)
        self._no_color = no_color

        if WINDOWS and colorama:
            self.stream = colorama.AnsiToWin32(self.stream) 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:8,代碼來源:logging.py

示例6: add

# 需要導入模塊: from pip._internal import compat [as 別名]
# 或者: from pip._internal.compat import WINDOWS [as 別名]
def add(self, entry):
        entry = os.path.normcase(entry)
        # On Windows, os.path.normcase converts the entry to use
        # backslashes.  This is correct for entries that describe absolute
        # paths outside of site-packages, but all the others use forward
        # slashes.
        if WINDOWS and not os.path.splitdrive(entry)[0]:
            entry = entry.replace('\\', '/')
        self.entries.add(entry) 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:11,代碼來源:req_uninstall.py


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