summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2004-07-23 14:45:28 +0000
committerNarayan Desai <desai@mcs.anl.gov>2004-07-23 14:45:28 +0000
commit092227eada0e8c8b97bed3800fafc54e905a0f60 (patch)
tree06665f8c8eef70ffdb7d82c6810e8a9280a3c253 /src
parentee3a679f6495da59632ea575cee4e531c59cdccd (diff)
downloadbcfg2-092227eada0e8c8b97bed3800fafc54e905a0f60.tar.gz
bcfg2-092227eada0e8c8b97bed3800fafc54e905a0f60.tar.bz2
bcfg2-092227eada0e8c8b97bed3800fafc54e905a0f60.zip
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
Diffstat (limited to 'src')
-rw-r--r--src/Types.py31
1 files 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="<ConfigFile name='%s' owner='%s' group='%s' perms='%s' encoding='%s'>%s</ConfigFile>"
@@ -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 = '''<Package name='%s' type='%s' url='%s'/>'''
+
+ 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</%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,''))