def make_file_extension_assertion(extension):
    """Function factory for file extension argparse assertion
        Args:
            extension (string): the file extension to assert

        Returns:
            string: the supplied extension, if assertion is successful.

    """
    def file_extension_assertion(file_path):
        base, ext = os.path.splitext(file_path)
        if ext.lower() != extension:
            raise argparse.ArgumentTypeError('File must have ' + extension + ' extension')
        return file_path
    return file_extension_assertion
def make_file_extension_assertion ( extension ) : def file_extension_assertion ( file_path ) : base , ext = os . path . splitext ( file_path ) if ext . lower ( ) != extension : raise argparse . ArgumentTypeError ( 'File must have ' + extension + ' extension' ) return file_path return file_extension_assertion
Function factory for file extension argparse assertion
        Args:
            extension (string): the file extension to assert

        Returns:
            string: the supplied extension, if assertion is successful.