pyLodStorage 0.0.45__tar.gz → 0.0.46__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.45/pylodstorage.egg-info → pylodstorage-0.0.46}/PKG-INFO +1 -1
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/entity.py +16 -9
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/storageconfig.py +4 -13
- {pylodstorage-0.0.45 → pylodstorage-0.0.46/pylodstorage.egg-info}/PKG-INFO +1 -1
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/setup.py +1 -1
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/LICENSE +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/README.md +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/__init__.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/csv.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/jsonable.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/jsonpicklemixin.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/lod.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/plot.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/query.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/sample.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/schema.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/sql.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/uml.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/lodstorage/yamlablemixin.py +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/pylodstorage.egg-info/requires.txt +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.0.45 → pylodstorage-0.0.46}/setup.cfg +0 -0
|
@@ -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,
|
|
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
|
-
|
|
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=
|
|
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
|
-
|
|
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,6 +219,7 @@ 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))
|
|
@@ -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
|
|
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()
|
|
@@ -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
|
-
|
|
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):
|
|
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
|