Condense exclusion customization logic
authorgfyoung <redacted>
Sun, 14 May 2017 18:19:57 +0000 (14:19 -0400)
committergfyoung <redacted>
Mon, 15 May 2017 02:10:19 +0000 (22:10 -0400)
updateHostsFile.py

index 462043bbdaa265669f7a3e8db1f5dd8e647547ea..0d1caffd3ee99ccc8a9afdbb8da158f9d2902d5e 100644 (file)
@@ -188,11 +188,6 @@ def promptForExclusions():
             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():
     if settings["flushdnscache"]:
         flush_dns_cache()
@@ -231,18 +226,29 @@ def displayExclusionOptions():
             continue
 
     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:
-        # Cross-python Input
-        domainFromUser = raw_input("Enter the domain you want to exclude (e.g. facebook.com): ")
-        if isValidDomainFormat(domainFromUser):
-            excludeDomain(domainFromUser)
-        if not promptForMoreCustomExclusions():
+        domain_prompt = ("Enter the domain you want "
+                         "to exclude (e.g. facebook.com): ")
+        user_domain = raw_input(domain_prompt)
+
+        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
 
+
 def excludeDomain(domain):
     settings["exclusionregexs"].append(re.compile(settings["exclusionpattern"] + domain))
 
git clone https://git.99rst.org/PROJECT