diff --git a/src/caosadvancedtools/table_importer.py b/src/caosadvancedtools/table_importer.py index 54fb61bb05da0aeebf5a1da5ff46a9443e59112d..15fb89af503e108aed2343e3d50838b797e31369 100755 --- a/src/caosadvancedtools/table_importer.py +++ b/src/caosadvancedtools/table_importer.py @@ -146,6 +146,29 @@ def win_path_converter(val): def enum_converter(val, options, ignore_case=True): + """Return the given value if it is contained in options, raise an + error otherwise. + + Parameters + ---------- + val : str + String value to be checked. + options : list<str> + List of possible values that val may obtain + ignore_case : bool, optional + Specify whether the comparison of val and the possible options + should ignor capitalization. Default is True. + + Returns + ------- + val : str + The original value if it is contained in options + + Raises + ------ + ValueError + If val is not contained in options. + """ if ignore_case: val = val.lower() options = [o.lower() for o in options] @@ -158,6 +181,7 @@ def enum_converter(val, options, ignore_case=True): return val + class TSVImporter(object): def __init__(self, converters, obligatory_columns=[], unique_columns=[]): raise NotImplementedError()