summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Options
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2013-08-09 16:45:45 -0400
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2013-08-09 16:45:45 -0400
commit0f7edd60e67d32438a8be42002faacde4e4a7649 (patch)
tree2b11b02f5bf4f9e7a6e609136bf2a19c8f166cc4 /src/lib/Bcfg2/Options
parentcc11ada6b8871d7719fd0ea8a2ff382bba8a3bc2 (diff)
downloadbcfg2-0f7edd60e67d32438a8be42002faacde4e4a7649.tar.gz
bcfg2-0f7edd60e67d32438a8be42002faacde4e4a7649.tar.bz2
bcfg2-0f7edd60e67d32438a8be42002faacde4e4a7649.zip
testsuite: fixed most pylint complaints
Diffstat (limited to 'src/lib/Bcfg2/Options')
-rw-r--r--src/lib/Bcfg2/Options/Actions.py4
-rw-r--r--src/lib/Bcfg2/Options/Common.py2
-rw-r--r--src/lib/Bcfg2/Options/OptionGroups.py7
-rw-r--r--src/lib/Bcfg2/Options/Options.py10
-rw-r--r--src/lib/Bcfg2/Options/Parser.py22
-rw-r--r--src/lib/Bcfg2/Options/Types.py2
6 files changed, 30 insertions, 17 deletions
diff --git a/src/lib/Bcfg2/Options/Actions.py b/src/lib/Bcfg2/Options/Actions.py
index 7a30d9623..637a09577 100644
--- a/src/lib/Bcfg2/Options/Actions.py
+++ b/src/lib/Bcfg2/Options/Actions.py
@@ -2,7 +2,7 @@
import sys
import argparse
-from Parser import get_parser
+from Parser import get_parser # pylint: disable=W0403
__all__ = ["ConfigFileAction", "ComponentAction", "PluginsAction"]
@@ -88,6 +88,8 @@ class ComponentAction(argparse.Action):
argparse.Action.__init__(self, *args, **kwargs)
def _import(self, module, name):
+ """ Import the given name from the given module, handling
+ errors """
try:
return getattr(__import__(module, fromlist=[name]), name)
except (AttributeError, ImportError):
diff --git a/src/lib/Bcfg2/Options/Common.py b/src/lib/Bcfg2/Options/Common.py
index 302be61f4..b44c58990 100644
--- a/src/lib/Bcfg2/Options/Common.py
+++ b/src/lib/Bcfg2/Options/Common.py
@@ -1,9 +1,11 @@
""" Common options used in multiple different contexts. """
+# pylint: disable=W0403
import Types
from Actions import PluginsAction, ComponentAction
from Parser import repository as _repository_option
from Options import Option, PathOption, BooleanOption
+# pylint: enable=W0403
__all__ = ["Common"]
diff --git a/src/lib/Bcfg2/Options/OptionGroups.py b/src/lib/Bcfg2/Options/OptionGroups.py
index 537deaa61..6cbe1a8e3 100644
--- a/src/lib/Bcfg2/Options/OptionGroups.py
+++ b/src/lib/Bcfg2/Options/OptionGroups.py
@@ -3,17 +3,12 @@
import re
import copy
import fnmatch
-from Options import Option
+from Options import Option # pylint: disable=W0403
from itertools import chain
__all__ = ["OptionGroup", "ExclusiveOptionGroup", "Subparser",
"WildcardSectionGroup"]
-#: A dict that records a mapping of argparse action name (e.g.,
-#: "store_true") to the argparse Action class for it. See
-#: :func:`_get_action_class`
-_action_map = dict()
-
class OptionContainer(list):
""" Parent class of all option groups """
diff --git a/src/lib/Bcfg2/Options/Options.py b/src/lib/Bcfg2/Options/Options.py
index ca0261907..d60c536cf 100644
--- a/src/lib/Bcfg2/Options/Options.py
+++ b/src/lib/Bcfg2/Options/Options.py
@@ -4,7 +4,7 @@ need to be associated with an option parser; it exists on its own."""
import os
import copy
-import Types
+import Types # pylint: disable=W0403
import fnmatch
import argparse
from Bcfg2.Compat import ConfigParser
@@ -15,7 +15,7 @@ __all__ = ["Option", "BooleanOption", "PathOption", "PositionalArgument"]
#: A dict that records a mapping of argparse action name (e.g.,
#: "store_true") to the argparse Action class for it. See
#: :func:`_get_action_class`
-_action_map = dict()
+_action_map = dict() # pylint: disable=C0103
def _get_action_class(action_name):
@@ -82,7 +82,7 @@ class Option(object):
#: The tuple giving the section and option name for this
#: option in the config file
- self.cf = None
+ self.cf = None # pylint: disable=C0103
#: The environment variable that this option can take its
#: value from
@@ -214,9 +214,11 @@ class Option(object):
self.default = val
def _get_default(self):
+ """ Getter for the ``default`` property """
return self._default
def _set_default(self, value):
+ """ Setter for the ``default`` property """
self._default = value
for action in self.actions.values():
action.default = value
@@ -225,9 +227,11 @@ class Option(object):
default = property(_get_default, _set_default)
def _get_dest(self):
+ """ Getter for the ``dest`` property """
return self._dest
def _set_dest(self, value):
+ """ Setter for the ``dest`` property """
self._dest = value
for action in self.actions.values():
action.dest = value
diff --git a/src/lib/Bcfg2/Options/Parser.py b/src/lib/Bcfg2/Options/Parser.py
index 343399db9..dd7874d35 100644
--- a/src/lib/Bcfg2/Options/Parser.py
+++ b/src/lib/Bcfg2/Options/Parser.py
@@ -5,7 +5,7 @@ import sys
import argparse
from Bcfg2.version import __version__
from Bcfg2.Compat import ConfigParser
-from Options import Option, PathOption, BooleanOption
+from Options import Option, PathOption, BooleanOption # pylint: disable=W0403
__all__ = ["setup", "OptionParserException", "Parser", "get_parser"]
@@ -13,14 +13,14 @@ __all__ = ["setup", "OptionParserException", "Parser", "get_parser"]
#: The repository option. This is specified here (and imported into
#: :module:`Bcfg2.Options.Common`) rather than vice-versa due to
#: circular imports.
-repository = PathOption(
+repository = PathOption( # pylint: disable=C0103
'-Q', '--repository', cf=('server', 'repository'),
default='var/lib/bcfg2', help="Server repository path")
#: A module-level :class:`argparse.Namespace` object that stores all
#: configuration for Bcfg2.
-setup = argparse.Namespace(version=__version__,
+setup = argparse.Namespace(version=__version__, # pylint: disable=C0103
name="Bcfg2",
uri='http://trac.mcs.anl.gov/projects/bcfg2')
@@ -115,6 +115,9 @@ class Parser(argparse.ArgumentParser):
self.add_options(getattr(component, "options"))
def _set_defaults(self):
+ """ Set defaults from the config file for all options that can
+ come from the config file, but haven't yet had their default
+ set """
for opt in self.option_list:
if opt not in self._defaults_set:
opt.default_from_config(self._cfp)
@@ -137,10 +140,16 @@ class Parser(argparse.ArgumentParser):
setattr(self.namespace, opt.dest, value)
def _finalize(self):
+ """ Finalize the value of any options that require that
+ additional post-processing step. (Mostly
+ :class:`Bcfg2.Options.Actions.ComponentAction` subclasses.)
+ """
for opt in self.option_list[:]:
opt.finalize(self.namespace)
def _reset_namespace(self):
+ """ Delete all options from the namespace except for a few
+ predefined values and config file options. """
self.parsed = False
for attr in dir(self.namespace):
if (not attr.startswith("_") and
@@ -200,11 +209,10 @@ class Parser(argparse.ArgumentParser):
# components, until all components have been loaded. On each
# iteration, set defaults from config file/environment
# variables
- remaining = self.argv
while not self.parsed:
self.parsed = True
self._set_defaults()
- self.parse_known_args(namespace=self.namespace)[1]
+ self.parse_known_args(namespace=self.namespace)
self._parse_config_options()
self._finalize()
self._parse_config_options()
@@ -227,7 +235,7 @@ class Parser(argparse.ArgumentParser):
#: A module-level :class:`Bcfg2.Options.Parser` object that is used
#: for all parsing
-_parser = Parser()
+_parser = Parser() # pylint: disable=C0103
#: Track whether or not the module-level parser has been initialized
#: yet. We track this separately because some things (e.g., modules
@@ -235,7 +243,7 @@ _parser = Parser()
#: been initialized, so we can't just set
#: :attr:`Bcfg2.Options._parser` to None and wait for
#: :func:`Bcfg2.Options.get_parser` to be called.
-_parser_initialized = False
+_parser_initialized = False # pylint: disable=C0103
def get_parser(description=None, components=None, namespace=None):
diff --git a/src/lib/Bcfg2/Options/Types.py b/src/lib/Bcfg2/Options/Types.py
index 5769d674a..2f0fd7d52 100644
--- a/src/lib/Bcfg2/Options/Types.py
+++ b/src/lib/Bcfg2/Options/Types.py
@@ -83,6 +83,7 @@ def timeout(value):
return rv
+# pylint: disable=C0103
_bytes_multipliers = dict(k=1,
m=2,
g=3,
@@ -90,6 +91,7 @@ _bytes_multipliers = dict(k=1,
_suffixes = "".join(_bytes_multipliers.keys()).lower()
_suffixes += _suffixes.upper()
_bytes_re = re.compile(r'(?P<value>\d+)(?P<multiplier>[%s])?' % _suffixes)
+# pylint: enable=C0103
def size(value):