From: Steven Black Date: Thu, 24 Sep 2015 03:55:36 +0000 (-0400) Subject: Fix the update script so we don't write any dupes. X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=71499a4153410f5005773b63ad0269df58dd648f;p=stevenblack-hosts.git Fix the update script so we don't write any dupes. Signed-off-by: Steven Black --- diff --git a/updateHostsFile.py b/updateHostsFile.py index 1c283a4d9..82e151d51 100644 --- a/updateHostsFile.py +++ b/updateHostsFile.py @@ -173,12 +173,10 @@ def removeDups(mergeFile): continue hostname, normalizedRule = normalizeRule(strippedRule) # normalize rule - if normalizedRule and hostname not in hostnames: + if normalizedRule and (hostname not in hostnames): finalFile.write(normalizedRule) hostnames.add(hostname) numberOfRules += 1 - else: - finalFile.write(line) mergeFile.close() @@ -188,7 +186,7 @@ def normalizeRule(rule): result = re.search(r'^[ \t]*(\d+\.\d+\.\d+\.\d+)\s+([\w\.-]+)(.*)',rule) if result: target, hostname, suffix = result.groups() - return hostname, "%s\t%s%s\n" % (TARGET_HOST, hostname, suffix) + return hostname, "%s %s %s\n" % (TARGET_HOST, hostname, suffix) print '==>%s<==' % rule return None, None