pylint and coherency on Repository references

svn: r11799
This commit is contained in:
Jérôme Rapinat 2009-02-02 14:27:40 +00:00
parent a4ce178893
commit 1ecbaae622
2 changed files with 47 additions and 35 deletions

View File

@ -24,7 +24,7 @@ Display references for any object
""" """
from ReportBase import (CATEGORY_QR_SOURCE, CATEGORY_QR_PERSON, from ReportBase import (CATEGORY_QR_SOURCE, CATEGORY_QR_PERSON,
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT,
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY) CATEGORY_QR_PLACE)
from Simple import SimpleAccess, SimpleDoc, SimpleTable from Simple import SimpleAccess, SimpleDoc, SimpleTable
from gettext import gettext as _ from gettext import gettext as _
@ -32,7 +32,7 @@ from gen.plug import PluginManager
# mention so that will be translated for below # mention so that will be translated for below
[_('Person'), _('Family'), _('Event'), _('Source'), [_('Person'), _('Family'), _('Event'), _('Source'),
_('Place'), _('Repository')] _('Place')]
def get_ref(db, objclass, handle): def get_ref(db, objclass, handle):
""" """
@ -48,8 +48,6 @@ def get_ref(db, objclass, handle):
ref = db.get_source_from_handle(handle) ref = db.get_source_from_handle(handle)
elif objclass == 'Place': elif objclass == 'Place':
ref = db.get_place_from_handle(handle) ref = db.get_place_from_handle(handle)
elif objclass == 'Repository':
ref = db.get_repository_from_handle(handle)
else: else:
ref = objclass ref = objclass
return ref return ref
@ -91,7 +89,6 @@ refitems = [(CATEGORY_QR_PERSON, 'person', _("Person")),
(CATEGORY_QR_EVENT, 'event', _("Event")), (CATEGORY_QR_EVENT, 'event', _("Event")),
(CATEGORY_QR_SOURCE, 'source', _("Source")), (CATEGORY_QR_SOURCE, 'source', _("Source")),
(CATEGORY_QR_PLACE, 'place', _("Place")), (CATEGORY_QR_PLACE, 'place', _("Place")),
(CATEGORY_QR_REPOSITORY, 'repository', _("Repository")),
] ]
pmgr = PluginManager.get_instance() pmgr = PluginManager.get_instance()

View File

@ -1,3 +1,5 @@
#!/usr/bin/python
# -*- coding: utf-8 -*-
# #
# Gramps - a GTK+/GNOME based genealogy program # Gramps - a GTK+/GNOME based genealogy program
# #
@ -19,58 +21,71 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# #
"""
Display RepoRef for sources related to active repository
"""
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# #
# gramps modules # gramps modules
# #
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
from Simple import SimpleAccess, SimpleDoc, SimpleTable """
Display RepoRef for sources related to active repository
"""
from Simple import SimpleDoc
from gettext import gettext as _ from gettext import gettext as _
from gen.plug import PluginManager from gen.plug import PluginManager
from ReportBase import CATEGORY_QR_REPOSITORY from ReportBase import CATEGORY_QR_REPOSITORY
import gen.lib import gen.lib
def run(database, document, repo): def run(database, document, repo):
sa = SimpleAccess(database)
sdoc = SimpleDoc(document) sdoc = SimpleDoc(document)
# First we find repository and add its text # First we find repository and add its text
sdoc.title("%s\n" % repo.get_name())
sdoc.title('%s\n' % repo.get_name())
# Go over all the sources that refer to this repository # Go over all the sources that refer to this repository
repo_handle = repo.handle repo_handle = repo.handle
source_list = [item[1] for item in database.find_backlink_handles(repo_handle,['Source'])] source_list = [item[1] for item in
database.find_backlink_handles(repo_handle, ['Source'
])]
for source_handle in source_list: for source_handle in source_list:
src = database.get_source_from_handle(source_handle) src = database.get_source_from_handle(source_handle)
# Get the list of references from this source to our repo # Get the list of references from this source to our repo
# (can be more than one, technically) # (can be more than one, technically)
for reporef in src.get_reporef_list(): for reporef in src.get_reporef_list():
if reporef.ref == repo_handle: if reporef.ref == repo_handle:
# Determine the text for this source # Determine the text for this source
mt = str(reporef.get_media_type())
cn = reporef.get_call_number() media = str(reporef.get_media_type())
sdoc.paragraph("%s, %s" % (mt, cn)) call = reporef.get_call_number()
sdoc.paragraph("%s\n" % src.get_title()) sdoc.paragraph('%s, %s' % (media, call))
sdoc.paragraph('%s\n' % src.get_title())
else: else:
continue continue
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
# #
# #
# #
# ------------------------------------------------------------------------ # ------------------------------------------------------------------------
pmgr = PluginManager.get_instance() pmgr = PluginManager.get_instance()
pmgr.register_quick_report( pmgr.register_quick_report(
name='RepoRef', name='RepoRef',
category=CATEGORY_QR_REPOSITORY, category=CATEGORY_QR_REPOSITORY,
run_func=run, run_func=run,
translated_name = _("RepoRef"), translated_name=_('RepoRef'),
status = _("Beta"), status=_('Beta'),
description= _("Display RepoRef for sources related to active repository"), description=_('Display RepoRef for sources related to active repository'
),
) )