From: Steven Black Date: Sun, 11 Dec 2016 17:22:51 +0000 (-0500) Subject: Create a sourcesdata hash for each flavor of hosts file generated. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=e22e3dc594ced1d8e1cc95907ad37fea96627737;p=stevenblack-hosts.git Create a sourcesdata hash for each flavor of hosts file generated. --- diff --git a/updateHostsFile.py b/updateHostsFile.py index 8787411a2..b195b20cf 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -88,7 +88,7 @@ defaults = { "targetip" : "0.0.0.0", "ziphosts" : False, "sourcedatafilename" : "update.json", - "sourcedata" : [], + "sourcesdata": [], "readmefilename" : "readme.md", "readmetemplate" : os.path.join(BASEDIR_PATH, "readme_template.md"), "readmedata" : {}, @@ -266,7 +266,6 @@ def getUpdateURLsFromFile(source): if os.path.exists(pathToUpdateFile): updateFile = open(pathToUpdateFile, "r") updateData = json.load(updateFile) - settings["sourcedata"].append(updateData) retURLs = [updateData["url"]] updateFile.close() else: @@ -279,6 +278,7 @@ def getUpdateURLsFromFile(source): # File Logic def createInitialFile(): mergeFile = tempfile.NamedTemporaryFile() + # spin the sources for the base file for source in settings["sources"]: filename = os.path.join(settings["datapath"], source, settings["datafilenames"]) @@ -286,6 +286,13 @@ def createInitialFile(): #Done in a cross-python way writeData(mergeFile, curFile.read()) + pathToUpdateFile = os.path.join(settings["datapath"], source, settings["sourcedatafilename"]) + if os.path.exists(pathToUpdateFile): + updateFile = open(pathToUpdateFile, "r") + updateData = json.load(updateFile) + settings["sourcesdata"].append(updateData) + updateFile.close() + # spin the sources for extensions to the base file for source in settings["extensions"]: filename = os.path.join(settings["extensionspath"], source, settings["datafilenames"]) @@ -293,6 +300,13 @@ def createInitialFile(): #Done in a cross-python way writeData(mergeFile, curFile.read()) + pathToUpdateFile = os.path.join(settings["datapath"], source, settings["sourcedatafilename"]) + if os.path.exists(pathToUpdateFile): + updateFile = open(pathToUpdateFile, "r") + updateData = json.load(updateFile) + settings["sourcesdata"].append(updateData) + updateFile.close() + if os.path.isfile(settings["blacklistfile"]): with open(settings["blacklistfile"], "r") as curFile: #Done in a cross-python way @@ -421,7 +435,7 @@ def updateReadmeData(): generationData = {"location": os.path.join(settings["outputsubfolder"], ""), "entries": settings["numberofrules"], - "sourcedata": settings["sourcedata"]} + "sourcesdata": settings["sourcesdata"]} settings["readmedata"][extensionsKey] = generationData with open(settings["readmedatafilename"], "w") as f: json.dump(settings["readmedata"], f)