From 1e6bd7f623dead2c5bcbdb5c89a0c9e65c7a86e4 Mon Sep 17 00:00:00 2001 From: zelda2774 <69368340+zelda2774@users.noreply.github.com> Date: Tue, 29 Dec 2020 00:37:52 +0100 Subject: [PATCH] Fix multiprocessing usage for extract_assets as well (#575) Co-authored-by: zelda2774 --- extract_assets.py | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/extract_assets.py b/extract_assets.py index 398c5d0179..f234ca4a7f 100755 --- a/extract_assets.py +++ b/extract_assets.py @@ -24,19 +24,23 @@ def ExtractFunc(fullPath): else: Extract(fullPath, outPath) -xmlFiles = [] +def main(): + xmlFiles = [] -for currentPath, folders, files in os.walk("assets"): - for file in files: - fullPath = os.path.join(currentPath, file) - if file.endswith(".xml") and currentPath.startswith("assets/xml"): - outPath = ("assets/" + fullPath.split("assets/xml/")[1]).split(".xml")[0] - xmlFiles.append(fullPath) + for currentPath, folders, files in os.walk("assets"): + for file in files: + fullPath = os.path.join(currentPath, file) + if file.endswith(".xml") and currentPath.startswith("assets/xml/"): + outPath = ("assets/" + fullPath.split("assets/xml/")[1]).split(".xml")[0] + xmlFiles.append(fullPath) -numCores = cpu_count() -print("Extracting assets with " + str(numCores) + " CPU cores.") -p = Pool(numCores) -p.map(ExtractFunc, xmlFiles) + numCores = cpu_count() + print("Extracting assets with " + str(numCores) + " CPU cores.") + p = Pool(numCores) + p.map(ExtractFunc, xmlFiles) -#os.system("make resources") \ No newline at end of file + #os.system("make resources") + +if __name__ == "__main__": + main()