import ConfigParser class MovingProfiles: config_file="/etc/lliurex-moving-profiles.conf" def __init__(self): pass #def __init__ def startup(self): pass #def startup def load_conf(self): cfg=ConfigParser.SafeConfigParser() cfg.read([MovingProfiles.config_file]) data={"include":{},"exclude":{}} for item in cfg.items("include"): name,value=item data["include"][name]=value for item in cfg.items("exclude"): name,value=item data["exclude"][name]=value return data #def def save_conf(self,data): cfg=ConfigParser.SafeConfigParser() cfg.add_section("include") cfg.add_section("exclude") for d in data["include"]: cfg.set("include",d,data["include"][d]) for d in data["exclude"]: cfg.set("exclude",d,data["exclude"][d]) f=open(MovingProfiles.config_file,"wb") cfg.write(f) f.close() if __name__=="__main__": pass #mp = MovingProfiles() #mp.load_conf() #data={"include":{"duke":"nukem","iron":"maiden"},"exclude":{"silver":"surfer"}} #mp.save_conf(data)