A little patch that should make some future pylint errors disappear.
-- Martin^3 Babinsky
From 42516cf53e26870016b93dee6504127b03eab9c4 Mon Sep 17 00:00:00 2001 From: Martin Babinsky <[email protected]> Date: Mon, 18 Jan 2016 18:35:52 +0100 Subject: [PATCH] ipalib/cli.py: pythonify Collector class The implementation of Collector class is hard for pylint to chew and unwieldy. This patch rewrites the class to a more readable and pythonic form. --- ipalib/cli.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/ipalib/cli.py b/ipalib/cli.py index a95648533df19919adb4304576d2e2ccf820e437..f98951210583f2e56fedcc49776086ab29e71af2 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -971,21 +971,24 @@ cli_application_commands = ( class Collector(object): - def __init__(self): - object.__setattr__(self, '_Collector__options', {}) - def __setattr__(self, name, value): - if name in self.__options: - v = self.__options[name] + if name in self.__dict__: + v = self.__dict__[name] if type(v) is tuple: value = v + (value,) else: value = (v, value) - self.__options[name] = value - object.__setattr__(self, name, value) + self.__dict__[name] = value + + def __getitem__(self, item): + return self.__dict__[item] + + def __setitem__(self, key, value): + self.__dict__[key] = value def __todict__(self): - return dict(self.__options) + return self.__dict__ + class CLIOptionParserFormatter(optparse.IndentedHelpFormatter): def format_argument(self, name, help_string): -- 2.5.0
-- Manage your subscription for the Freeipa-devel mailing list: https://www.redhat.com/mailman/listinfo/freeipa-devel Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code
