pyLodStorage 0.0.65__tar.gz → 0.0.67__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.65 → pylodstorage-0.0.67}/PKG-INFO +1 -1
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/jsonable.py +57 -36
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/PKG-INFO +1 -1
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/setup.py +1 -1
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/LICENSE +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/README.md +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/__init__.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/csv.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/entity.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/jsonpicklemixin.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/lod.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/plot.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/query.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/sample.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/schema.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/sql.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/storageconfig.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/uml.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/yamlablemixin.py +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/requires.txt +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.0.65 → pylodstorage-0.0.67}/setup.cfg +0 -0
|
@@ -204,15 +204,17 @@ class JSONAble(object):
|
|
|
204
204
|
self.fromDict(jsonMap)
|
|
205
205
|
|
|
206
206
|
|
|
207
|
-
def fromDict(self,data):
|
|
207
|
+
def fromDict(self,data:dict):
|
|
208
208
|
'''
|
|
209
209
|
initialize me from the given data
|
|
210
210
|
|
|
211
211
|
Args:
|
|
212
|
-
data: the dictionary to
|
|
212
|
+
data(dict): the dictionary to initialize me from
|
|
213
213
|
'''
|
|
214
|
-
# https://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression-in-python-taking-union-o
|
|
215
|
-
|
|
214
|
+
# https://stackoverflow.com/questions/38987/how-do-i-merge-two-dictionaries-in-a-single-expression-in-python-taking-union-o
|
|
215
|
+
for key in data.keys():
|
|
216
|
+
value=data[key]
|
|
217
|
+
setattr(self,key,value)
|
|
216
218
|
|
|
217
219
|
def toJsonAbleValue(self,v):
|
|
218
220
|
'''
|
|
@@ -541,7 +543,7 @@ class JSONAbleList(JSONAble):
|
|
|
541
543
|
if typeSamples is None:
|
|
542
544
|
types = None
|
|
543
545
|
else:
|
|
544
|
-
types = Types(self.listName)
|
|
546
|
+
types = Types(self.listName,warnOnUnsupportedTypes=not self.handleInvalidListTypes)
|
|
545
547
|
types.getTypes(self.listName, typeSamples, len(typeSamples))
|
|
546
548
|
lod = self.getLoDfromJson(jsonStr, types,listName=self.listName)
|
|
547
549
|
return lod
|
|
@@ -566,31 +568,35 @@ class Types(JSONAble):
|
|
|
566
568
|
|
|
567
569
|
}
|
|
568
570
|
|
|
569
|
-
def __init__(self,name,debug=False):
|
|
571
|
+
def __init__(self,name:str,warnOnUnsupportedTypes=True,debug=False):
|
|
570
572
|
'''
|
|
571
573
|
Constructor
|
|
572
574
|
|
|
573
575
|
Args:
|
|
574
576
|
name(str): the name of the type map
|
|
577
|
+
warnOnUnsupportedTypes(bool): if TRUE warn if an item value has an unsupported type
|
|
578
|
+
debug(bool): if True - debugging information should be shown
|
|
575
579
|
'''
|
|
576
580
|
self.name=name
|
|
581
|
+
self.warnOnUnsupportedTypes=warnOnUnsupportedTypes
|
|
577
582
|
self.debug=debug
|
|
578
583
|
self.typeMap={}
|
|
579
584
|
|
|
580
585
|
@staticmethod
|
|
581
|
-
def forTable(instance,listName,debug=False):
|
|
586
|
+
def forTable(instance,listName:str,warnOnUnsupportedTypes:bool=True,debug=False):
|
|
582
587
|
'''
|
|
583
588
|
get the types for the list of Dicts (table) in the given instance with the given listName
|
|
584
589
|
Args:
|
|
585
590
|
instance(object): the instance to inspect
|
|
586
591
|
listName(string): the list of dicts to inspect
|
|
592
|
+
warnOnUnsupportedTypes(bool): if TRUE warn if an item value has an unsupported type
|
|
587
593
|
debug(bool): True if debuggin information should be shown
|
|
588
594
|
|
|
589
595
|
Returns:
|
|
590
596
|
Types: a types object
|
|
591
597
|
'''
|
|
592
598
|
clazz=type(instance)
|
|
593
|
-
types=Types(clazz.__name__,debug=debug)
|
|
599
|
+
types=Types(clazz.__name__,warnOnUnsupportedTypes=warnOnUnsupportedTypes,debug=debug)
|
|
594
600
|
types.getTypes(listName,instance.__dict__[listName])
|
|
595
601
|
return types
|
|
596
602
|
|
|
@@ -610,42 +616,57 @@ class Types(JSONAble):
|
|
|
610
616
|
if not field in typeMap:
|
|
611
617
|
typeMap[field]=valueType
|
|
612
618
|
|
|
613
|
-
def getTypes(self,listName,sampleRecords,limit=10):
|
|
619
|
+
def getTypes(self,listName:str,sampleRecords:list,limit:int=10):
|
|
614
620
|
'''
|
|
615
621
|
determine the types for the given sample records
|
|
622
|
+
|
|
623
|
+
Args:
|
|
624
|
+
listName(str): the name of the list
|
|
625
|
+
sampleRecords(list): a list of items
|
|
626
|
+
limit(int): the maximum number of items to check
|
|
616
627
|
'''
|
|
617
628
|
for sampleRecord in sampleRecords[:limit]:
|
|
618
629
|
items=sampleRecord.items()
|
|
619
630
|
self.getTypesForItems(listName,items,warnOnNone=len(sampleRecords)==1)
|
|
620
631
|
|
|
621
|
-
def getTypesForItems(self,listName,items,warnOnNone=False):
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
632
|
+
def getTypesForItems(self,listName:str, items:list, warnOnNone:bool=False):
|
|
633
|
+
'''
|
|
634
|
+
get the types for the given items
|
|
635
|
+
side effect is setting my types
|
|
636
|
+
|
|
637
|
+
Args:
|
|
638
|
+
listName(str): the name of the list
|
|
639
|
+
items(list): a list of items
|
|
640
|
+
warnOnNone(bool): if TRUE warn if an item value is None
|
|
641
|
+
|
|
642
|
+
'''
|
|
643
|
+
for key,value in items:
|
|
644
|
+
valueType=None
|
|
645
|
+
if value is None:
|
|
646
|
+
if warnOnNone and self.debug:
|
|
647
|
+
print(f"Warning sampleRecord field {key} is None - using string as type")
|
|
648
|
+
valueType=str
|
|
649
|
+
else:
|
|
650
|
+
valueType=type(value)
|
|
651
|
+
if valueType == str:
|
|
652
|
+
pass
|
|
653
|
+
elif valueType == int:
|
|
654
|
+
pass
|
|
655
|
+
elif valueType == float:
|
|
656
|
+
pass
|
|
657
|
+
elif valueType == bool:
|
|
658
|
+
pass
|
|
659
|
+
elif valueType == datetime.date:
|
|
660
|
+
pass
|
|
661
|
+
elif valueType== datetime.datetime:
|
|
662
|
+
pass
|
|
663
|
+
else:
|
|
647
664
|
if valueType is not None:
|
|
648
|
-
|
|
665
|
+
msg=f"warning: unsupported type {str(valueType)} for field {key}"
|
|
666
|
+
if self.debug and self.warnOnUnsupportedTypes:
|
|
667
|
+
print(msg)
|
|
668
|
+
if valueType is not None:
|
|
669
|
+
self.addType(listName,key,valueType.__name__)
|
|
649
670
|
|
|
650
671
|
def fixTypes(self,lod:list,listName:str):
|
|
651
672
|
'''
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|