def folder_source_clean_path(folder_source): if folder_source.path is not None: path = Path(folder_source.path) if not path.exists(): raise ValidationError({ "path": "The folder does not exist." }) elif path.islink(): raise ValidationError({ "path": "Symbolic links not allowed." }) elif not path.isdir(): raise ValidationError({ "path": "Not a folder." })
def file_source_clean_path(file_source): if file_source.path is not None: path = Path(file_source.path) if not path.exists(): raise ValidationError({ "path": "The file does not exist." }) elif path.islink(): raise ValidationError({ "path": "Symbolic links not allowed." }) elif not path.isfile(): raise ValidationError({ "path": "Not a file." }) elif not is_valid_file(path): raise ValidationError({ "path": "Not a valid file." })