Skip to content

Commit 0dc008b

Browse files
committed
UUID as element marker
1 parent 635dfee commit 0dc008b

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

libs/x3ml.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
from dataclasses import dataclass, field
88
import re
99
from enum import auto, Enum
10+
import uuid
1011

11-
1212

1313
############################################################################################################################
1414

@@ -159,7 +159,7 @@ def elements(self, elem: etree.Element) -> list:
159159
return ch
160160
return []
161161

162-
162+
163163
'''Mapping lido tags to its ID hosts'''
164164
LIDO_ID_MAP = {
165165
'lido:lido': ID_Host('lido:lidoRecID'),
@@ -179,6 +179,7 @@ def elements(self, elem: etree.Element) -> list:
179179
'lido:repositoryName': ID_Host('lido:legalBodyID')
180180
}
181181

182+
182183
def load_lido_map(fname='./lido-id-map.json'):
183184
'''Loads the LIDO ID map from file'''
184185
global LIDO_ID_MAP
@@ -235,18 +236,18 @@ def from_elem(cls, elem, i):
235236
info.id = ids[0]
236237
elif len(elem) > 0 and not text:
237238
# Has subelements, use path as ID
238-
info.mode = IDMode.PATH
239+
info.mode = IDMode.PATH
239240
if n := elem.get('n4o_id'):
240241
info.id = n
241242
else:
242-
info.id = root_path_as_list(elem) + '/'+str(i)
243+
info.id = str(uuid.uuid4()) # generate a unique ID
243244
elem.set('n4o_id', info.id)
244245
else:
245246
# Just text
246247
info.mode = IDMode.NONE
247248

248249
return info
249-
250+
250251
def hasID(self) -> bool:
251252
'''Tests if the info has an ID'''
252253
return self.mode in (IDMode.LIDO_ID, IDMode.PATH)

0 commit comments

Comments
 (0)