本文整理汇总了Python中uuid.uuid3方法的典型用法代码示例。如果您正苦于以下问题:Python uuid.uuid3方法的具体用法?Python uuid.uuid3怎么用?Python uuid.uuid3使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uuid
的用法示例。
在下文中一共展示了uuid.uuid3方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def __init__(self, module, block, module_name, extra):
self.module = module
self.block = block
self.module_name = module_name
self._extra = extra
method_block_index = self.get_code_block_index(self.block)
if method_block_index is None:
raise Exception('Block of code of a method from %s module was not found', self.module_name)
self.name = self.block[method_block_index + 1].arg
self._id = uuid3(UUID('{baa187e0-2c51-4ef6-aa42-b3421c22d5e1}'), self.full_name)
self.start_line_no = self.block[method_block_index].lineno
self.code_object = self.block[method_block_index].arg
# dis.dis(code_object)
self.code, self.dictionary_defs = preprocess_method_body(self.code_object)
self.bytecode = Bytecode.from_code(self.code)
self.evaluate_annotations(method_block_index)
self.setup()
示例2: test_uuid3
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def test_uuid3(self):
equal = self.assertEqual
# Test some known version-3 UUIDs.
for u, v in [(uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org'),
'6fa459ea-ee8a-3ca4-894e-db77e160355e'),
(uuid.uuid3(uuid.NAMESPACE_URL, 'http://python.org/'),
'9fe8e8c4-aaa8-32a9-a55c-4535a88b748d'),
(uuid.uuid3(uuid.NAMESPACE_OID, '1.3.6.1'),
'dd1a1cef-13d5-368a-ad82-eca71acd4cd1'),
(uuid.uuid3(uuid.NAMESPACE_X500, 'c=ca'),
'658d3002-db6b-3040-a1d1-8ddd7d189a4d'),
]:
equal(u.variant, uuid.RFC_4122)
equal(u.version, 3)
equal(u, uuid.UUID(v))
equal(str(u), v)
示例3: _fix
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def _fix(self):
if self.uuid_template:
return uuid.UUID(("%08x%04x%04x" + ("%02x" * 8))
% self.uuid_template)
elif self.version == 1:
return uuid.uuid1(self.node, self.clock_seq)
elif self.version == 3:
return uuid.uuid3(self.namespace, self.name)
elif self.version == 4:
return uuid.uuid4()
elif self.version == 5:
return uuid.uuid5(self.namespace, self.name)
else:
raise ValueError("Unhandled version")
# Automatic timestamp
示例4: generate_uuid_from_subject
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def generate_uuid_from_subject(self, baseuuid, subject):
uuidregx = re.compile(r"[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}")
matches = uuidregx.search(str(subject))
if matches:
return matches.group(0)
else:
return str(uuid.uuid3(baseuuid, str(subject)))
示例5: _fabric_server_uuid
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def _fabric_server_uuid(host, port):
"""Create a UUID using host and port"""
return uuid.uuid3(uuid.NAMESPACE_URL, _fabric_xmlrpc_uri(host, port))
示例6: __init__
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def __init__(self, url):
self.fullurl = self._complete_url(url)
uinfo = urlparse.urlparse(self.fullurl)
pext = os.path.splitext(uinfo.path)
if len(pext) == 2 and pext[1] not in ('.cgi', '.sh'):
warnings.warn("Recommended suffix CGI!")
self.host = uinfo.hostname
self.uuid = uuid.uuid3(uuid.NAMESPACE_DNS, 'hanchen.me').hex
self.user = 'unknown'
self._init_opener()
示例7: get_uuid3
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def get_uuid3(str_in):
""" make a UUID using an MD5 hash of a namespace UUID and a name
@param str_in 输入字符串
"""
s = uuid.uuid3(uuid.NAMESPACE_DNS, str_in)
return str(s)
示例8: get_uuid3
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def get_uuid3(str_in):
"""Generate a UUID using an MD5 hash of a namespace UUID and a name
Args:
str_in: Input string.
Returns:
s: UUID3 string.
"""
uid3 = uuid.uuid3(uuid.NAMESPACE_DNS, str_in)
s = str(uid3)
return s
示例9: generate_material_name
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def generate_material_name(shader_name, macros=None):
if macros is not None and 0 < len(macros):
keys = sorted(macros.keys())
add_name = [key + "_" + str(macros[key]) for key in keys]
shader_name += "_" + str(uuid.uuid3(uuid.NAMESPACE_DNS, "_".join(add_name))).replace("-", "_")
return shader_name
示例10: confuse_text
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def confuse_text(text):
seeds = 'abcdefghijklmnopqrst'
uid = str(uuid.uuid3(uuid.NAMESPACE_DNS, text))
uid = "".join(uid.split('-'))
result = ""
for c in uid:
try:
num = int(c)
result += seeds[num]
except Exception as e:
result += c
return result.upper()
# 生成混淆文件
示例11: test_uuid_binary_3
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def test_uuid_binary_3(self):
from uuid import uuid3, NAMESPACE_DNS
uuid = uuid3(NAMESPACE_DNS, 'python.org')
registry = self.init_registry(simple_column, ColumnType=UUID)
test = registry.Test.insert(col=uuid)
assert test.col is uuid
示例12: test_uuid3_matches
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def test_uuid3_matches():
for _ in range(100):
uuid_format_validator(str(uuid.uuid3(uuid.uuid4(), 'test-4')))
uuid_format_validator(str(uuid.uuid3(uuid.uuid1(), 'test-1')))
示例13: id_from_name
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def id_from_name(name):
"""Generate a UUID using a name as the namespace
:type name: str
:rtype: str
"""
return str(uuid.uuid3(uuid.NAMESPACE_DNS, name)).upper()
示例14: create_uuid3
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def create_uuid3(namespace, name):
"""
Return new UUID based on a hash of a UUID namespace and a string.
:param namespace: The namespace
:param name: The string
:type namespace: uuid.UUID
:type name: six.text
:return:
:rtype: uuid.UUID
"""
return uuid.uuid3(namespace, six.ensure_str(name))
示例15: generateUuid
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import uuid3 [as 别名]
def generateUuid(self, email_id, machine_name):
""" return a uuid which uniquely identifies machinename and email id """
uuidstr = None
if machine_name not in self.d:
myNamespace = uuid.uuid3(uuid.NAMESPACE_URL, machine_name)
uuidstr = str(uuid.uuid3(myNamespace, email_id))
self.d[machine_name] = (machine_name, uuidstr, email_id)
self.d[uuidstr] = (machine_name, uuidstr ,email_id)
else:
(machine_name, uuidstr, email_id) = self.d[machine_name]
return uuidstr