From bd331d3789fa199d8b2bd3932ed4a026581d929d Mon Sep 17 00:00:00 2001 From: Seth Schoen Date: Sun, 1 Jul 2012 22:41:26 -0700 Subject: [PATCH] more concise file content search using list comprehension --- client-webserver/sni_challenge.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/client-webserver/sni_challenge.py b/client-webserver/sni_challenge.py index 4c953c98b..1b2666d76 100644 --- a/client-webserver/sni_challenge.py +++ b/client-webserver/sni_challenge.py @@ -58,12 +58,7 @@ def checkForApacheConfInclude(mainConfig): searchStr = "Include " + APACHE_CHALLENGE_CONF #conf = open(mainConfig, 'r+') conf = open(mainConfig, 'r') - flag = False - for line in conf: - if line.startswith(searchStr): - flag = True - break - if not flag: + if not any(line.startswith(searchStr) for line in conf): #conf.write(searchStr) process = subprocess.Popen(["echo", "\n" + searchStr], stdout=subprocess.PIPE) subprocess.check_output(["sudo", "tee", "-a", mainConfig], stdin=process.stdout)