Create a sourcesdata hash for each flavor of hosts file generated.
authorSteven Black <redacted>
Sun, 11 Dec 2016 17:22:51 +0000 (12:22 -0500)
committerSteven Black <redacted>
Sun, 11 Dec 2016 17:22:51 +0000 (12:22 -0500)
updateHostsFile.py

index 8787411a2f503d242641f33c7e65b191b5368271..b195b20cf5192465bd23c8b7472dbc055255e46d 100644 (file)
@@ -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)
git clone https://git.99rst.org/PROJECT