import Property class Configurator: def __init__(self, configuration): self.propertyList = self.setPath(configuration) def setPath(self, configuration): try: f = open(configuration, "r") props = f.readlines() ret = [] for i in props: # loop through the properties if "=" in i: # check only for field=value combinations if "#" not in i: #if commented, skip them try: name, val = i.split("=") ret.append(Property.Property(name, val)) except ValueError: # if there's more than 1 equal sign, this it's an invalid property. pass f.close() return ret except: raise Exception("Error reading file") def configure(self, prop, val): pass c = Configurator("/tmp/cmservice.properties") for i in c.propertyList: print i.name, "=", i.value