ATLAS Offline Software
Functions | Variables
pool_uuid Namespace Reference

Functions

def uuid_to_ts (myuuid)
 
def uuid_split (guid)
 
def pool_to_uuid (mypool)
 
def timorder_uuid (myuuid)
 
def timorder_pool (mypool)
 
def printuuid (myuuid)
 
def usage ()
 
def example ()
 

Variables

tuple version_str
 
bool regular = False
 
 guid = sys.argv[1]
 

Function Documentation

◆ example()

def pool_uuid.example ( )

Definition at line 89 of file pool_uuid.py.

89 def example():
90  # [avalassi@lxplus248 tcsh] ~ > date ; pool_gen_uuid ; uuidgen -t
91  # A2E338DD-2265-DF11-AFE1-001E4F3E5C33
92  # dd3a5aac-6522-11df-82eb-001e4f3e5c33
93 
94  guid1='dd3a5aac-6522-11df-82eb-001e4f3e5c33' # from uuidgen
95  guid2='A2E338DD-2265-DF11-AFE1-001E4F3E5C33' # from POOL
96  guid3='A2E338DD-2265-D011-AFE1-001E4F3E5C33' # POOL token for the year 1997
97  printuuid( guid1 )
98  printuuid( pool_to_uuid( guid2 ) )
99  printuuid( pool_to_uuid( guid3 ) )
100 
101 

◆ pool_to_uuid()

def pool_uuid.pool_to_uuid (   mypool)

Definition at line 32 of file pool_uuid.py.

32 def pool_to_uuid( mypool ) :
33  print('POOL guid:', mypool)
34  f0, f1, f2, f3, f4 = uuid_split(mypool)
35  myuuid = '%s%s%s%s-%s%s-%s%s-%s-%s'\
36  %(f0[6:8],f0[4:6],f0[2:4],f0[0:2],\
37  f1[2:4],f1[0:2],f2[2:4],f2[0:2],f3,f4)
38  print('UUID guid:', myuuid)
39  return myuuid
40 
41 # AABBCCDD-EEFF-GHIJ-xxxx-xxxxxxxxxxxx to HIJEEFFAABBCCDD

◆ printuuid()

def pool_uuid.printuuid (   myuuid)

Definition at line 63 of file pool_uuid.py.

63 def printuuid( myuuid ) :
64  myUUID=uuid.UUID(myuuid)
65  print('UUID:', myUUID)
66  print('UUID variant:', myUUID.variant)
67  print('UUID version:', myUUID.version, '-',version_str[myUUID.version])
68  print('UUID field#0 (time_low): %12.8x (%12.8x)'\
69  %( myUUID.fields[0], myUUID.time_low ))
70  print('UUID field#1 (time_mid): %12.4x (%12.4x)'\
71  %( myUUID.fields[1], myUUID.time_mid ))
72  print('UUID field#2 (time_hi_version): %12.4x (%12.4x)'\
73  %( myUUID.fields[2], myUUID.time_hi_version ))
74  print('UUID field#3 (clock_seq_hi_variant): %12.2x (%12.2x)'\
75  %( myUUID.fields[3], myUUID.clock_seq_hi_variant ))
76  print('UUID field#4 (clock_seq_low): %12.2x (%12.2x)'\
77  %( myUUID.fields[4], myUUID.clock_seq_low ))
78  print('UUID field#5 (node): %12.12x (%12.12x)'\
79  %( myUUID.fields[5], myUUID.node ))
80  if myUUID.version == 1:
81  timorder_uuid( myuuid )
82  print('================================================')
83 

◆ timorder_pool()

def pool_uuid.timorder_pool (   mypool)

Definition at line 53 of file pool_uuid.py.

53 def timorder_pool( mypool ) :
54  print('POOL guid:', mypool)
55  f0, f1, f2, f3, f4 = uuid_split(mypool)
56  myuuidto = '%s%s%s%s%s%s%s%s'\
57  %(f2[2:3],f2[0:2],f1[2:4],f1[0:2],\
58  f0[6:8],f0[4:6],f0[2:4],f0[0:2],)
59  print('UUID timeordered:', myuuidto)
60  return myuuidto
61 
62 

◆ timorder_uuid()

def pool_uuid.timorder_uuid (   myuuid)

Definition at line 42 of file pool_uuid.py.

