All pastes #623644 Raw Edit

Untitled

public python v1 · immutable
·published 2007-07-17 19:09 UTC
rendered paste body
import Propertyclass 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):        passc = Configurator("/tmp/cmservice.properties")for i in c.propertyList:    print i.name, "=", i.value