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.
Files changed (23) hide show
  1. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/PKG-INFO +1 -1
  2. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/jsonable.py +4 -30
  3. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/lod.py +42 -1
  4. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/PKG-INFO +1 -1
  5. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/setup.py +1 -1
  6. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/LICENSE +0 -0
  7. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/README.md +0 -0
  8. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/__init__.py +0 -0
  9. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/csv.py +0 -0
  10. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/mwTable.py +0 -0
  11. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/plot.py +0 -0
  12. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/query.py +0 -0
  13. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/sample.py +0 -0
  14. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/schema.py +0 -0
  15. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/sparql.py +0 -0
  16. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/sql.py +0 -0
  17. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/tabulateCounter.py +0 -0
  18. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/lodstorage/uml.py +0 -0
  19. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/SOURCES.txt +0 -0
  20. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/dependency_links.txt +0 -0
  21. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/requires.txt +0 -0
  22. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/pylodstorage.egg-info/top_level.txt +0 -0
  23. {pylodstorage-0.0.35 → pylodstorage-0.0.37}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.35
3
+ Version: 0.0.37
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -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
- lookup={}
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.35
3
+ Version: 0.0.37
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -11,7 +11,7 @@ with open(path.join(this_directory, 'README.md'), encoding='utf-8') as f:
11
11
 
12
12
  setup(
13
13
  name='pylodstorage',
14
- version='0.0.35',
14
+ version='0.0.37',
15
15
 
16
16
  packages=['lodstorage',],
17
17
  author='Wolfgang Fahl',
File without changes
File without changes
File without changes