File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 9
9
args = parser .parse_args ()
10
10
11
11
12
- def read_stripped (file : str ):
12
+ def read_stripped (file : str , strip_lines = True ):
13
+ """
14
+ This reads the file and strips out any empty and comment lines with `#`
15
+ """
13
16
try :
14
17
with open (file , "r" ) as f :
18
+ file_contents = f .readlines ()
19
+
20
+ if not strip_lines :
21
+ return file_contents
22
+
15
23
strip_comments = [l .strip ()
16
24
if not l .startswith ("#" ) else None
17
- for l in f . readlines () ]
25
+ for l in file_contents ]
18
26
19
27
return list (filter (None , strip_comments ))
20
28
@@ -34,6 +42,7 @@ def dnsmasq_fmt(*domains):
34
42
def main ():
35
43
hosts_record = read_stripped ("hosts" )
36
44
dnsmasq_record = read_stripped ("dnsmasq" )
45
+ pihole_record = read_stripped ("PiHole" , False )
37
46
38
47
39
48
if __name__ == "__main__" :
You can’t perform that action at this time.
0 commit comments