def del_from_config(self, dirnum): self.configdatei = file(os.environ.get("HOME")+"/.pyflphoto", 'w') self.configuration["alben"].pop(dirnum-1) self.alben = self.configuration["alben"] generic.dump(self.configuration, self.configdatei) self.configdatei.flush() self.configdatei.close()
def add_to_config(self, dirname): b = False self.configdatei = file(os.environ.get("HOME")+"/.pyflphoto", 'w') if self.configuration["alben"].count(dirname) == 0: self.configuration["alben"].append(dirname) b = True self.alben = self.configuration["alben"] generic.dump(self.configuration, self.configdatei) self.configdatei.flush() self.configdatei.close() return b
def load_config(self, win): self.configdatei = file(os.environ.get("HOME")+"/.pyflphoto", 'a+') try: self.configuration = generic.load(self.configdatei) #for i in self.configuration["alben"]: # if self.configuration["alben"].count(i) > 1: # self.configuration["alben"].remove(i) except: self.configuration["alben"] = [] self.configuration["options"] = {} generic.dump(self.configuration, self.configdatei) self.configdatei.flush() self.configdatei.close() self.alben = self.configuration["alben"]
def pyxml_marshal(): try: from xml.marshal import generic except ImportError: # Skip comparison with PyXML's xml.marshal if unavailable print("Skipping PyXML xml.marshal") return f = mk_foo() print("CREATE XML (xml.marshal style)") t1 = time() fh = open('bbb.xml','w') x = generic.dump(f,fh) fh.close() print("TIME = %f"%(time()-t1)) print("Pickle len = ",os.stat('bbb.xml')[ST_SIZE]) print("xml.marshal load") t1 = time() fh = open('bbb.xml','r') m = generic.load(fh) fh.close() print("TIME = %f"%(time()-t1)) del m
def pyxml_marshal(): try: from xml.marshal import generic except ImportError: # Skip comparison with PyXML's xml.marshal if unavailable print "Skipping PyXML xml.marshal" return f = mk_foo(6) print "CREATE XML (xml.marshal style)" t1 = time() fh = open('bbb.xml','w') x = generic.dump(f,fh) fh.close() print "TIME = %f"%(time()-t1) print "Pickle len = ",os.stat('bbb.xml')[ST_SIZE] print "xml.marshal load" t1 = time() fh = open('bbb.xml','r') m = generic.load(fh) fh.close() print "TIME = %f"%(time()-t1) del m
def set_option(self, option, value): self.configdatei = file(os.environ.get("HOME")+"/.pyflphoto", 'w') self.configuration["options"][option] = value generic.dump(self.configuration, self.configdatei) self.configdatei.flush() self.configdatei.close()