\dkdZddlZddlZddlmZmZdZejdvrdxZZ nddlZej Z e dkZe dkZ d Z dZ erd Z d Z gd \ZZZZeZeZeeGd dZGddZdZdZdZdZdZdZdZdZdZ dZ!dZ"dZ# ddl$Z$e%e$ddZ&e%e$ddZ'e$j(Z)n#e*$r dZ$dZ&dZ'dZ)YnwxYwdZ+d Z,d!Z-d"Z.e reegZ/n,ejd#kreee!gZ/nejd$krgZ/n ere!gZ/neeee!e gZ/ej0d%kre,ge/zZ1nej0d&kre-ge/zZ1ne/Z1da2d'Z3da4d0d(Z5d)Z6d*Z7d+Z8ed,Z9ed-Z:ed.Z;ed/Z>> 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') N)Enum _simple_enumzKa-Ping Yee )win32darwinFAIXLinux:.T)zreserved for NCS compatibilityzspecified in RFC 4122z$reserved for Microsoft compatibilityzreserved for future definitionceZdZdZdZdZdS)SafeUUIDrN)__name__ __module__ __qualname__safeunsafeunknown..\python\lib\uuid.pyr r Ns D FGGGrr ceZdZdZdZ d!ejddZdZdZ dZ d Z d Z d Z d Zd ZdZdZdZdZedZedZedZedZedZedZedZedZedZedZedZedZ edZ!edZ"ed Z#dS)"UUIDa 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) is_safe An enum indicating whether the UUID has been generated in a way that is safe for multiprocessing applications, via uuid_generate_time_safe(3). )intis_safe __weakref__N)rc|||||gddkrtd||dddd}|ddd}t |d krt d t |d }|Pt |d krt d |d dd|dd dz|dddz|ddz}|ht |d krt dt|tsJt|t |}|t |dkrt d|\}} } } } } d|cxkrdksnt dd| cxkrdksnt dd| cxkrdksnt dd| cxkrdksnt dd| cxkrdksnt dd| cxkrdksnt d| dz| z}|d z| d!zz| d"zz|d#zz| z}|!d|cxkr d$d%zksnt d&|5d$|cxkrdksnt d'|d(z}|d)z}|d*z}||d+zz}t |d,|t |d-|dS).aLCreate a UUID from either a string of 32 hexadecimal digits, a string of 16 bytes as the 'bytes' argument, a string of 16 bytes in little-endian order as the 'bytes_le' argument, a tuple of six integers (32-bit time_low, 16-bit time_mid, 16-bit time_hi_version, 8-bit clock_seq_hi_variant, 8-bit clock_seq_low, 48-bit node) as the 'fields' argument, or a single 128-bit integer as the 'int' argument. When a string of hex digits is given, curly braces, hyphens, and a URN prefix are all optional. For example, these expressions all yield the same UUID: UUID('{12345678-1234-5678-1234-567812345678}') UUID('12345678123456781234567812345678') UUID('urn:uuid:12345678-1234-5678-1234-567812345678') UUID(bytes='\x12\x34\x56\x78'*4) UUID(bytes_le='\x78\x56\x34\x12\x34\x12\x78\x56' + '\x12\x34\x56\x78\x12\x34\x56\x78') UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)) UUID(int=0x12345678123456781234567812345678) Exactly one of 'hex', 'bytes', 'bytes_le', 'fields', or 'int' must be given. The 'version' argument is optional; if given, the resulting UUID will have its variant and version set according to RFC 4122, overriding the given 'hex', 'bytes', 'bytes_le', 'fields', or 'int'. is_safe is an enum exposed as an attribute on the instance. It indicates whether the UUID has been generated in a way that is safe for multiprocessing applications, via uuid_generate_time_safe(3). NzGone of the hex, bytes, bytes_le, fields, or int arguments must be givenzurn:zuuid:z{}- z$badly formed hexadecimal UUID stringz bytes_le is not a 16-char stringr zbytes is not a 16-char stringzfields is not a 6-tuplerlz*field 1 out of range (need a 32-bit value)iz*field 2 out of range (need a 16-bit value)z*field 3 out of range (need a 16-bit value)z*field 4 out of range (need an 8-bit value)z*field 5 out of range (need an 8-bit value)z*field 6 out of range (need a 48-bit value)`P@0z*int is out of range (need a 128-bit value)zillegal version numberl lLrr) count TypeErrorreplacestriplen ValueErrorint_ isinstancebytes_repr from_bytesobject __setattr__)selfhexbytesbytes_lefieldsrversionrtime_lowtime_midtime_hi_versionclock_seq_hi_variant clock_seq_lownode clock_seqs r__init__z UUID.__init__s@ &# . 4 4T : :a ? ?=>> > ?++fb))11'2>>C))D//))#r22C3xx2~~ !GHHHsB--C  8}}"" !CDDDcg2g&#c"*)==c#bj)*,4QRRL9E  5zzR !@AAAeV,, 9 9d5kk 9 9 9//%((C  6{{a !:;;;:@ 8Xx !=$((((5(((( !MNNN((((5(((( !MNNN////%//// !MNNN,3333t3333 !MNNN ,,,,,,,, !MNNN$$$$u$$$$ !MNNN-2mCINx2~6#r)+.72o?AEFC ?$$$$af$$$$ !MNNN  $$$$1$$$$ !9::: ? "C < C ? "C 7b= C4,,,4G44444rc`d|ji}|jtjkr|jj|d<|SNrr)rrr rvalue)r>ds r __getstate__zUUID.__getstate__s3 DH  <8+ + + <-AiLrct|d|dt|dd|vrt|dn tjdSrM)r<r=r r)r>states r __setstate__zUUID.__setstate__so4e 5554'500$E)$45556>6F H H H H HrcZt|tr|j|jkStSNr8rrNotImplementedr>others r__eq__z UUID.__eq__) eT " " )8uy( (rcZt|tr|j|jkStSrUrVrXs r__lt__z UUID.__lt__) eT " " (8ei' 'rcZt|tr|j|jkStSrUrVrXs r__gt__z UUID.__gt__r^rcZt|tr|j|jkStSrUrVrXs r__le__z UUID.__le__r[rcZt|tr|j|jkStSrUrVrXs r__ge__z UUID.__ge__r[rc*t|jSrU)hashrr>s r__hash__z UUID.__hash__ sDH~~rc|jSrUrrgs r__int__z UUID.__int__s xrc@|jjdt|dS)N()) __class__rstrrgs r__repr__z UUID.__repr__s">222CIIII>>rc td)NzUUID objects are immutable)r2)r>namerNs rr=zUUID.__setattr__s4555rc d|jz}|ddd|ddd|ddd|ddd|dd S)N%032xr%r r!rj)r>r?s r__str__z UUID.__str__s_  GGGS2YYYBrE C2JJJBCCB Brc6|jdS)Nr!)rto_bytesrgs rr@z UUID.bytessx  $$$rcl|j}|ddd|dddz|dddz|ddzS)Nr"r r#r$r%r@)r>r@s rrAz UUID.bytes_le!sK cg2gs3rz!22U3s2:5FFabb  rcN|j|j|j|j|j|jfSrU)rDrErFrGrHrIrgs rrBz UUID.fields's+ t}d.B)4+=tyJ Jrc|jdz S)Nr)rjrgs rrDz UUID.time_low,sx2~rc|jdz dzS)Nr*rjrgs rrEz UUID.time_mid0B&((rc|jdz dzS)Nr+rrjrgs rrFzUUID.time_hi_version4rrc|jdz dzS)N8rjrgs rrGzUUID.clock_seq_hi_variant8B$&&rc|jdz dzS)Nr,rrjrgs rrHzUUID.clock_seq_low<rrcB|jdzdz|jdzz|jzS)Nr,r )rFrErDrgs rtimez UUID.time@s0&/B6"$&(, 6 7rc,|jdzdz|jzS)N?r%)rGrHrgs rrJzUUID.clock_seqEs"+d2q8"# $rc|jdzS)Nlrjrgs rrIz UUID.nodeJsx.((rcd|jzS)Nrurjrgs rr?zUUID.hexNs!!rc&dt|zS)Nz urn:uuid:)rprgs rurnzUUID.urnRsSYY&&rcv|jdzstS|jdzstS|jdzstStS)Nr/ll)r RESERVED_NCSRFC_4122RESERVED_MICROSOFTRESERVED_FUTURErgs rvariantz UUID.variantVsFx<( # \* #O\* #% %" "rcZ|jtkrt|jdz dzSdS)Nr0)rrrrgs rrCz UUID.versionas2 <8 # #B#-.. . $ #r)NNNNNN)$rrr__doc__ __slots__r rrKrPrSrZr]r`rbrdrhrkrqr=rxpropertyr@rArBrDrErFrGrHrrJrIr?rrrCrrrrrUs11f2ICG)-T5"*"2T5T5T5T5T5lHHH    ???666BBB %%X%X JJXJX))X)))X)''X'''X'77X7$$X$))X)""X"''X'##X#//X///rrcPddl}ddl}ddl}ddl} |jd|j|j}| ddg| ||j |}|dSt|j}d|d<|dkr|g|R}n|f}| ||j|j| } | sdS| \} } || S#t$|jf$rYdSwxYw) NrPATHz/sbinz /usr/sbin)pathCLC_ALL)r)stdoutstderrenv)ioosshutil subprocessenvirongetdefpathsplitpathsepextendwhichjoindictPopenPIPEDEVNULL communicateBytesIOOSErrorSubprocessError) commandargsrrrr path_dirs executablerprocrrs r_get_command_stdoutrhsk%%%%%%%%%%%%%%%%JNN62:66<z_parse_mac..sD9941D &&&&Q&&&&999999rrc3BK|]}|ddVdS)r0N)rjustrs rrz_parse_mac..s0@@$$**Q--@@@@@@rc3<K|]}t|dkVdS)rNrrs rrz_parse_mac..s,44d3t99>444444rr!)rrr5_MAC_OMITS_LEADING_ZEROESallrrr6)rpartshexstrs r _parse_macrs JJz " "E 5zzQ ! 99599999  F@@%@@@@@44e44444  F%62 s#B33 CCct||}|dS|} ||}n#t $rYdSwxYwd}|D]k}|} ||} n#t $rY>wxYwt| } | Tt| r| cS|| }l|S)aLooks for a MAC address under a heading in a command's output. The first line of words in the output is searched for the given heading. Words at the same word index as the heading in subsequent lines are then examined to see if they look like MAC addresses. N) rreadlinerrindexr6rrr) rrheadingrr column_indexrrrrrs r_find_mac_under_headingrs !$ / /F ~t  ''))//11H~~g.. ttO " " ##%% &DD    H  ;     JJJ  "!O s$A$$ A21A2"B++ B87B8cFd}dD]}td||d}|r|cSdS)z5Get the hardware address on Unix by running ifconfig.)shwaddrsethersaddress:slladdr)rz-az-avifconfigc |dzSNr-rrs rz#_ifconfig_getnode..s 1Q3rNr)rrrs r_ifconfig_getnodersH=H!$ZxOO  JJJ  4rc6tdddgd}|r|SdS)z/Get the hardware address on Unix by running ip.iplinks link/etherc |dzSrrrs rrz_ip_getnode.. s !A#rNrrs r _ip_getnoder s- !v  N NC  4rcddl}ddl}t|dsdS ||}n#t $rYdSwxYwt dd|j|gd}|r|St dd|j|gd}|r|St dd|jd|zgd }|r|SdS) z0Get the hardware address on Unix by running arp.rN gethostbynamearpz-ancdS)Nr rrs rrz_arp_getnode..sQSrc |dzSrrrs rrz_arp_getnode..!s QRSTQTrz(%s)c |dzS)Nrrrs rrz_arp_getnode..'s acr)rsockethasattrr gethostnamerrfsencode)rrip_addrrs r _arp_getnoders# 6? + +t&&v'9'9';';<< tt !  G0D0D/E|| T TC   !  G0D0D/E}} U UC   !  FW.0srrrrr_lanscan_getnoder-s ")UWI{{ K KKrc$tdddS)z4Get the hardware address on Unix by running netstat.netstatz-iansAddress)rrrr_netstat_getnoder2s #9fj A AArctSz1[DEPRECATED] Get the hardware address on Windows._windll_getnoderrr_ipconfig_getnoder 7   rctSrr rrr_netbios_getnoder<r rgenerate_time_safe UuidCreatecdS)z>[DEPRECATED] Platform-specific functions loaded at import timeNrrrr_load_system_functionsrOsrc`tr&t\}}t|jSdS)zBGet the hardware address on Unix using the _uuid extension module.r|N)_generate_time_saferrI) uuid_time_s r _unix_getnoderSs7**,, 1)$$$))**rcZtr#t}t|jSdS)zEGet the hardware address on Windows using the _uuid extension module.)rAN) _UuidCreaterrI) uuid_bytess rr r Ys1. ]] Z(((--..rc:ddl}|ddzS)zGet a random node ID.rNr,l)random getrandbits)rs r_random_getnoder_s&MMM   b ! !W --rrrposixntcttSttgzD]:} |an#YxYwtdtcxkrdkr n1tcS;Jdt)a3Get 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. Nrr(Fz,_random_getnode() returned invalid value: {})_node_GETTERSrformat)getters rgetnoder&s  o.. FHHEE  H  A$:$:$:$:'$:$:$:$:$:LLLN@GGNNNNNs -1ctY||cxurRnnOt\}} t|}n#t$rtj}YnwxYwt ||Sddl}|}|dzdz}t|tkr tdz}|a|ddl}| d}|dz} |d z d z} |d z d z} |d z} |dz dz} |t}t | | | | | |fdS)aGenerate 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.N)r@rrdl@'Hw r-lr rr,rrr%r)rBrC) rr r6rrrtime_ns_last_timestamprrr&)rIrJrsafely_generatedrr nanoseconds timestamprrDrErFrHrGs ruuid1r/so&49+D+D+D+D+D+D+D+D&9&;&;# # '/00GG ' ' '&GGG ')W5555KKK,,..Ks"%77I"yO'C'C#a' O &&r** :%HR6)H B&0O$M%Nd2 |yy (O,mTCLM O O OOs4A  A cddlm}||jt|dzd}t |ddd S) zAGenerate a UUID from the MD5 hash of a namespace UUID and a name.r)md5utf-8F)usedforsecurityNr!r"r@rC)hashlibr1r@digestr) namespacersr1r6s ruuid3r8sl S%g... fhh  fSbSk1 - - --rcHttjddS)zGenerate a random UUID.r!rr4)rrurandomrrruuid4r;s bjnna 0 0 00rcddlm}||jt|dz}t |dddS)zCGenerate a UUID from the SHA-1 hash of a namespace UUID and a name.r)sha1r2Nr!r#r4)r5r=r@r6r)r7rsr=rfs ruuid5r>s[ 4 %g"6"66 7 7 > > @ @D d3B3i + + ++rz$6ba7b810-9dad-11d1-80b4-00c04fd430c8z$6ba7b811-9dad-11d1-80b4-00c04fd430c8z$6ba7b812-9dad-11d1-80b4-00c04fd430c8z$6ba7b814-9dad-11d1-80b4-00c04fd430c8)NN)=rrsysenumrr __author__platform_AIX_LINUXsystem_platform_systemrrrrrrrr7r@r9r rrrrrrrrrrrr r_uuidgetattrrrhas_uuid_generate_time_safe_has_uuid_generate_time_safe ImportErrorrrr r _OS_GETTERSrsr#r"r&r+r/r8r;r> NAMESPACE_DNS NAMESPACE_URL NAMESPACE_OIDNAMESPACE_X500rrrrQs ,,\ ########+ <&&&D66OOO&x((5(D7*F  !%J $?N?N?N; h*O  d P/P/P/P/P/P/P/P/f\!!! # # #F8!!!L8LLL BBB   (LLL!'%)=tDD'%t44K#(#D  ((( EK#'   (III*** ... . . ., 7 12KK\X$l4DEKK\WKK 7#$KK$k<#%57K7g,HHW__ ;.HHH OOO,$O$O$O$OL...111,,,;<< ;<< ;<< <==s)%C CC