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


Python os.environb方法代码示例

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


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

示例1: test_environb

# 需要导入模块: import os [as 别名]
# 或者: from os import environb [as 别名]
def test_environb(self):
        # os.environ -> os.environb
        value = 'euro\u20ac'
        try:
            value_bytes = value.encode(sys.getfilesystemencoding(),
                                       'surrogateescape')
        except UnicodeEncodeError:
            msg = "U+20AC character is not encodable to %s" % (
                sys.getfilesystemencoding(),)
            self.skipTest(msg)
        os.environ['unicode'] = value
        self.assertEqual(os.environ['unicode'], value)
        self.assertEqual(os.environb[b'unicode'], value_bytes)

        # os.environb -> os.environ
        value = b'\xff'
        os.environb[b'bytes'] = value
        self.assertEqual(os.environb[b'bytes'], value)
        value_str = value.decode(sys.getfilesystemencoding(), 'surrogateescape')
        self.assertEqual(os.environ['bytes'], value_str)

    # On FreeBSD < 7 and OS X < 10.6, unsetenv() doesn't return a value (issue
    # #13415). 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:25,代码来源:test_os.py

示例2: get_env_with_bytes_locale

# 需要导入模块: import os [as 别名]
# 或者: from os import environb [as 别名]
def get_env_with_bytes_locale(environ=os.environb, locale=b"C.UTF-8"):
    """Return an environment dict with locale vars set (to C.UTF-8 by default).

    C.UTF-8 is the new en_US.UTF-8, i.e. it's the new default locale when no
    other locale makes sense.

    This function takes a starting environment, by default that of the current
    process, strips away all locale and language settings (i.e. LC_* and LANG)
    and selects C.UTF-8 in their place.

    :param environ: A base environment to start from. By default this is
        ``os.environb``. It will not be modified.
    :param locale: The locale to set in the environment, 'C.UTF-8' by default.
    """
    environ = {
        name: value
        for name, value in environ.items()
        if not name.startswith(b"LC_")
    }
    environ.update({b"LC_ALL": locale, b"LANG": locale, b"LANGUAGE": locale})
    return environ 
开发者ID:maas,项目名称:maas,代码行数:23,代码来源:shell.py

示例3: main

# 需要导入模块: import os [as 别名]
# 或者: from os import environb [as 别名]
def main():
    trailers = os.environb[b'TRAILERS'].split(b'\n') if os.environb[b'TRAILERS'] else []
    assert all(b':' in trailer for trailer in trailers), trailers
    original_commit_message = STDIN.read().strip()
    new_commit_message = rework_commit_message(original_commit_message, trailers)
    STDOUT.write(new_commit_message) 
开发者ID:smarkets,项目名称:marge-bot,代码行数:8,代码来源:trailerfilter.py

示例4: setUp

# 需要导入模块: import os [as 别名]
# 或者: from os import environb [as 别名]
def setUp(self):
        self.__save = dict(os.environ)
        if os.supports_bytes_environ:
            self.__saveb = dict(os.environb)
        for key, value in self._reference().items():
            os.environ[key] = value 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_os.py

示例5: tearDown

# 需要导入模块: import os [as 别名]
# 或者: from os import environb [as 别名]
def tearDown(self):
        os.environ.clear()
        os.environ.update(self.__save)
        if os.supports_bytes_environ:
            os.environb.clear()
            os.environb.update(self.__saveb) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_os.py

示例6: init_hypothesis

# 需要导入模块: import os [as 别名]
# 或者: from os import environb [as 别名]
def init_hypothesis():
    """Initialize hypothesis profile if hypothesis is available"""
    try:  # pragma: no cover:w
        if b'HYPOTHESIS_PROFILE' in environb:
            from hypothesis import Settings
            Settings.register_profile("ci", Settings(
                max_examples=10000
            ))
            Settings.load_profile(os.getenv(u'HYPOTHESIS_PROFILE', 'default'))
    except (ImportError, AttributeError):  # pragma: no cover
        pass 
开发者ID:adfinis-sygroup,项目名称:pyaptly,代码行数:13,代码来源:__init__.py


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