From dd2d878e95d58daa8fd7a1ac1f0a170aebb7cd40 Mon Sep 17 00:00:00 2001 From: Anthony Molinaro Date: Mon, 13 Apr 2020 12:14:34 -0700 Subject: [PATCH] Allow whitelist/blacklist files to be passed via command line --- readme_template.md | 7 +++++++ updateHostsFile.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/readme_template.md b/readme_template.md index fb449f913..05118aa4a 100644 --- a/readme_template.md +++ b/readme_template.md @@ -146,6 +146,13 @@ each domain on a separate line. This is necessary because many implementations of URL blockers that rely on `hosts` files do not conform to the standard which allows multiple hosts on a single line. +`--blacklist `, or `-x `: Append the given blacklist file +in hosts format to the generated hosts file. + +`--whitelist `, or `-w `: Use the given whitelist file +to remove hosts from the generated hosts file. + + ## How do I control which sources are unified? Add one or more *additional* sources, each in a subfolder of the `data/` diff --git a/updateHostsFile.py b/updateHostsFile.py index 79d1deb9b..9b190468c 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -201,6 +201,20 @@ def main(): "ignoring non-necessary lines " "(empty lines and comments).", ) + parser.add_argument( + "--whitelist", + "-w", + dest="whitelistfile", + default="", + help="Whitelist file to use while generating hosts files.", + ) + parser.add_argument( + "--blacklist", + "-x", + dest="blacklistfile", + default="", + help="Blacklist file to use while generating hosts files.", + ) global settings