コード例 #1
0
 def _change_status(self, peer_id, status):
     """mark given peer as Friend, Blacklisted or Anonymous"""
     peer_desc = AbstractContactsData._change_status(self, peer_id, status)
     if status != PeerDescriptor.ANONYMOUS:
         self._write_peer(peer_id, peer_desc)
     else:
         self.remove_peer(peer_id)
コード例 #2
0
 def __init__(self):
     # dictionary of peers. {pseudo : PeerDescriptor}
     self.peers = {}
     AbstractContactsData.__init__(self)
コード例 #3
0
 def __init__(self):
     self.config.add_section(SECTION_OTHERS)
     AbstractContactsData.__init__(self)
コード例 #4
0
                except ValueError, error:
                    print error
        #else return default value
        return result

    def _change_status(self, peer_id, status):
        """mark given peer as Friend, Blacklisted or Anonymous"""
        peer_desc = AbstractContactsData._change_status(self, peer_id, status)
        if status != PeerDescriptor.ANONYMOUS:
            self._write_peer(peer_id, peer_desc)
        else:
            self.remove_peer(peer_id)

    def fill_data(self, (peer_id, document)):
        """stores CacheDocument associated with peer"""
        peer_desc = AbstractContactsData.fill_data(self, (peer_id, document))
        if peer_desc.state != PeerDescriptor.ANONYMOUS:
            self._write_peer(peer_id, peer_desc)

    def fill_blog(self, (peer_id, blog)):
        """stores CacheDocument associated with peer"""
        peer_desc = AbstractContactsData.fill_blog(self, (peer_id, blog))
        if peer_desc.state != PeerDescriptor.ANONYMOUS:
            blog.save()
            
    def fill_shared_files(self, (peer_id, files)):
        """connect shared files with shared files"""
        # nothing to do in FileDocuments when receiving files
        pass

class FileSaverMixin(SaverMixin):