Pylint improvements: bookmarks.py

This commit is contained in:
kulath 2016-06-28 15:30:23 +01:00
parent a7ea1d98b4
commit c817b0dedc

View File

@ -34,7 +34,6 @@ from io import StringIO
#
#-------------------------------------------------------------------------
import logging
log = logging.getLogger(".Bookmarks")
#-------------------------------------------------------------------------
#
@ -60,6 +59,7 @@ _ = glocale.translation.sgettext
# Constants
#
#-------------------------------------------------------------------------
LOG = logging.getLogger(".Bookmarks")
WIKI_HELP_PAGE = '%s_-_Navigation' % URL_MANUAL_PAGE
WIKI_HELP_SEC = _('manual|Bookmarks')
@ -94,6 +94,14 @@ class Bookmarks :
self.connect_signals()
self.dbstate.connect('database-changed', self.db_changed)
# initialise attributes
self.namemodel = None
self.namemodel_cols = None
self.top = None
self.modified = None
self.response = None
self.namelist = None
def db_changed(self, data):
"""
Reconnect the signals on a database changed.
@ -155,7 +163,7 @@ class Bookmarks :
text.write('<placeholder name="GoToBook">')
for item in self.bookmarks.get():
try:
label, obj = self.make_label(item)
label, dummy_obj = self.make_label(item)
func = self.callback(item)
action_id = "BM:%s" % item
actions.append((action_id, None, label, None, None, func))
@ -173,9 +181,18 @@ class Bookmarks :
text.close()
def make_label(self, handle):
"""
Returns a (label, object) tuple appropriate to the type of the object
that the handle refers to. The label is a text for the object, e.g. the
object name.
"""
raise NotImplementedError
def callback(self, handle):
"""
Returns a unique call to a function with the associated handle. The
function that will be called is defined in the derived class
"""
raise NotImplementedError
def add(self, person_handle):
@ -276,7 +293,7 @@ class Bookmarks :
def delete_clicked(self, obj):
"""Remove the current selection from the list."""
store, the_iter = self.namemodel.get_selected()
dummy_store, the_iter = self.namemodel.get_selected()
if not the_iter:
return
row = self.namemodel.get_selected_row()
@ -308,6 +325,8 @@ class Bookmarks :
display_help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
class ListBookmarks(Bookmarks):
""" Derived class from which all the specific type bookmark handlers are in
turn derived"""
def __init__(self, dbstate, uistate, change_active):
self.change_active = change_active
@ -317,6 +336,7 @@ class ListBookmarks(Bookmarks):
return make_callback(handle, self.do_callback)
def do_callback(self, handle):
"""Callback routine"""
self.change_active(handle)
class PersonBookmarks(ListBookmarks):