From ab2c1b25ec5da5f2ba238868c4dfca95a44da30e Mon Sep 17 00:00:00 2001 From: Kelly Brazil Date: Sat, 4 Apr 2020 16:56:11 -0700 Subject: [PATCH] use startswith() and in instead of find() --- jc/parsers/hosts.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jc/parsers/hosts.py b/jc/parsers/hosts.py index 3d3a6776..ba42cf31 100644 --- a/jc/parsers/hosts.py +++ b/jc/parsers/hosts.py @@ -61,7 +61,7 @@ import jc.utils class info(): - version = '1.0' + version = '1.1' description = '/etc/hosts file parser' author = 'Kelly Brazil' author_email = 'kellyjonbrazil@gmail.com' @@ -126,7 +126,7 @@ def parse(data, raw=False, quiet=False): for line in cleandata: output_line = {} # ignore commented lines - if line.strip().find('#') == 0: + if line.strip().startswith('#'): continue line_list = line.split(maxsplit=1) @@ -136,7 +136,7 @@ def parse(data, raw=False, quiet=False): comment_found = False for i, item in enumerate(hosts_list): - if item.find('#') != -1: + if '#' in item: comment_found = True comment_item = i break