self.assertFalse(update_sources)
output = sys.stdout.getvalue()
- expected = "OK, we'll stick with " "what we've got locally."
+ expected = "OK, we'll stick with what we've got locally."
self.assertIn(expected, output)
sys.stdout = StringIO()
self.assertFalse(gather_exclusions)
output = sys.stdout.getvalue()
- expected = "OK, we'll only exclude " "domains in the whitelist."
+ expected = "OK, we'll only exclude domains in the whitelist."
self.assertIn(expected, output)
self.assert_called_once(mock_query)
os.name = "posix"
flush_dns_cache()
- expected = "Flushing the DNS cache by " "restarting nscd succeeded"
+ expected = "Flushing the DNS cache by restarting nscd succeeded"
output = sys.stdout.getvalue()
self.assertIn(expected, output)
os.name = "posix"
flush_dns_cache()
- expected = "Flushing the DNS cache by " "restarting nscd failed"
+ expected = "Flushing the DNS cache by restarting nscd failed"
output = sys.stdout.getvalue()
self.assertIn(expected, output)
output = sys.stdout.getvalue()
for expected in [
- ("Flushing the DNS cache by " "restarting nscd failed"),
+ ("Flushing the DNS cache by restarting nscd failed"),
(
"Flushing the DNS cache by restarting "
"NetworkManager.service succeeded"
def test_invalid_domain(self):
expected = (
- "Do not include www.domain.com or " "http(s)://domain.com. Try again."
+ "Do not include www.domain.com or http(s)://domain.com. Try again."
)
for invalid_domain in [
def main():
parser = argparse.ArgumentParser(
description="Creates a unified hosts "
- "file from hosts stored in "
- "data subfolders."
+ "file from hosts stored in the data subfolders."
)
parser.add_argument(
"--auto",
dest="backup",
default=False,
action="store_true",
- help="Backup the hosts " "files before they " "are overridden.",
+ help="Backup the hosts files before they are overridden.",
)
parser.add_argument(
"--extensions",
dest="extensions",
default=[],
nargs="*",
- help="Host extensions to include " "in the final hosts file.",
+ help="Host extensions to include in the final hosts file.",
)
parser.add_argument(
"--ip",
dest="noupdate",
default=False,
action="store_true",
- help="Don't update from " "host data sources.",
+ help="Don't update from host data sources.",
)
parser.add_argument(
"--skipstatichosts",
dest="skipstatichosts",
default=False,
action="store_true",
- help="Skip static localhost entries " "in the final hosts file.",
+ help="Skip static localhost entries in the final hosts file.",
)
parser.add_argument(
"--nogendata",
dest="replace",
default=False,
action="store_true",
- help="Replace your active " "hosts file with this " "new hosts file.",
+ help="Replace your active hosts file with this new hosts file.",
)
parser.add_argument(
"--flush-dns-cache",
dest="flushdnscache",
default=False,
action="store_true",
- help="Attempt to flush DNS cache " "after replacing the hosts file.",
+ help="Attempt to flush DNS cache after replacing the hosts file.",
)
parser.add_argument(
"--compress",
dest="compress",
default=False,
action="store_true",
- help="Compress the hosts file "
- "ignoring non-necessary lines "
- "(empty lines and comments) and "
- "putting multiple domains in "
- "each line. Improve the "
- "performances under Windows.",
+ help="Compress the hosts file ignoring non-necessary lines "
+ "(empty lines and comments) and putting multiple domains in "
+ "each line. Improve the performance under Windows.",
)
parser.add_argument(
"--minimise",
dest="minimise",
default=False,
action="store_true",
- help="Minimise the hosts file "
- "ignoring non-necessary lines "
+ help="Minimise the hosts file ignoring non-necessary lines "
"(empty lines and comments).",
)
parser.add_argument(
-------
aug_exclusion_regexes : list
The original list of regex patterns potentially with additional
- patterns from domains that user chooses to exclude.
+ patterns from domains that the user chooses to exclude.
"""
for exclusion_option in common_exclusions:
-------
aug_exclusion_regexes : list
The original list of regex patterns potentially with additional
- patterns from domains that user chooses to exclude.
+ patterns from domains that the user chooses to exclude.
"""
# We continue running this while-loop until the user
"""
Exclude a domain from being blocked.
- This create the domain regex by which to exclude this domain and appends
+ This creates the domain regex by which to exclude this domain and appends
it a list of already-existing exclusion regexes.
Parameters
to be the same for all sources.
host_filename : str
The name of the file in which the updated source information
- in stored for a particular URL. This filename is assumed to be
+ is stored for a particular URL. This filename is assumed to be
the same for all sources.
"""
def domain_to_idna(line):
"""
- Encode a domain which is presente into a line into `idna`. This way we
- avoid the most encoding issue.
+ Encode a domain that is present into a line into `idna`. This way we
+ avoid most encoding issues.
Parameters
----------
Notes
-----
- - This function encode only the domain to `idna` format because in
+ - This function encodes only the domain to `idna` format because in
most cases, the encoding issue is due to a domain which looks like
`b'\xc9\xa2oogle.com'.decode('idna')`.
- About the splitting: