import os import re EMPTY_ANNOTATION_FILE = ('' '') def sanitize_identifier(identifier, replacement='-'): return re.sub(r'[^\w-]', replacement, identifier) def check_is_file_empty(filepath): """ Check whether file is empty or not. :param filepath: Path of a file that will be checked. :return: True if the file empty. """ if os.path.exists(filepath): return os.stat(filepath).st_size == 0 else: raise FileNotFoundError("Path '%s' doesn't exist" % filepath)