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