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


Python six.PY2屬性代碼示例

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


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

示例1: setup_py

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def setup_py(self):
        assert self.source_dir, "No source dir for %s" % self
        try:
            import setuptools  # noqa
        except ImportError:
            if get_installed_version('setuptools') is None:
                add_msg = "Please install setuptools."
            else:
                add_msg = traceback.format_exc()
            # Setuptools is not available
            raise InstallationError(
                "Could not import setuptools which is required to "
                "install from a source distribution.\n%s" % add_msg
            )

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:24,代碼來源:req_install.py

示例2: setup_py

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def setup_py(self):
        try:
            import setuptools
        except ImportError:
            # Setuptools is not available
            raise InstallationError(
                "setuptools must be installed to install from a source "
                "distribution"
            )

        setup_file = 'setup.py'

        if self.editable_options and 'subdirectory' in self.editable_options:
            setup_py = os.path.join(self.source_dir,
                                    self.editable_options['subdirectory'],
                                    setup_file)

        else:
            setup_py = os.path.join(self.source_dir, setup_file)

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py 
開發者ID:aliyun,項目名稱:oss-ftp,代碼行數:27,代碼來源:req.py

示例3: _copy_source_tree

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def _copy_source_tree(source, target):
    # type: (str, str) -> None
    def ignore(d, names):
        # type: (str, List[str]) -> List[str]
        # Pulling in those directories can potentially be very slow,
        # exclude the following directories if they appear in the top
        # level dir (and only it).
        # See discussion at https://github.com/pypa/pip/pull/6770
        return ['.tox', '.nox'] if d == source else []

    kwargs = dict(ignore=ignore, symlinks=True)  # type: CopytreeKwargs

    if not PY2:
        # Python 2 does not support copy_function, so we only ignore
        # errors on special file copy in Python 3.
        kwargs['copy_function'] = _copy2_ignoring_special_files

    shutil.copytree(source, target, **kwargs) 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:20,代碼來源:prepare.py

示例4: remove_tracebacks

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def remove_tracebacks(output):
    pattern = (r'(?:\W+File "(?:.*)", line (?:.*)\W+(?:.*)\W+\^\W+)?'
               r'Syntax(?:Error|Warning): (?:.*)')
    output = re.sub(pattern, '', output)
    if PY2:
        return output
    # compileall.compile_dir() prints different messages to stdout
    # in Python 3
    return re.sub(r"\*\*\* Error compiling (?:.*)", '', output) 
開發者ID:jpush,項目名稱:jbox,代碼行數:11,代碼來源:__init__.py

示例5: setup_py

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def setup_py(self):
        assert self.source_dir, "No source dir for %s" % self

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:12,代碼來源:req_install.py

示例6: pyproject_toml

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def pyproject_toml(self):
        assert self.source_dir, "No source dir for %s" % self

        pp_toml = os.path.join(self.setup_py_dir, 'pyproject.toml')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(pp_toml, six.text_type):
            pp_toml = pp_toml.encode(sys.getfilesystemencoding())

        return pp_toml 
開發者ID:HaoZhang95,項目名稱:Python24,代碼行數:12,代碼來源:req_install.py

示例7: make_pyproject_path

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def make_pyproject_path(setup_py_dir):
    # type: (str) -> str
    path = os.path.join(setup_py_dir, 'pyproject.toml')

    # Python2 __file__ should not be unicode
    if six.PY2 and isinstance(path, six.text_type):
        path = path.encode(sys.getfilesystemencoding())

    return path 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:11,代碼來源:pyproject.py

示例8: setup_py

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def setup_py(self):
        # type: () -> str
        assert self.source_dir, "No source dir for %s" % self

        setup_py = os.path.join(self.setup_py_dir, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py 
開發者ID:PacktPublishing,項目名稱:Mastering-Elasticsearch-7.0,代碼行數:13,代碼來源:req_install.py

示例9: get_metadata

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def get_metadata(self, name):
        if not self.egg_info:
            return ""
        path = self._get_metadata_path(name)
        value = self._get(path)
        if six.PY2:
            return value
        try:
            return value.decode('utf-8')
        except UnicodeDecodeError as exc:
            # Include the path in the error message to simplify
            # troubleshooting, and without changing the exception type.
            exc.reason += ' in {} file at path: {}'.format(name, path)
            raise 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:16,代碼來源:__init__.py

示例10: make_pyproject_path

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def make_pyproject_path(unpacked_source_directory):
    # type: (str) -> str
    path = os.path.join(unpacked_source_directory, 'pyproject.toml')

    # Python2 __file__ should not be unicode
    if six.PY2 and isinstance(path, six.text_type):
        path = path.encode(sys.getfilesystemencoding())

    return path 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:11,代碼來源:pyproject.py

示例11: path_to_display

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def path_to_display(path):
    # type: (Optional[Union[str, Text]]) -> Optional[Text]
    """
    Convert a bytes (or text) path to text (unicode in Python 2) for display
    and logging purposes.

    This function should never error out. Also, this function is mainly needed
    for Python 2 since in Python 3 str paths are already text.
    """
    if path is None:
        return None
    if isinstance(path, text_type):
        return path
    # Otherwise, path is a bytes object (str in Python 2).
    try:
        display_path = path.decode(sys.getfilesystemencoding(), 'strict')
    except UnicodeDecodeError:
        # Include the full bytes to make troubleshooting easier, even though
        # it may not be very human readable.
        if PY2:
            # Convert the bytes to a readable str representation using
            # repr(), and then convert the str to unicode.
            #   Also, we add the prefix "b" to the repr() return value both
            # to make the Python 2 output look like the Python 3 output, and
            # to signal to the user that this is a bytes representation.
            display_path = str_to_display('b{!r}'.format(path))
        else:
            # Silence the "F821 undefined name 'ascii'" flake8 error since
            # in Python 3 ascii() is a built-in.
            display_path = ascii(path)  # noqa: F821

    return display_path 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:34,代碼來源:misc.py

示例12: __eq__

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def __eq__(self, other):
        # type: (Any) -> bool
        if type(self) != type(other):
            return False

        # The string being used for redaction doesn't also have to match,
        # just the raw, original string.
        return (self.secret == other.secret)

    # We need to provide an explicit __ne__ implementation for Python 2.
    # TODO: remove this when we drop PY2 support. 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:13,代碼來源:misc.py

示例13: setup_py_path

# 需要導入模塊: from pip._vendor import six [as 別名]
# 或者: from pip._vendor.six import PY2 [as 別名]
def setup_py_path(self):
        # type: () -> str
        assert self.source_dir, "No source dir for %s" % self
        setup_py = os.path.join(self.unpacked_source_directory, 'setup.py')

        # Python2 __file__ should not be unicode
        if six.PY2 and isinstance(setup_py, six.text_type):
            setup_py = setup_py.encode(sys.getfilesystemencoding())

        return setup_py 
開發者ID:pantsbuild,項目名稱:pex,代碼行數:12,代碼來源:req_install.py


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