当前位置: 首页>>代码示例>>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;未经允许,请勿转载。