Added more comments

This commit is contained in:
Manuel Cortez 2018-12-03 15:55:55 -06:00
parent 08484d9807
commit 26b78eecf6
2 changed files with 18 additions and 18 deletions

View File

@ -1,44 +1,44 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
""" A buffer is a (virtual) list of items. All items belongs to a category (wall posts, messages, persons...)""" """ A buffer is a (virtual) list of items. All items belong to a category (wall posts, messages, persons...)"""
import languageHandler import logging
import webbrowser
import arrow import arrow
import wx import wx
import languageHandler
import widgetUtils import widgetUtils
import messages import messages
import utils import utils
import posts
import player import player
import output import output
import logging
import selector import selector
import webbrowser
import posts import posts
import attach import attach
from wxUI.tabs import home
from pubsub import pub from pubsub import pub
from vk.exceptions import VkAPIError
from wxUI.tabs import home
from sessionmanager import session from sessionmanager import session
from mysc.thread_utils import call_threaded from mysc.thread_utils import call_threaded
from mysc import upload from mysc import upload
from wxUI import commonMessages, menus from wxUI import commonMessages, menus
from vk.exceptions import VkAPIError
from utils import add_attachment from utils import add_attachment
log = logging.getLogger("controller.buffers") log = logging.getLogger("controller.buffers")
class baseBuffer(object): class baseBuffer(object):
""" a basic representation of a buffer. Other buffers should be derived from this class""" """ a basic representation of a buffer. Other buffers should be derived from this class. This buffer represents the "news feed" """
def get_post(self): def get_post(self):
""" Returns the currently focused post.""" """ Return the currently focused post."""
return self.session.db[self.name]["items"][self.tab.list.get_selected()] return self.session.db[self.name]["items"][self.tab.list.get_selected()]
def __init__(self, parent=None, name="", session=None, composefunc=None, *args, **kwargs): def __init__(self, parent=None, name="", session=None, composefunc=None, *args, **kwargs):
""" Constructor: """ Constructor:
parent wx.Treebook: parent for the buffer panel, @parent wx.Treebook: parent for the buffer panel,
name str: Name for saving this buffer's data in the local storage variable, @name str: Name for saving this buffer's data in the local storage variable,
session sessionmanager.session.vkSession: Session for performing operations in the Vk API. This session should be logged in when this class is instanciated. @session sessionmanager.session.vkSession: Session for performing operations in the Vk API. This session should be logged in when this class is instanciated.
composefunc str: This function will be called for composing the result which will be put in the listCtrl. Composefunc should existss in the sessionmanager.session module. @composefunc str: This function will be called for composing the result which will be put in the listCtrl. Composefunc should existss in the sessionmanager.session module.
args and kwargs will be passed to get_items() without any filtering. Be careful there.""" args and kwargs will be passed to get_items() without any filtering. Be careful there.
"""
super(baseBuffer, self).__init__() super(baseBuffer, self).__init__()
self.args = args self.args = args
self.kwargs = kwargs self.kwargs = kwargs
@ -63,7 +63,7 @@ class baseBuffer(object):
self.can_get_items = True self.can_get_items = True
def create_tab(self, parent): def create_tab(self, parent):
""" Creates the Wx panel.""" """ Create the Wx panel."""
self.tab = home.homeTab(parent) self.tab = home.homeTab(parent)
def insert(self, item, reversed=False): def insert(self, item, reversed=False):
@ -72,8 +72,8 @@ class baseBuffer(object):
self.tab.list.insert_item(reversed, *item_) self.tab.list.insert_item(reversed, *item_)
def get_items(self, show_nextpage=False): def get_items(self, show_nextpage=False):
""" Retrieves items from the VK API. This function is called repeatedly by the main controller and users could call it implicitly as well with the update buffer option. """ Retrieve items from the VK API. This function is called repeatedly by the main controller and users could call it implicitly as well with the update buffer option.
show_nextpage boolean: If it's true, it will try to load previous results. @show_nextpage boolean: If it's true, it will try to load previous results.
""" """
if self.can_get_items == False: return if self.can_get_items == False: return
retrieved = True # Control variable for handling unauthorised/connection errors. retrieved = True # Control variable for handling unauthorised/connection errors.

View File

@ -113,7 +113,7 @@ class Controller(object):
self.window.insert_buffer(requests_.tab, _(u"Friendship requests"), self.window.search("people")) self.window.insert_buffer(requests_.tab, _(u"Friendship requests"), self.window.search("people"))
incoming_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests", composefunc="compose_person", session=self.session, count=1000) incoming_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests", composefunc="compose_person", session=self.session, count=1000)
self.buffers.append(incoming_requests) self.buffers.append(incoming_requests)
self.window.insert_buffer(incoming_requests.tab, _(u"Followers"), self.window.search("requests")) self.window.insert_buffer(incoming_requests.tab, _(u"Pending requests"), self.window.search("requests"))
outgoing_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests_sent", composefunc="compose_person", session=self.session, count=1000, out=1) outgoing_requests = buffers.requestsBuffer(parent=self.window.tb, name="friend_requests_sent", composefunc="compose_person", session=self.session, count=1000, out=1)
self.buffers.append(outgoing_requests) self.buffers.append(outgoing_requests)
self.window.insert_buffer(outgoing_requests.tab, _(u"I follow"), self.window.search("requests")) self.window.insert_buffer(outgoing_requests.tab, _(u"I follow"), self.window.search("requests"))