From 092227eada0e8c8b97bed3800fafc54e905a0f60 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 23 Jul 2004 14:45:28 +0000 Subject: move to using toxml for xml serialization method 2004/07/08 15:01:40-05:00 anl.gov!desai add Package Type 2004/07/08 13:59:38-05:00 anl.gov!desai add Dependent and Independent classes (Logical change 1.23) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@107 ce84e21b-d406-0410-9b95-82705330c041 --- src/Types.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Types.py b/src/Types.py index 03159e04d..3ec7a0469 100644 --- a/src/Types.py +++ b/src/Types.py @@ -1,6 +1,7 @@ #!/usr/bin/env python from binascii import b2a_base64 +from string import join class ConfigFile(object): format="%s" @@ -16,7 +17,7 @@ class ConfigFile(object): else: self.xcontent=self.content - def XMLSerialize(self): + def toxml(self): return self.format%(self.name,self.owner,self.group,self.perms,self.encoding,self.xcontent) class Service(object): @@ -28,5 +29,31 @@ class Service(object): self.status = status self.scope = scope - def XMLSerialize(self): + 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