本文整理匯總了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)