summaryrefslogtreecommitdiffstats
path: root/src/lib/Server/Plugins/Editor.py
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2011-04-05 14:32:29 -0500
committerSol Jerome <sol.jerome@gmail.com>2011-04-06 19:35:21 -0500
commit2d90970d7da08e3c89fe67f4ebf8d0c1cdafeb20 (patch)
tree32bd5e0d28bb6a154f630b6a4f91c55c95c936cc /src/lib/Server/Plugins/Editor.py
parent9d8f65a64a5319f3e48dd43e2ea3a3ac4c051f9c (diff)
downloadbcfg2-2d90970d7da08e3c89fe67f4ebf8d0c1cdafeb20.tar.gz
bcfg2-2d90970d7da08e3c89fe67f4ebf8d0c1cdafeb20.tar.bz2
bcfg2-2d90970d7da08e3c89fe67f4ebf8d0c1cdafeb20.zip
Plugins: PY3K + PEP8 fixes
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
Diffstat (limited to 'src/lib/Server/Plugins/Editor.py')
-rw-r--r--src/lib/Server/Plugins/Editor.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/Server/Plugins/Editor.py b/src/lib/Server/Plugins/Editor.py
index bfd4d6e93..e68d28d8b 100644
--- a/src/lib/Server/Plugins/Editor.py
+++ b/src/lib/Server/Plugins/Editor.py
@@ -2,6 +2,7 @@ import Bcfg2.Server.Plugin
import re
import lxml.etree
+
def linesub(pattern, repl, filestring):
"""Substitutes instances of pattern with repl in filestring."""
if filestring == None:
@@ -12,6 +13,7 @@ def linesub(pattern, repl, filestring):
output.append(re.sub(pattern, repl, filestring))
return '\n'.join(output)
+
class EditDirectives(Bcfg2.Server.Plugin.SpecificData):
"""This object handles the editing directives."""
def ProcessDirectives(self, input):
@@ -22,23 +24,29 @@ class EditDirectives(Bcfg2.Server.Plugin.SpecificData):
temp = linesub(directive[0], directive[1], temp)
return temp
+
class EditEntrySet(Bcfg2.Server.Plugin.EntrySet):
def __init__(self, basename, path, entry_type, encoding):
- self.ignore = re.compile("^(\.#.*|.*~|\\..*\\.(tmp|sw[px])|%s\.H_.*)$" %path.split('/')[-1])
- Bcfg2.Server.Plugin.EntrySet.__init__(self, basename, path, entry_type, encoding)
+ self.ignore = re.compile("^(\.#.*|.*~|\\..*\\.(tmp|sw[px])|%s\.H_.*)$" % path.split('/')[-1])
+ Bcfg2.Server.Plugin.EntrySet.__init__(self,
+ basename,
+ path,
+ entry_type,
+ encoding)
self.inputs = dict()
def bind_entry(self, entry, metadata):
client = metadata.hostname
filename = entry.get('name')
- permdata = {'owner':'root', 'group':'root'}
- permdata['perms'] = '0644'
+ permdata = {'owner': 'root',
+ 'group': 'root'
+ 'perms': '0644'}
[entry.attrib.__setitem__(key, permdata[key]) for key in permdata]
entry.text = self.entries['edits'].ProcessDirectives(self.get_client_data(client))
if not entry.text:
entry.set('empty', 'true')
try:
- f = open('%s/%s.H_%s' %(self.path, filename.split('/')[-1], client), 'w')
+ f = open('%s/%s.H_%s' % (self.path, filename.split('/')[-1], client), 'w')
f.write(entry.text)
f.close()
except:
@@ -60,7 +68,7 @@ class Editor(Bcfg2.Server.Plugin.GroupSpool,
def GetProbes(self, _):
'''Return a set of probes for execution on client'''
probelist = list()
- for name in self.entries.keys():
+ for name in list(self.entries.keys()):
probe = lxml.etree.Element('probe')
probe.set('name', name)
probe.set('source', "Editor")