Reads an XML configuration file (produced by a mini-cluster) into a dictionary accessible via get()
| 34 | |
| 35 | |
| 36 | class HdfsConfig(object): |
| 37 | """Reads an XML configuration file (produced by a mini-cluster) into a dictionary |
| 38 | accessible via get()""" |
| 39 | def __init__(self, *filename): |
| 40 | self.conf = {} |
| 41 | for arg in filename: |
| 42 | tree = parse(arg) |
| 43 | for property in tree.getroot().iter('property'): |
| 44 | self.conf[property.find('name').text] = property.find('value').text |
| 45 | |
| 46 | def get(self, key): |
| 47 | return self.conf.get(key) |
| 48 | |
| 49 | |
| 50 | # Configuration object for the configuration that the minicluster will use. |
no outgoing calls