当前位置: 首页>>代码示例>>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;未经允许,请勿转载。