From 4dd12055af3a8161ac1a44b0d36d4d2c00b9b725 Mon Sep 17 00:00:00 2001 From: Timo Date: Wed, 17 Apr 2024 14:11:12 +0200 Subject: [PATCH] fixes --- util/doc/templateutils.py | 14 +++++++++----- util/export/pages/owltimepage.py | 29 +++++++++++++++-------------- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/util/doc/templateutils.py b/util/doc/templateutils.py index 28ea61ef..ada1768a 100644 --- a/util/doc/templateutils.py +++ b/util/doc/templateutils.py @@ -2,14 +2,17 @@ import os import re from .docdefaults import DocDefaults +from qgis.core import Qgis, QgsMessageLog + -includepattern=r'{%\s*include\s*(.*)\s*%}' class TemplateUtils: + includepattern = r'{%\s*include\s*(.*)\s*%}' + @staticmethod def resolveIncludes(template,templates): - matches=re.findall(includepattern,template) + matches=re.findall(TemplateUtils.includepattern,template) if len(matches)>0: for mat in matches: if mat.replace(".html","") in templates: @@ -19,6 +22,9 @@ def resolveIncludes(template,templates): @staticmethod def resolveTemplate(templatename,templatepath): templates=DocDefaults.templates + templates["includes"] = {} + templates["js"] = {} + templates["layouts"] = {} print(templatepath+"/"+templatename+" "+str(os.path.exists(templatepath+"/"+templatename+"/templates/"))) print(templatepath + "/" + templatename + " " + str( os.path.exists(templatepath + "/" + templatename))) @@ -35,8 +41,6 @@ def resolveTemplate(templatename,templatepath): templates[file] = f.read() elif os.path.exists(templatepath+"/"+templatename+"/templates/"): if os.path.exists(templatepath+"/"+templatename+"/templates/layouts/") and os.path.exists(templatepath+"/"+templatename+"/templates/includes/"): - templates["includes"]={} - templates["layouts"] = {} for filename in os.listdir(templatepath+"/"+templatename+"/templates/includes/"): print("FOUND INCLUDE: "+str(filename)) if filename.endswith(".html") or filename.endswith(".css"): @@ -81,6 +85,6 @@ def resolveTemplate(templatename,templatepath): templates[filename.replace(".css", "")] = content print("Found templates.... "+str(len(templates))) for temp in templates: - if temp!="includes" and temp!="layouts": + if temp!="includes" and temp!="layouts" and temp!="js" and templates[temp] is not None: templates[temp]=TemplateUtils.resolveIncludes(templates[temp],templates) return templates \ No newline at end of file diff --git a/util/export/pages/owltimepage.py b/util/export/pages/owltimepage.py index 0e891664..99e63400 100644 --- a/util/export/pages/owltimepage.py +++ b/util/export/pages/owltimepage.py @@ -1,5 +1,6 @@ from ...doc.docconfig import DocConfig from ...doc.docutils import DocUtils +from ...sparqlutils import SPARQLUtils from rdflib import URIRef, Literal class OWLTimePage: @@ -8,17 +9,17 @@ class OWLTimePage: def resolveTimeObject(pred, obj, graph, timeobj): if str(pred) == "http://www.w3.org/2006/time#hasBeginning": for tobj2 in graph.predicate_objects(obj): - if str(tobj2[0]) in DocConfig.timeproperties: + if str(tobj2[0]) in SPARQLUtils.timeproperties: timeobj["begin"] = tobj2[1] elif str(pred) == "http://www.w3.org/2006/time#hasEnd": for tobj2 in graph.predicate_objects(obj): - if str(tobj2[0]) in DocConfig.timeproperties: + if str(tobj2[0]) in SPARQLUtils.timeproperties: timeobj["end"] = tobj2[1] elif str(pred) == "http://www.w3.org/2006/time#hasTime" or str( pred) == "http://www.w3.org/ns/sosa/phenomenonTime" or str( pred) == "http://www.w3.org/ns/sosa/resultTime": for tobj2 in graph.predicate_objects(obj): - if str(tobj2[0]) in DocConfig.timeproperties: + if str(tobj2[0]) in SPARQLUtils.timeproperties: timeobj["timepoint"] = tobj2[1] return timeobj @@ -27,28 +28,28 @@ def timeObjectToHTML(timeobj,prefixes): timeres = None if "begin" in timeobj and "end" in timeobj: timeres = str(timeobj["begin"]) + " " - if str(timeobj["begin"].datatype) in DocConfig.timeliteraltypes: + if str(timeobj["begin"].datatype) in SPARQLUtils.timeliteraltypes: timeres += DocUtils.createURILink(prefixes, - DocConfig.timeliteraltypes[str(timeobj["begin"].datatype)]) + SPARQLUtils.timeliteraltypes[str(timeobj["begin"].datatype)]) timeres += " - " + str(timeobj["end"]) - if str(timeobj["end"].datatype) in DocConfig.timeliteraltypes: + if str(timeobj["end"].datatype) in SPARQLUtils.timeliteraltypes: timeres += DocUtils.createURILink(prefixes, - DocConfig.timeliteraltypes[str(timeobj["end"].datatype)]) + SPARQLUtils.timeliteraltypes[str(timeobj["end"].datatype)]) elif "begin" in timeobj and not "end" in timeobj: timeres = str(timeobj["begin"]) - if str(timeobj["begin"].datatype) in DocConfig.timeliteraltypes: + if str(timeobj["begin"].datatype) in SPARQLUtils.timeliteraltypes: timeres += DocUtils.createURILink(prefixes, - DocConfig.timeliteraltypes[str(timeobj["begin"].datatype)]) + SPARQLUtils.timeliteraltypes[str(timeobj["begin"].datatype)]) elif "begin" not in timeobj and "end" in timeobj: timeres = str(timeobj["end"]) - if str(timeobj["end"].datatype) in DocConfig.timeliteraltypes: + if str(timeobj["end"].datatype) in SPARQLUtils.timeliteraltypes: timeres += DocUtils.createURILink(prefixes, - DocConfig.timeliteraltypes[str(timeobj["end"].datatype)]) + SPARQLUtils.timeliteraltypes[str(timeobj["end"].datatype)]) elif "timepoint" in timeobj: timeres = timeobj["timepoint"] - if str(timeobj["timepoint"].datatype) in DocConfig.timeliteraltypes: + if str(timeobj["timepoint"].datatype) in SPARQLUtils.timeliteraltypes: timeres += DocUtils.createURILink(prefixes, - DocConfig.timeliteraltypes[str(timeobj["timepoint"].datatype)]) + SPARQLUtils.timeliteraltypes[str(timeobj["timepoint"].datatype)]) return timeres @staticmethod @@ -59,7 +60,7 @@ def resolveTimeLiterals(pred, obj, graph): pred) == "http://www.w3.org/ns/sosa/resultTime"): for tobj in graph.predicate_objects(obj): timeobj = OWLTimePage.resolveTimeObject(tobj[0], tobj[1], graph, timeobj) - elif isinstance(obj, URIRef) and str(pred) in DocConfig.timepointerproperties: + elif isinstance(obj, URIRef) and str(pred) in SPARQLUtils.timepointerproperties: timeobj = OWLTimePage.resolveTimeObject(pred, obj, graph, timeobj) elif isinstance(obj, Literal): timeobj = OWLTimePage.resolveTimeObject(pred, obj, graph, timeobj)