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


Python locale.resetlocale方法代码示例

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


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

示例1: test_main_resets_locale

# 需要导入模块: import locale [as 别名]
# 或者: from locale import resetlocale [as 别名]
def test_main_resets_locale(self):
        """
        Reporter entry point should reset encoding to utf-8, as libapt-pkg
        encodes description with system encoding and python-apt decodes
        them as utf-8 (LP: #1827857).
        """
        self._add_package_to_deb_dir(
            self.repository_dir, "gosa", description=u"GOsa\u00B2")
        self.facade.reload_channels()

        # Set the only non-utf8 locale which we're sure exists.
        # It behaves slightly differently than the bug, but fails on the
        # same condition.
        locale.setlocale(locale.LC_CTYPE, (None, None))
        self.addCleanup(locale.resetlocale)

        with mock.patch("landscape.client.package.reporter.run_task_handler"):
            main([])

        # With the actual package, the failure will occur looking up the
        # description translation.
        pkg = self.facade.get_packages_by_name("gosa")[0]
        skel = self.facade.get_package_skeleton(pkg, with_info=True)
        self.assertEqual(u"GOsa\u00B2", skel.description) 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:26,代码来源:test_reporter.py

示例2: test_build_skeleton_with_unicode_and_non_ascii

# 需要导入模块: import locale [as 别名]
# 或者: from locale import resetlocale [as 别名]
def test_build_skeleton_with_unicode_and_non_ascii(self):
        """
        If with_unicode and with_info are passed to build_skeleton_apt,
        the description is decoded.
        """
        # Py2 used to convert to lossy ascii (thus LC_ in Makefile)
        # Py3 doesn't, and python3-apt assumes UTF8 (LP: #1827857).
        # If you revisit this test, also check reporter.main(), which
        # should set this globally to the reporter process.
        locale.setlocale(locale.LC_CTYPE, "C.UTF-8")
        self.addCleanup(locale.resetlocale)

        self._add_package_to_deb_dir(
            self.skeleton_repository_dir, "pkg", description=u"T\xe9st")
        self.facade._cache.update(None)
        self.facade._cache.open(None)
        pkg = self.get_package("pkg")
        skeleton = build_skeleton_apt(pkg, with_unicode=True, with_info=True)
        self.assertEqual(u"T\u00E9st", skeleton.description) 
开发者ID:CanonicalLtd,项目名称:landscape-client,代码行数:21,代码来源:test_skeleton.py

示例3: test_float_rejects_point_for_comma_locale

# 需要导入模块: import locale [as 别名]
# 或者: from locale import resetlocale [as 别名]
def test_float_rejects_point_for_comma_locale():
    locale.setlocale(locale.LC_ALL, "de_DE")
    IMPORTSTRUCT = {"RFCFLOAT": "1.2"}
    try:
        output = client.call("STFC_STRUCTURE", IMPORTSTRUCT=IMPORTSTRUCT)
    except Exception as ex:
        assert type(ex) is ExternalRuntimeError
        assert ex.code == 22
        assert ex.key == "RFC_CONVERSION_FAILURE"
        assert (
            ex.message
            == "Cannot convert string value 1.2 at position 1 for the field RFCFLOAT to type RFCTYPE_FLOAT"
        )
    locale.resetlocale(locale.LC_ALL) 
开发者ID:SAP,项目名称:PyRFC,代码行数:16,代码来源:test_datatypes.py

示例4: test_float_accepts_comma_for_comma_locale

# 需要导入模块: import locale [as 别名]
# 或者: from locale import resetlocale [as 别名]
def test_float_accepts_comma_for_comma_locale():
    locale.setlocale(locale.LC_ALL, "de_DE")
    IMPORTSTRUCT = {"RFCFLOAT": "1,2"}
    output = client.call("STFC_STRUCTURE", IMPORTSTRUCT=IMPORTSTRUCT)["ECHOSTRUCT"]
    assert output["RFCFLOAT"] == 1.2
    locale.resetlocale(locale.LC_ALL) 
开发者ID:SAP,项目名称:PyRFC,代码行数:8,代码来源:test_datatypes.py

示例5: reader_status

# 需要导入模块: import locale [as 别名]
# 或者: from locale import resetlocale [as 别名]
def reader_status(status_fd, update):
	# try to get nicer number formating
	try:
		locale.resetlocale(locale.LC_NUMERIC)
	except Exception:
		pass
	count = 0
	while True:
		update('{0:n} lines read'.format(count))
		data = os.read(status_fd, 8)
		if not data:
			break
		count = struct.unpack("=Q", data)[0] 
开发者ID:eBay,项目名称:accelerator,代码行数:15,代码来源:a_csvimport.py

示例6: script

# 需要导入模块: import locale [as 别名]
# 或者: from locale import resetlocale [as 别名]
def script():
    import locale
    locale.resetlocale()
    parser = argparse.ArgumentParser()
    parser.add_argument('-d', '--database', metavar='DB', help='database connection string')
    parser.add_argument('-v', '--verbose', action='store_true', help='be more verbose')
    parser.add_argument('-o', '--outfile', help='write output to given file instead of stdout')
    subparsers = parser.add_subparsers(title='Commands')
    parserBrowse = subparsers.add_parser('browse', help='browse and plot results')
    browse.initParser(parserBrowse)
    parserCodes = subparsers.add_parser('code', help='code toolkit')
    code.initParser(parserCodes)

    args = parser.parse_args()
    args.func(args) 
开发者ID:supermihi,项目名称:lpdec,代码行数:17,代码来源:__init__.py

示例7: resetlocale

# 需要导入模块: import locale [as 别名]
# 或者: from locale import resetlocale [as 别名]
def resetlocale():
    # locale.resetlocale is bugged with some locales.
    for ln in get_locales():
        try:
            ln = ln[0:ln.index('.')]
            return locale.setlocale(locale.LC_ALL, ln)
        except locale.Error:
            continue 
开发者ID:guohuadeng,项目名称:odoo13-x64,代码行数:10,代码来源:translate.py


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