当前位置: 首页>>代码示例>>Python>>正文


Python uuid.RFC_4122属性代码示例

本文整理汇总了Python中uuid.RFC_4122属性的典型用法代码示例。如果您正苦于以下问题:Python uuid.RFC_4122属性的具体用法?Python uuid.RFC_4122怎么用?Python uuid.RFC_4122使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在uuid的用法示例。


在下文中一共展示了uuid.RFC_4122属性的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_uuid3

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [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) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_uuid.py

示例2: test_uuid5

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_uuid5(self):
        equal = self.assertEqual

        # Test some known version-5 UUIDs.
        for u, v in [(uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org'),
                      '886313e1-3b8a-5372-9b90-0c9aee199e5d'),
                     (uuid.uuid5(uuid.NAMESPACE_URL, 'http://python.org/'),
                      '4c565f0d-3f5a-5890-b41b-20cf47701c5e'),
                     (uuid.uuid5(uuid.NAMESPACE_OID, '1.3.6.1'),
                      '1447fa61-5277-5fef-a9b3-fbc6e44f4af3'),
                     (uuid.uuid5(uuid.NAMESPACE_X500, 'c=ca'),
                      'cc957dd1-a972-5349-98cd-874190002798'),
                    ]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 5)
            equal(u, uuid.UUID(v))
            equal(str(u), v) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_uuid.py

示例3: test_uuid4

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_uuid4(self):
        # uuid4 requires ctypes.
        try:
            import ctypes
        except ImportError:
            return

        equal = self.assertEqual

        # Make sure uuid4() generates UUIDs that are actually version 4.
        for u in [uuid.uuid4() for i in range(10)]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 4)

        # Make sure the generated UUIDs are actually unique.
        uuids = {}
        for u in [uuid.uuid4() for i in range(1000)]:
            uuids[u] = 1
        equal(len(uuids.keys()), 1000) 
开发者ID:dxwu,项目名称:BinderFilter,代码行数:21,代码来源:test_uuid.py

示例4: _check_uuid

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def _check_uuid(uuid_str, spec_version):
    """
    Check whether the given UUID string is valid with respect to the given STIX
    spec version.  STIX 2.0 requires UUIDv4; 2.1 only requires the RFC 4122
    variant.

    :param uuid_str: A UUID as a string
    :param spec_version: The STIX spec version
    :return: True if the UUID is valid, False if not
    :raises ValueError: If uuid_str is malformed
    """
    uuid_obj = uuid.UUID(uuid_str)

    ok = uuid_obj.variant == uuid.RFC_4122
    if ok and spec_version == "2.0":
        ok = uuid_obj.version == 4

    return ok 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:20,代码来源:properties.py

示例5: test_custom_observable_object_no_id_contrib_props

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_custom_observable_object_no_id_contrib_props():
    @stix2.v21.CustomObservable(
        'x-det-id-observable-3', [
            ('property1', stix2.properties.StringProperty(required=True)),
        ],
    )
    class DetIdObs3():
        pass

    dio = DetIdObs3(property1="I am property1!")

    uuid_obj = uuid.UUID(dio.id[-36:])
    assert uuid_obj.variant == uuid.RFC_4122
    assert uuid_obj.version == 4

# Custom Extensions 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:18,代码来源:test_custom.py

示例6: test_no_contrib_props_defined

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_no_contrib_props_defined():

    class SomeSCO(stix2.v21._Observable):
        _type = "some-sco"
        _properties = OrderedDict((
            ('type', TypeProperty(_type, spec_version='2.1')),
            ('id', IDProperty(_type, spec_version='2.1')),
            (
                'extensions', ExtensionsProperty(
                    spec_version='2.1', enclosing_type=_type,
                ),
            ),
        ))
        _id_contributing_properties = []

    sco = SomeSCO()
    uuid_ = _uuid_from_id(sco["id"])

    assert uuid_.variant == uuid.RFC_4122
    assert uuid_.version == 4 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:22,代码来源:test_deterministic_ids.py

