コード例 #1
0
ファイル: xmlparse.py プロジェクト: pombredanne/paella-svn
 def __init__(self, element):
     ParserHelper.__init__(self)
     self.name = element.getAttribute('name')
     devs = element.getElementsByTagName('machine_disk')
     mods = element.getElementsByTagName('module')
     fams = element.getElementsByTagName('family')
     scripts = element.getElementsByTagName('script')
     vars_ = element.getElementsByTagName('machine_type_variable')
     
     self.mtype = MachineType(self.name)
     for d in devs:
         device = d.getAttribute('device')
         diskname = d.getAttribute('diskname')
         self.mtype.append_disk(MachineDisk(diskname, device))
     moddict = dict(map(parse_module, mods))
     modorder = moddict.keys()
     modorder.sort()
     modules = []
     for i in modorder:
         modules.append(moddict[i])
     self.mtype.append_modules(modules)
     for f in fams:
         family = get_child(f)
         self.mtype.append_family(family)
     for s in scripts:
         name = s.getAttribute('name')
         self.mtype.append_script(name, name)
     for v in vars_:
         trait = v.getAttribute('trait')
         name = v.getAttribute('name')
         value = get_child(v)
         self.mtype.append_variable(trait, name, value)
コード例 #2
0
class MachineTypeParser(ParserHelper):
    def __init__(self, element):
        ParserHelper.__init__(self)
        self.name = element.getAttribute('name')
        devs = element.getElementsByTagName('machine_disk')
        mods = element.getElementsByTagName('module')
        fams = element.getElementsByTagName('family')
        scripts = element.getElementsByTagName('script')
        vars_ = element.getElementsByTagName('machine_type_variable')
        
        self.mtype = MachineType(self.name)
        for d in devs:
            device = d.getAttribute('device')
            diskname = d.getAttribute('diskname')
            self.mtype.append_disk(MachineDisk(diskname, device))
        moddict = dict(map(parse_module, mods))
        modorder = moddict.keys()
        modorder.sort()
        modules = []
        for i in modorder:
            modules.append(moddict[i])
        self.mtype.append_modules(modules)
        for f in fams:
            family = get_child(f)
            self.mtype.append_family(family)
        for s in scripts:
            name = s.getAttribute('name')
            self.mtype.append_script(name, name)
        for v in vars_:
            trait = v.getAttribute('trait')
            name = v.getAttribute('name')
            value = get_child(v)
            self.mtype.append_variable(trait, name, value)
コード例 #3
0
ファイル: xmlparse.py プロジェクト: pombredanne/paella-svn
 def _parse_mtypeOrig(self, element):
     name = get_attribute('name', element)
     md_elements = element.getElementsByTagName('machine_disk')
     mod_elements = element.getElementsByTagName('module')
     mtype = MachineType(name)
     map(mtype.append_disk, map(parse_mdisk, md_elements))
     moddict = dict(map(parse_module, mod_elements))
     modorder = moddict.keys()
     modorder.sort()
     modules = []
     for i in modorder:
         modules.append(moddict[i])
     mtype.append_modules(modules)
     return mtype
コード例 #4
0
ファイル: xmlparse.py プロジェクト: pombredanne/paella-svn
 def _parse_mtype(self, element):
     name = get_attribute('name', element)
     md_elements = element.getElementsByTagName('machine_disk')
     mtype = MachineType(name)
     map(mtype.append_disk, map(parse_mdisk, md_elements))
     return mtype