pyLodStorage 0.2.2__tar.gz → 0.2.4__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 (39) hide show
  1. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/PKG-INFO +1 -1
  2. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/querymain.py +14 -2
  3. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/trulytabular.py +1 -0
  4. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/version.py +2 -2
  5. pylodstorage-0.2.4/lodstorage/xml.py +49 -0
  6. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/pylodstorage.egg-info/PKG-INFO +1 -1
  7. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/pylodstorage.egg-info/SOURCES.txt +1 -0
  8. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/wikidata.yaml +44 -0
  9. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/LICENSE +0 -0
  10. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/README.md +0 -0
  11. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/csv.py +0 -0
  12. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/entity.py +0 -0
  13. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/jsonable.py +0 -0
  14. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/jsonpicklemixin.py +0 -0
  15. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/lod.py +0 -0
  16. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/mwTable.py +0 -0
  17. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/plot.py +0 -0
  18. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/query.py +0 -0
  19. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/sample.py +0 -0
  20. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/schema.py +0 -0
  21. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/sparql.py +0 -0
  22. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/sql.py +0 -0
  23. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/storageconfig.py +0 -0
  24. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/tabulateCounter.py +0 -0
  25. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/uml.py +0 -0
  26. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/lodstorage/yamlablemixin.py +0 -0
  27. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/pylodstorage.egg-info/dependency_links.txt +0 -0
  28. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/pylodstorage.egg-info/entry_points.txt +0 -0
  29. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/pylodstorage.egg-info/requires.txt +0 -0
  30. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/pylodstorage.egg-info/top_level.txt +0 -0
  31. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/__init__.py +0 -0
  32. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/endpoints.yaml +0 -0
  33. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/formats.yaml +0 -0
  34. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/queries.yaml +0 -0
  35. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/scholia.yaml +0 -0
  36. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/trulytabular.yaml +0 -0
  37. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/sampledata/wf.yaml +0 -0
  38. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/setup.cfg +0 -0
  39. {pylodstorage-0.2.2 → pylodstorage-0.2.4}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -15,17 +15,22 @@ import requests
15
15
  import sys
16
16
  import traceback
17
17
  import os
18
+
18
19
  from argparse import ArgumentParser
19
20
  from argparse import RawDescriptionHelpFormatter
20
- from lodstorage.query import QueryManager, QueryResultDocumentation, EndpointManager, Format, ValueFormatter
21
+
22
+ from lodstorage.csv import CSV
23
+ from lodstorage.query import QueryManager, EndpointManager, Format, ValueFormatter
21
24
  from lodstorage.sparql import SPARQL
22
25
  from lodstorage.sql import SQLDB
23
- from lodstorage.csv import CSV
26
+ from lodstorage.xml import Lod2Xml
27
+
24
28
 
25
29
  class QueryMain:
26
30
  '''
27
31
  Commandline handler
28
32
  '''
33
+
29
34
  @classmethod
30
35
  def main(cls,args):
31
36
  '''
@@ -99,6 +104,13 @@ class QueryMain:
99
104
  print (docstr)
100
105
  elif args.format in [Format.json]:
101
106
  print(json.dumps(qlod))
107
+ elif args.format in [Format.xml]:
108
+ lod2xml=Lod2Xml(qlod)
109
+ xml=lod2xml.asXml()
110
+ print(xml)
111
+
112
+ else:
113
+ raise Exception(f"format {args.format} not supported yet")
102
114
 
103
115
  @staticmethod
104
116
  def rawQuery(endpoint, query, resultFormat, mimeType):
@@ -262,6 +262,7 @@ class TrulyTabular(object):
262
262
  endpoint=TrulyTabular.endpoint
263
263
  self.endpoint=endpoint
264
264
  self.sparql=SPARQL(endpoint,method=method)
265
+ self.sparql.debug=self.debug
265
266
  self.where=f"\n {where}" if where is not None else ""
266
267
  self.lang=lang
267
268
  self.item=WikidataItem(itemQid,sparql=self.sparql,lang=lang)
@@ -9,6 +9,6 @@ class Version(object):
9
9
  Version handling for pyLoDStorage
10
10
  '''
11
11
  name="pylodstorage"
12
- version='0.2.2'
12
+ version='0.2.4'
13
13
  date = '2020-09-10'
