Skip to content

Commit f8297cc

Browse files
author
Peter Amstutz
committed
Cache external schemas after being loaded 1st time (doesn't cache to disk, though.)
1 parent 2300cb0 commit f8297cc

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

schema_salad/ref_resolver.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,14 @@ def add_schemas(self, ns, base_url):
168168
for sch in aslist(ns):
169169
for fmt in ['xml', 'turtle', 'rdfa']:
170170
try:
171-
self.graph.parse(urlparse.urljoin(base_url, sch),
172-
format=fmt)
171+
fetchurl = urlparse.urljoin(base_url, sch)
172+
if fetchurl not in self.cache:
173+
_logger.info("Getting external schema %s", fetchurl)
174+
cachekey = hashlib.md5(fetchurl).hexdigest()
175+
if os.path.join(os.environ["HOME"], ".settings
176+
self.cache[fetchurl] = rdflib.graph.Graph()
177+
self.cache[fetchurl].parse(fetchurl, format=fmt)
178+
self.graph += self.cache[fetchurl]
173179
break
174180
except xml.sax.SAXParseException: # type: ignore
175181
pass

0 commit comments

Comments
 (0)