Started to document autocompltion users module

This commit is contained in:
Manuel Cortez 2022-05-26 05:45:46 -05:00
parent c89dff053d
commit a138b8c02e
2 changed files with 20 additions and 2 deletions

View File

@ -1,5 +1,4 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
# -*- 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. """
from . import completion, settings from . import completion, settings

View File

@ -1,15 +1,34 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" Module to display the user autocompletion menu in tweet or direct message dialogs. """
import output import output
from . import storage from . import storage
from . import wx_menu from . import wx_menu
class autocompletionUsers(object): class autocompletionUsers(object):
def __init__(self, window, session_id): 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.
: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.
"""
super(autocompletionUsers, self).__init__() super(autocompletionUsers, self).__init__()
self.window = window self.window = window
self.db = storage.storage(session_id) self.db = storage.storage(session_id)
def show_menu(self, mode="tweet"): def show_menu(self, mode="tweet"):
""" displays a menu with possible users matching the specified pattern.
this menu can be displayed in tweet dialogs or in any other dialog where an username is expected. For tweet dialogs, the string should start with an at symbol (@), otherwise it won't match the pattern.
Of course, users must be already loaded in database before attempting this.
If no users are found, an error message will be spoken.
:param mode: this controls how the dialog will behave. Possible values are 'tweet' and 'dm'. In tweet mode, the matching pattern will be @user (@ is required), while in 'dm' mode the matching pattern will be anything written in the text control.
:type mode: str
"""
position = self.window.text.GetInsertionPoint() position = self.window.text.GetInsertionPoint()
if mode == "tweet": if mode == "tweet":
text = self.window.text.GetValue() text = self.window.text.GetValue()