pyLodStorage 0.2.9__tar.gz → 0.2.10__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 (40) hide show
  1. {pylodstorage-0.2.9/pylodstorage.egg-info → pylodstorage-0.2.10}/PKG-INFO +1 -1
  2. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/sparql.py +5 -2
  3. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/trulytabular.py +27 -12
  4. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/version.py +2 -2
  5. {pylodstorage-0.2.9 → pylodstorage-0.2.10/pylodstorage.egg-info}/PKG-INFO +1 -1
  6. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/LICENSE +0 -0
  7. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/README.md +0 -0
  8. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/__init__.py +0 -0
  9. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/csv.py +0 -0
  10. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/entity.py +0 -0
  11. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/jsonable.py +0 -0
  12. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/jsonpicklemixin.py +0 -0
  13. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/lod.py +0 -0
  14. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/mwTable.py +0 -0
  15. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/plot.py +0 -0
  16. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/query.py +0 -0
  17. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/querymain.py +0 -0
  18. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/sample.py +0 -0
  19. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/schema.py +0 -0
  20. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/sql.py +0 -0
  21. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/storageconfig.py +0 -0
  22. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/tabulateCounter.py +0 -0
  23. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/uml.py +0 -0
  24. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/xml.py +0 -0
  25. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/lodstorage/yamlablemixin.py +0 -0
  26. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/pylodstorage.egg-info/SOURCES.txt +0 -0
  27. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/pylodstorage.egg-info/dependency_links.txt +0 -0
  28. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/pylodstorage.egg-info/entry_points.txt +0 -0
  29. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/pylodstorage.egg-info/requires.txt +0 -0
  30. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/pylodstorage.egg-info/top_level.txt +0 -0
  31. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/__init__.py +0 -0
  32. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/endpoints.yaml +0 -0
  33. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/formats.yaml +0 -0
  34. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/queries.yaml +0 -0
  35. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/scholia.yaml +0 -0
  36. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/trulytabular.yaml +0 -0
  37. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/wf.yaml +0 -0
  38. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/sampledata/wikidata.yaml +0 -0
  39. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/setup.cfg +0 -0
  40. {pylodstorage-0.2.9 → pylodstorage-0.2.10}/setup.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pylodstorage
3
- Version: 0.2.9
3
+ Version: 0.2.10
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
@@ -22,7 +22,7 @@ class SPARQL(object):
22
22
  :ivar sparql: the SPARQLWrapper2 instance to be used
23
23
  :ivar method(str): the HTTP method to be used 'POST' or 'GET'
24
24
  '''
25
- def __init__(self,url,mode='query', debug=False, typedLiterals=False, profile=False, agent='PyLodStorage',method='POST'):
25
+ def __init__(self,url,mode='query', debug=False, isFuseki=False,typedLiterals=False, profile=False, agent='PyLodStorage',method='POST'):
26
26
  '''
27
27
  Constructor a SPARQL wrapper
28
28
 
@@ -35,7 +35,10 @@ class SPARQL(object):
35
35
  agent(string): the User agent to use
36
36
  method(string): the HTTP method to be used 'POST' or 'GET'
37
37
  '''
38
- self.url="url%s" % (mode)
38
+ if isFuseki:
39
+ self.url=f"{url}/{mode}"
40
+ else:
41
+ self.url=url
39
42
  self.mode=mode
40
43
  self.debug=debug
41
44
  self.typedLiterals=typedLiterals
@@ -6,6 +6,7 @@ Created on 2022-04-14
6
6
  from lodstorage.sparql import SPARQL
7
7
  from lodstorage.query import Query,QueryManager,YamlPath
8
8
  import os
9
+ import textwrap
9
10
  import re
10
11
 
11
12
  class WikidataProperty():
@@ -140,15 +141,15 @@ class WikidataItem:
140
141
  self.qlabel,self.description=WikidataItem.getLabelAndDescription(sparql, self.qid, self.lang)
141
142
 
142
143
  def __str__(self):
143
-
144
144
  return self.asText(long=False)
145
145
 
146
- def asText(self,long:bool=True):
146
+ def asText(self,long:bool=True,wrapAt:int=0):
147
147
  '''
148
148
  returns my content as a text representation
149
149
 
150
150
  Args:
151
151
  long(bool): True if a long format including url is wished
152
+ wrapAt(int): wrap long lines at the given width (if >0)
152
153
 
153
154
  Returns:
154
155
  str: a text representation of my content
@@ -157,9 +158,12 @@ class WikidataItem:
157
158
  if hasattr(self, "qlabel"):
158
159
  text=f"{self.qlabel} ({self.qid})"
159
160
  if hasattr(self,"description"):
160
- text+=f":{self.description}"
161
+ desc=self.description
162
+ if wrapAt>0:
163
+ desc=textwrap.fill(desc,width=wrapAt)
164
+ text+=f"☞{desc}"
161
165
  if long:
