Last active
November 1, 2015 23:36
-
-
Save tshauck/6ebb0c2d6adc667608b8 to your computer and use it in GitHub Desktop.
python case
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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