mirror of
https://github.com/kellyjonbrazil/jc.git
synced 2025-06-23 00:29:59 +02:00
use startswith() and in instead of find()
This commit is contained in:
@ -61,7 +61,7 @@ import jc.utils
|
|||||||
|
|
||||||
|
|
||||||
class info():
|
class info():
|
||||||
version = '1.0'
|
version = '1.1'
|
||||||
description = '/etc/hosts file parser'
|
description = '/etc/hosts file parser'
|
||||||
author = 'Kelly Brazil'
|
author = 'Kelly Brazil'
|
||||||
author_email = 'kellyjonbrazil@gmail.com'
|
author_email = 'kellyjonbrazil@gmail.com'
|
||||||
@ -126,7 +126,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
for line in cleandata:
|
for line in cleandata:
|
||||||
output_line = {}
|
output_line = {}
|
||||||
# ignore commented lines
|
# ignore commented lines
|
||||||
if line.strip().find('#') == 0:
|
if line.strip().startswith('#'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
line_list = line.split(maxsplit=1)
|
line_list = line.split(maxsplit=1)
|
||||||
@ -136,7 +136,7 @@ def parse(data, raw=False, quiet=False):
|
|||||||
|
|
||||||
comment_found = False
|
comment_found = False
|
||||||
for i, item in enumerate(hosts_list):
|
for i, item in enumerate(hosts_list):
|
||||||
if item.find('#') != -1:
|
if '#' in item:
|
||||||
comment_found = True
|
comment_found = True
|
||||||
comment_item = i
|
comment_item = i
|
||||||
break
|
break
|
||||||
|
Reference in New Issue
Block a user