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


Python compat.StringIO方法代碼示例

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


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

示例1: test_bdist_egg

# 需要導入模塊: from setuptools import compat [as 別名]
# 或者: from setuptools.compat import StringIO [as 別名]
def test_bdist_egg(self):
        dist = Distribution(dict(
            script_name='setup.py',
            script_args=['bdist_egg'],
            name='foo',
            py_modules=['hi']
            ))
        os.makedirs(os.path.join('build', 'src'))
        old_stdout = sys.stdout
        sys.stdout = o = StringIO()
        try:
            dist.parse_command_line()
            dist.run_commands()
        finally:
            sys.stdout = old_stdout

        # let's see if we got our egg link at the right place
        [content] = os.listdir('dist')
        self.assertTrue(re.match('foo-0.0.0-py[23].\d.egg$', content)) 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:21,代碼來源:test_bdist_egg.py

示例2: make_trivial_sdist

# 需要導入模塊: from setuptools import compat [as 別名]
# 或者: from setuptools.compat import StringIO [as 別名]
def make_trivial_sdist(dist_path, setup_py):
    """Create a simple sdist tarball at dist_path, containing just a
    setup.py, the contents of which are provided by the setup_py string.
    """

    setup_py_file = tarfile.TarInfo(name='setup.py')
    try:
        # Python 3 (StringIO gets converted to io module)
        MemFile = BytesIO
    except AttributeError:
        MemFile = StringIO
    setup_py_bytes = MemFile(setup_py.encode('utf-8'))
    setup_py_file.size = len(setup_py_bytes.getvalue())
    dist = tarfile.open(dist_path, 'w:gz')
    try:
        dist.addfile(setup_py_file, fileobj=setup_py_bytes)
    finally:
        dist.close() 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:20,代碼來源:test_easy_install.py

示例3: quiet_context

# 需要導入模塊: from setuptools import compat [as 別名]
# 或者: from setuptools.compat import StringIO [as 別名]
def quiet_context():
    """
    Redirect stdout/stderr to StringIO objects to prevent console output from
    distutils commands.
    """

    old_stdout = sys.stdout
    old_stderr = sys.stderr
    new_stdout = sys.stdout = StringIO()
    new_stderr = sys.stderr = StringIO()
    try:
        yield new_stdout, new_stderr
    finally:
        new_stdout.seek(0)
        new_stderr.seek(0)
        sys.stdout = old_stdout
        sys.stderr = old_stderr 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:19,代碼來源:test_easy_install.py

示例4: test_get_script_header_jython_workaround

# 需要導入模塊: from setuptools import compat [as 別名]
# 或者: from setuptools.compat import StringIO [as 別名]
def test_get_script_header_jython_workaround(self):
        # This test doesn't work with Python 3 in some locales
        if (sys.version_info >= (3,) and os.environ.get("LC_CTYPE")
                in (None, "C", "POSIX")):
            return

        class java:
            class lang:
                class System:
                    @staticmethod
                    def getProperty(property):
                        return ""
        sys.modules["java"] = java

        platform = sys.platform
        sys.platform = 'java1.5.0_13'
        stdout, stderr = sys.stdout, sys.stderr
        try:
            # A mock sys.executable that uses a shebang line (this file)
            exe = os.path.normpath(os.path.splitext(__file__)[0] + '.py')
            self.assertEqual(
                get_script_header('#!/usr/local/bin/python', executable=exe),
                '#!/usr/bin/env %s\n' % exe)

            # Ensure we generate what is basically a broken shebang line
            # when there's options, with a warning emitted
            sys.stdout = sys.stderr = StringIO()
            self.assertEqual(get_script_header('#!/usr/bin/python -x',
                                               executable=exe),
                             '#!%s  -x\n' % exe)
            self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue())
            sys.stdout = sys.stderr = StringIO()
            self.assertEqual(get_script_header('#!/usr/bin/python',
                                               executable=self.non_ascii_exe),
                             '#!%s -x\n' % self.non_ascii_exe)
            self.assertTrue('Unable to adapt shebang line' in sys.stdout.getvalue())
        finally:
            del sys.modules["java"]
            sys.platform = platform
            sys.stdout, sys.stderr = stdout, stderr 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:42,代碼來源:test_resources.py

示例5: quiet

# 需要導入模塊: from setuptools import compat [as 別名]
# 或者: from setuptools.compat import StringIO [as 別名]
def quiet():
    global old_stdout, old_stderr
    old_stdout, old_stderr = sys.stdout, sys.stderr
    sys.stdout, sys.stderr = StringIO(), StringIO() 
開發者ID:sugarguo,項目名稱:Flask_Blog,代碼行數:6,代碼來源:test_sdist.py

示例6: write_requirements

# 需要導入模塊: from setuptools import compat [as 別名]
# 或者: from setuptools.compat import StringIO [as 別名]
def write_requirements(cmd, basename, filename):
    dist = cmd.distribution
    data = StringIO()
    _write_requirements(data, dist.install_requires)
    extras_require = dist.extras_require or {}
    for extra in sorted(extras_require):
        data.write('\n[{extra}]\n'.format(**vars()))
        _write_requirements(data, extras_require[extra])
    cmd.write_or_delete_file("requirements", filename, data.getvalue()) 
開發者ID:DirceuSilvaLabs,項目名稱:noc-orchestrator,代碼行數:11,代碼來源:egg_info.py

示例7: write_setup_requirements

# 需要導入模塊: from setuptools import compat [as 別名]
# 或者: from setuptools.compat import StringIO [as 別名]
def write_setup_requirements(cmd, basename, filename):
    data = StringIO()
    _write_requirements(data, cmd.distribution.setup_requires)
    cmd.write_or_delete_file("setup-requirements", filename, data.getvalue()) 
開發者ID:DirceuSilvaLabs,項目名稱:noc-orchestrator,代碼行數:6,代碼來源:egg_info.py


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