Skip to content

Commit

Permalink
fixes issue where config.ext was not set (FCREPO-2347) (#13)
Browse files Browse the repository at this point in the history
* add extension mapping based on rdflang

* delete print used for debugging

* fixed wording of error messages
  • Loading branch information
jwestgard authored and ruebot committed Dec 16, 2016
1 parent 53ab9e1 commit ce1aec4
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
#============================================================================
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit ce1aec4

Please sign in to comment.