3 class MinetestCheckError(Exception):
4 def __init__(self, value):
7 return repr("Error validating package: " + self.value)
9 class ContentType(Enum):
17 return self == ContentType.MOD or self == ContentType.MODPACK
19 def validate_same(self, other):
21 Whether or not `other` is an acceptable type for this
25 if self == ContentType.MOD:
26 if not other.isModLike():
27 raise MinetestCheckError("Expected a mod or modpack, found " + other.value)
29 elif self == ContentType.TXP:
30 if other != ContentType.UNKNOWN and other != ContentType.TXP:
31 raise MinetestCheckError("expected a " + self.value + ", found a " + other.value)
34 raise MinetestCheckError("Expected a " + self.value + ", found a " + other.value)
37 from .tree import PackageTreeNode, get_base_dir
39 def build_tree(path, expected_type=None, author=None, repo=None, name=None):
40 path = get_base_dir(path)
42 root = PackageTreeNode(path, "/", author=author, repo=repo, name=name)
46 expected_type.validate_same(root.type)