Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Feb 6, 2025
1 parent 3845d6e commit 62c875c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion tasks/processing/loadgraphtask.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ def run(self):
path = os.path.join(__location__, "../../tmp/graphcache/" + str(
str(self.filenames).replace("/", "_").replace("['", "").replace("']", "").replace(
"\\", "_").replace(":", "_")) + ".ttl")
self.graph = Graph()
if isinstance(self.filenames,str):
if os.path.isfile(path):
self.graph.parse(path)
else:
self.graph=SPARQLUtils.loadGraph(self.filenames)
self.graph.serialize(path, format="ttl")
else:
self.graph=Graph()
for file in self.filenames:
SPARQLUtils.loadGraph(file,self.graph)
self.graph.serialize(path,format="ttl")
Expand Down
2 changes: 1 addition & 1 deletion util/graphutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def testTripleStoreConnection(self, triplestoreurl, query="SELECT ?a ?b ?c WHERE
return results

def detectPropertiesByName(self,triplestoreurl, query="SELECT ?a ?b ?c WHERE { ?a ?b ?c .} LIMIT 1",credentialUserName=None,credentialPassword=None,authmethod=None):
query="SELECT DISTINCT ?prop ?propLabel WHERE {?a ?prop ?b .{ ?ab wikibase:directClaim ?prop . ?ab rdfs:label ?propLabel .}UNION {?prop rdfs:label ?propLabel .} FILTER(lang(?propLabel)=\"en\"))}"
query="SELECT DISTINCT ?prop ?propLabel WHERE {?a ?prop ?b .{ ?ab <http://wikiba.se/ontology#directClaim> ?prop . ?ab <http://www.w3.org/2000/01/rdf-schema#label> ?propLabel .}UNION {?prop <<http://www.w3.org/2000/01/rdf-schema#label> ?propLabel .} FILTER(lang(?propLabel)=\"en\"))}"
results = SPARQLUtils.executeQuery(triplestoreurl, query, {"auth": {"method": authmethod, "userCredential": credentialUserName, "userPassword": credentialPassword}})


Expand Down
3 changes: 2 additions & 1 deletion util/sparqlutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ def loadAdditionalGraphResources(existinggraph,graphuri):

@staticmethod
def loadGraph(graphuri,graph=None):
QgsMessageLog.logMessage('GraphURI: ' + str(graphuri), MESSAGE_CATEGORY, Qgis.Info)
if graphuri is None or graphuri=="":
return None
s = QSettings() # getting proxy from qgis options settings
Expand All @@ -329,7 +330,7 @@ def loadGraph(graphuri,graph=None):
proxy = urllib.request.ProxyHandler({'http': proxyHost})
opener = urllib.request.build_opener(proxy)
urllib.request.install_opener(opener)
#QgsMessageLog.logMessage('Started task "{}"'.format("Load Graph"), MESSAGE_CATEGORY, Qgis.Info)
QgsMessageLog.logMessage('Started task "{}"'.format("Load Graph"), MESSAGE_CATEGORY, Qgis.Info)
if graph is None:
graph = Graph()
try:
Expand Down

0 comments on commit 62c875c

Please sign in to comment.