ž §ÿfMWc@sdZdZddddg\ZZZZeZeZ Gdd„de ƒZ dd „Z d d „Z d d „Zdd„ZeZZZyDddlZddlZx‡ddgD]yZyejejjeƒƒZWn w²YnXeedƒrejZneedƒr+ejZeek r(Pnnq²WddlZejdkrŽddl Z ee j!ƒj"j#dƒdƒdkr‹eZZnnyej$j%ZWneZYnXe&ede&edeƒƒZWnYnXdd„Z'dd„Z(dd „Z)ea*d!d"„Z+ea,eed#d$„Z-d%d&„Z.d'd(„Z/d)d*„Z0e d+ƒZ1e d,ƒZ2e d-ƒZ3e d.ƒZ4dS(/uQUUID objects (universally unique identifiers) according to RFC 4122. This module provides immutable UUID objects (class UUID) and the functions uuid1(), uuid3(), uuid4(), uuid5() for generating version 1, 3, 4, and 5 UUIDs as specified in RFC 4122. If all you want is a unique ID, you should probably call uuid1() or uuid4(). Note that uuid1() may compromise privacy since it creates a UUID containing the computer's network address. uuid4() creates a random UUID. Typical usage: >>> import uuid # make a UUID based on the host ID and current time >>> uuid.uuid1() # doctest: +SKIP UUID('a8098c1a-f86e-11da-bd1a-00112444be1e') # make a UUID using an MD5 hash of a namespace UUID and a name >>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org') UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e') # make a random UUID >>> uuid.uuid4() # doctest: +SKIP UUID('16fd2706-8baf-433b-82eb-8c7fada847da') # make a UUID using a SHA-1 hash of a namespace UUID and a name >>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org') UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d') # make a UUID from a string of hex digits (braces and hyphens ignored) >>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}') # convert a UUID to a string of hex digits in standard form >>> str(x) '00010203-0405-0607-0809-0a0b0c0d0e0f' # get the raw 16 bytes of the UUID >>> x.bytes b'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f' # make a UUID from a 16-byte string >>> uuid.UUID(bytes=x.bytes) UUID('00010203-0405-0607-0809-0a0b0c0d0e0f') uKa-Ping Yee ureserved for NCS compatibilityuspecified in RFC 4122u$reserved for Microsoft compatibilityureserved for future definitioncBsÊ|EeZdZdZd8d8d8d8d8d8dd„Zdd„Zdd„Zdd „Zd d „Z d d „Z dd„Z dd„Z dd„Z dd„Zdd„Zdd„Zedd„ƒZedd„ƒZedd„ƒZed d!„ƒZed"d#„ƒZed$d%„ƒZed&d'„ƒZed(d)„ƒZed*d+„ƒZed,d-„ƒZed.d/„ƒZed0d1„ƒZed2d3„ƒZed4d5„ƒZed6d7„ƒZ d8S(9uUUIDuÚInstances of the UUID class represent UUIDs as specified in RFC 4122. UUID objects are immutable, hashable, and usable as dictionary keys. Converting a UUID to a string with str() yields something in the form '12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts five possible forms: a similar string of hexadecimal digits, or a tuple of six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and 48-bit values respectively) as an argument named 'fields', or a string of 16 bytes (with all the integer fields in big-endian order) as an argument named 'bytes', or a string of 16 bytes (with the first three fields in little-endian order) as an argument named 'bytes_le', or a single 128-bit integer as an argument named 'int'. UUIDs have these read-only attributes: bytes the UUID as a 16-byte string (containing the six integer fields in big-endian byte order) bytes_le the UUID as a 16-byte string (with time_low, time_mid, and time_hi_version in little-endian byte order) fields a tuple of the six integer fields of the UUID, which are also available as six individual attributes and two derived attributes: time_low the first 32 bits of the UUID time_mid the next 16 bits of the UUID time_hi_version the next 16 bits of the UUID clock_seq_hi_variant the next 8 bits of the UUID clock_seq_low the next 8 bits of the UUID node the last 48 bits of the UUID time the 60-bit timestamp clock_seq the 14-bit sequence number hex the UUID as a 32-character hexadecimal string int the UUID as a 128-bit integer urn the UUID as a URN as specified in RFC 4122 variant the UUID variant (one of the constants RESERVED_NCS, RFC_4122, RESERVED_MICROSOFT, or RESERVED_FUTURE) version the UUID version number (1 through 5, meaningful only when the variant is RFC_4122) c CsÖ|||||gjdƒdkr3tdƒ‚n|dk r«|jddƒjddƒ}|jdƒjddƒ}t|ƒdkr™td ƒ‚nt|d ƒ}n|dk r9t|ƒd krØtd ƒ‚ntt |d d…ƒƒtt |dd …ƒƒtt |d d…ƒƒ|dd…}n|dk r§t|ƒd krftdƒ‚nt |tƒs‡t t |ƒƒ‚tdd t |ƒd ƒ}n|dk r%t|ƒd krÔtdƒ‚n|\}}} } } } d |kod'knstdƒ‚nd |ko.d(knsBtdƒ‚nd | koYd)knsmtdƒ‚nd | ko„d*kns˜tdƒ‚nd | ko¯d+knsÃtdƒ‚nd | koÚd,knsîtdƒ‚n| d>| B} |d>|d>B| d>B| d>B| B}n|dk r_d |koHd-kns_tdƒ‚q_n|dk rÅd|ko‚d kns–td!ƒ‚n|d/M}|d0O}|d2M}||d%>O}n||jd&|jd>B|jBS(Niÿi0i (utime_hi_versionutime_midutime_low(uself((u)/opt/alt/python33/lib64/python3.3/uuid.pyutimesu UUID.timecCs|jd@d>|jBS(Ni?i(uclock_seq_hi_variantu clock_seq_low(uself((u)/opt/alt/python33/lib64/python3.3/uuid.pyu clock_seqsuUUID.clock_seqcCs |jd@S(Nlÿÿÿ(uint(uself((u)/opt/alt/python33/lib64/python3.3/uuid.pyunodesu UUID.nodecCs d|jS(Nu%032x(uint(uself((u)/opt/alt/python33/lib64/python3.3/uuid.pyuhex!suUUID.hexcCsdt|ƒS(Nu urn:uuid:(ustr(uself((u)/opt/alt/python33/lib64/python3.3/uuid.pyuurn%suUUID.urncCs;|jd@stS|jd@s"tS|jd@s3tStSdS(Ni€i0i@i lll(uintu RESERVED_NCSuRFC_4122uRESERVED_MICROSOFTuRESERVED_FUTURE(uself((u)/opt/alt/python33/lib64/python3.3/uuid.pyuvariant)s   u UUID.variantcCs(|jtkr$t|jd?d@ƒSdS(NiLi(uvariantuRFC_4122uint(uself((u)/opt/alt/python33/lib64/python3.3/uuid.pyuversion4su UUID.versionN(!u__name__u __module__u __qualname__u__doc__uNoneu__init__u__eq__u__ne__u__lt__u__gt__u__le__u__ge__u__hash__u__int__u__repr__u __setattr__u__str__upropertyubytesubytes_leufieldsutime_lowutime_midutime_hi_versionuclock_seq_hi_variantu clock_seq_lowutimeu clock_sequnodeuhexuurnuvariantuversion(u __locals__((u)/opt/alt/python33/lib64/python3.3/uuid.pyuUUID8s:. P            uUUIDc CsGddl}ddl}|j|ƒ}|dkrm|jjd ƒ}|j|d|ƒ}|dkrmdSnyÁd||f}|j|ƒœ} x’| D]Š} | jƒjƒ} xot t | ƒƒD][} | | |krÄy't | || ƒj ddƒdƒSWqt tfk rYqXqÄqÄWq™WWdQXWntk rBYnXdS( Niu/sbinu /usr/sbinupathuLC_ALL=C %s %s 2>/dev/nullu:ui(u/sbinu /usr/sbin(uosushutiluwhichuNoneupathsepujoinupopenuloweruspliturangeulenuintureplaceu ValueErroru IndexErroruIOError( ucommanduargsuhw_identifiersu get_indexuosushutilu executableupathucmdupipeulineuwordsui((u)/opt/alt/python33/lib64/python3.3/uuid.pyu _find_mac:s*   $ u _find_maccCs±x9dD]1}td|ddgdd„ƒ}|r|SqWd d l}|j|jƒƒ}td d |gd d„ƒ}|r…|Stdddgdd„ƒ}|r­|Sd S(u5Get the hardware address on Unix by running ifconfig.uu-au-avuifconfiguhwaddruethercSs|dS(Ni((ui((u)/opt/alt/python33/lib64/python3.3/uuid.pyu^su#_ifconfig_getnode..iNuarpu-ancSsdS(Niiÿÿÿÿ((ui((u)/opt/alt/python33/lib64/python3.3/uuid.pyufsulanscanu-aiulan0cSsdS(Ni((ui((u)/opt/alt/python33/lib64/python3.3/uuid.pyuks(uu-au-av(u _find_macusocketu gethostbynameu gethostnameuNone(uargsumacusocketuip_addr((u)/opt/alt/python33/lib64/python3.3/uuid.pyu_ifconfig_getnodeYs ! u_ifconfig_getnodec CsCddl}ddl}dddg}yQddl}|jdƒ}|jjj|dƒ|jd|jj dƒƒWnYnXx¹|D]±}zy&|j |j j |dƒd ƒ}Wnt k rÐwŠYn\XxX|D]P}|jd ƒdjƒjƒ}|jd |ƒrØt|jd dƒdƒSqØWWd|jƒXqŠWdS(u<Get the hardware address on Windows by running ipconfig.exe.iNuuc:\windows\system32uc:\winnt\system32i,umbcsuipconfigu /allu:iu&([0-9a-f][0-9a-f]-){5}[0-9a-f][0-9a-f]u-iiÿÿÿÿ(uosureuctypesucreate_string_bufferuwindllukernel32uGetSystemDirectoryAuinsertuvalueudecodeupopenupathujoinuIOErrorusplitustripulowerumatchuintureplaceuclose( uosureudirsuctypesubufferudirupipeulineuvalue((u)/opt/alt/python33/lib64/python3.3/uuid.pyu_ipconfig_getnodeqs&   &  !u_ipconfig_getnodecCs•ddl}ddl}|jƒ}|j|_|jƒ|_}|jƒ|j|ƒdkrfdS|j ƒxt |j ƒD] }|j ƒ|j |_t|j|ƒ|_|j|ƒdkrÍq€n|j ƒ|j|_t|j|ƒ|_djdƒ|_|jƒ|_}|j|ƒdkr9q€n|j ƒ|j}|dd>|dd>|dd >|d d>|d d >|d SWdS(utGet the hardware address on Windows using NetBIOS calls. See http://support.microsoft.com/kb/118623 for details.iNu*ii(ii iiiiii(u win32wnetunetbiosuNCBuNCBENUMuCommandu LANA_ENUMuBufferu_packuNetbiosu_unpackurangeulengthuResetuNCBRESETuordulanauLana_numuNCBASTATuljustuCallnameuADAPTER_STATUSuadapter_address(u win32wnetunetbiosuncbuadaptersuiustatusubytes((u)/opt/alt/python33/lib64/python3.3/uuid.pyu_netbios_getnode‰s0          u_netbios_getnodeiNuuuiducuuuid_generate_randomuuuid_generate_timeudarwinu.i uUuidCreateSequentialu UuidCreatecCs2tjdƒ}t|ƒtdt|jƒƒjS(u.Get the hardware address on Unix using ctypes.iubytes(uctypesucreate_string_bufferu_uuid_generate_timeuUUIDubytes_urawunode(u_buffer((u)/opt/alt/python33/lib64/python3.3/uuid.pyu_unixdll_getnodeÚs u_unixdll_getnodecCs>tjdƒ}t|ƒdkr:tdt|jƒƒjSdS(u1Get the hardware address on Windows using ctypes.iiubytesN(uctypesucreate_string_bufferu _UuidCreateuUUIDubytes_urawunode(u_buffer((u)/opt/alt/python33/lib64/python3.3/uuid.pyu_windll_getnodeàsu_windll_getnodecCs ddl}|jddƒdBS(uCGet a random node ID, with eighth bit set as suggested by RFC 4122.iNii0ll(urandomu randrange(urandom((u)/opt/alt/python33/lib64/python3.3/uuid.pyu_random_getnodeæs u_random_getnodec Cstdk rtSddl}|jdkr=tttg}n ttg}x@|t gD]1}y |ƒaWn wWYnXtdk rWtSqWWdS(u3Get the hardware address as a 48-bit positive integer. The first time this runs, it may launch a separate program, which could be quite slow. If all attempts to obtain the hardware address fail, we choose a random 48-bit number with its eighth bit set to 1 as recommended in RFC 4122. iNuwin32( u_nodeuNoneusysuplatformu_windll_getnodeu_netbios_getnodeu_ipconfig_getnodeu_unixdll_getnodeu_ifconfig_getnodeu_random_getnode(usysugettersugetter((u)/opt/alt/python33/lib64/python3.3/uuid.pyugetnodeís     ugetnodec CsWtrQ||kodknrQtjdƒ}t|ƒtdt|jƒƒSddl}t|jƒdƒ}t|dƒd}t dk r¬|t kr¬t d}n|a |dkrÜddl }|j dƒ}n|d @}|d ?d @}|d ?d@} |d@} |d?d@} |dkr2t ƒ}ntd||| | | |fddƒS(uGenerate a UUID from a host ID, sequence number, and the current time. If 'node' is not given, getnode() is used to obtain the hardware address. If 'clock_seq' is given, it is used as the sequence number; otherwise a random 14-bit sequence number is chosen.iubytesiNgeÍÍAidl@'Hw iilÿÿi iÿÿi0iÿiÿii?ufieldsuversioni@( u_uuid_generate_timeuNoneuctypesucreate_string_bufferuUUIDubytes_urawutimeuintu_last_timestampurandomu randrangeugetnode( unodeu clock_sequ_bufferutimeu nanosecondsu timestampurandomutime_lowutime_midutime_hi_versionu clock_seq_lowuclock_seq_hi_variant((u)/opt/alt/python33/lib64/python3.3/uuid.pyuuuid1 s,"         uuuid1cCsOddlm}||jt|dƒƒjƒ}td|dd…ddƒS( uAGenerate a UUID from the MD5 hash of a namespace UUID and a name.i(umd5uutf-8ubytesNiuversioni(uhashlibumd5ubytesudigestuUUID(u namespaceunameumd5uhash((u)/opt/alt/python33/lib64/python3.3/uuid.pyuuuid3-s"uuuid3c s´tr5tjdƒ}t|ƒtdt|jƒƒSy,ddl}td|jdƒddƒSWnLddl‰t‡fdd†t dƒDƒƒ}td|ddƒSYnXdS( uGenerate a random UUID.iubytesiNuversionic3s|]}ˆjdƒVqdS(iN(u randrange(u.0ui(urandom(u)/opt/alt/python33/lib64/python3.3/uuid.pyu Bsuuuid4..( u_uuid_generate_randomuctypesucreate_string_bufferuUUIDubytes_urawuosuurandomurandomurange(u_bufferuosubytes((urandomu)/opt/alt/python33/lib64/python3.3/uuid.pyuuuid43s    %uuuid4cCsOddlm}||jt|dƒƒjƒ}td|dd…ddƒS( uCGenerate a UUID from the SHA-1 hash of a namespace UUID and a name.i(usha1uutf-8ubytesNiuversioni(uhashlibusha1ubytesudigestuUUID(u namespaceunameusha1uhash((u)/opt/alt/python33/lib64/python3.3/uuid.pyuuuid5Es"uuuid5u$6ba7b810-9dad-11d1-80b4-00c04fd430c8u$6ba7b811-9dad-11d1-80b4-00c04fd430c8u$6ba7b812-9dad-11d1-80b4-00c04fd430c8u$6ba7b814-9dad-11d1-80b4-00c04fd430c8(5u__doc__u __author__u RESERVED_NCSuRFC_4122uRESERVED_MICROSOFTuRESERVED_FUTUREuintuint_ubytesubytes_uobjectuUUIDu _find_macu_ifconfig_getnodeu_ipconfig_getnodeu_netbios_getnodeuNoneu_uuid_generate_randomu_uuid_generate_timeu _UuidCreateuctypesu ctypes.utilulibnameuCDLLuutilu find_libraryulibuhasattruuuid_generate_randomuuuid_generate_timeusysuplatformuosuunameureleaseusplituwindllurpcrt4ugetattru_unixdll_getnodeu_windll_getnodeu_random_getnodeu_nodeugetnodeu_last_timestampuuuid1uuuid3uuuid4uuuid5u NAMESPACE_DNSu NAMESPACE_URLu NAMESPACE_OIDuNAMESPACE_X500(((u)/opt/alt/python33/lib64/python3.3/uuid.pyu-shÿ    !     (       #