pyLodStorage 0.0.45__tar.gz → 0.0.47__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.45/pylodstorage.egg-info → pylodstorage-0.0.47}/PKG-INFO +1 -1
  2. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/entity.py +18 -11
  3. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/storageconfig.py +4 -13
  4. {pylodstorage-0.0.45 → pylodstorage-0.0.47/pylodstorage.egg-info}/PKG-INFO +1 -1
  5. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/setup.py +1 -1
  6. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/LICENSE +0 -0
  7. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/README.md +0 -0
  8. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/__init__.py +0 -0
  9. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/csv.py +0 -0
  10. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/jsonable.py +0 -0
  11. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/jsonpicklemixin.py +0 -0
  12. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/lod.py +0 -0
  13. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/mwTable.py +0 -0
  14. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/plot.py +0 -0
  15. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/query.py +0 -0
  16. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/sample.py +0 -0
  17. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/schema.py +0 -0
  18. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/sparql.py +0 -0
  19. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/sql.py +0 -0
  20. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/tabulateCounter.py +0 -0
  21. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/uml.py +0 -0
  22. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/lodstorage/yamlablemixin.py +0 -0
  23. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/pylodstorage.egg-info/SOURCES.txt +0 -0
  24. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/pylodstorage.egg-info/dependency_links.txt +0 -0
  25. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/pylodstorage.egg-info/requires.txt +0 -0
  26. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/pylodstorage.egg-info/top_level.txt +0 -0
  27. {pylodstorage-0.0.45 → pylodstorage-0.0.47}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.45
3
+ Version: 0.0.47
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -75,12 +75,15 @@ class EntityManager(YamlAbleMixin, JsonPickleMixin):
75
75
  if config.cacheFile is not None:
76
76
  return config.cacheFile
77
77
  ''' get the path to the file for my cached data '''
78
- if mode is StoreMode.JSON:
79
- cachepath="%s/%s-%s.%s" % (cachedir,self.name,"events",'json')
78
+ if mode is StoreMode.JSON or mode is StoreMode.JSONABLE:
79
+ cachepath="%s/%s-%s.%s" % (cachedir,self.name,self.entityPluralName,'json')
80
80
  elif mode is StoreMode.SPARQL:
81
81
  cachepath="%s %s" % ('SPARQL',config.endpoint)
82
82
  elif mode is StoreMode.SQL:
83
- cachepath="%s/%s.db" % (cachedir,config.tableName)
83
+ tableName=config.tableName
84
+ if tableName is None:
85
+ tableName=self.name
86
+ cachepath="%s/%s.db" % (cachedir,tableName)
84
87
  else:
85
88
  cachepath="undefined cachepath for %s" % (mode)
86
89
  return cachepath
@@ -88,7 +91,7 @@ class EntityManager(YamlAbleMixin, JsonPickleMixin):
88
91
  def removeCacheFile(self):
89
92
  ''' remove my cache file '''
90
93
  mode=self.config.mode
91
- if mode is StoreMode.JSON:
94
+ if mode is StoreMode.JSON or mode is StoreMode.JSONABLE:
92
95
  cacheFile=self.getCacheFile(mode=mode)
93
96
  if os.path.isfile(cacheFile):
94
97
  os.remove(cacheFile)
@@ -119,8 +122,8 @@ class EntityManager(YamlAbleMixin, JsonPickleMixin):
119
122
  result=False
120
123
  config=self.config
121
124
  mode=self.config.mode
122
- if mode is StoreMode.JSON:
123
- result=os.path.isfile(self.getCacheFile(config=self.config,mode=StoreMode.JSON))
125
+ if mode is StoreMode.JSON or mode is StoreMode.JSONABLE:
126
+ result=os.path.isfile(self.getCacheFile(config=self.config,mode=mode))
124
127
  elif mode is StoreMode.SPARQL:
125
128
  # @FIXME - make abstract
126
129
  query=config.prefix+"""
@@ -164,7 +167,7 @@ GROUP by ?source
164
167
  self.cacheFile=self.store(listOfDicts)
165
168
  else:
166
169
  # fromStore also sets self.cacheFile
167
- listOfDicts=self.fromStore()
170
+ self.fromStore()
168
171
  return listOfDicts
169
172
 
170
173
  def fromStore(self,cacheFile=None):
@@ -184,6 +187,9 @@ GROUP by ?source
184
187
  mode=self.config.mode
185
188
  if mode is StoreMode.JSON:
186
189
  JSONem=JsonPickleMixin.readJson(cacheFile)
190
+ elif mode is StoreMode.JSONABLE:
191
+ # TODO: implement
192
+ pass
187
193
  elif mode is StoreMode.SPARQL:
188
194
  # @FIXME make abstract
189
195
  eventQuery="""