162
- text+=f"-> https://www.wikidata.org/wiki/{self.qid}"
166
+ text+=f"→ https://www.wikidata.org/wiki/{self.qid}"
163
167
  return text
164
168
 
165
169
  @classmethod
@@ -269,7 +273,7 @@ class TrulyTabular(object):
269
273
  self.queryManager=TrulyTabular.getQueryManager(debug=self.debug)
270
274
  self.properties=WikidataProperty.getPropertiesByIds(self.sparql,propertyIds,lang)
271
275
  self.properties.update(WikidataProperty.getPropertiesByLabels(self.sparql, propertyLabels, lang))
272
-
276
+ self.error=None
273
277
 
274
278
  def __str__(self):
275
279
  '''
@@ -282,8 +286,9 @@ class TrulyTabular(object):
282
286
  '''
283
287
  get my count
284
288
  '''
285
- query=f"""# Count all items with the given
286
- # type {self.item.asText(long=True)}
289
+ itemText=self.getItemText()
290
+ query=f"""# Count all items with the given type
291
+ # {itemText}
287
292
  PREFIX wd: <http://www.wikidata.org/entity/>
288
293
  PREFIX wdt: <http://www.wikidata.org/prop/direct/>
289
294
  SELECT (COUNT (DISTINCT ?item) AS ?count)
@@ -295,6 +300,7 @@ WHERE
295
300
  try:
296
301
  count=self.sparql.getValue(query, "count")
297
302
  except Exception as ex:
303
+ self.error=ex
298
304
  count=None
299
305
 
300
306
  return count
@@ -312,6 +318,12 @@ WHERE
312
318
  text=self.item.asText(long)
313
319
  return text
314
320
 
321
+ def getItemText(self):
322
+ # leads to 405 Method not allowed in SPARQLWrapper under certain circumstances
323
+ # itemText=self.asText(long=True)
324
+ itemText=self.itemQid
325
+ return itemText
326
+
315
327
  @classmethod
316
328
  def getQueryManager(cls,lang='sparql',name="trulytabular",debug=False):
317
329
  '''
@@ -340,9 +352,10 @@ WHERE
340
352
  if whereClause is None:
341
353
  whereClause=f"?item wdt:P31 wd:{self.itemQid};";
342
354
  else:
343
- whereClause+=";"
344
- query.title=f"most frequently used properties for {self.asText(long=True)}"
345
- query.query=query.query % (self.item.asText(long=True),whereClause,self.lang)
355
+ whereClause+=";"
356
+ itemText=self.getItemText()
357
+ query.title=f"most frequently used properties for {self.item.asText(long=True)}"
358
+ query.query=query.query % (itemText,whereClause,self.lang)
346
359
  return query
347
360
 
348
361
  def noneTabularQuery(self,wdProperty:WikidataProperty,asFrequency:bool=True):
@@ -384,7 +397,9 @@ ORDER BY DESC (?frequency)"""
384
397
  sparql=f"""{sparql}
385
398
  HAVING (COUNT (?value) > 1)
386
399
  ORDER BY DESC(?count)"""
387
- query=Query(query=sparql,name=f"NonTabular {self.item.qlabel}/{propertyLabel}:{freqDesc}",title=f"non tabular entries for {self.item.qlabel}/{propertyLabel}:{freqDesc}")
400
+ title=f"non tabular entries for {self.item.qlabel}/{propertyLabel}:{freqDesc}"
401
+ name=f"NonTabular {self.item.qlabel}/{propertyLabel}:{freqDesc}"
402
+ query=Query(query=sparql,name=name,title=title)
388
403
  return query
389
404
 
390
405
  def noneTabular(self,wdProperty:WikidataProperty):
@@ -435,7 +450,7 @@ ORDER BY DESC(?count)"""
435
450
  if count>maxCount:
436
451
  maxCount=count
437
452
  total+=f
438
- statsRow["max"]=maxCount
453
+ statsRow["maxf"]=maxCount
439
454
  if withQuery:
440
455
  statsRow["queryf"]=self.noneTabularQuery(wdProperty).query
441
456
  statsRow["queryex"]=self.noneTabularQuery(wdProperty,asFrequency=False).query
@@ -9,7 +9,7 @@ class Version(object):
9
9
  Version handling for pyLoDStorage
10
10
  '''
11
11
  name="pylodstorage"
12
- version='0.2.9'
12
+ version='0.2.10'
13
13
  date = '2020-09-10'
14
- updated = '2022-07-23'
14
+ updated = '2022-07-26'
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.2.9
3
+ Version: 0.2.10
4
4
  Summary: python List of Dict (Table) Storage library
5
5
  Home-page: https://github.com/WolfgangFahl/pyLodStorage
6
6
  Author: Wolfgang Fahl
File without changes
File without changes
File without changes
File without changes