示例7: test_deterministic_id_diff_extra_prop_vals

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_deterministic_id_diff_extra_prop_vals():
    email_addr_1 = stix2.v21.EmailAddress(
        value="john@example.com",
        display_name="Johnny Doe",
    )

    email_addr_2 = stix2.v21.EmailAddress(
        value="john@example.com",
        display_name="Janey Doe",
    )

    assert email_addr_1.id == email_addr_2.id

    uuid_obj_1 = uuid.UUID(email_addr_1.id[-36:])
    assert uuid_obj_1.variant == uuid.RFC_4122
    assert uuid_obj_1.version == 5

    uuid_obj_2 = uuid.UUID(email_addr_2.id[-36:])
    assert uuid_obj_2.variant == uuid.RFC_4122
    assert uuid_obj_2.version == 5 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:22,代码来源:test_deterministic_ids.py

示例8: test_deterministic_id_diff_contributing_prop_vals

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_deterministic_id_diff_contributing_prop_vals():
    email_addr_1 = stix2.v21.EmailAddress(
        value="john@example.com",
        display_name="Johnny Doe",
    )

    email_addr_2 = stix2.v21.EmailAddress(
        value="jane@example.com",
        display_name="Janey Doe",
    )

    assert email_addr_1.id != email_addr_2.id

    uuid_obj_1 = uuid.UUID(email_addr_1.id[-36:])
    assert uuid_obj_1.variant == uuid.RFC_4122
    assert uuid_obj_1.version == 5

    uuid_obj_2 = uuid.UUID(email_addr_2.id[-36:])
    assert uuid_obj_2.variant == uuid.RFC_4122
    assert uuid_obj_2.version == 5 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:22,代码来源:test_deterministic_ids.py

示例9: test_deterministic_id_no_contributing_props

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_deterministic_id_no_contributing_props():
    email_msg_1 = stix2.v21.EmailMessage(
        is_multipart=False,
    )

    email_msg_2 = stix2.v21.EmailMessage(
        is_multipart=False,
    )

    assert email_msg_1.id != email_msg_2.id

    uuid_obj_1 = uuid.UUID(email_msg_1.id[-36:])
    assert uuid_obj_1.variant == uuid.RFC_4122
    assert uuid_obj_1.version == 4

    uuid_obj_2 = uuid.UUID(email_msg_2.id[-36:])
    assert uuid_obj_2.variant == uuid.RFC_4122
    assert uuid_obj_2.version == 4 
开发者ID:oasis-open,项目名称:cti-python-stix2,代码行数:20,代码来源:test_deterministic_ids.py

示例10: test_uuid1

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_uuid1(self):
        equal = self.assertEqual

        # Make sure uuid1() generates UUIDs that are actually version 1.
        for u in [uuid.uuid1() for i in range(10)]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 1)

        # Make sure the generated UUIDs are actually unique.
        uuids = {}
        for u in [uuid.uuid1() for i in range(1000)]:
            uuids[u] = 1
        equal(len(uuids.keys()), 1000)

        # Make sure the supplied node ID appears in the UUID.
        u = uuid.uuid1(0)
        equal(u.node, 0)
        u = uuid.uuid1(0x123456789abc)
        equal(u.node, 0x123456789abc)
        u = uuid.uuid1(0xffffffffffff)
        equal(u.node, 0xffffffffffff)

        # Make sure the supplied clock sequence appears in the UUID.
        u = uuid.uuid1(0x123456789abc, 0)
        equal(u.node, 0x123456789abc)
        equal(((u.clock_seq_hi_variant & 0x3f) << 8) | u.clock_seq_low, 0)
        u = uuid.uuid1(0x123456789abc, 0x1234)
        equal(u.node, 0x123456789abc)
        equal(((u.clock_seq_hi_variant & 0x3f) << 8) |
                         u.clock_seq_low, 0x1234)
        u = uuid.uuid1(0x123456789abc, 0x3fff)
        equal(u.node, 0x123456789abc)
        equal(((u.clock_seq_hi_variant & 0x3f) << 8) |
                         u.clock_seq_low, 0x3fff) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:36,代码来源:test_uuid.py

示例11: test_uuid4

# 需要导入模块: import uuid [as 别名]
# 或者: from uuid import RFC_4122 [as 别名]
def test_uuid4(self):
        equal = self.assertEqual

        # Make sure uuid4() generates UUIDs that are actually version 4.
        for u in [uuid.uuid4() for i in range(10)]:
            equal(u.variant, uuid.RFC_4122)
            equal(u.version, 4)

        # Make sure the generated UUIDs are actually unique.
        uuids = {}
        for u in [uuid.uuid4() for i in range(1000)]:
            uuids[u] = 1
        equal(len(uuids.keys()), 1000) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:15,代码来源:test_uuid.py


注:本文中的uuid.RFC_4122属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。