pyLodStorage 0.3.7__tar.gz → 0.3.9__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 (41) hide show
  1. {pylodstorage-0.3.7/pylodstorage.egg-info → pylodstorage-0.3.9}/PKG-INFO +1 -1
  2. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/query.py +13 -8
  3. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/querymain.py +3 -0
  4. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/trulytabular.py +2 -2
  5. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/version.py +2 -2
  6. {pylodstorage-0.3.7 → pylodstorage-0.3.9/pylodstorage.egg-info}/PKG-INFO +1 -1
  7. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/pylodstorage.egg-info/SOURCES.txt +1 -0
  8. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/endpoints.yaml +1 -1
  9. pylodstorage-0.3.9/sampledata/got.yaml +62 -0
  10. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/LICENSE +0 -0
  11. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/README.md +0 -0
  12. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/__init__.py +0 -0
  13. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/csv.py +0 -0
  14. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/entity.py +0 -0
  15. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/jsonable.py +0 -0
  16. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/jsonpicklemixin.py +0 -0
  17. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/lod.py +0 -0
  18. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/mwTable.py +0 -0
  19. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/plot.py +0 -0
  20. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/sample.py +0 -0
  21. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/schema.py +0 -0
  22. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/sparql.py +0 -0
  23. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/sql.py +0 -0
  24. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/storageconfig.py +0 -0
  25. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/tabulateCounter.py +0 -0
  26. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/uml.py +0 -0
  27. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/xml.py +0 -0
  28. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/lodstorage/yamlablemixin.py +0 -0
  29. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/pylodstorage.egg-info/dependency_links.txt +0 -0
  30. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/pylodstorage.egg-info/entry_points.txt +0 -0
  31. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/pylodstorage.egg-info/requires.txt +0 -0
  32. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/pylodstorage.egg-info/top_level.txt +0 -0
  33. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/__init__.py +0 -0
  34. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/formats.yaml +0 -0
  35. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/queries.yaml +0 -0
  36. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/scholia.yaml +0 -0
  37. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/trulytabular.yaml +0 -0
  38. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/wf.yaml +0 -0
  39. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/sampledata/wikidata.yaml +0 -0
  40. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/setup.cfg +0 -0
  41. {pylodstorage-0.3.7 → pylodstorage-0.3.9}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.3.7
3
+ Version: 0.3.9
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -199,7 +199,6 @@ class QueryResultDocumentation():
199
199
  self.resultHeader=resultHeader
200
200
  self.result=result
201
201
 
202
-
203
202
  @staticmethod
204
203
  def uniCode2Latex(text:str,withConvert:bool=False)->str:
205
204
  '''
@@ -245,7 +244,7 @@ class QueryResultDocumentation():
245
244
  class Query(object):
246
245
  ''' a Query e.g. for SPAQRL '''
247
246
 
248
- def __init__(self,name:str,query:str,lang='sparql',endpoint:str=None,title:str=None,description:str=None,prefixes=None,tryItUrl:str=None,formats:list=None,debug=False):
247
+ def __init__(self,name:str,query:str,lang='sparql',endpoint:str=None,database:str="blazegraph",title:str=None,description:str=None,prefixes=None,tryItUrl:str=None,formats:list=None,debug=False):
249
248
  '''
250
249
  constructor
251
250
  Args:
@@ -253,6 +252,7 @@ class Query(object):
253
252
  query(string): the native Query text e.g. in SPARQL
254
253
  lang(string): the language of the query e.g. SPARQL
255
254
  endpoint(string): the endpoint url to use
255
+ database(string): the type of database e.g. "blazegraph"
256
256
  title(string): the header/title of the query
257
257
  description(string): the description of the query
258
258
  prefixes(list): list of prefixes to be resolved
@@ -264,11 +264,13 @@ class Query(object):
264
264
  self.query=query
265
265
  self.lang=lang
266
266
  self.endpoint=endpoint
267
+ self.database=database
268
+ self.tryItUrl=tryItUrl
269
+
267
270
  self.title=title=name if title is None else title
268
271
  self.description="" if description is None else description
269
272
  self.prefixes=prefixes
270
273
  self.debug=debug
271
- self.tryItUrl=tryItUrl
272
274
  self.formats=formats
273
275
  self.formatCallBacks=[]
274
276
 
@@ -325,7 +327,7 @@ class Query(object):
325
327
  valueFormatter.applyFormat(record,keytoformat,tablefmt)
326
328
  pass
327
329
 
328
- def getTryItUrl(self,baseurl:str):
330
+ def getTryItUrl(self,baseurl:str,database:str="blazegraph"):
329
331
  '''
330
332
  return the "try it!" url for the given baseurl
331
333
 
@@ -337,8 +339,11 @@ class Query(object):
337
339
  '''
338
340
  # https://stackoverflow.com/a/9345102/1497139
339
341
  quoted=urllib.parse.quote(str(self.query))
340
- quoted=f"#{quoted}"
341
- url=f"{baseurl}/{quoted}"
342
+ if database=="blazegraph":
343
+ delim="/#"
344
+ else:
345
+ delim="?query="
346
+ url=f"{baseurl}{delim}{quoted}"
342
347
  return url
343
348
 
344
349
  def getLink(self,url,title,tablefmt):
@@ -463,7 +468,7 @@ class Query(object):
463
468
  title=f"{self.title}"
464
469
  resultHeader="result:"
465
470
  if withSourceCode:
466
- tryItUrlEncoded=self.getTryItUrl(tryItUrl)
471
+ tryItUrlEncoded=self.getTryItUrl(tryItUrl,self.database)
467
472
  tryItMarkup=self.getLink(tryItUrlEncoded, "try it!", tablefmt)
