Generate a UUID from three custom blocks. * 'a' is the first 48-bit chunk of the UUID (octets 0-5); * 'b' is the mid 12-bit chunk (octets 6-7); * 'c' is the last 62-bit chunk (octets 8-15). When a value is not specified, a pseudo-random value is generated.
(a=None, b=None, c=None)
| 907 | |
| 908 | |
| 909 | def uuid8(a=None, b=None, c=None): |
| 910 | """Generate a UUID from three custom blocks. |
| 911 | |
| 912 | * 'a' is the first 48-bit chunk of the UUID (octets 0-5); |
| 913 | * 'b' is the mid 12-bit chunk (octets 6-7); |
| 914 | * 'c' is the last 62-bit chunk (octets 8-15). |
| 915 | |
| 916 | When a value is not specified, a pseudo-random value is generated. |
| 917 | """ |
| 918 | if a is None: |
| 919 | import random |
| 920 | a = random.getrandbits(48) |
| 921 | if b is None: |
| 922 | import random |
| 923 | b = random.getrandbits(12) |
| 924 | if c is None: |
| 925 | import random |
| 926 | c = random.getrandbits(62) |
| 927 | int_uuid_8 = (a & 0xffff_ffff_ffff) << 80 |
| 928 | int_uuid_8 |= (b & 0xfff) << 64 |
| 929 | int_uuid_8 |= c & 0x3fff_ffff_ffff_ffff |
| 930 | # by construction, the variant and version bits are already cleared |
| 931 | int_uuid_8 |= _RFC_4122_VERSION_8_FLAGS |
| 932 | return UUID._from_int(int_uuid_8) |
| 933 | |
| 934 | |
| 935 | def main(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…