pKa/Design_pKa_help.py
def update_data(self):
        """Add new data to the file on disk"""
        if self.data_added>0 and self.save_file:
            self.lock()
            import cPickle, os
            if os.path.isfile(self.datafile):
                fd=open(self.datafile)
                old_data=cPickle.load(fd)
                fd.close()
            else:
                old_data={}
            #
            # Put any new data into our dict
            #
            for key1 in old_data.keys():
                if not self.data.has_key(key1):
                    #
                    # copy entire sub-entry
                    #
                    import copy
                    self.data[key1]=copy.deepcopy(old_data[key1])
                else:
                    #
                    # check if we have all subentries
                    #
                    import types, copy
                    if type(old_data[key1]) is types.DictType:
                        for key2 in old_data[key1].keys():
                            if not self.data[key1].has_key(key2):
                                self.data[key1][key2]=copy.deepcopy(old_data[key1][key2])
            #
            # Done, now save the complete dictionary
            #
            tempfile=self.datafile+'_write'
            fd=open(tempfile,'w')
            cPickle.dump(self.data,fd)
            fd.close()
            import shutil
            shutil.move(tempfile,self.datafile)
            self.unlock()
        #
        # Done
        #
        return
Add new data to the file on disk
Add new data to the file on disk
Add new data to the file on disk
def update_data(self):
        if self.data_added>0 and self.save_file:
            self.lock()
            import cPickle, os
            if os.path.isfile(self.datafile):
                fd=open(self.datafile)
                old_data=cPickle.load(fd)
                fd.close()
            else:
                old_data={}
             Put any new data into our dict
            for key1 in old_data.keys():
                if not self.data.has_key(key1):
                     copy entire sub-entry
                    import copy
                    self.data[key1]=copy.deepcopy(old_data[key1])
                else:
                     check if we have all subentries
                    import types, copy
                    if type(old_data[key1]) is types.DictType:
                        for key2 in old_data[key1].keys():
                            if not self.data[key1].has_key(key2):
                                self.data[key1][key2]=copy.deepcopy(old_data[key1][key2])
             Done, now save the complete dictionary
            tempfile=self.datafile+'_write'
            fd=open(tempfile,'w')
            cPickle.dump(self.data,fd)
            fd.close()
            import shutil
            shutil.move(tempfile,self.datafile)
            self.unlock()
         Done
        return
def update_data ( self ) : if self . data_added > 0 and self . save_file : self . lock ( ) import cPickle , os if os . path . isfile ( self . datafile ) : fd = open ( self . datafile ) old_data = cPickle . load ( fd ) fd . close ( ) else : old_data = { } for key1 in old_data . keys ( ) : if not self . data . has_key ( key1 ) : import copy self . data [ key1 ] = copy . deepcopy ( old_data [ key1 ] ) else : import types , copy if type ( old_data [ key1 ] ) is types . DictType : for key2 in old_data [ key1 ] . keys ( ) : if not self . data [ key1 ] . has_key ( key2 ) : self . data [ key1 ] [ key2 ] = copy . deepcopy ( old_data [ key1 ] [ key2 ] ) tempfile = self . datafile + '_write' fd = open ( tempfile , 'w' ) cPickle . dump ( self . data , fd ) fd . close ( ) import shutil shutil . move ( tempfile , self . datafile ) self . unlock ( ) return
Add new data to the file on disk
Add new data to the file on disk
"""Add new data to the file on disk""" # # Put any new data into our dict # # # copy entire sub-entry # # # check if we have all subentries # # # Done, now save the complete dictionary # # # Done #
self