Skip to content

Instantly share code, notes, and snippets.

@barrucadu
Last active March 2, 2019 15:36
Show Gist options
  • Select an option

  • Save barrucadu/4185c88abf20cdf3bd2c232299574af7 to your computer and use it in GitHub Desktop.

Select an option

Save barrucadu/4185c88abf20cdf3bd2c232299574af7 to your computer and use it in GitHub Desktop.
if 'document_type' not in raw:
raise NoDocumentType()
document_type = raw['document_type']
document_type_parser = f'parse_type_{document_type}'
if document_type_parser not in globals():
raise UnknownDocumentType(document_type)
return globals()[document_type_parser](raw)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment