def from_test_repr(file_test_repr, base_path=None): assert is_arrayish(file_test_repr) assert len(file_test_repr) >= 2 file_type, old_path, *remainder = file_test_repr old_file_ref = FileReference( BAONPath.from_test_repr(base_path, old_path), file_type == 'DIR', ) new_path = old_path override = False if len(remainder) > 0 and remainder[-1] == 'OVERRIDE': remainder = remainder[:-1] override = True if len(remainder) > 0 and not is_arrayish(remainder[0]): new_path, *remainder = remainder return RenamedFileReference( old_file_ref, BAONPath.from_test_repr(base_path, new_path), [BAONError.from_test_repr(error_repr) for error_repr in remainder], override, )
def from_test_repr(file_test_repr, base_path=None): assert is_arrayish(file_test_repr) assert len(file_test_repr) >= 2 file_type, path, *errors = file_test_repr assert file_type in ['FILE', 'DIR'] file_ref = FileReference( BAONPath.from_test_repr(base_path, path), file_type == 'DIR', problems=[BAONError.from_test_repr(error_repr) for error_repr in errors], ) return file_ref