Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
situx committed Apr 17, 2024
1 parent 84af14b commit 4dd1205
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
14 changes: 9 additions & 5 deletions util/doc/templateutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)))
Expand All @@ -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"):
Expand Down Expand Up @@ -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
29 changes: 15 additions & 14 deletions util/export/pages/owltimepage.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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

Expand All @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 4dd1205

Please sign in to comment.