1
0
mirror of https://github.com/kellyjonbrazil/jc.git synced 2025-08-06 22:32:54 +02:00

filter out comments at the end of the line

This commit is contained in:
Kelly Brazil
2019-11-14 21:55:08 -08:00
parent a3a8369dc0
commit 7113e5a844

View File

@ -120,6 +120,16 @@ def parse(data, raw=False, quiet=False):
hosts = line_list[1] hosts = line_list[1]
hosts_list = hosts.split() hosts_list = hosts.split()
comment_found = False
for i, item in enumerate(hosts_list):
if item.find('#') != -1:
comment_found = True
comment_item = i
break
if comment_found:
hosts_list = hosts_list[:comment_item]
output_line['ip'] = ip output_line['ip'] = ip
output_line['hostname'] = hosts_list output_line['hostname'] = hosts_list