From ec10fc704146f0cf9e496220977bd2785b9da70c Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 11 Aug 2004 19:54:35 +0000 Subject: Rename: src/Types.py -> src/lib/Server/Types.py (Logical change 1.33) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@178 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Types.py | 59 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) (limited to 'src') diff --git a/src/lib/Server/Types.py b/src/lib/Server/Types.py index e69de29bb..3ec7a0469 100644 --- a/src/lib/Server/Types.py +++ b/src/lib/Server/Types.py @@ -0,0 +1,59 @@ +#!/usr/bin/env python + +from binascii import b2a_base64 +from string import join + +class ConfigFile(object): + format="%s" + def __init__(self,name,owner,group,perms,content,encoding='ascii'): + self.name=name + self.owner=owner + self.group=group + self.perms=perms + self.content=content + self.encoding=encoding + if encoding == 'base64': + self.xcontent=b2a_base64(content) + else: + self.xcontent=self.content + + def toxml(self): + return self.format%(self.name,self.owner,self.group,self.perms,self.encoding,self.xcontent) + +class Service(object): + format = '''''' + + def __init__(self,name,stype,status,scope): + self.name = name + self.type = stype + self.status = status + self.scope = scope + + def toxml(self): + return self.format%(self.name,self.type,self.status,self.scope) + +class Package(object): + format = '''''' + + def __init__(self, name, t, url): + self.name = name + self.type = t + self.url = url + + def toxml(self): + return self.format%(self.name, self.type, self.url) + +class Clause(list): + format = '''<%s name='%s'>%%s''' + + def __init__(self, t, name, data=None): + list.__init__(self) + self.type = t + self.name = name + if data: + self.extend(data) + + def toxml(self): + r = self.format%(self.type,self.name,self.type) + children = map(lambda x:x.toxml(), self) + return r%(join(children,'')) -- cgit v1.2.3-1-g7c22