From 6e80b320c916cfe81599468fb7b39b009303b882 Mon Sep 17 00:00:00 2001 From: Manuel Cortez Date: Fri, 29 Jul 2022 12:08:05 -0500 Subject: [PATCH] Improved documentation in some classes --- src/extra/autocompletionUsers/__init__.py | 3 +-- src/extra/autocompletionUsers/completion.py | 2 +- src/extra/autocompletionUsers/manage.py | 11 +++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/extra/autocompletionUsers/__init__.py b/src/extra/autocompletionUsers/__init__.py index 6b498407..78fa88df 100644 --- a/src/extra/autocompletionUsers/__init__.py +++ b/src/extra/autocompletionUsers/__init__.py @@ -1,3 +1,2 @@ # -*- coding: utf-8 -*- -# -*- coding: utf-8 -*- -""" Autocompletion users feature for TWBlue. This package contains all needed code to support this feature, including automatic addition of users, management and code to show the autocompletion menu when an user is composing a tweet. """ +""" Autocompletion users for TWBlue. This package contains all needed code to support this feature, including automatic addition of users, management and code to show the autocompletion menu when an user is composing a tweet. """ diff --git a/src/extra/autocompletionUsers/completion.py b/src/extra/autocompletionUsers/completion.py index 47abfcbf..1c6750a3 100644 --- a/src/extra/autocompletionUsers/completion.py +++ b/src/extra/autocompletionUsers/completion.py @@ -8,7 +8,7 @@ class autocompletionUsers(object): def __init__(self, window, session_id): """ Class constructor. Displays a menu with users matching the specified pattern for autocompletion. - :param window: A wx control where the menu should be displayed. + :param window: A wx control where the menu should be displayed. Normally this is going to be the wx.TextCtrl indicating the tweet's text or direct message recipient. :type window: wx.Dialog :param session_id: Session ID which calls this class. We will load the users database from this session. :type session_id: str. diff --git a/src/extra/autocompletionUsers/manage.py b/src/extra/autocompletionUsers/manage.py index 729c1bfb..c9398a4f 100644 --- a/src/extra/autocompletionUsers/manage.py +++ b/src/extra/autocompletionUsers/manage.py @@ -4,8 +4,8 @@ import time import widgetUtils from tweepy.cursor import Cursor from tweepy.errors import TweepyException -from . import storage, wx_manage from wxUI import commonMessageDialogs +from . import storage, wx_manage class autocompletionManager(object): def __init__(self, session): @@ -16,9 +16,11 @@ class autocompletionManager(object): """ super(autocompletionManager, self).__init__() self.session = session + # Instantiate database so we can perform modifications on it. self.database = storage.storage(self.session.session_id) def show_settings(self): + """ display user management dialog and connect events associated to it. """ self.dialog = wx_manage.autocompletionManageDialog() self.users = self.database.get_all_users() self.dialog.put_users(self.users) @@ -27,6 +29,7 @@ class autocompletionManager(object): self.dialog.get_response() def update_list(self): + """ update users list in management dialog. This function is normallhy used after we modify the database in any way, so we can reload all users in the autocompletion user management list. """ item = self.dialog.users.get_selected() self.dialog.users.clear() self.users = self.database.get_all_users() @@ -34,9 +37,12 @@ class autocompletionManager(object): self.dialog.users.select_item(item) def add_user(self, *args, **kwargs): + """ Add a new Twitter username to the autocompletion database. """ usr = self.dialog.get_user() if usr == False: return + # check if user exists. + # ToDo: in case we want to adapt this for other networks we'd need to refactor this check. try: data = self.session.twitter.get_user(screen_name=usr) except TweepyException as e: @@ -46,7 +52,8 @@ class autocompletionManager(object): self.database.set_user(data.screen_name, data.name, 0) self.update_list() - def remove_user(self, ev): + def remove_user(self, *args, **kwargs): + """ Remove focused user from the autocompletion database. """ if commonMessageDialogs.delete_user_from_db() == widgetUtils.YES: item = self.dialog.users.get_selected() user = self.users[item]