@@ -213,12 +219,13 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
213
219
  raise Exception("unsupported store mode %s" % self.mode)
214
220
 
215
221
  if JSONem is not None:
222
+ # TODO FIXME
216
223
  return JSONem
217
224
  else:
218
225
  self.showProgress("read %d %s from %s in %5.1f s" % (len(listOfDicts),self.entityPluralName,self.name,time.time()-startTime))
219
226
  return listOfDicts
220
227
 
221
- def store(self,listOfDicts,limit=10000000,batchSize=250,cacheFile=None,sampleRecordCount=1):
228
+ def store(self,listOfDicts,limit=10000000,batchSize=250,cacheFile=None,fixNone=True,sampleRecordCount=1):
222
229
  '''
223
230
  store my entities
224
231
 
@@ -231,10 +238,10 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
231
238
  '''
232
239
  config=self.config
233
240
  mode=config.mode
234
- if mode is StoreMode.JSON:
241
+ if mode is StoreMode.JSON or mode is StoreMode.JSONABLE:
235
242
  if cacheFile is None:
236
243
  cacheFile=self.getCacheFile(config=self.config,mode=StoreMode.JSON)
237
- self.showProgress ("storing %d events for %s to cache %s" % (len(self.events),self.name,cacheFile))
244
+ self.showProgress (f"storing {len(listOfDicts)} {self.entityPluralName} for {self.name} to cache {cacheFile}")
238
245
  self.writeJson(cacheFile)
239
246
  elif mode is StoreMode.SPARQL:
240
247
  startTime=time.time()
@@ -252,7 +259,7 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
252
259
  sqldb=self.getSQLDB(cacheFile)
253
260
  self.showProgress ("storing %d %s for %s to %s:%s" % (len(listOfDicts),self.entityPluralName,self.name,config.mode,cacheFile))
254
261
  entityInfo=sqldb.createTable(listOfDicts, config.tableName, "eventId",withDrop=True,sampleRecordCount=sampleRecordCount)
255
- self.sqldb.store(listOfDicts, entityInfo,executeMany=self.executeMany)
262
+ self.sqldb.store(listOfDicts, entityInfo,executeMany=self.executeMany,fixNone=fixNone)
256
263
  self.showProgress ("store for %s done after %5.1f secs" % (self.name,time.time()-startTime))
257
264
  else:
258
265
  raise Exception("unsupported store mode %s" % self.mode)
@@ -10,7 +10,7 @@ class StoreMode(Enum):
10
10
  '''
11
11
  possible supported storage modes
12
12
  '''
13
- JSON = 1
13
+ JSON = 1 # JSON Pickle
14
14
  JSONABLE = 2
15
15
  SQL = 3
16
16
  SPARQL = 4
@@ -20,17 +20,6 @@ class StorageConfig(object):
20
20
  '''
21
21
  a storage configuration
22
22
  '''
23
-
24
- def ensureDirectoryExists(self,file_path:str):
25
- '''
26
- check that the given path exists and otherwise create it
27
-
28
- Args
29
- file_path(str): the path to check
30
- '''
31
- directory = os.path.dirname(file_path)
32
- if not os.path.exists(directory):
33
- os.makedirs(directory)
34
23
 
35
24
  def getCachePath(self,ensureExists=True)->str:
36
25
  '''
@@ -41,8 +30,10 @@ class StorageConfig(object):
41
30
  '''
42
31
  home = str(Path.home())
43
32
  cachedir=f"{home}/.{self.cacheDirName}"
33
+
44
34
  if ensureExists:
45
- self.ensureDirectoryExists(cachedir)
35
+ if not os.path.exists(cachedir):
36
+ os.makedirs(cachedir)
46
37
  return cachedir
47
38
 
48
39
  def __init__(self, mode=StoreMode.SQL,cacheDirName="lodstorage",cacheFile=None,withShowProgress=True,profile=True,debug=False,errorDebug=True):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.0.45
3
+ Version: 0.0.47
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.45',
14
+ version='0.0.47',
15
15
 
16
16
  packages=['lodstorage',],
17
17
  author='Wolfgang Fahl',
File without changes
File without changes
File without changes