GEPS023: merge branch (changes 17960-18546) into trunk
svn: r18548
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2008 Brian G. Matherly
|
||||
# Copyright (C) 2010 Jakim Friant
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -33,6 +34,7 @@ from _pluginreg import (PluginData, PluginRegister, REPORT, TOOL,
|
||||
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
|
||||
CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
|
||||
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION,
|
||||
START, END, make_environment,
|
||||
)
|
||||
from _manager import BasePluginManager
|
||||
@@ -54,4 +56,5 @@ __all__ = [ "docbackend", "docgen", "menu", Plugin, PluginData,
|
||||
CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE,
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY, CATEGORY_QR_NOTE,
|
||||
CATEGORY_QR_DATE, PTYPE_STR, CATEGORY_QR_MEDIA,
|
||||
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION,
|
||||
START, END, make_environment]
|
||||
|
@@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2009 Benny Malengier
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -116,6 +117,8 @@ CATEGORY_QR_REPOSITORY = 5
|
||||
CATEGORY_QR_NOTE = 6
|
||||
CATEGORY_QR_DATE = 7
|
||||
CATEGORY_QR_MEDIA = 8
|
||||
CATEGORY_QR_CITATION = 9
|
||||
CATEGORY_QR_SOURCE_OR_CITATION = 10
|
||||
|
||||
# Modes for generating reports
|
||||
REPORT_MODE_GUI = 1 # Standalone report using GUI
|
||||
@@ -1009,6 +1012,8 @@ def make_environment(**kwargs):
|
||||
'CATEGORY_QR_FAMILY': CATEGORY_QR_FAMILY,
|
||||
'CATEGORY_QR_EVENT': CATEGORY_QR_EVENT,
|
||||
'CATEGORY_QR_SOURCE': CATEGORY_QR_SOURCE,
|
||||
'CATEGORY_QR_CITATION': CATEGORY_QR_CITATION,
|
||||
'CATEGORY_QR_SOURCE_OR_CITATION': CATEGORY_QR_SOURCE_OR_CITATION,
|
||||
'CATEGORY_QR_PLACE': CATEGORY_QR_PLACE,
|
||||
'CATEGORY_QR_MEDIA': CATEGORY_QR_MEDIA,
|
||||
'CATEGORY_QR_REPOSITORY': CATEGORY_QR_REPOSITORY,
|
||||
|
@@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2007 Brian G. Matherly
|
||||
# Copyright (C) 2010 Jakim Friant
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -25,7 +26,7 @@ Contain and organize bibliographic information.
|
||||
"""
|
||||
import string
|
||||
import math
|
||||
from gen.lib import SourceRef
|
||||
import gen.lib
|
||||
|
||||
class Citation(object):
|
||||
"""
|
||||
@@ -71,7 +72,7 @@ class Citation(object):
|
||||
add another one.
|
||||
|
||||
@param source_ref: Source Reference
|
||||
@type source_ref: L{gen.lib.srcref}
|
||||
@type source_ref: L{gen.lib.citation}
|
||||
@return: The key of the added reference among all the references.
|
||||
@rtype: char
|
||||
"""
|
||||
@@ -113,7 +114,7 @@ class Bibliography(object):
|
||||
def __init__(self, mode=MODE_ALL):
|
||||
"""
|
||||
A bibliography will store citations (sources) and references to those
|
||||
citations (source refs). Duplicate entries will not be added. To change
|
||||
citations (citations). Duplicate entries will not be added. To change
|
||||
what is considered duplicate, you can tell the bibliography what source
|
||||
ref information you are interested in by passing in the mode.
|
||||
|
||||
@@ -131,20 +132,28 @@ class Bibliography(object):
|
||||
self.__citation_list = []
|
||||
self.mode = mode
|
||||
|
||||
def add_reference(self, source_ref):
|
||||
def add_reference(self, lib_citation):
|
||||
"""
|
||||
Add a reference to a source to this bibliography. If the source already
|
||||
exists, don't add it again. If a similar reference exists, don't
|
||||
add another one.
|
||||
|
||||
@param source_ref: Source Reference
|
||||
@type source_ref: L{gen.lib.srcref}
|
||||
@param citation: Citation object
|
||||
@type citation: L{gen.lib.Citation}
|
||||
@return: A tuple containing the index of the source among all the
|
||||
sources and the key of the reference among all the references. If
|
||||
there is no reference information, the second element will be None.
|
||||
@rtype: (int,char) or (int,None)
|
||||
|
||||
N.B. Within this file, the name 'citation' is used both for
|
||||
gen.lib.Citation, and for _bibliography.Citation. It is not clear how
|
||||
best to rename the concepts in this file to avoid the clash, so the
|
||||
names have been retained. In this function, lib_citation is used for
|
||||
gen.lib.Citation instances, and citation for _bibliography.Citation
|
||||
instances. Elsewhere in this file, source_ref is used for
|
||||
gen.lib.Citation instances.
|
||||
"""
|
||||
source_handle = source_ref.get_reference_handle()
|
||||
source_handle = lib_citation.get_reference_handle()
|
||||
cindex = 0
|
||||
rkey = ""
|
||||
citation = None
|
||||
@@ -161,13 +170,13 @@ class Bibliography(object):
|
||||
cindex = len(self.__citation_list)
|
||||
self.__citation_list.append(citation)
|
||||
|
||||
if self.__sref_has_info(source_ref):
|
||||
if self.__sref_has_info(lib_citation):
|
||||
for key, ref in citation.get_ref_list():
|
||||
if self.__srefs_are_equal(ref, source_ref):
|
||||
if self.__srefs_are_equal(ref, lib_citation):
|
||||
# if a reference like this already exists, don't add
|
||||
# another one
|
||||
return (cindex, key)
|
||||
rkey = citation.add_reference(source_ref)
|
||||
rkey = citation.add_reference(lib_citation)
|
||||
|
||||
return (cindex, rkey)
|
||||
|
||||
@@ -203,7 +212,8 @@ class Bibliography(object):
|
||||
return True
|
||||
if ( self.mode & self.MODE_CONF ) == self.MODE_CONF:
|
||||
confidence = source_ref.get_confidence_level()
|
||||
if confidence is not None and confidence != SourceRef.CONF_NORMAL:
|
||||
if confidence is not None and confidence != \
|
||||
gen.lib.Citation.CONF_NORMAL:
|
||||
return True
|
||||
if ( self.mode & self.MODE_NOTE ) == self.MODE_NOTE:
|
||||
if len(source_ref.get_note_list()) != 0:
|
||||
@@ -216,8 +226,17 @@ class Bibliography(object):
|
||||
Determine if two source references are equal based on the
|
||||
current mode.
|
||||
"""
|
||||
# The criterion for equality (in mode==MODE_ALL) is changed for
|
||||
# citations. Previously, it was based on is_equal from SecondaryObject,
|
||||
# which does a 'cmp' on the serialised data. (Note that this might not
|
||||
# have worked properly for Dates; see comments in Date.is_equal and
|
||||
# EditCitation.data_has_changed). The comparison is now made as to
|
||||
# whether the two gen.lib.Citations have the same handle (i.e. they are
|
||||
# actually the same database objects). It is felt that this better
|
||||
# reflects the intent of Citation objects, which can be merged if they
|
||||
# are intended to represent the same citation.
|
||||
if self.mode == self.MODE_ALL:
|
||||
return source_ref1.is_equal(source_ref2)
|
||||
return source_ref1.handle == source_ref2.handle
|
||||
if ( self.mode & self.MODE_PAGE ) == self.MODE_PAGE:
|
||||
if source_ref1.get_page() != source_ref2.get_page():
|
||||
return False
|
||||
|
@@ -5,6 +5,7 @@
|
||||
# Copyright (C) 2010 Peter Landgren
|
||||
# Copyright (C) 2010 Jakim Friant
|
||||
# Copyright (C) 2011 Adam Stein <adam@csh.rit.edu>
|
||||
# Copyright (C) 2011 Tim G L Lyons
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -26,7 +27,7 @@
|
||||
Provide utilities for printing endnotes in text reports.
|
||||
"""
|
||||
from gen.plug.docgen import FontStyle, ParagraphStyle, FONT_SANS_SERIF
|
||||
from gen.lib import NoteType, SourceRef
|
||||
from gen.lib import NoteType, Citation
|
||||
from gen.ggettext import gettext as _
|
||||
from Utils import confidence
|
||||
from DateHandler import displayer
|
||||
@@ -76,24 +77,25 @@ def add_endnote_styles(style_sheet):
|
||||
para.set_description(_('The basic style used for the endnotes reference notes display.'))
|
||||
style_sheet.add_paragraph_style("Endnotes-Ref-Notes", para)
|
||||
|
||||
def cite_source(bibliography, obj):
|
||||
def cite_source(bibliography, database, obj):
|
||||
"""
|
||||
Cite any sources for the object and add them to the bibliography.
|
||||
|
||||
@param bibliography: The bibliography to contain the citations.
|
||||
@type bibliography: L{Bibliography}
|
||||
@param obj: An object with source references.
|
||||
@type obj: L{gen.lib.srcbase}
|
||||
@type obj: L{gen.lib.CitationBase}
|
||||
"""
|
||||
txt = ""
|
||||
slist = obj.get_source_references()
|
||||
slist = obj.get_citation_list()
|
||||
if slist:
|
||||
first = 1
|
||||
for ref in slist:
|
||||
if not first:
|
||||
txt += ', '
|
||||
first = 0
|
||||
(cindex, key) = bibliography.add_reference(ref)
|
||||
citation = database.get_citation_from_handle(ref)
|
||||
(cindex, key) = bibliography.add_reference(citation)
|
||||
txt += "%d" % (cindex + 1)
|
||||
if key is not None:
|
||||
txt += key
|
||||
@@ -186,7 +188,7 @@ def _format_ref_text(ref, key):
|
||||
ref_txt = ref.get_page()
|
||||
|
||||
# Print only confidence level if it is not Normal
|
||||
if ref.get_confidence_level() != SourceRef.CONF_NORMAL:
|
||||
if ref.get_confidence_level() != Citation.CONF_NORMAL:
|
||||
ref_txt += " [" + confidence[ref.get_confidence_level()] + "]"
|
||||
|
||||
return ref_txt
|
||||
|
Reference in New Issue
Block a user