summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Yang <jjyang@mcs.anl.gov>2008-07-29 19:51:20 +0000
committerJames Yang <jjyang@mcs.anl.gov>2008-07-29 19:51:20 +0000
commitc9edce3cc022f15e929ff61590e0bbb15804d21a (patch)
tree6d2e015c672a2c58f3ff26d282c2d029e191cd13 /src
parentd674cf5b4d64de4f8aac82b6ffb1f57c52e0be9f (diff)
downloadbcfg2-c9edce3cc022f15e929ff61590e0bbb15804d21a.tar.gz
bcfg2-c9edce3cc022f15e929ff61590e0bbb15804d21a.tar.bz2
bcfg2-c9edce3cc022f15e929ff61590e0bbb15804d21a.zip
Added some basic docstrings for Editor
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@4837 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugins/Editor.py8
1 files changed, 6 insertions, 2 deletions
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