action="store_true",
help="Skip static localhost entries " "in the final hosts file.",
)
+ parser.add_argument(
+ "--skip-readme-data-update",
+ "-d",
+ dest="skipreadmedataupdate",
+ default=False,
+ action="store_true",
+ help="Skip update of readme data",
+ )
parser.add_argument(
"--output",
"-o",
)
merge_file = create_initial_file()
- remove_old_hosts_file(settings["backup"])
+ remove_old_hosts_file(
+ path_join_robust(settings["outputpath"], "hosts"),
+ settings["backup"])
if settings["compress"]:
final_file = open(path_join_robust(settings["outputpath"], "hosts"), "w+b")
compressed_file = tempfile.NamedTemporaryFile()
)
final_file.close()
- update_readme_data(
- settings["readmedatafilename"],
- extensions=extensions,
- numberofrules=number_of_rules,
- outputsubfolder=output_subfolder,
- sourcesdata=sources_data,
- )
+ if not settings["skipreadmedataupdate"]:
+ update_readme_data(
+ settings["readmedatafilename"],
+ extensions=extensions,
+ numberofrules=number_of_rules,
+ outputsubfolder=output_subfolder,
+ sourcesdata=sources_data,
+ )
print_success(
"Success! The hosts file has been saved in folder "
if not os.path.isfile(hosts_file):
try:
+ print("HERE HERE")
open(hosts_file, "w+").close()
except (IOError, OSError):
# Starting in Python 3.3, IOError is aliased
print_failure("Unable to determine DNS management tool.")
-def remove_old_hosts_file(backup):
+def remove_old_hosts_file(old_file_path, backup):
"""
Remove the old hosts file.
Whether or not to backup the existing hosts file.
"""
- old_file_path = path_join_robust(BASEDIR_PATH, "hosts")
-
# Create if already removed, so remove won't raise an error.
open(old_file_path, "a").close()
if backup:
- backup_file_path = path_join_robust(
- BASEDIR_PATH, "hosts-{}".format(time.strftime("%Y-%m-%d-%H-%M-%S"))
- )
+ backup_file_path = old_file_path + "{}".format(time.strftime("%Y-%m-%d-%H-%M-%S"))
# Make a backup copy, marking the date in which the list was updated
shutil.copy(old_file_path, backup_file_path)