From e5a228906db2fc8584cfb2e3244f4b97ccff31b9 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Tue, 25 Oct 2016 00:10:11 +0300 Subject: [PATCH] docs for new classes structure --- toxygen/basecontact.py | 3 ++- toxygen/contact.py | 11 ++++++++--- toxygen/friend.py | 6 +----- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/toxygen/basecontact.py b/toxygen/basecontact.py index 2bd407f..8988e44 100644 --- a/toxygen/basecontact.py +++ b/toxygen/basecontact.py @@ -10,7 +10,8 @@ class BaseContact: """ Class encapsulating TOX contact Properties: name (alias of contact or name), status_message, status (connection status) - widget - widget for update + widget - widget for update, tox id (or public key) + Base class for all contacts. """ def __init__(self, name, status_message, widget, tox_id): diff --git a/toxygen/contact.py b/toxygen/contact.py index 4c5af1e..86b0282 100644 --- a/toxygen/contact.py +++ b/toxygen/contact.py @@ -12,8 +12,7 @@ import file_transfers as ft class Contact(basecontact.BaseContact): """ Class encapsulating TOX contact - Properties: name (alias of contact or name), status_message, status (connection status) - widget - widget for update + Properties: number, message getter, history etc. Base class for friend and gc classes """ def __init__(self, message_getter, number, name, status_message, widget, tox_id): @@ -59,6 +58,9 @@ class Contact(basecontact.BaseContact): self._history_loaded = True def load_all_corr(self): + """ + Get all chat history from db for current friend + """ data = list(self._message_getter.get_all()) if data is not None and len(data): data.reverse() @@ -115,6 +117,9 @@ class Contact(basecontact.BaseContact): self._message_getter.delete_one() def delete_old_messages(self): + """ + Delete old messages (reduces RAM if messages saving is not enabled) + """ old = filter(lambda x: x.get_type() in (2, 3) and (x.get_status() >= 2 or x.get_status() is None), self._corr[:-SAVE_MESSAGES]) old = list(old) @@ -182,7 +187,7 @@ class Contact(basecontact.BaseContact): visibility = property(get_visibility, set_visibility) # ----------------------------------------------------------------------------------------------------------------- - # Unread messages from friend + # Unread messages and other actions from friend # ----------------------------------------------------------------------------------------------------------------- def get_actions(self): diff --git a/toxygen/friend.py b/toxygen/friend.py index 5991b36..5871876 100644 --- a/toxygen/friend.py +++ b/toxygen/friend.py @@ -4,14 +4,10 @@ from messages import * class Friend(contact.Contact): """ - Friend in list of friends. Can be hidden, properties 'has unread messages' and 'has alias' added + Friend in list of friends. """ def __init__(self, message_getter, number, name, status_message, widget, tox_id): - """ - :param message_getter: gets messages from db - :param number: number of friend. - """ super().__init__(message_getter, number, name, status_message, widget, tox_id) self._receipts = 0