mirror of
https://github.com/StevenBlack/hosts.git
synced 2024-07-07 13:02:27 +02:00
Condense exclusion customization logic
This commit is contained in:
parent
05e94500ab
commit
190592577d
@ -188,11 +188,6 @@ def promptForExclusions():
|
|||||||
print("OK, we'll only exclude domains in the whitelist.")
|
print("OK, we'll only exclude domains in the whitelist.")
|
||||||
|
|
||||||
|
|
||||||
def promptForMoreCustomExclusions(question="Do you have more domains "
|
|
||||||
"you want to enter?"):
|
|
||||||
return query_yes_no(question)
|
|
||||||
|
|
||||||
|
|
||||||
def promptForFlushDnsCache():
|
def promptForFlushDnsCache():
|
||||||
if settings["flushdnscache"]:
|
if settings["flushdnscache"]:
|
||||||
flush_dns_cache()
|
flush_dns_cache()
|
||||||
@ -231,18 +226,29 @@ def displayExclusionOptions():
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
if query_yes_no("Do you want to exclude any other domains?"):
|
if query_yes_no("Do you want to exclude any other domains?"):
|
||||||
gatherCustomExclusions()
|
gather_custom_exclusions()
|
||||||
|
|
||||||
|
|
||||||
def gatherCustomExclusions():
|
def gather_custom_exclusions():
|
||||||
|
"""
|
||||||
|
Gather custom exclusions from the user.
|
||||||
|
"""
|
||||||
|
|
||||||
|
# We continue running this while-loop until the user
|
||||||
|
# says that they have no more domains to exclude.
|
||||||
while True:
|
while True:
|
||||||
# Cross-python Input
|
domain_prompt = ("Enter the domain you want "
|
||||||
domainFromUser = raw_input("Enter the domain you want to exclude (e.g. facebook.com): ")
|
"to exclude (e.g. facebook.com): ")
|
||||||
if isValidDomainFormat(domainFromUser):
|
user_domain = raw_input(domain_prompt)
|
||||||
excludeDomain(domainFromUser)
|
|
||||||
if not promptForMoreCustomExclusions():
|
if isValidDomainFormat(user_domain):
|
||||||
|
excludeDomain(user_domain)
|
||||||
|
|
||||||
|
continue_prompt = "Do you have more domains you want to enter?"
|
||||||
|
if not query_yes_no(continue_prompt):
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def excludeDomain(domain):
|
def excludeDomain(domain):
|
||||||
settings["exclusionregexs"].append(re.compile(settings["exclusionpattern"] + domain))
|
settings["exclusionregexs"].append(re.compile(settings["exclusionpattern"] + domain))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user