pyLodStorage 0.0.43__tar.gz → 0.0.45__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.43 → pylodstorage-0.0.45}/PKG-INFO +1 -1
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/entity.py +12 -8
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/storageconfig.py +18 -6
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/pylodstorage.egg-info/PKG-INFO +1 -1
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/pylodstorage.egg-info/requires.txt +1 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/setup.py +3 -2
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/LICENSE +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/README.md +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/__init__.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/csv.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/jsonable.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/jsonpicklemixin.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/lod.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/mwTable.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/plot.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/query.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/sample.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/schema.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/sparql.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/sql.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/tabulateCounter.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/uml.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/lodstorage/yamlablemixin.py +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/pylodstorage.egg-info/SOURCES.txt +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/pylodstorage.egg-info/dependency_links.txt +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/pylodstorage.egg-info/top_level.txt +0 -0
- {pylodstorage-0.0.43 → pylodstorage-0.0.45}/setup.cfg +0 -0
|
@@ -70,9 +70,10 @@ class EntityManager(YamlAbleMixin, JsonPickleMixin):
|
|
|
70
70
|
config(StorageConfig): if None get the cache for my mode
|
|
71
71
|
mode(StoreMode): the storeMode to use
|
|
72
72
|
'''
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
if config is not None:
|
|
74
|
+
cachedir=config.getCachePath()
|
|
75
|
+
if config.cacheFile is not None:
|
|
76
|
+
return config.cacheFile
|
|
76
77
|
''' get the path to the file for my cached data '''
|
|
77
78
|
if mode is StoreMode.JSON:
|
|
78
79
|
cachepath="%s/%s-%s.%s" % (cachedir,self.name,"events",'json')
|
|
@@ -84,6 +85,14 @@ class EntityManager(YamlAbleMixin, JsonPickleMixin):
|
|
|
84
85
|
cachepath="undefined cachepath for %s" % (mode)
|
|
85
86
|
return cachepath
|
|
86
87
|
|
|
88
|
+
def removeCacheFile(self):
|
|
89
|
+
''' remove my cache file '''
|
|
90
|
+
mode=self.config.mode
|
|
91
|
+
if mode is StoreMode.JSON:
|
|
92
|
+
cacheFile=self.getCacheFile(mode=mode)
|
|
93
|
+
if os.path.isfile(cacheFile):
|
|
94
|
+
os.remove(cacheFile)
|
|
95
|
+
|
|
87
96
|
def getSQLDB(self,cacheFile):
|
|
88
97
|
'''
|
|
89
98
|
get the SQL database for the given cacheFile
|
|
@@ -227,11 +236,6 @@ SELECT ?eventId ?acronym ?series ?title ?year ?country ?city ?startDate ?endDate
|
|
|
227
236
|
cacheFile=self.getCacheFile(config=self.config,mode=StoreMode.JSON)
|
|
228
237
|
self.showProgress ("storing %d events for %s to cache %s" % (len(self.events),self.name,cacheFile))
|
|
229
238
|
self.writeJson(cacheFile)
|
|
230
|
-
elif mode is StoreMode.DGRAPH:
|
|
231
|
-
startTime=time.time()
|
|
232
|
-
self.showProgress ("storing %d %s for %s to %s" % (len(self.events),self.entityPluralName,self.name,self.mode))
|
|
233
|
-
self.dgraph.addData(listOfDicts,limit=limit,batchSize=batchSize)
|
|
234
|
-
self.showProgress ("store for %s done after %5.1f secs" % (self.name,time.time()-startTime))
|
|
235
239
|
elif mode is StoreMode.SPARQL:
|
|
236
240
|
startTime=time.time()
|
|
237
241
|
# @ FIXME make abstract
|
|
@@ -4,9 +4,8 @@ Created on 2020-08-29
|
|
|
4
4
|
@author: wf
|
|
5
5
|
'''
|
|
6
6
|
from enum import Enum
|
|
7
|
-
import os
|
|
8
7
|
from pathlib import Path
|
|
9
|
-
|
|
8
|
+
import os
|
|
10
9
|
class StoreMode(Enum):
|
|
11
10
|
'''
|
|
12
11
|
possible supported storage modes
|
|
@@ -22,8 +21,18 @@ class StorageConfig(object):
|
|
|
22
21
|
a storage configuration
|
|
23
22
|
'''
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
|
|
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
|
+
|
|
35
|
+
def getCachePath(self,ensureExists=True)->str:
|
|
27
36
|
'''
|
|
28
37
|
get the path to the default cache
|
|
29
38
|
|
|
@@ -31,10 +40,12 @@ class StorageConfig(object):
|
|
|
31
40
|
name(str): the name of the cache to use
|
|
32
41
|
'''
|
|
33
42
|
home = str(Path.home())
|
|
34
|
-
cachedir=f"{home}
|
|
43
|
+
cachedir=f"{home}/.{self.cacheDirName}"
|
|
44
|
+
if ensureExists:
|
|
45
|
+
self.ensureDirectoryExists(cachedir)
|
|
35
46
|
return cachedir
|
|
36
47
|
|
|
37
|
-
def __init__(self, mode=StoreMode.SQL,cacheFile=None,withShowProgress=True,profile=True,debug=False,errorDebug=True):
|
|
48
|
+
def __init__(self, mode=StoreMode.SQL,cacheDirName="lodstorage",cacheFile=None,withShowProgress=True,profile=True,debug=False,errorDebug=True):
|
|
38
49
|
'''
|
|
39
50
|
Constructor
|
|
40
51
|
|
|
@@ -46,6 +57,7 @@ class StorageConfig(object):
|
|
|
46
57
|
debug(boolean): True if debugging information should be shown
|
|
47
58
|
errorDebug(boolean): True if debug info should be provided on errors (should not be used for production since it might reveal data)
|
|
48
59
|
'''
|
|
60
|
+
self.cacheDirName=cacheDirName
|
|
49
61
|
self.mode=mode
|
|
50
62
|
self.cacheFile=cacheFile
|
|
51
63
|
self.profile=profile
|
|
@@ -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.
|
|
14
|
+
version='0.0.45',
|
|
15
15
|
|
|
16
16
|
packages=['lodstorage',],
|
|
17
17
|
author='Wolfgang Fahl',
|
|
@@ -30,7 +30,8 @@ setup(
|
|
|
30
30
|
install_requires=[
|
|
31
31
|
'SPARQLWrapper',
|
|
32
32
|
'PyYAML',
|
|
33
|
-
'pandas'
|
|
33
|
+
'pandas',
|
|
34
|
+
'jsonpickle',
|
|
34
35
|
],
|
|
35
36
|
classifiers=[
|
|
36
37
|
'Programming Language :: Python',
|
|
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
|