Skip to content

Instantly share code, notes, and snippets.

@tshauck
Last active November 1, 2015 23:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tshauck/6ebb0c2d6adc667608b8 to your computer and use it in GitHub Desktop.
Save tshauck/6ebb0c2d6adc667608b8 to your computer and use it in GitHub Desktop.
python case
def linkbase_type(filepath):
"""Get the type of linkbase from the filename."""
cases = (
(filepath.endswith("_cal.xml"), "calculation"),
(filepath.endswith('_def.xml'), "definition"),
(filepath.endswith('_lab.xml'), "label"),
(filepath.endswith('_pre.xml'), "presentation"),
(filepath.endswith('.xsd'), "reference"),
(filepath.endswith('.xml'), "filing"),
(True, "unknown_linkbase")
)
return next(value for case, value in cases if case)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment