#!/usr/bin/python3 import argparse from pathlib import Path, PurePath import re DLL_EXCLUSIONS_REGEX = r"(System|Microsoft|Mono|IronPython|DiscordRPC)\." def getAssemblyReferences(path): asmDir = Path(path) result = list() for child in asmDir.iterdir(): if child.is_file() and re.search(DLL_EXCLUSIONS_REGEX, str(child), re.I) is None and str(child).lower().endswith(".dll"): result.append(str(child).replace("\\", "/")) return result def buildReferencesXml(path): assemblyPathes = getAssemblyReferences(path) result = list() for asm in assemblyPathes: asmPath = str(asm) xml = " \n" \ + " " + asmPath.replace("/", "\\") + "\n" \ + " ..\\" + asmPath.replace("/", "\\") + "\n" \ + " \n" result.append(xml) return "\n \n" + "".join(result) + " \n" if __name__ == "__main__": parser = argparse.ArgumentParser(description="Generate GamecraftModdingAPI.csproj") # TODO (maybe?): add params for custom csproj read and write locations args = parser.parse_args() print("Building Assembly references") asmXml = buildReferencesXml("../ref/Gamecraft_Data/Managed") # print(asmXml) with open("../GamecraftModdingAPI/GamecraftModdingAPI.csproj", "r") as xmlFile: print("Parsing GamecraftModdingAPI.csproj") fileStr = xmlFile.read() # print(fileStr) depsStart = re.search(r"\