468
473
  if tablefmt=="github":
469
474
  sourceCodeHeader="### query"
@@ -606,5 +611,5 @@ class Endpoint(JSONAble):
606
611
  Returns:
607
612
  str: a string representation of this Endpoint
608
613
  '''
609
- text=f"{self.name}({self.name}):{self.endpoint}({self.method})"
614
+ text=f"{self.name}:{self.website}:{self.endpoint}({self.method})"
610
615
  return text
@@ -53,6 +53,7 @@ class QueryMain:
53
53
  for name,query in qm.queriesByName.items():
54
54
  print(f"{name}:{query.title}")
55
55
  elif args.listEndpoints:
56
+ # list endpoints
56
57
  for endpoint in endpoints.values():
57
58
  if hasattr(endpoint, "lang") and endpoint.lang==args.language:
58
59
  print(endpoint)
@@ -85,6 +86,8 @@ class QueryMain:
85
86
  if args.endpointName:
86
87
  endPointUrl=endpointConf.endpoint
87
88
  method=endpointConf.method
89
+ query.tryItUrl=endpointConf.website
90
+ query.database=endpointConf.database
88
91
  else:
89
92
  endPointUrl=query.endpoint
90
93
  if args.method:
@@ -607,8 +607,8 @@ ORDER BY DESC(?count)"""
607
607
  nttotal=0
608
608
  maxCount=0
609
609
  for record in ntlod:
610
- f=record["frequency"]
611
- count=record["count"]
610
+ f=int(record["frequency"])
611
+ count=int(record["count"])
612
612
  #statsRow[f"f{count}"]=f
613
613
  if count>1:
614
614
  nttotal+=f
@@ -9,7 +9,7 @@ class Version(object):
9
9
  Version handling for pyLoDStorage
10
10
  '''
11
11
  name="pylodstorage"
12
- version='0.3.7'
12
+ version='0.3.9'
13
13
  date = '2020-09-10'
14
- updated = '2022-07-31'
14
+ updated = '2022-08-01'
15
15
  description='python List of Dict (Table) Storage library'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.3.7
3
+ Version: 0.3.9
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -31,6 +31,7 @@ pylodstorage.egg-info/top_level.txt
31
31
  sampledata/__init__.py
32
32
  sampledata/endpoints.yaml
33
33
  sampledata/formats.yaml
34
+ sampledata/got.yaml
34
35
  sampledata/queries.yaml
35
36
  sampledata/scholia.yaml
36
37
  sampledata/trulytabular.yaml
@@ -3,7 +3,7 @@
3
3
  'wikidata':
4
4
  lang: sparql
5
5
  endpoint: https://query.wikidata.org/sparql
6
- website: https://query.wikidata.org/
6
+ website: https://query.wikidata.org
7
7
  database: blazegraph
8
8
  method: POST
9
9
  prefixes: |
@@ -0,0 +1,62 @@
1
+ # Game of Thrones example
2
+ # WF 2022-07-31
3
+ 'gotNaive1':
4
+ sparql: |
5
+ # Game of Thrones Characters
6
+ SELECT
7
+ ?item ?itemLabel
8
+ ?genderLabel
9
+ ?countryLabel
10
+ ?placeOfBirthLabel
11
+ ?placeOfDeathLabel
12
+ WHERE
13
+ {
14
+ ?item wdt:P31 wd:Q20086263. # must be a game of thrones character
15
+ ?item wdt:P21 ?gender.
16
+ ?item wdt:P27 ?country.
17
+ ?item wdt:P19 ?placeOfBirth.
18
+ ?item wdt:P20 ?placeOfDeath.
19
+ SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
20
+ }
21
+ 'gotNaive2':
22
+ sparql: |
23
+ # Game of Thrones Characters
24
+ SELECT
25
+ ?item ?itemLabel
26
+ ?genderLabel
27
+ ?countryLabel
28
+ ?placeOfBirthLabel
29
+ ?placeOfDeathLabel
30
+ WHERE
31
+ {
32
+ ?item wdt:P31 wd:Q20086263. # must be a game of thrones character
33
+ OPTIONAL { ?item wdt:P21 ?gender}.
34
+ OPTIONAL { ?item wdt:P27 ?country}.
35
+ OPTIONAL { ?item wdt:P19 ?placeOfBirth}.
36
+ OPTIONAL { ?item wdt:P20 ?placeOfDeath}.
37
+ SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
38
+ }
39
+ 'gotNaive3':
40
+ sparql: |
41
+ # Game of Thrones Characters
42
+ SELECT
43
+ ?item ?itemLabel
44
+ ?genderLabel
45
+ ?countryLabel
46
+ ?placeOfBirthLabel
47
+ ?placeOfDeathLabel
48
+ ?killedByLabel
49
+ ?familyLabel
50
+ ?occupationLabel
51
+ WHERE
52
+ {
53
+ ?item wdt:P31 wd:Q20086263. # must be a game of thrones character
54
+ OPTIONAL { ?item wdt:P21 ?gender}.
55
+ OPTIONAL { ?item wdt:P27 ?country}.
56
+ OPTIONAL { ?item wdt:P19 ?placeOfBirth}.
57
+ OPTIONAL { ?item wdt:P20 ?placeOfDeath}.
58
+ OPTIONAL { ?item wdt:P157 ?killedBy}.
59
+ OPTIONAL { ?item wdt:P53 ?family}.
60
+ OPTIONAL { ?item wdt:P106 ?occupation}.
61
+ SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
62
+ }
File without changes
File without changes
File without changes
File without changes