本文整理汇总了Python中mimetypes._winreg方法的典型用法代码示例。如果您正苦于以下问题:Python mimetypes._winreg方法的具体用法?Python mimetypes._winreg怎么用?Python mimetypes._winreg使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mimetypes
的用法示例。
在下文中一共展示了mimetypes._winreg方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_non_latin_extension
# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import _winreg [as 别名]
def test_non_latin_extension(self):
import _winreg
class MockWinreg(object):
def __getattr__(self, name):
if name == 'EnumKey':
return lambda key, i: _winreg.EnumKey(key, i) + "\xa3"
elif name == 'OpenKey':
return lambda key, name: _winreg.OpenKey(key, name.rstrip("\xa3"))
elif name == 'QueryValueEx':
return lambda subkey, label: (u'текст/простой' , _winreg.REG_SZ)
return getattr(_winreg, name)
mimetypes._winreg = MockWinreg()
try:
# this used to throw an exception if registry contained non-Latin
# characters in extensions (issue #9291)
mimetypes.init()
finally:
mimetypes._winreg = _winreg
示例2: test_non_latin_type
# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import _winreg [as 别名]
def test_non_latin_type(self):
import _winreg
class MockWinreg(object):
def __getattr__(self, name):
if name == 'QueryValueEx':
return lambda subkey, label: (u'текст/простой', _winreg.REG_SZ)
return getattr(_winreg, name)
mimetypes._winreg = MockWinreg()
try:
# this used to throw an exception if registry contained non-Latin
# characters in content types (issue #9291)
mimetypes.init()
finally:
mimetypes._winreg = _winreg
示例3: test_registry_read_error
# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import _winreg [as 别名]
def test_registry_read_error(self):
import _winreg
class MockWinreg(object):
def OpenKey(self, key, name):
if key != _winreg.HKEY_CLASSES_ROOT:
raise WindowsError(5, "Access is denied")
return _winreg.OpenKey(key, name)
def __getattr__(self, name):
return getattr(_winreg, name)
mimetypes._winreg = MockWinreg()
try:
mimetypes.init()
finally:
mimetypes._winreg = _winreg
示例4: test_type_map_values
# 需要导入模块: import mimetypes [as 别名]
# 或者: from mimetypes import _winreg [as 别名]
def test_type_map_values(self):
import _winreg
class MockWinreg(object):
def __getattr__(self, name):
if name == 'QueryValueEx':
return lambda subkey, label: (u'text/plain', _winreg.REG_SZ)
return getattr(_winreg, name)
mimetypes._winreg = MockWinreg()
try:
mimetypes.init()
self.assertTrue(isinstance(mimetypes.types_map.values()[0], str))
finally:
mimetypes._winreg = _winreg