當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。