當前位置: 首頁>>代碼示例>>Python>>正文


Python uuid.NAMESPACE_DNS屬性代碼示例

本文整理匯總了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 
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:8,代碼來源:test_column.py

示例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)) 
開發者ID:enen92,項目名稱:script.tubecast,代碼行數:9,代碼來源:kodicast.py

示例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 
開發者ID:AnyBlok,項目名稱:AnyBlok,代碼行數:8,代碼來源:test_column.py

示例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 
開發者ID:andela,項目名稱:troupon,代碼行數:39,代碼來源:views.py

示例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 
開發者ID:polyaxon,項目名稱:polyaxon,代碼行數:10,代碼來源:option_owners.py

示例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) 
開發者ID:polyaxon,項目名稱:polyaxon,代碼行數:5,代碼來源:volumes.py


注:本文中的uuid.NAMESPACE_DNS屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。