14
- updated = '2022-04-11'
14
+ updated = '2022-06-20'
@@ -0,0 +1,49 @@
1
+ '''
2
+ Created on 2022-06-20
3
+
4
+ see
5
+ https://github.com/tyleradams/json-toolkit
6
+ https://stackoverflow.com/questions/36021526/converting-an-array-dict-to-xml-in-python
7
+
8
+ @author: tyleradams
9
+ @author: wf
10
+ '''
11
+ from dicttoxml import dicttoxml
12
+ from xml.dom.minidom import parseString
13
+
14
+
15
+ class Lod2Xml():
16
+ '''
17
+ convert a list of dicts to XML
18
+ '''
19
+
20
+ def __init__(self,lod,root:str="root",node_name:callable=(lambda x:'node')):
21
+ '''
22
+ construct me with the given list of dicts
23
+
24
+ Args:
25
+ lod(list): the list of dicts to convert to XML
26
+ root(str): the name of the root nod
27
+ item_name(func): the function to use to calculate node names
28
+ '''
29
+ self.lod=lod
30
+ self.root=root
31
+ self.item_name=node_name
32
+
33
+
34
+ def asXml(self,pretty:bool=True):
35
+ '''
36
+ convert result to XML
37
+
38
+ Args:
39
+ pretty(bool): if True pretty print the result
40
+
41
+ '''
42
+ xml=dicttoxml(self.lod, custom_root=self.root,item_func=self.item_name, attr_type=False)
43
+ if pretty:
44
+ dom=parseString(xml)
45
+ prettyXml=dom.toprettyxml()
46
+ else:
47
+ prettyXml=xml
48
+ return prettyXml
49
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.2.2
3
+ Version: 0.2.4
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -19,6 +19,7 @@ lodstorage/tabulateCounter.py
19
19
  lodstorage/trulytabular.py
20
20
  lodstorage/uml.py
21
21
  lodstorage/version.py
22
+ lodstorage/xml.py
22
23
  lodstorage/yamlablemixin.py
23
24
  pylodstorage.egg-info/PKG-INFO
24
25
  pylodstorage.egg-info/SOURCES.txt
@@ -79,3 +79,47 @@
79
79
  }
80
80
  }
81
81
  ORDER BY(?playerLabel)
82
+ 'Top200HumanSettlementClasses':
83
+ title: top 200 human settlement classes https://www.wikidata.org/wiki/Q486972
84
+ description: based on wdtaxonomy Q486972 -c -d -m = using https://www.npmjs.com/package/wikidata-taxonomy
85
+ formats:
86
+ - item:wikidata
87
+ sparql: |
88
+ # relevant human settlement classes in wikidata
89
+ # based on wdtaxonomy Q486972 -c -d -m = -s
90
+ # WF 2021-08-25
91
+ SELECT ?item ?itemLabel ?itemDescription ?instances ?sites WITH {
92
+ SELECT DISTINCT ?item { ?item wdt:P279* wd:Q486972 }
93
+ } AS %items WHERE {
94
+ INCLUDE %items .
95
+ {
96
+ SELECT ?item (count(distinct ?element) as ?instances) {
97
+ INCLUDE %items.
98
+ OPTIONAL { ?element wdt:P31 ?item }
99
+ } GROUP BY ?item
100
+ }
101
+ {
102
+ SELECT ?item (count(distinct ?site) as ?sites) {
103
+ INCLUDE %items.
104
+ OPTIONAL { ?site schema:about ?item }
105
+ } GROUP BY ?item
106
+ }
107
+ SERVICE wikibase:label {
108
+ bd:serviceParam wikibase:language "en"
109
+ }
110
+
111
+ FILTER(?instances>700)
112
+ } ORDER BY DESC (?instances)
113
+ LIMIT 200
114
+ 'AcademicConferenceItemLabel':
115
+ sparql: |
116
+ # get the label for the given item
117
+ SELECT ?itemLabel
118
+ WHERE
119
+ {
120
+ VALUES (?item) {
121
+ (wd:Q2020153)
122
+ }
123
+ ?item rdfs:label ?itemLabel.
124
+ filter (lang(?itemLabel) = "en").
125
+ }
File without changes
File without changes
File without changes
File without changes