Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def source2source(req, source):
"""Harmonize the different Source implementations in clld and pycldf."""
bibrecord = source.bibtex()
fields = OrderedDict({'%s_url' % req.dataset.id: req.resource_url(source)})
for key, value in bibrecord.items():
fields[key] = '; '.join(value) if isinstance(value, list) else value
return sources.Source(
getattr(bibrecord.genre, 'value', bibrecord.genre) if bibrecord.genre else 'misc',
source.id,
**fields)