pyLodStorage 0.0.35__tar.gz → 0.0.37__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/PKG-INFO +1 -1
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/jsonable.py +4 -30
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/lod.py +42 -1
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/PKG-INFO +1 -1
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/setup.py +1 -1
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/LICENSE +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/README.md +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/__init__.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/csv.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/plot.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/query.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/sample.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/schema.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/sql.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/uml.py +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/requires.txt +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.0.35 → pylodstorage-0.0.37}/setup.cfg +0 -0
|
@@ -358,6 +358,7 @@ class JSONAbleList(JSONAble):
|
|
|
358
358
|
'''
|
|
359
359
|
return self.__dict__[self.listName]
|
|
360
360
|
|
|
361
|
+
|
|
361
362
|
def getLookup(self,attrName:str,withDuplicates:bool=False):
|
|
362
363
|
'''
|
|
363
364
|
create a lookup dictionary by the given attribute name
|
|
@@ -367,36 +368,9 @@ class JSONAbleList(JSONAble):
|
|
|
367
368
|
withDuplicates(bool): whether to retain single values or lists
|
|
368
369
|
|
|
369
370
|
Return:
|
|
370
|
-
a dictionary for lookup
|
|
371
|
-
'''
|
|
372
|
-
|
|
373
|
-
duplicates=[]
|
|
374
|
-
for entity in self.getList():
|
|
375
|
-
value=None
|
|
376
|
-
if isinstance(entity,dict):
|
|
377
|
-
if attrName in entity:
|
|
378
|
-
value=entity[attrName]
|
|
379
|
-
else:
|
|
380
|
-
if hasattr(entity, attrName):
|
|
381
|
-
value=getattr(entity,attrName)
|
|
382
|
-
if value is not None:
|
|
383
|
-
if value in lookup:
|
|
384
|
-
if withDuplicates:
|
|
385
|
-
lookupResult=lookup[value]
|
|
386
|
-
lookupResult.append(entity)
|
|
387
|
-
else:
|
|
388
|
-
duplicates.append(entity)
|
|
389
|
-
else:
|
|
390
|
-
if withDuplicates:
|
|
391
|
-
lookupResult=[entity]
|
|
392
|
-
else:
|
|
393
|
-
lookupResult=entity
|
|
394
|
-
lookup[value]=lookupResult
|
|
395
|
-
if withDuplicates:
|
|
396
|
-
return lookup
|
|
397
|
-
else:
|
|
398
|
-
return lookup,duplicates
|
|
399
|
-
|
|
371
|
+
a dictionary for lookup or a tuple dictionary,list of duplicates depending on withDuplicates
|
|
372
|
+
'''
|
|
373
|
+
return LOD.getLookup(self, self.getList(), attrName, withDuplicates)
|
|
400
374
|
|
|
401
375
|
def getJsonData(self):
|
|
402
376
|
'''
|
|
@@ -90,4 +90,45 @@ class LOD(object):
|
|
|
90
90
|
c2=next(i2)
|
|
91
91
|
except StopIteration:
|
|
92
92
|
break
|
|
93
|
-
return lr
|
|
93
|
+
return lr
|
|
94
|
+
|
|
95
|
+
@staticmethod
|
|
96
|
+
def getLookup(self,lod:list,attrName:str,withDuplicates:bool=False):
|
|
97
|
+
'''
|
|
98
|
+
create a lookup dictionary by the given attribute name for the given list of dicts
|
|
99
|
+
|
|
100
|
+
Args:
|
|
101
|
+
lod(list): the list of dicts to get the lookup dictionary for
|
|
102
|
+
attrName(str): the attribute to lookup
|
|
103
|
+
withDuplicates(bool): whether to retain single values or lists
|
|
104
|
+
|
|
105
|
+
Return:
|
|
106
|
+
a dictionary for lookup
|
|
107
|
+
'''
|
|
108
|
+
lookup={}
|
|
109
|
+
duplicates=[]
|
|
110
|
+
for record in lod:
|
|
111
|
+
value=None
|
|
112
|
+
if isinstance(record,dict):
|
|
113
|
+
if attrName in record:
|
|
114
|
+
value=record[attrName]
|
|
115
|
+
else:
|
|
116
|
+
if hasattr(record, attrName):
|
|
117
|
+
value=getattr(record,attrName)
|
|
118
|
+
if value is not None:
|
|
119
|
+
if value in lookup:
|
|
120
|
+
if withDuplicates:
|
|
121
|
+
lookupResult=lookup[value]
|
|
122
|
+
lookupResult.append(record)
|
|
123
|
+
else:
|
|
124
|
+
duplicates.append(record)
|
|
125
|
+
else:
|
|
126
|
+
if withDuplicates:
|
|
127
|
+
lookupResult=[record]
|
|
128
|
+
else:
|
|
129
|
+
lookupResult=record
|
|
130
|
+
lookup[value]=lookupResult
|
|
131
|
+
if withDuplicates:
|
|
132
|
+
return lookup
|
|
133
|
+
else:
|
|
134
|
+
return lookup,duplicates
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|