diff --git a/to-rpz/host_rpz_argv.py b/to-rpz/host_rpz_argv.py index 9159cc7..6f6b1fb 100644 --- a/to-rpz/host_rpz_argv.py +++ b/to-rpz/host_rpz_argv.py @@ -18,6 +18,15 @@ with open(infile, 'w') as f1: f1.writelines(["%s\n" % item for item in file]) f.close() +remove_words = ['localhost','localhost.localdomain','local','broadcasthost','loopback','ip6-localnet','ip6-mcastprefix','ip6-allnodes','ip6-allrouters','ip6-allhosts','ip6-loopback'] + +with open(infile, 'r') as f: + lines = f.read().splitlines() +with open(outfile, 'w') as f: + for line in lines: + if not line.endswith((tuple(remove_words))): + f.write('\n'.join([line + '\n'])) + with open(infile) as f: file = f.read().split('\n') for i in range(len(file)): @@ -43,15 +52,6 @@ with open(infile, 'w') as f: # load file in write mode f.write('\n'.join([line + '\n'])) f.close() -remove_words = ['localhost','localhost.localdomain','local','broadcasthost','loopback','ip6-localnet','ip6-mcastprefix','ip6-allnodes','ip6-allrouters','ip6-allhosts','ip6-loopback'] - -with open(infile, 'r') as f: - lines = f.read().splitlines() -with open(outfile, 'w') as f: - for line in lines: - if not line.endswith((tuple(remove_words))): - f.write('\n'.join([line + '\n'])) - with open(infile) as f: file = f.read().split('\n') for i in range(len(file)):