1234567891011121314151617181920212223 |
- import os
- import re
- EMPTY_ANNOTATION_FILE = ('<?xml version="1.0" encoding="UTF-8" ?>'
- '<document><annotations></annotations></document>')
- 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)
|