Skip to content

Commit

Permalink
fixes for nonns in harddisk export
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Sep 14, 2024
1 parent a9e39e8 commit 0697004
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion util/doc/ontdocgeneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,8 @@ def getSubjectPagesForNonGraphURIs(self,uristorender,graph,prefixnamespace,corpu
labeltouri[label] = prefixnamespace + "nonns_" + DocUtils.shortenURI(uri) + ".html"
if counter%10==0:
self.updateProgressBar(counter,nonnsuris,"NonNS URIs")
#QgsMessageLog.logMessage("NonNS Counter " +str(counter)+"/"+str(nonnsuris)+" "+ str(uri), "OntdocGeneration", Qgis.Info)
QgsMessageLog.logMessage("NonNS Counter " +str(counter)+"/"+str(nonnsuris)+" "+ str(uri), "OntdocGeneration", Qgis.Info)
QgsMessageLog.logMessage("NonNS Outpath " +outpath+"nonns_"+DocUtils.shortenURI(uri)+".html", "OntdocGeneration", Qgis.Info)
self.htmlexporter.createHTML(outpath+"nonns_"+DocUtils.shortenURI(uri)+".html", None, URIRef(uri), baseurl, graph.subject_predicates(URIRef(uri),True), graph, str(corpusid) + "_search.js", str(corpusid) + "_classtree.js", None, self.pubconfig["license"], None, Graph(),uristorender,True,label)
counter+=1

Expand Down
12 changes: 11 additions & 1 deletion util/export/data/htmlexporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from ..pages.bibpage import BibPage
from ..pages.owltimepage import OWLTimePage
from rdflib import URIRef, Graph, BNode, Literal
from qgis.core import Qgis, QgsMessageLog
import re
import os
import json
Expand Down Expand Up @@ -320,7 +321,13 @@ def createHTML(self, savepath, predobjs, subject, baseurl, subpreds, graph, sear
URIRef("https://www.iana.org/assignments/media-types/text/turtle#Resource")))
nonnslink = ""
if nonns:
completesavepath=savepath[0:savepath.find("http:")-1]+savepath[savepath.find("http:"):0].replace(":","_").replace("/","_")
QgsMessageLog.logMessage("NonNS Savepath HTMLEx Prev " +savepath, "OntdocGeneration", Qgis.Info)
if "http:" in savepath:
completesavepath = savepath[0:savepath.find("http:") - 1] + savepath[savepath.find("http:"):0].replace(
":", "_").replace("/", "_")
else:
completesavepath = savepath[0:savepath.rfind("/")+1]+savepath[savepath.rfind("/")+1:].replace(":", "_").replace("/", "_")
QgsMessageLog.logMessage("NonNS Savepath HTMLEx Post " +completesavepath, "OntdocGeneration", Qgis.Info)
nonnslink = "<div>This page describes linked instances to the concept <a target=\"_blank\" href=\"" + str(
subject) + "\">" + str(foundlabel) + " (" + str(DocUtils.shortenURI(
subject)) + ") </a> in this knowledge graph. It is defined <a target=\"_blank\" href=\"" + str(
Expand All @@ -339,6 +346,9 @@ def createHTML(self, savepath, predobjs, subject, baseurl, subpreds, graph, sear
except Exception as e:
print(e)
print(traceback.format_exc())
else:
if os.path.exists(completesavepath):
return
with open(completesavepath, 'w', encoding='utf-8') as f:
searchfilelink = DocUtils.generateRelativeLinkFromGivenDepth(baseurl, checkdepth, searchfilename, False)
classtreelink = DocUtils.generateRelativeLinkFromGivenDepth(baseurl, checkdepth, classtreename, False)
Expand Down

0 comments on commit 0697004

Please sign in to comment.