当前位置: 首页>>代码示例>>Python>>正文


Python compat.PY3属性代码示例

本文整理汇总了Python中setuptools.compat.PY3属性的典型用法代码示例。如果您正苦于以下问题:Python compat.PY3属性的具体用法?Python compat.PY3怎么用?Python compat.PY3使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在setuptools.compat的用法示例。


在下文中一共展示了compat.PY3属性的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: read_manifest

# 需要导入模块: from setuptools import compat [as 别名]
# 或者: from setuptools.compat import PY3 [as 别名]
def read_manifest(self):
        """Read the manifest file (named by 'self.manifest') and use it to
        fill in 'self.filelist', the list of files to include in the source
        distribution.
        """
        log.info("reading manifest file '%s'", self.manifest)
        manifest = open(self.manifest, 'rbU')
        for line in manifest:
            # The manifest must contain UTF-8. See #303.
            if PY3:
                try:
                    line = line.decode('UTF-8')
                except UnicodeDecodeError:
                    log.warn("%r not UTF-8 decodable -- skipping" % line)
                    continue
            # ignore comments and blank lines
            line = line.strip()
            if line.startswith('#') or not line:
                continue
            self.filelist.append(line)
        manifest.close() 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:23,代码来源:sdist.py

示例2: run_tests

# 需要导入模块: from setuptools import compat [as 别名]
# 或者: from setuptools.compat import PY3 [as 别名]
def run_tests(self):
        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if PY3 and getattr(self.distribution, 'use_2to3', False):
            module = self.test_args[-1].split('.')[0]
            if module in _namespace_packages:
                del_modules = []
                if module in sys.modules:
                    del_modules.append(module)
                module += '.'
                for name in sys.modules:
                    if name.startswith(module):
                        del_modules.append(name)
                list(map(sys.modules.__delitem__, del_modules))

        unittest_main(
            None, None, [unittest.__file__] + self.test_args,
            testLoader=self._resolve_as_ep(self.test_loader),
            testRunner=self._resolve_as_ep(self.test_runner),
        ) 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:23,代码来源:test.py

示例3: run_tests

# 需要导入模块: from setuptools import compat [as 别名]
# 或者: from setuptools.compat import PY3 [as 别名]
def run_tests(self):
        # Purge modules under test from sys.modules. The test loader will
        # re-import them from the build location. Required when 2to3 is used
        # with namespace packages.
        if PY3 and getattr(self.distribution, 'use_2to3', False):
            module = self.test_suite.split('.')[0]
            if module in _namespace_packages:
                del_modules = []
                if module in sys.modules:
                    del_modules.append(module)
                module += '.'
                for name in sys.modules:
                    if name.startswith(module):
                        del_modules.append(name)
                list(map(sys.modules.__delitem__, del_modules))

        unittest_main(
            None, None, self._argv,
            testLoader=self._resolve_as_ep(self.test_loader),
            testRunner=self._resolve_as_ep(self.test_runner),
        ) 
开发者ID:theemadnes,项目名称:PDF_text_extract,代码行数:23,代码来源:test.py

示例4: write_file

# 需要导入模块: from setuptools import compat [as 别名]
# 或者: from setuptools.compat import PY3 [as 别名]
def write_file(self, what, filename, data):
        """Write `data` to `filename` (if not a dry run) after announcing it

        `what` is used in a log message to identify what is being written
        to the file.
        """
        log.info("writing %s to %s", what, filename)
        if PY3:
            data = data.encode("utf-8")
        if not self.dry_run:
            f = open(filename, 'wb')
            f.write(data)
            f.close() 
开发者ID:DirceuSilvaLabs,项目名称:noc-orchestrator,代码行数:15,代码来源:egg_info.py

示例5: posix

# 需要导入模块: from setuptools import compat [as 别名]
# 或者: from setuptools.compat import PY3 [as 别名]
def posix(path):
    if PY3 and not isinstance(path, str):
        return path.replace(os.sep.encode('ascii'), b('/'))
    else:
        return path.replace(os.sep, '/')


# HFS Plus uses decomposed UTF-8 
开发者ID:ayush1997,项目名称:Sudoku-Solver,代码行数:10,代码来源:test_sdist.py

示例6: test_manifest_is_read_with_utf8_encoding

# 需要导入模块: from setuptools import compat [as 别名]
# 或者: from setuptools.compat import PY3 [as 别名]
def test_manifest_is_read_with_utf8_encoding(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # Create manifest
        with quiet():
            cmd.run()

        # Add UTF-8 filename to manifest
        filename = os.path.join(b('sdist_test'), b('smörbröd.py'))
        cmd.manifest = os.path.join('sdist_test.egg-info', 'SOURCES.txt')
        manifest = open(cmd.manifest, 'ab')
        manifest.write(b('\n') + filename)
        manifest.close()

        # The file must exist to be included in the filelist
        open(filename, 'w').close()

        # Re-read manifest
        cmd.filelist.files = []
        with quiet():
            cmd.read_manifest()

        # The filelist should contain the UTF-8 filename
        if PY3:
            filename = filename.decode('utf-8')
        assert filename in cmd.filelist.files

    # Python 3 only 
开发者ID:ayush1997,项目名称:Sudoku-Solver,代码行数:34,代码来源:test_sdist.py

示例7: test_sdist_with_utf8_encoded_filename

# 需要导入模块: from setuptools import compat [as 别名]
# 或者: from setuptools.compat import PY3 [as 别名]
def test_sdist_with_utf8_encoded_filename(self):
        # Test for #303.
        dist = Distribution(SETUP_ATTRS)
        dist.script_name = 'setup.py'
        cmd = sdist(dist)
        cmd.ensure_finalized()

        # UTF-8 filename
        filename = os.path.join(b('sdist_test'), b('smörbröd.py'))
        open(filename, 'w').close()

        with quiet():
            cmd.run()

        if sys.platform == 'darwin':
            filename = decompose(filename)

        if PY3:
            fs_enc = sys.getfilesystemencoding()

            if sys.platform == 'win32':
                if fs_enc == 'cp1252':
                    # Python 3 mangles the UTF-8 filename
                    filename = filename.decode('cp1252')
                    assert filename in cmd.filelist.files
                else:
                    filename = filename.decode('mbcs')
                    assert filename in cmd.filelist.files
            else:
                filename = filename.decode('utf-8')
                assert filename in cmd.filelist.files
        else:
            assert filename in cmd.filelist.files 
开发者ID:ayush1997,项目名称:Sudoku-Solver,代码行数:35,代码来源:test_sdist.py


注:本文中的setuptools.compat.PY3属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。