Pylint improvements: bookmarks.py
This commit is contained in:
parent
a7ea1d98b4
commit
c817b0dedc
@ -34,7 +34,6 @@ from io import StringIO
|
|||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
import logging
|
import logging
|
||||||
log = logging.getLogger(".Bookmarks")
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
@ -60,6 +59,7 @@ _ = glocale.translation.sgettext
|
|||||||
# Constants
|
# Constants
|
||||||
#
|
#
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
|
LOG = logging.getLogger(".Bookmarks")
|
||||||
WIKI_HELP_PAGE = '%s_-_Navigation' % URL_MANUAL_PAGE
|
WIKI_HELP_PAGE = '%s_-_Navigation' % URL_MANUAL_PAGE
|
||||||
WIKI_HELP_SEC = _('manual|Bookmarks')
|
WIKI_HELP_SEC = _('manual|Bookmarks')
|
||||||
|
|
||||||
@ -94,6 +94,14 @@ class Bookmarks :
|
|||||||
self.connect_signals()
|
self.connect_signals()
|
||||||
self.dbstate.connect('database-changed', self.db_changed)
|
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):
|
def db_changed(self, data):
|
||||||
"""
|
"""
|
||||||
Reconnect the signals on a database changed.
|
Reconnect the signals on a database changed.
|
||||||
@ -155,7 +163,7 @@ class Bookmarks :
|
|||||||
text.write('<placeholder name="GoToBook">')
|
text.write('<placeholder name="GoToBook">')
|
||||||
for item in self.bookmarks.get():
|
for item in self.bookmarks.get():
|
||||||
try:
|
try:
|
||||||
label, obj = self.make_label(item)
|
label, dummy_obj = self.make_label(item)
|
||||||
func = self.callback(item)
|
func = self.callback(item)
|
||||||
action_id = "BM:%s" % item
|
action_id = "BM:%s" % item
|
||||||
actions.append((action_id, None, label, None, None, func))
|
actions.append((action_id, None, label, None, None, func))
|
||||||
@ -173,9 +181,18 @@ class Bookmarks :
|
|||||||
text.close()
|
text.close()
|
||||||
|
|
||||||
def make_label(self, handle):
|
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
|
raise NotImplementedError
|
||||||
|
|
||||||
def callback(self, handle):
|
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
|
raise NotImplementedError
|
||||||
|
|
||||||
def add(self, person_handle):
|
def add(self, person_handle):
|
||||||
@ -276,7 +293,7 @@ class Bookmarks :
|
|||||||
|
|
||||||
def delete_clicked(self, obj):
|
def delete_clicked(self, obj):
|
||||||
"""Remove the current selection from the list."""
|
"""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:
|
if not the_iter:
|
||||||
return
|
return
|
||||||
row = self.namemodel.get_selected_row()
|
row = self.namemodel.get_selected_row()
|
||||||
@ -308,6 +325,8 @@ class Bookmarks :
|
|||||||
display_help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
|
display_help(webpage=WIKI_HELP_PAGE, section=WIKI_HELP_SEC)
|
||||||
|
|
||||||
class ListBookmarks(Bookmarks):
|
class ListBookmarks(Bookmarks):
|
||||||
|
""" Derived class from which all the specific type bookmark handlers are in
|
||||||
|
turn derived"""
|
||||||
|
|
||||||
def __init__(self, dbstate, uistate, change_active):
|
def __init__(self, dbstate, uistate, change_active):
|
||||||
self.change_active = change_active
|
self.change_active = change_active
|
||||||
@ -317,6 +336,7 @@ class ListBookmarks(Bookmarks):
|
|||||||
return make_callback(handle, self.do_callback)
|
return make_callback(handle, self.do_callback)
|
||||||
|
|
||||||
def do_callback(self, handle):
|
def do_callback(self, handle):
|
||||||
|
"""Callback routine"""
|
||||||
self.change_active(handle)
|
self.change_active(handle)
|
||||||
|
|
||||||
class PersonBookmarks(ListBookmarks):
|
class PersonBookmarks(ListBookmarks):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user