Getting dfc ontologies

main
Bob Mottram 2021-09-12 11:47:20 +01:00
parent 330e72bc2a
commit eac1672fee
1 changed files with 28 additions and 0 deletions

View File

@ -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')