pyLodStorage 0.1.0__tar.gz → 0.1.3__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 (30) hide show
  1. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/PKG-INFO +1 -1
  2. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/query.py +8 -2
  3. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/querymain.py +18 -3
  4. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/pylodstorage.egg-info/PKG-INFO +1 -1
  5. pylodstorage-0.1.3/pylodstorage.egg-info/entry_points.txt +5 -0
  6. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/setup.py +4 -4
  7. pylodstorage-0.1.0/pylodstorage.egg-info/entry_points.txt +0 -5
  8. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/LICENSE +0 -0
  9. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/README.md +0 -0
  10. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/__init__.py +0 -0
  11. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/csv.py +0 -0
  12. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/entity.py +0 -0
  13. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/jsonable.py +0 -0
  14. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/jsonpicklemixin.py +0 -0
  15. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/lod.py +0 -0
  16. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/mwTable.py +0 -0
  17. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/plot.py +0 -0
  18. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/sample.py +0 -0
  19. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/schema.py +0 -0
  20. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/sparql.py +0 -0
  21. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/sql.py +0 -0
  22. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/storageconfig.py +0 -0
  23. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/tabulateCounter.py +0 -0
  24. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/uml.py +0 -0
  25. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/lodstorage/yamlablemixin.py +0 -0
  26. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/pylodstorage.egg-info/SOURCES.txt +0 -0
  27. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/pylodstorage.egg-info/dependency_links.txt +0 -0
  28. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/pylodstorage.egg-info/requires.txt +0 -0
  29. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/pylodstorage.egg-info/top_level.txt +0 -0
  30. {pylodstorage-0.1.0 → pylodstorage-0.1.3}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.1.0
3
+ Version: 0.1.3
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -46,7 +46,7 @@ class QueryResultDocumentation():
46
46
 
47
47
 
48
48
  @staticmethod
49
- def uniCode2Latex(text:str)->str:
49
+ def uniCode2Latex(text:str,withConvert:bool=False)->str:
50
50
  '''
51
51
  converts unicode text to latex and
52
52
  fixes UTF-8 chars for latex in a certain range:
@@ -56,13 +56,19 @@ class QueryResultDocumentation():
56
56
 
57
57
  Args:
58
58
  text(str): the string to fix
59
+ withConvert(bool): if unicode to latex libary conversion should be used
59
60
 
60
61
  Return:
61
62
  str: latex presentation of UTF-8 char
62
63
  '''
63
64
  for code in range(8320,8330):
64
65
  text=text.replace(chr(code),f"$_{code-8320}$")
65
- return unicode_to_latex(text)
66
+ if withConvert:
67
+ latex=unicode_to_latex(text)
68
+ # workaround {\textbackslash} being returned
69
+ #latex=latex.replace("{\\textbackslash}",'\\')
70
+ text=latex
71
+ return text
66
72
 
67
73
  @staticmethod
68
74
  def wikiDataLink(record,key,value,tablefmt):
@@ -3,7 +3,7 @@ Created on 2022-02-13
3
3
 
4
4
  @author: wf
5
5
  '''
6
- __version__ = "0.1.0"
6
+ __version__ = "0.1.3"
7
7
  __date__ = '2020-09-10'
8
8
  __updated__ = '2022-02-13'
9
9
  DEBUG = 0
@@ -13,7 +13,7 @@ import sys
13
13
  import os
14
14
  from argparse import ArgumentParser
15
15
  from argparse import RawDescriptionHelpFormatter
16
- from lodstorage.query import QueryManager
16
+ from lodstorage.query import QueryManager, QueryResultDocumentation
17
17
  from lodstorage.sparql import SPARQL
18
18
  from lodstorage.csv import CSV
19
19
 
@@ -22,6 +22,9 @@ class Format(Enum):
22
22
  json = 'json'
23
23
  xml = 'xml'
24
24
  tsv = 'tsv'
25
+ latex = 'latex'
26
+ mediawiki= 'mediawiki'
27
+ github = 'github'
25
28
 
26
29
  def __str__(self):
27
30
  return self.value
@@ -36,7 +39,11 @@ class QueryMain:
36
39
  command line activation with parsed args
37
40
  '''
38
41
  debug=args.debug
39
- if args.queryName is not None:
42
+ if args.list:
43
+ qm=QueryManager(lang=args.language,debug=debug,queriesPath=args.queriesPath)
44
+ for name,query in qm.queriesByName.items():
45
+ print(f"{name}:{query.title}")
46
+ elif args.queryName is not None:
40
47
  if debug:
41
48
  print(f"named query {args.queryName}:")
42
49
  qm=QueryManager(lang=args.language,debug=debug,queriesPath=args.queriesPath)
@@ -45,10 +52,17 @@ class QueryMain:
45
52
  query=qm.queriesByName[args.queryName]
46
53
  if args.language=="sparql":
47
54
  endpoint=SPARQL(query.endpoint)
55
+ if "wikidata" in query.endpoint:
56
+ query.addFormatCallBack(QueryResultDocumentation.wikiDataLink)
48
57
  qlod=endpoint.queryAsListOfDicts(query.query)
49
58
  if args.format is Format.csv:
50
59
  csv=CSV.toCSV(qlod)
51
60
  print(csv)
61
+ elif args.format is Format.latex or args.format is Format.github or args.format is Format.mediawiki:
62
+ doc=query.documentQueryResult(qlod, tablefmt=str(args.format),floatfmt=".0f")
63
+ docstr=doc.asText()
64
+ print (docstr)
65
+
52
66
 
53
67
 
54
68
  def mainSQL(argv=None):
@@ -89,6 +103,7 @@ USAGE
89
103
  parser.add_argument("-d", "--debug", dest="debug", action="store_true", help="set debug [default: %(default)s]")
90
104
  parser.add_argument('-e', '--endpoint', default="https://query.wikidata.org/sparql", help="SPARQL endpoint to use for queries")
91
105
  parser.add_argument('-f','--format', type=Format, choices=list(Format))
106
+ parser.add_arguemnt('-l','--list',help="show the list of available queries")
92
107
  parser.add_argument('-qp', '--queriesPath',help="path to YAML file with query definitions")
93
108
  parser.add_argument("-q", "--query",help="the query to run")
94
109
  parser.add_argument("-qn","--queryName",help="run a named query")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.1.0
3
+ Version: 0.1.3
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ lodquery = lodstorage.querymain:main
3
+ sparqlquery = lodstorage.querymain:mainSPARQL
4
+ sqlquery = lodstorage.querymain:mainSQL
5
+
@@ -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.1.0',
14
+ version='0.1.3',
15
15
 
16
16
  packages=['lodstorage',],
17
17
  author='Wolfgang Fahl',
@@ -44,9 +44,9 @@ setup(
44
44
  ],
45
45
  entry_points={
46
46
  'console_scripts': [
47
- 'sparqlquery = lodstorage.query:mainSPARQL',
48
- 'sqlquery=lodstorage.query:mainSQL',
49
- 'lodquery=lodstorage.query:main'
47
+ 'sparqlquery = lodstorage.querymain:mainSPARQL',
48
+ 'sqlquery=lodstorage.querymain:mainSQL',
49
+ 'lodquery=lodstorage.querymain:main'
50
50
  ],
51
51
  },
52
52
  long_description=long_description,
@@ -1,5 +0,0 @@
1
- [console_scripts]
2
- lodquery = lodstorage.query:main
3
- sparqlquery = lodstorage.query:mainSPARQL
4
- sqlquery = lodstorage.query:mainSQL
5
-
File without changes
File without changes
File without changes