本文整理汇总了Python中uuid.NAMESPACE_DNS属性的典型用法代码示例。如果您正苦于以下问题:Python uuid.NAMESPACE_DNS属性的具体用法?Python uuid.NAMESPACE_DNS怎么用?Python uuid.NAMESPACE_DNS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类uuid
的用法示例。
在下文中一共展示了uuid.NAMESPACE_DNS属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_uuid_binary_5
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import NAMESPACE_DNS [as 别名]
def test_uuid_binary_5(self):
from uuid import uuid5, NAMESPACE_DNS
uuid = uuid5(NAMESPACE_DNS, 'python.org')
registry = self.init_registry(simple_column, ColumnType=UUID)
test = registry.Test.insert(col=uuid)
assert test.col is uuid
示例2: generate_uuid
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import NAMESPACE_DNS [as 别名]
def generate_uuid():
friendly_name = 'device.tubecast.{}'.format(Kodicast.friendlyName)
if not PY3:
friendly_name = friendly_name.encode('utf8')
Kodicast.uuid = str(uuid.uuid5(
uuid.NAMESPACE_DNS,
friendly_name))
示例3: test_uuid_binary_3
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import NAMESPACE_DNS [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
示例4: generate_unique_code
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import NAMESPACE_DNS [as 别名]
def generate_unique_code(self, deal, user):
"""
Generates Tickets for virtual deals
Arguments:
deal -- object representing the deal being purchased
user -- object representing customer
Returns:
filename -- name of the file where QR code is stored
id -- unique ID generated for this transaction
"""
# Converts utf8 to ascii strings because that is what UUID works with
merchant_name = deal.advertiser.name.encode("utf8")
deal_name = deal.advertiser.name.encode("utf8")
username = user.username.encode("utf8")
# Generates a unique code with python's UUID library
# and embed in qrcode
ticket_id = uuid.uuid5(
uuid.NAMESPACE_DNS, merchant_name + deal_name + username
)
qr = qrcode.QRCode(
version=1,
error_correction=qrcode.constants.ERROR_CORRECT_L,
box_size=10,
border=4,
)
qr.add_data(ticket_id)
qr.make(fit=True)
img = qr.make_image()
output = StringIO.StringIO()
img.save(output, 'PNG')
img = output.getvalue().encode("base64")
output.close()
return img, ticket_id
示例5: __str__
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import NAMESPACE_DNS [as 别名]
def __str__(self):
return uuid.uuid5(
namespace=uuid.NAMESPACE_DNS,
name=f"user<{self.user}>:"
f"project<{self.project}>:"
f"team<{self.team}>:"
f"organization<{self.organization}>",
).hex
示例6: get_volume_name
# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import NAMESPACE_DNS [as 别名]
def get_volume_name(path: str) -> str:
name = uuid.uuid5(namespace=uuid.NAMESPACE_DNS, name=path).hex
return constants.CONTEXT_VOLUME_CONNECTIONS_FORMAT.format(name)