import pprint
import os
from xml.dom import minidom
-from types import StringTypes
-
-class Spec(dict):
-
- fields = {}
- plcFields = {}
- type = None
-
- def __init__(self, spec_dict):
- sdict = self.plcToSpec(spec_dict)
- dict.__init__(self, sdict)
-
- def plcToSpec(self, spec_dict):
- spec = {}
- for field in self.fields:
- plc_field = plc_fields[field]
-
- if spec_dict.has_key(field):
- spec[field] = spec_dict(field)
-
- return {self.type: spec}
-
-
-class IfSpec(Spec):
- pass
-
-
class Rspec():
dicts.append(value)
return dicts
+ def getDictByTagNameValue(self, tagname, value, dom = None):
+ """
+ Search the dom for the first element with the specified tagname
+ and value and return it as a dict.
+ """
+ tempdict = {}
+ if not dom:
+ dom = self.rootNode
+ dicts = self.getDictsByTagName(tagname, dom)
+
+ for rdict in dicts:
+ if rdict.has_key('name') and rdict['name'] in [value]:
+ return rdict
+
+ return tempdict
# vim:ts=4:expandtab