From 4e3145e787479af5007ddf7ddaa91b3f9c54f0cb Mon Sep 17 00:00:00 2001 From: fspreck <f.spreckelsen@indiscale.com> Date: Mon, 11 Oct 2021 13:59:39 +0200 Subject: [PATCH] DOC: Add docstring to enum_converter --- src/caosadvancedtools/table_importer.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/caosadvancedtools/table_importer.py b/src/caosadvancedtools/table_importer.py index 54fb61bb..15fb89af 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() -- GitLab