pyLodStorage 0.2.8__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.8 → pylodstorage-0.2.10}/PKG-INFO +1 -1
  2. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/sparql.py +5 -2
  3. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/trulytabular.py +33 -13
  4. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/version.py +2 -2
  5. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/pylodstorage.egg-info/PKG-INFO +1 -1
  6. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/pylodstorage.egg-info/SOURCES.txt +1 -0
  7. pylodstorage-0.2.10/sampledata/__init__.py +0 -0
  8. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/LICENSE +0 -0
  9. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/README.md +0 -0
  10. {pylodstorage-0.2.8/sampledata → pylodstorage-0.2.10/lodstorage}/__init__.py +0 -0
  11. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/csv.py +0 -0
  12. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/entity.py +0 -0
  13. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/jsonable.py +0 -0
  14. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/jsonpicklemixin.py +0 -0
  15. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/lod.py +0 -0
  16. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/mwTable.py +0 -0
  17. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/plot.py +0 -0
  18. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/query.py +0 -0
  19. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/querymain.py +0 -0
  20. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/sample.py +0 -0
  21. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/schema.py +0 -0
  22. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/sql.py +0 -0
  23. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/storageconfig.py +0 -0
  24. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/tabulateCounter.py +0 -0
  25. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/uml.py +0 -0
  26. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/xml.py +0 -0
  27. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/lodstorage/yamlablemixin.py +0 -0
  28. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/pylodstorage.egg-info/dependency_links.txt +0 -0
  29. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/pylodstorage.egg-info/entry_points.txt +0 -0
  30. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/pylodstorage.egg-info/requires.txt +0 -0
  31. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/pylodstorage.egg-info/top_level.txt +0 -0
  32. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/sampledata/endpoints.yaml +0 -0
  33. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/sampledata/formats.yaml +0 -0
  34. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/sampledata/queries.yaml +0 -0
  35. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/sampledata/scholia.yaml +0 -0
  36. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/sampledata/trulytabular.yaml +0 -0
  37. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/sampledata/wf.yaml +0 -0
  38. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/sampledata/wikidata.yaml +0 -0
  39. {pylodstorage-0.2.8 → pylodstorage-0.2.10}/setup.cfg +0 -0
  40. {pylodstorage-0.2.8 → 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.8
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)
@@ -292,7 +297,13 @@ WHERE
292
297
  # instance of {self.item.qlabel}
293
298
  ?item wdt:P31 wd:{self.item.qid}.{self.where}
294
299
  }}"""
295
- return self.sparql.getValue(query, "count")
300
+ try:
301
+ count=self.sparql.getValue(query, "count")
302
+ except Exception as ex:
303
+ self.error=ex
304
+ count=None
305
+
306
+ return count
296
307
 
297
308
  def asText(self,long:bool=True):
298
309
  '''
@@ -307,6 +318,12 @@ WHERE
307
318
  text=self.item.asText(long)
308
319
  return text
309
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
+
310
327
  @classmethod
311
328
  def getQueryManager(cls,lang='sparql',name="trulytabular",debug=False):
312
329
  '''
@@ -335,9 +352,10 @@ WHERE
335
352
  if whereClause is None:
336
353
  whereClause=f"?item wdt:P31 wd:{self.itemQid};";
337
354
  else:
338
- whereClause+=";"
339
- query.title=f"most frequently used properties for {self.asText(long=True)}"
340
- 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)
341
359
  return query
342
360
 
343
361
  def noneTabularQuery(self,wdProperty:WikidataProperty,asFrequency:bool=True):
@@ -379,7 +397,9 @@ ORDER BY DESC (?frequency)"""
379
397
  sparql=f"""{sparql}
380
398
  HAVING (COUNT (?value) > 1)
381
399
  ORDER BY DESC(?count)"""
382
- 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)
383
403
  return query
384
404
 
385
405
  def noneTabular(self,wdProperty:WikidataProperty):
@@ -430,7 +450,7 @@ ORDER BY DESC(?count)"""
430
450
  if count>maxCount:
431
451
  maxCount=count
432
452
  total+=f
433
- statsRow["max"]=maxCount
453
+ statsRow["maxf"]=maxCount
434
454
  if withQuery:
435
455
  statsRow["queryf"]=self.noneTabularQuery(wdProperty).query
436
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.8'
12
+ version='0.2.10'
13
13
  date = '2020-09-10'
14
- updated = '2022-07-22'
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.8
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
@@ -1,6 +1,7 @@
1
1
  LICENSE
2
2
  README.md
3
3
  setup.py
4
+ lodstorage/__init__.py
4
5
  lodstorage/csv.py
5
6
  lodstorage/entity.py
6
7
  lodstorage/jsonable.py
File without changes
File without changes
File without changes
File without changes
File without changes