42 def timorder_uuid( myuuid ) :
43  f0, f1, f2, f3, f4 = uuid_split(myuuid)
44  myuuidto = '%s%s%s'%(f2[1:4],f1,f0)
45  myUUID=uuid.UUID(myuuid)
46  print('UUID:', myUUID)
47  print('UUID time (100ns intervals since 15 Oct 1582):', myUUID.time, "hex:", hex(myUUID.time))
48  print('UUID timeordered:', myuuidto)
49  print('UUID timestamp:', uuid_to_ts(myUUID))
50  return myuuidto
51 
52 # DDCCBBAA-FFEE-IJGH-xxxx-xxxxxxxxxxxx to HIJEEFFAABBCCDD

◆ usage()

def pool_uuid.usage ( )

Definition at line 84 of file pool_uuid.py.

84 def usage():
85  print(sys.argv[0],"-h | [-u] UUID")
86  print(" -u : assume uuidgen standard format (not POOL)")
87  sys.exit(0)
88 

◆ uuid_split()

def pool_uuid.uuid_split (   guid)

Definition at line 21 of file pool_uuid.py.

21 def uuid_split( guid ):
22  fields = guid.split('-')
23  if len(fields) != 5: raise ValueError( f"Wrong number of fields in '{guid}'" )
24  if len(fields[0]) != 8: raise ValueError( f"Wrong length of field#0: '{fields[0]}'" )
25  if len(fields[1]) != 4: raise ValueError( f"Wrong length of field#1: '{fields[1]}'" )
26  if len(fields[2]) != 4: raise ValueError( f"Wrong length of field#2: '{fields[2]}'" )
27  if len(fields[3]) != 4: raise ValueError( f"Wrong length of field#3: '{fields[3]}'" )
28  if len(fields[4]) != 12: raise ValueError( f"Wrong length of field#4: '{fields[4]}'" )
29  return (fields[0], fields[1], fields[2], fields[3], fields[4])
30 
31 # DDCCBBAA-FFEE-HHGG-IIJJ-KKLLMMNNOOPP to AABBCCDD-EEFF-GGHH-IIJJ-KKLLMMNNOOPP

◆ uuid_to_ts()

def pool_uuid.uuid_to_ts (   myuuid)

Definition at line 12 of file pool_uuid.py.

12 def uuid_to_ts( myuuid ) :
13  # from web.archive.org/web/20110817134817/http://www.gossamer-threads.com:80/lists/python/dev/670680
14  DTD_DELTA = ( datetime.datetime( *time.gmtime(0)[0:3] ) -
15  datetime.datetime( 1582, 10, 15 ) )
16  DTD_SECS_DELTA = DTD_DELTA.days * 86400 # 0x01b21dd213814000/1e7
17  secs = myuuid.time / 1e7
18  secs_epoch = secs - DTD_SECS_DELTA
19  return datetime.datetime.fromtimestamp( secs_epoch )
20 

Variable Documentation

◆ guid

def pool_uuid.guid = sys.argv[1]

Definition at line 112 of file pool_uuid.py.

◆ regular

bool pool_uuid.regular = False

Definition at line 103 of file pool_uuid.py.

◆ version_str

tuple pool_uuid.version_str
Initial value:
1 = ('Unused', 'Gregorian time based', 'DCE', 'MD5 based', 'RNG based', 'SHA',
2  'Reordered Gregorian', 'Epoch time based', 'Custom') + ('Reserved',)*7

Definition at line 9 of file pool_uuid.py.

pool_uuid.uuid_to_ts
def uuid_to_ts(myuuid)
Definition: pool_uuid.py:12
pool_uuid.timorder_pool
def timorder_pool(mypool)
Definition: pool_uuid.py:53
pool_uuid.printuuid
def printuuid(myuuid)
Definition: pool_uuid.py:63
pool_uuid.example
def example()
Definition: pool_uuid.py:89
pool_uuid.uuid_split
def uuid_split(guid)
Definition: pool_uuid.py:21
pool_uuid.pool_to_uuid
def pool_to_uuid(mypool)
Definition: pool_uuid.py:32
pool_uuid.usage
def usage()
Definition: pool_uuid.py:84
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
pool_uuid.timorder_uuid
def timorder_uuid(myuuid)
Definition: pool_uuid.py:42