Check for release key in minetestcheck

This commit is contained in:
rubenwardy 2021-01-16 18:19:51 +00:00
parent 07d7282383
commit 05a08b4c05

@ -64,37 +64,39 @@ class PackageTreeNode:
self.add_children_from_mod_dir(None) self.add_children_from_mod_dir(None)
def getMetaFilePath(self): def getMetaFileName(self):
filename = None
if self.type == ContentType.GAME: if self.type == ContentType.GAME:
filename = "game.conf" return "game.conf"
elif self.type == ContentType.MOD: elif self.type == ContentType.MOD:
filename = "mod.conf" return "mod.conf"
elif self.type == ContentType.MODPACK: elif self.type == ContentType.MODPACK:
filename = "modpack.conf" return "modpack.conf"
elif self.type == ContentType.TXP: elif self.type == ContentType.TXP:
filename = "texture_pack.conf" return "texture_pack.conf"
else: else:
return None return None
return self.baseDir + "/" + filename
def read_meta(self): def read_meta(self):
result = {} result = {}
# .conf file # .conf file
meta_file_path = self.getMetaFilePath() meta_file_name = self.getMetaFileName()
meta_file_rel = self.relative + meta_file_name
meta_file_path = self.baseDir + "/" + meta_file_name
try: try:
with open(meta_file_path or "", "r") as myfile: with open(meta_file_path or "", "r") as myfile:
conf = parse_conf(myfile.read()) conf = parse_conf(myfile.read())
for key, value in conf.items(): for key, value in conf.items():
result[key] = value result[key] = value
except SyntaxError as e: except SyntaxError as e:
raise MinetestCheckError("Error while reading {}: {}".format(meta_file_path , e.msg)) raise MinetestCheckError("Error while reading {}: {}".format(meta_file_rel , e.msg))
except IOError: except IOError:
pass pass
if "release" in result:
raise MinetestCheckError("{} should not contain 'release' key, as this is for use by ContentDB only.".format(meta_file_rel))
# description.txt # description.txt
if not "description" in result: if not "description" in result:
try: try: