Add optionals support to extract dependencies tool, Add more checks if folders are present (#4394)

This commit is contained in:
jonpas 2016-09-17 11:40:50 +02:00 committed by Glowbal
parent 87b3308b0f
commit fda10f0e7b

View File

@ -30,10 +30,12 @@ def main():
script_path = os.path.realpath(__file__) script_path = os.path.realpath(__file__)
project_path = os.path.dirname(os.path.dirname(script_path)) project_path = os.path.dirname(os.path.dirname(script_path))
addons_path = os.path.join(project_path, "addons") addons_path = os.path.join(project_path, "addons")
optionals_path = os.path.join(project_path, "optionals")
if "--acex" in sys.argv: if "--acex" in sys.argv:
projectx_path = sys.argv[sys.argv.index("--acex") + 1] projectx_path = sys.argv[sys.argv.index("--acex") + 1]
addonsx_path = os.path.join(projectx_path, "addons") addonsx_path = os.path.join(projectx_path, "addons")
optionalsx_path = os.path.join(projectx_path, "optionals")
# Documentation paths # Documentation paths
include_path = os.path.join(project_path, "docs", "_includes") include_path = os.path.join(project_path, "docs", "_includes")
@ -47,14 +49,20 @@ def main():
sys.exit(0) sys.exit(0)
open(dependencies_path, "w", newline="\n").close() open(dependencies_path, "w", newline="\n").close()
if os.path.exists(addons_path):
addons = next(os.walk(addons_path))[1] addons = next(os.walk(addons_path))[1]
if os.path.exists(optionals_path):
addons += ["."] + next(os.walk(optionals_path))[1]
dependencies_path_current = dependencies_path dependencies_path_current = dependencies_path
addons_path_current = addons_path addons_path_current = addons_path
if "--acex" in sys.argv: if "--acex" in sys.argv:
open(dependenciesx_path, "w", newline="\n").close() open(dependenciesx_path, "w", newline="\n").close()
addons.append(".") if os.path.exists(addonsx_path):
addons += next(os.walk(addonsx_path))[1] addons += [".."] + next(os.walk(addonsx_path))[1]
if os.path.exists(optionalsx_path):
addons += ["."] + next(os.walk(optionalsx_path))[1]
# Iterate through folders in the addons directories # Iterate through folders in the addons directories
for folder in addons: for folder in addons:
@ -62,8 +70,16 @@ def main():
if folder == "main": if folder == "main":
continue continue
# Change to ACEX list on "." separator # Change to optionals list on "." separator
if folder == ".": if folder == ".":
if addons_path_current == addons_path:
addons_path_current = optionals_path
else:
addons_path_current = optionalsx_path
continue
# Change to ACEX list on ".." separator
if folder == "..":
dependencies_path_current = dependenciesx_path dependencies_path_current = dependenciesx_path
addons_path_current = addonsx_path addons_path_current = addonsx_path
continue continue