From c9edce3cc022f15e929ff61590e0bbb15804d21a Mon Sep 17 00:00:00 2001 From: James Yang Date: Tue, 29 Jul 2008 19:51:20 +0000 Subject: Added some basic docstrings for Editor git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4837 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Plugins/Editor.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/lib/Server/Plugins/Editor.py') diff --git a/src/lib/Server/Plugins/Editor.py b/src/lib/Server/Plugins/Editor.py index f638e1496..b759b4973 100644 --- a/src/lib/Server/Plugins/Editor.py +++ b/src/lib/Server/Plugins/Editor.py @@ -5,6 +5,7 @@ import lxml.etree from getopt import getopt def linesub(pattern, repl, filestring): + '''Substitutes instances of pattern with repl in filestring''' if filestring == None: filestring = '' output = list() @@ -14,7 +15,9 @@ def linesub(pattern, repl, filestring): return '\n'.join(output) class EditDirectives(Bcfg2.Server.Plugin.SpecificData): + '''This object handles the editing directives''' def ProcessDirectives(self, input): + '''Processes a list of edit directives on input''' temp = input for directive in self.data.split('\n'): directive = directive.split(',') @@ -23,6 +26,7 @@ class EditDirectives(Bcfg2.Server.Plugin.SpecificData): class EditEntrySet(Bcfg2.Server.Plugin.EntrySet): def __init__(self, basename, path, props, entry_type, encoding): + self.ignore = re.compile("^(\.#.*|.*~|\\..*\\.(tmp|sw[px])|%s\.H_.*)$" %path.split('/')[-1]) Bcfg2.Server.Plugin.EntrySet.__init__(self, basename, path, props, entry_type, encoding) self.inputs = dict() @@ -36,7 +40,7 @@ class EditEntrySet(Bcfg2.Server.Plugin.EntrySet): if not entry.text: entry.set('empty', 'true') try: - f = open(self.path + filename + '.H_' + client, 'w') + f = open('%s/%s.H_%s' %(self.path, filename.split('/')[-1], client), 'w') f.write(entry.text) f.close() except: @@ -55,6 +59,7 @@ class Editor(Bcfg2.Server.Plugin.GroupSpool,Bcfg2.Server.Plugin.ProbingPlugin): es_cls = EditEntrySet def GetProbes(self, _): + '''Return a set of probes for execution on client''' probelist = list() for name in self.entries.keys(): probe = lxml.etree.Element('probe') @@ -67,4 +72,3 @@ class Editor(Bcfg2.Server.Plugin.GroupSpool,Bcfg2.Server.Plugin.ProbingPlugin): def ReceiveData(self, client, datalist): for data in datalist: self.entries[data.get('name')].inputs[client.hostname] = data.text - print data, data.attrib -- cgit v1.2.3-1-g7c22