diff options
author | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-20 14:09:57 -0700 |
---|---|---|
committer | Joshua Harlow <harlowja@yahoo-inc.com> | 2012-09-20 14:09:57 -0700 |
commit | d27690ebe160bf3eae8dc92f7364daef5cf56208 (patch) | |
tree | d00b42eb4cc75c00cf0d8426bb4bd54407573d7c /cloudinit/distros/helpers.py | |
parent | 4b910d7bca47cb4fd26394fb4d14ebc72b1a73f8 (diff) | |
download | vyos-cloud-init-d27690ebe160bf3eae8dc92f7364daef5cf56208.tar.gz vyos-cloud-init-d27690ebe160bf3eae8dc92f7364daef5cf56208.zip |
Pylint cleanups.
Diffstat (limited to 'cloudinit/distros/helpers.py')
-rw-r--r-- | cloudinit/distros/helpers.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/cloudinit/distros/helpers.py b/cloudinit/distros/helpers.py index e1db74dc..251d5051 100644 --- a/cloudinit/distros/helpers.py +++ b/cloudinit/distros/helpers.py @@ -77,7 +77,7 @@ class ResolvConf(object): found = [] for (line_type, components) in self._contents: if line_type == 'option': - (cfg_opt, cfg_value, comment_tail) = components + (cfg_opt, cfg_value, _comment_tail) = components if cfg_opt == opt_name: found.append(cfg_value) return found @@ -104,13 +104,16 @@ class ResolvConf(object): def remove_opt(item): line_type, components = item if line_type != 'option': - return True - (cfg_opt, cfg_value, comment_tail) = components + return False + (cfg_opt, _cfg_value, _comment_tail) = components if cfg_opt != opt_name: - return True - return False + return False + return True - new_contents = filter(remove_opt, self._contents) + new_contents = [] + for c in self._contents: + if not remove_opt(c): + new_contents.append(c) self._contents = new_contents def add_search_domain(self, search_domain): @@ -170,8 +173,10 @@ class ResolvConf(object): try: (cfg_opt, cfg_values) = head.split(None, 1) except (IndexError, ValueError): - raise IOError("Incorrectly formatted resolv.conf line %s" % (i + 1)) - if cfg_opt not in ('nameserver', 'domain', 'search', 'sortlist', 'options'): + raise IOError("Incorrectly formatted resolv.conf line %s" + % (i + 1)) + if cfg_opt not in ['nameserver', 'domain', + 'search', 'sortlist', 'options']: raise IOError("Unexpected resolv.conf option %s" % (cfg_opt)) entries.append(("option", [cfg_opt, cfg_values, tail])) return entries |