mirror of
https://github.com/StevenBlack/hosts.git
synced 2026-09-24 14:20:09 +01:00
Issue #77: fix — account for empty lines.
This commit is contained in:
+4
-2
@@ -315,12 +315,14 @@ def removeDupsAndExcl(mergeFile):
|
|||||||
exclusions = settings["exclusions"]
|
exclusions = settings["exclusions"]
|
||||||
for line in mergeFile.readlines():
|
for line in mergeFile.readlines():
|
||||||
write = 'true'
|
write = 'true'
|
||||||
# Trim trailing whitespace
|
|
||||||
line = line.rstrip()
|
|
||||||
# Explicit encoding
|
# Explicit encoding
|
||||||
line = line.decode("UTF-8")
|
line = line.decode("UTF-8")
|
||||||
# replace tabs with space
|
# replace tabs with space
|
||||||
line = line.replace('\t+', ' ')
|
line = line.replace('\t+', ' ')
|
||||||
|
# Trim trailing whitespace
|
||||||
|
line = line.rstrip()
|
||||||
|
if not line:
|
||||||
|
continue
|
||||||
# Testing the first character doesn't require startswith
|
# Testing the first character doesn't require startswith
|
||||||
if line[0] == '#' or re.match(r'^\s*$', line[0]):
|
if line[0] == '#' or re.match(r'^\s*$', line[0]):
|
||||||
# Cross-python write
|
# Cross-python write
|
||||||
|
|||||||
Reference in New Issue
Block a user