Lines Matching refs:UUID

1 r"""UUID objects (universally unique identifiers) according to RFC 4122.
3 This module provides immutable UUID objects (class UUID) and the functions
8 Note that uuid1() may compromise privacy since it creates a UUID containing
9 the computer's network address. uuid4() creates a random UUID.
15 # make a UUID based on the host ID and current time
17 UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
19 # make a UUID using an MD5 hash of a namespace UUID and a name
21 UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
23 # make a random UUID
25 UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
27 # make a UUID using a SHA-1 hash of a namespace UUID and a name
29 UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
31 # make a UUID from a string of hex digits (braces and hyphens ignored)
32 >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
34 # convert a UUID to a string of hex digits in standard form
38 # get the raw 16 bytes of the UUID
42 # make a UUID from a 16-byte string
43 >>> uuid.UUID(bytes=x.bytes)
44 UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
85 class UUID:
86 """Instances of the UUID class represent UUIDs as specified in RFC 4122.
87 UUID objects are immutable, hashable, and usable as dictionary keys.
88 Converting a UUID to a string with str() yields something in the form
89 '12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts
100 bytes the UUID as a 16-byte string (containing the six
103 bytes_le the UUID as a 16-byte string (with time_low, time_mid,
106 fields a tuple of the six integer fields of the UUID,
110 time_low the first 32 bits of the UUID
111 time_mid the next 16 bits of the UUID
112 time_hi_version the next 16 bits of the UUID
113 clock_seq_hi_variant the next 8 bits of the UUID
114 clock_seq_low the next 8 bits of the UUID
115 node the last 48 bits of the UUID
120 hex the UUID as a 32-character hexadecimal string
122 int the UUID as a 128-bit integer
124 urn the UUID as a URN as specified in RFC 4122
126 variant the UUID variant (one of the constants RESERVED_NCS,
129 version the UUID version number (1 through 5, meaningful only
132 is_safe An enum indicating whether the UUID has been generated in
142 r"""Create a UUID from either a string of 32 hexadecimal digits,
150 expressions all yield the same UUID:
152 UUID('{12345678-1234-5678-1234-567812345678}')
153 UUID('12345678123456781234567812345678')
154 UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
155 UUID(bytes='\x12\x34\x56\x78'*4)
156 UUID(bytes_le='\x78\x56\x34\x12\x34\x12\x78\x56' +
158 UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
159 UUID(int=0x12345678123456781234567812345678)
163 UUID will have its variant and version set according to RFC 4122,
167 indicates whether the UUID has been generated in a way that is safe
178 raise ValueError('badly formed hexadecimal UUID string')
241 if isinstance(other, UUID):
249 if isinstance(other, UUID):
254 if isinstance(other, UUID):
259 if isinstance(other, UUID):
264 if isinstance(other, UUID):
278 raise TypeError('UUID objects are immutable')
599 return UUID(bytes=uuid_time).node
605 return UUID(bytes_le=uuid_bytes).node
675 """Generate a UUID from a host ID, sequence number, and the current time.
680 # When the system provides a version-1 UUID generator, use it (but don't
688 return UUID(bytes=uuid_time, is_safe=is_safe)
694 # UUID epoch 1582-10-15 00:00:00 and the Unix epoch 1970-01-01 00:00:00.
709 return UUID(fields=(time_low, time_mid, time_hi_version,
713 """Generate a UUID from the MD5 hash of a namespace UUID and a name."""
719 return UUID(bytes=digest[:16], version=3)
722 """Generate a random UUID."""
723 return UUID(bytes=os.urandom(16), version=4)
726 """Generate a UUID from the SHA-1 hash of a namespace UUID and a name."""
729 return UUID(bytes=hash[:16], version=5)
733 NAMESPACE_DNS = UUID('6ba7b810-9dad-11d1-80b4-00c04fd430c8')
734 NAMESPACE_URL = UUID('6ba7b811-9dad-11d1-80b4-00c04fd430c8')
735 NAMESPACE_OID = UUID('6ba7b812-9dad-11d1-80b4-00c04fd430c8')
736 NAMESPACE_X500 = UUID('6ba7b814-9dad-11d1-80b4-00c04fd430c8')