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