def open_file(path: Union[str, IO], mode='rb'): if isinstance(path, str): file = open(path, mode) else: file = path return file