From eac1672fee6df7f7139e1703658abc421ab43594 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 12 Sep 2021 11:47:20 +0100 Subject: [PATCH] Getting dfc ontologies --- daemon.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/daemon.py b/daemon.py index eac622b3a..e81b344ea 100644 --- a/daemon.py +++ b/daemon.py @@ -6480,6 +6480,28 @@ class PubServer(BaseHTTPRequestHandler): return self._404() + def _getOntology(self, callingDomain: str, + path: str, baseDir: str, + GETstartTime, GETtimings: {}) -> None: + """Returns an ontology file + """ + if '.owl' in path or '.rdf' in path: + ontologyStr = path.split('/ontologies/')[1].replace('#', '') + ontologyFilename = baseDir + '/ontology/DFC/' + ontologyStr + if os.path.isfile(ontologyFilename): + ontologyFile = None + with open(ontologyFilename, 'r') as fp: + ontologyFile = fp.read() + if ontologyFile: + msg = ontologyFile.encode('utf-8') + self._set_headers('application/rdf+xml', len(msg), + None, callingDomain, False) + self._benchmarkGETtimings(GETstartTime, GETtimings, + 'show emoji done', + 'get onotology') + return + self._404() + def _showEmoji(self, callingDomain: str, path: str, baseDir: str, GETstartTime, GETtimings: {}) -> None: @@ -12929,6 +12951,12 @@ class PubServer(BaseHTTPRequestHandler): GETstartTime, GETtimings) return + if '/ontologies/' in self.path: + self._getOntology(callingDomain, + self.path, self.server.baseDir, + GETstartTime, GETtimings) + return + self._benchmarkGETtimings(GETstartTime, GETtimings, 'show emoji done', 'show media done')