mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-07-01 02:36:52 +00:00
Create a sourcesdata hash for each flavor of hosts file generated.
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user