ó i'dWc@s]dZddlZddlZddlmZdejfd„ƒYZd„Zd„Z dS(s* C structures from libefi.so and libefi.h iÿÿÿÿN(tUUIDtcUUIDcBsneZdZdejfdejfdejfdejfdejfdejdfgZdddddd„Z e d „ƒZ e d „ƒZ e d „ƒZ e d „ƒZe d „ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZe d„ƒZd„Zd„Zd„Zd„ZRS(s. struct uuid from /usr/include/sys/uuid.h t _time_lowt _time_midttime_hi_and_versiontclock_seq_hi_and_reservedt_clock_seq_lowt node_addric Cs{td|d|d|d|d|ƒ}tjdkrXtjtj|ƒ|jdƒntjtj|ƒ|jdƒdS( sÁCreate a UUID for C 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. Basically just like uuid.UUID(). These expressions all yield the same cUUID: cUUID('{12345678-1234-5678-1234-567812345678}') cUUID('12345678123456781234567812345678') cUUID('urn:uuid:12345678-1234-5678-1234-567812345678') cUUID(bytes='4Vx'*4) cUUID(bytes_le='xV44xV' + '4Vx4Vx') cUUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678)) cUUID(int=0x12345678123456781234567812345678) thextbytestbytes_letfieldstinttlittleiN(Rtsyst byteordertCtmemmovet addressofR R (tselfRR R R R tu((scuuid.pyt__init__>s  "cCsztjtj|ƒdƒ}tjdkr.|S|d|d|d|d|d|d|d |d |d Sd S( s'16 bytes of UUID as buffer (big-endian)itbigiiiiiiiiiN(Rt string_attbyrefRR(Rtnative((scuuid.pyR ]s ?cCsztjtj|ƒdƒ}tjdkr.|S|d|d|d|d|d|d|d |d |d Sd S( s*16 bytes of UUID as buffer (little-endian)iR iiiiiiiiiN(RRRRR(RR((scuuid.pyR hs ?cCs(|j|j|j|j|j|jfS(N(ttime_lowttime_midttime_hi_versiontclock_seq_hi_variantt clock_seq_lowtnode(R((scuuid.pyR sscCs|jS(s3closed interval of bytes [0:3] of the UUID (as int)(R(R((scuuid.pyRxscCs|jS(s3closed interval of bytes [4:5] of the UUID (as int)(R(R((scuuid.pyR}scCs|jS(s3closed interval of bytes [6:7] of the UUID (as int)(R(R((scuuid.pyR‚scCs|jS(sbyte 8 of the UUID (as int)(R(R((scuuid.pyR‡scCs|jS(sbyte 9 of the UUID (as int)(R(R((scuuid.pyRŒscCsWtdƒ}xDttdƒtdddƒƒD]!\}}||j||>O}q.W|S(s6closed interval of bytes [10:15] of the UUID (as long)iii(iøÿÿÿ(tlongtziptrangeR(Rtxtidxtshift((scuuid.pyR‘s .cCs d|jS(s-the UUID as a 32-character hexadecimal strings%032x(R (R((scuuid.pyR™scCsctdƒ}|j}xGttdƒtdddƒƒD]$\}}|t||ƒ|>O}q7W|S(sthe UUID as a 128-bit longiiixiøÿÿÿ(R R R!R"tord(RtvaltbyteR$R%((scuuid.pyR žs   .cCsdt|ƒS(s*the UUID as a URN as specified in RFC 4122s urn:uuid:(tstr(R((scuuid.pyturn§scCs!|jd@d>|jd>B|jBS(s the 60-bit timestamp of the UUIDlÿl0l (RRR(R((scuuid.pyttime¬scCs|jd@d>|jBS(s&the 14-bit sequence number of the UUIDl?l(RR(R((scuuid.pyt clock_seq²scCs&t|tƒr"t|j|jƒStS(N(t isinstanceRtcmpR tNotImplemented(Rtother((scuuid.pyt__cmp__¸scCs t|jƒS(N(thashR (R((scuuid.pyt__hash__½scCsAd|j}d|d |dd!|dd!|dd!|dfS(Ns%032xs%s-%s-%s-%s-%sii ii(R (RR((scuuid.pyt__str__Às cCsdt|ƒS(NsUUID(%r)(R)(R((scuuid.pyt__repr__ÅsN(t__name__t __module__t__doc__Rtc_uint32tc_uint16tc_uint8t_fields_tNoneRtpropertyR R R RRRRRRRR R*R+R,R1R3R4R5(((scuuid.pyR0s6             cCs t|jƒS(sconvert cUUID to a uuid.UUID(RR*(tcuuid((scuuid.pyt cUUID2UUIDÉscCs t|jƒS(sconvert uuid.UUID to a cUUID(RR*(tuuid((scuuid.pyt UUID2cUUIDÎs( R8tctypesRRRARt StructureRR@RB(((scuuid.pyts   ™