Improved documentation in some classes

This commit is contained in:
Manuel Cortez 2022-07-29 12:08:05 -05:00
parent 83c9db573e
commit 6e80b320c9
No known key found for this signature in database
GPG Key ID: 9E0735CA15EFE790
3 changed files with 11 additions and 5 deletions

View File

@ -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. """

View File

@ -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.

View File

@ -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]