From ce1aec4fbe7c71a83cb2520fa87f4126ad9757fc Mon Sep 17 00:00:00 2001 From: Joshua Westgard Date: Fri, 16 Dec 2016 09:06:40 -0500 Subject: [PATCH] fixes issue where config.ext was not set (FCREPO-2347) (#13) * add extension mapping based on rdflang * delete print used for debugging * fixed wording of error messages --- verify.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/verify.py b/verify.py index ca8b524..d04b448 100755 --- a/verify.py +++ b/verify.py @@ -22,6 +22,16 @@ except ImportError: from yaml import Loader, Dumper +EXT_MAP = {'application/ld+json': '.json', + 'application/n-triples': '.nt', + 'application/rdf+xml': '.xml', + 'text/n3': '.n3', + 'text/rdf+n3': '.n3', + 'text/plain': '.txt', + 'text/turtle': '.ttl', + 'application/x-turtle': '.ttl' + } + #============================================================================ # HELPER FUNCTIONS #============================================================================ @@ -108,10 +118,20 @@ def __init__(self, configfile, auth, logger): elif key == "rdfLang": self.lang = value - # if not specified in config, set default ext & lang to turtle + # if lang not specified in config, set the ext & lang to turtle if not hasattr(self, 'lang'): self.ext = '.ttl' self.lang = 'text/turtle' + # set the ext based on the rdfLang + else: + if self.lang in EXT_MAP: + self.ext = EXT_MAP[self.lang] + else: + logger.error( + 'Unrecognized RDF serialization specified in config file!' + ) + print('Unrecognized RDF serialization specified in config file!') + sys.exit(1) # split the repository URI into base and path components self.repopath = urlparse(self.repo).path