INNER CODE UNIT · Python

file_ext

linnabrown/run_dbcan · dbcan/cli/cgc_process_json.py:166

def file_ext(choices, fname, parser):
    """
    Validates the extension of a given file name against allowed choices.

    This function checks if the file extension of `fname` is among the specified `choices`. If not, it raises an error through the provided `parser`.

    Parameters
    ----------
        choices (tuple): A tuple of allowed file extensions (without the dot).
        fname (str): The file name to be checked.
        parser (argparse.ArgumentParser): The argument parser to use for raising an error if the extension is not allowed.

    Returns
    -------
        str: The validated file name if its extension is in `choices`.

    Raises
    ------

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…