From 2bdb9dce1bd1a9e77dd7383af4ca2c554021adbe Mon Sep 17 00:00:00 2001 From: Fabian Affolter Date: Mon, 12 Jul 2010 08:20:20 +0000 Subject: Some docstrings added git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5967 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Core.py | 11 +++++++++-- src/lib/Server/Plugin.py | 24 +++++++++++++++--------- 2 files changed, 24 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Core.py b/src/lib/Server/Core.py index 84e3f9882..976d90df9 100644 --- a/src/lib/Server/Core.py +++ b/src/lib/Server/Core.py @@ -130,6 +130,7 @@ class Core(Component): self.revision = plugin.get_revision() def init_plugins(self, plugin): + """Handling for the plugins.""" try: mod = getattr(__import__("Bcfg2.Server.Plugins.%s" % (plugin)).Server.Plugins, plugin) @@ -153,12 +154,14 @@ class Core(Component): (plugin), exc_info=1) def shutdown(self): + """.""" if not self.terminate.isSet(): self.terminate.set() for plugin in self.plugins.values(): plugin.shutdown() def validate_data(self, metadata, data, base_cls): + """Checks the data structure.""" for plugin in self.plugins.values(): if isinstance(plugin, base_cls): try: @@ -171,7 +174,7 @@ class Core(Component): % (plugin.name, err.message)) raise except: - logger.error("Plugin %s: unexpected structure val failure" \ + logger.error("Plugin %s: unexpected structure validation failure" \ % (plugin.name), exc_info=1) def GetStructures(self, metadata): @@ -282,6 +285,7 @@ class Core(Component): return config def GetDecisions(self, metadata, mode): + """Get data for the decision list.""" result = [] for plugin in self.plugins.values(): try: @@ -293,6 +297,7 @@ class Core(Component): return result def build_metadata(self, client_name): + """Build the metadata structure.""" if not hasattr(self, 'metadata'): # some threads start before metadata is even loaded raise Bcfg2.Server.Plugins.Metadata.MetadataRuntimeError @@ -307,6 +312,7 @@ class Core(Component): return imd def process_statistics(self, client_name, statistics): + """Proceed statistics for client.""" meta = self.build_metadata(client_name) state = statistics.find(".//Statistics") if state.get('version') >= '2.0': @@ -408,7 +414,7 @@ class Core(Component): @exposed def RecvStats(self, address, stats): - """Act on statistics upload""" + """Act on statistics upload.""" sdata = lxml.etree.XML(stats) client = self.metadata.resolve_client(address) self.process_statistics(client, sdata) @@ -424,6 +430,7 @@ class Core(Component): @exposed def GetDecisionList(self, address, mode): + """Get the data of the decision list.""" client = self.metadata.resolve_client(address) meta = self.build_metadata(client) return self.GetDecisions(meta, mode) diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py index b8278bf13..95569e3ac 100644 --- a/src/lib/Server/Plugin.py +++ b/src/lib/Server/Plugin.py @@ -131,11 +131,11 @@ class Connector(object): return list() def get_additional_data(self, metadata): - """Determine additional data for metadata inst.""" + """Determine additional data for metadata instances.""" return dict() class Probing(object): - """Signal probe capability for this plugin""" + """Signal probe capability for this plugin.""" def GetProbes(self, _): """Return a set of probes for execution on client.""" return [] @@ -163,7 +163,7 @@ class ThreadedStatistics(Statistics, self.start() def save(self): - """ Save any pending data to a file.""" + """Save any pending data to a file.""" pending_data = [] try: while not self.work_queue.empty(): @@ -184,7 +184,7 @@ class ThreadedStatistics(Statistics, self.logger.warning("Failed to save pending data") def load(self): - """ Load any pending data to a file.""" + """Load any pending data to a file.""" if not os.path.exists(self.pending_file): return True pending_data = [] @@ -268,7 +268,7 @@ class PullTarget(object): def AcceptPullData(self, specific, new_entry, verbose): """This is the null per-plugin implementation - of bcfg2-admin pull""" + of bcfg2-admin pull.""" raise PluginExecutionError class Decision(object): @@ -385,7 +385,10 @@ class DirectoryBacked(object): event.filename) class XMLFileBacked(FileBacked): - """This object is a coherent cache for an XML file to be used as a part of DirectoryBacked.""" + """ + This object is a coherent cache for an XML file to be used as a + part of DirectoryBacked. + """ __identifier__ = 'name' def __init__(self, filename): @@ -394,7 +397,7 @@ class XMLFileBacked(FileBacked): FileBacked.__init__(self, filename) def Index(self): - """Build local data structures""" + """Build local data structures.""" try: xdata = XML(self.data) except XMLSyntaxError: @@ -407,7 +410,7 @@ class XMLFileBacked(FileBacked): return iter(self.entries) class SingleXMLFileBacked(XMLFileBacked): - """This object is a coherent cache for an independent XML File.""" + """This object is a coherent cache for an independent XML file.""" def __init__(self, filename, fam): XMLFileBacked.__init__(self, filename) fam.AddMonitor(filename, self) @@ -450,7 +453,10 @@ class StructFile(XMLFileBacked): return [] class INode: - """LNodes provide lists of things available at a particular group intersection.""" + """ + LNodes provide lists of things available at a particular + group intersection. + """ raw = {'Client':"lambda x:'%s' == x.hostname and predicate(x)", 'Group':"lambda x:'%s' in x.groups and predicate(x)"} nraw = {'Client':"lambda x:'%s' != x.hostname and predicate(x)", -- cgit v1.2.3-1-g7c22