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.
Files changed (27) hide show
  1. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/PKG-INFO +1 -1
  2. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/jsonable.py +57 -36
  3. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/PKG-INFO +1 -1
  4. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/setup.py +1 -1
  5. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/LICENSE +0 -0
  6. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/README.md +0 -0
  7. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/__init__.py +0 -0
  8. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/csv.py +0 -0
  9. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/entity.py +0 -0
  10. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/jsonpicklemixin.py +0 -0
  11. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/lod.py +0 -0
  12. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/mwTable.py +0 -0
  13. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/plot.py +0 -0
  14. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/query.py +0 -0
  15. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/sample.py +0 -0
  16. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/schema.py +0 -0
  17. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/sparql.py +0 -0
  18. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/sql.py +0 -0
  19. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/storageconfig.py +0 -0
  20. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/tabulateCounter.py +0 -0
  21. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/uml.py +0 -0
  22. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/lodstorage/yamlablemixin.py +0 -0
  23. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/SOURCES.txt +0 -0
  24. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/dependency_links.txt +0 -0
  25. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/requires.txt +0 -0
  26. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/pylodstorage.egg-info/top_level.txt +0 -0
  27. {pylodstorage-0.0.65 → pylodstorage-0.0.67}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.65
3
+ Version: 0.0.67
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -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 initalize me from
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
- self.__dict__=data
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
- for key,value in items:
623
- valueType=None
624
- if value is None:
625
- if warnOnNone:
626
- if self.debug:
627
- print("Warning sampleRecord field %s is None - using string as type" % key)
628
- valueType=str
629
- else:
630
- valueType=type(value)
631
- if valueType == str:
632
- pass
633
- elif valueType == int:
634
- pass
635
- elif valueType == float:
636
- pass
637
- elif valueType == bool:
638
- pass
639
- elif valueType == datetime.date:
640
- pass
641
- elif valueType== datetime.datetime:
642
- pass
643
- else:
644
- if valueType is not None:
645
- msg="warning: unsupported type %s for field %s " % (str(valueType),key)
646
- print(msg)
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
- self.addType(listName,key,valueType.__name__)
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
  '''
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.65
3
+ Version: 0.0.67
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.65',
14
+ version='0.0.67',
15
15
 
16
16
  packages=['lodstorage',],
17
17
  author='Wolfgang Fahl',
File without changes
File without changes
File without changes