Added svn properties and improved some code layout (mainly long lines).

svn: r17977
This commit is contained in:
Tim G L Lyons 2011-07-29 10:31:41 +00:00
parent 763bea26ec
commit f9df3503b2
16 changed files with 101 additions and 63 deletions

View File

@ -1,7 +1,6 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2002-2006 Donald N. Allingham
# Copyright (C) 2011 Tim G L Lyons
#
# This program is free software; you can redistribute it and/or modify
@ -19,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: _SourceSidebarFilter.py 17555 2011-05-24 20:31:54Z m_d_n $
# $Id$
#-------------------------------------------------------------------------
#

View File

@ -51,7 +51,8 @@ def gramps_upgrade_16(self):
self.set_total(length)
LOG.debug("self %s" % self)
LOG.debug("self.find_next_citation_gramps_id %s" % self.find_next_citation_gramps_id)
LOG.debug("self.find_next_citation_gramps_id %s" %
self.find_next_citation_gramps_id)
# ---------------------------------
# Modify Media
# ---------------------------------
@ -63,7 +64,8 @@ def gramps_upgrade_16(self):
(handle, gramps_id, path, mime, desc,
attribute_list, source_list, note_list, change,
date, tag_list, private) = media
new_citation_list = convert_sourceref_to_citation_15(self, source_list)
new_citation_list = convert_sourceref_to_citation_15(self,
source_list)
new_media = (handle, gramps_id, path, mime, desc,
attribute_list, source_list, note_list, change,
date, tag_list, new_citation_list, private)
@ -89,7 +91,8 @@ def convert_sourceref_to_citation_15(self, source_list):
# is not initialised properly. However I don't understand how this
# is ever initialised.
# Also, self.cmap_index does not seem to be initialised, but
# again I don't see how it is initialised for find_next_citation_gramps_id
# again I don't see how it is initialised for
# find_next_citation_gramps_id
# Should self.citation_map and/or cmap_index be committed to the
# database after being updated?
LOG.debug(" cmap_index %s" % self.cmap_index)
@ -119,7 +122,8 @@ def __find_next_gramps_id(self, prefix, map_index):
# used_ids = {}
# for handle in self.citation_map.keys()
# used_ids += self.citation_map[handle][1]
used_ids = (self.citation_map[handle][1] for handle in self.citation_map.keys())
used_ids = (self.citation_map[handle][1] for handle
in self.citation_map.keys())
for i in used_ids:
LOG.debug(" used_ids %s" % i)
while index in used_ids:

View File

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: src.py 16425 2011-01-21 16:27:54Z gbritton $
# $Id$
"""
Citation object for GRAMPS.

View File

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: notebase.py 15645 2010-07-22 02:16:32Z dsblank $
# $Id$
"""
CitationBase class for GRAMPS.
@ -49,8 +49,8 @@ class CitationBase(object):
from classes like MediaRef, which does have attributes (in that case,
privacy, sources, notes and attributes).
This class, together with the Citation class, replaces the old SourceRef class.
I.e. SourceRef = CitationBase + Citation
This class, together with the Citation class, replaces the old SourceRef
class. I.e. SourceRef = CitationBase + Citation
"""
def __init__(self, source=None):
"""
@ -75,9 +75,11 @@ class CitationBase(object):
def add_citation(self, handle):
"""
Add the :class:`~gen.lib.citation.Citation` handle to the list of citation handles.
Add the :class:`~gen.lib.citation.Citation` handle to the list of
citation handles.
:param handle: :class:`~gen.lib.citation.Citation` handle to add the list of citations
:param handle: :class:`~gen.lib.citation.Citation` handle to add the
list of citations
:type handle: str
:returns: True if handle was added, False if it already was in the list
@ -94,14 +96,17 @@ class CitationBase(object):
Remove the specified handle from the list of citation handles, and all
secondary child objects.
:param handle: :class:`~gen.lib.citation.Citation` handle to remove from the list of citations
:param handle: :class:`~gen.lib.citation.Citation` handle to remove
from the list of citations
:type handle: str
"""
LOG.debug('enter remove_citation handle %s' % handle)
if handle in self.citation_list:
LOG.debug('remove handle %s from citation_list %s' % (handle, self.citation_list))
LOG.debug('remove handle %s from citation_list %s' %
(handle, self.citation_list))
self.citation_list.remove(handle)
LOG.debug('get_citation_child_list %s' % self.get_citation_child_list())
LOG.debug('get_citation_child_list %s' %
self.get_citation_child_list())
for item in self.get_citation_child_list():
item.remove_citation(handle)
@ -121,7 +126,8 @@ class CitationBase(object):
def get_citation_list(self):
"""
Return the list of :class:`~gen.lib.citation.Citation` handles associated with the object.
Return the list of :class:`~gen.lib.citation.Citation` handles
associated with the object.
:returns: The list of :class:`~gen.lib.citation.Citation` handles
:rtype: list
@ -151,9 +157,11 @@ class CitationBase(object):
def set_citation_list(self, citation_list):
"""
Assign the passed list to be object's list of :class:`~gen.lib.citation.Citation` handles.
Assign the passed list to be object's list of
:class:`~gen.lib.citation.Citation` handles.
:param citation_list: List of :class:`~gen.lib.citation.Citation` handles to be set on the object
:param citation_list: List of :class:`~gen.lib.citation.Citation`
handles to be set on the object
:type citation_list: list
"""
self.citation_list = citation_list
@ -162,8 +170,8 @@ class CitationBase(object):
"""
Merge the list of citations from acquisition with our own.
:param acquisition: The citation list of this object will be merged with
the current citation list.
:param acquisition: The citation list of this object will be merged
with the current citation list.
:rtype acquisition: CitationBase
"""
for addendum in acquisition.citation_list:
@ -171,10 +179,12 @@ class CitationBase(object):
def get_referenced_citation_handles(self):
"""
Return the list of (classname, handle) tuples for all referenced citations.
Return the list of (classname, handle) tuples for all referenced
citations.
This method should be used to get the :class:`~gen.lib.citation.Citation` portion of the list
by objects that store citation lists.
This method should be used to get the
:class:`~gen.lib.citation.Citation` portion of the list by objects
that store citation lists.
:returns: List of (classname, handle) tuples for referenced objects.
:rtype: list

View File

@ -4,6 +4,7 @@
# Copyright (C) 2000-2007 Donald N. Allingham
# Copyright (C) 2010 Michiel D. Nauta
# Copyright (C) 2010 Nick Hall
# 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
@ -216,8 +217,9 @@ class MediaObject(SourceBase, CitationBase, NoteBase, DateBase, AttributeBase,
LOG.debug ("Media: %s get_handle_referents: %s" %
(self.desc,
self.attribute_list + self.source_list))
# FIXME: This is wrong, because it returns the handle, when it should return the
# citation object. This is probably because the citation unpack has not been done.
# FIXME: This is wrong, because it returns the handle, when it should return
# the citation object. This is probably because the citation unpack has not
# been done.
return self.attribute_list + self.source_list
def merge(self, acquisition):

View File

@ -1,7 +1,6 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2006 Donald N. Allingham
# Copyright (C) 2011 Tim G L Lyons
#
# This program is free software; you can redistribute it and/or modify
@ -19,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: sourcebackreflist.py 13821 2009-12-16 06:11:06Z pez4brian $
# $Id$
#-------------------------------------------------------------------------
#

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2007 Donald N. Allingham
# 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
@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: notetab.py 14091 2010-01-18 04:42:17Z pez4brian $
# $Id$
#-------------------------------------------------------------------------
#
@ -122,8 +122,8 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
def add_button_clicked(self, obj):
"""
Create a new Citation instance and call the EditCitation editor with the new
citation.
Create a new Citation instance and call the EditCitation editor with
the new citation.
Called when the Add button is clicked.
If the window already exists (Errors.WindowActiveError), we ignore it.
@ -167,8 +167,8 @@ class CitationEmbedList(EmbeddedList, DbGUIElement):
def edit_button_clicked(self, obj):
"""
Get the selected Citation instance and call the EditCitation editor with the
citation.
Get the selected Citation instance and call the EditCitation editor
with the citation.
Called when the Edit button is clicked.
If the window already exists (Errors.WindowActiveError), we ignore it.

View File

@ -18,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: notemodel.py 15597 2010-06-28 07:43:41Z ldnp $
# $Id$
#-------------------------------------------------------------------------
#

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2011 Tim G L Lyons, Nick Hall
#
# 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
@ -270,10 +270,10 @@ class EditCitation(EditPrimary):
self.track_ref_for_deletion("data_tab")
# FIXME: This needs to enable the shared Citation warning box
self.citationref_list = SourceBackRefList(self.dbstate,self.uistate, self.track,
self.citationref_list = SourceBackRefList(self.dbstate,self.uistate,
self.track,
self.db.find_backlink_handles(self.obj.handle),
self.enable_warnbox
)
self.enable_warnbox)
self._add_tab(notebook_ref, self.citationref_list)
self.track_ref_for_deletion("citationref_list")
@ -284,7 +284,8 @@ class EditCitation(EditPrimary):
self._add_tab(notebook_src, self.primtab)
self.note_tab = NoteTab(self.dbstate, self.uistate, self.track,
self.source.get_note_list(), self.get_menu_title(),
self.source.get_note_list(),
self.get_menu_title(),
notetype=gen.lib.NoteType.SOURCE)
self._add_tab(notebook_src, self.note_tab)
self.track_ref_for_deletion("note_tab")
@ -312,10 +313,10 @@ class EditCitation(EditPrimary):
# References to Source, because they will all be citations,
# and the Citations will be displayed in the top part of the
# edit dialogue.
self.srcref_list = SourceBackRefList(self.dbstate,self.uistate, self.track,
self.srcref_list = SourceBackRefList(self.dbstate,self.uistate,
self.track,
self.db.find_backlink_handles(self.source.handle),
self.enable_warnbox
)
self.enable_warnbox)
self._add_tab(notebook_src, self.srcref_list)
self.track_ref_for_deletion("srcref_list")

View File

@ -3,6 +3,7 @@
#
# Copyright (C) 2000-2006 Donald N. Allingham
# Copyright (C) 2009 Gary Burton
# 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
@ -224,14 +225,19 @@ class DeleteSrcQuery(object):
# we can have:
# object(CitationBase) -> Citation(RefBase) -> Source
# We first have to remove the
# We first have to remove the CitationBase references to the
# Citation. Then we remove the Citations. (We don't need to
# remove the RefBase references to the Source, because we are
# removing the whole Citation). Then we can emove the Source
(person_list, family_list, event_list, place_list, source_list,
media_list, repo_list, citation_list, citation_referents_list) = self.the_lists
media_list, repo_list, citation_list,
citation_referents_list) = self.the_lists
# (1) delete the references to the citation
for (citation_handle, refs) in citation_referents_list:
LOG.debug('delete citation %s references %s' % (citation_handle, refs))
LOG.debug('delete citation %s references %s' %
(citation_handle, refs))
(person_list, family_list, event_list, place_list, source_list,
media_list, repo_list) = refs

View File

@ -1,8 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2003-2006 Donald N. Allingham
# 2009 Gary Burton
# Copyright (C) 2011 Tim G L Lyons, Nick Hall
#
# 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
@ -19,7 +18,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: selectsource.py 14091 2010-01-18 04:42:17Z pez4brian $
# $Id$
#-------------------------------------------------------------------------
#

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2011 Tim G L Lyons, Nick Hall
#
# 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
@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id:_SourceModel.py 9912 2008-01-22 09:17:46Z acraphae $
# $Id$
#-------------------------------------------------------------------------
#
@ -230,7 +230,7 @@ class CitationListModel(CitationBaseModel, FlatBaseModel):
CitationBaseModel.__init__(self, db)
FlatBaseModel.__init__(self, db, scol, order, tooltip_column=12,
search=search, skip=skip, sort_map=sort_map)
search=search, skip=skip, sort_map=sort_map)
def destroy(self):
"""
@ -253,10 +253,10 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
CitationBaseModel.__init__(self, db)
TreeBaseModel.__init__(self, db, scol=scol, order=order,
tooltip_column=12,
search=search, skip=skip, sort_map=sort_map,
nrgroups = 1,
group_can_have_handle = True)
tooltip_column=12,
search=search, skip=skip, sort_map=sort_map,
nrgroups = 1,
group_can_have_handle = True)
def destroy(self):
"""
@ -311,6 +311,18 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
data The object data.
"""
source_handle = data[COLUMN_SOURCE]
if source_handle:
source = self.db.get_source_from_handle(source_handle)
if source:
source_name = source.get_title()
sort_key = self.sort_func(data)
# add as node: parent, child, sortkey, handle; parent and child are
# nodes in the treebasemodel, and will be used as iters
self.add_node(source_name, handle, sort_key, handle)
else:
log.warn("Citation %s still has a pointer (handle %s) "
"to a deleted source" %
(data[COLUMN_ID], source_handle))
source = self.db.get_source_from_handle(source_handle)
if source is not None:
source_name = source.get_title()
@ -322,6 +334,9 @@ class CitationTreeModel(CitationBaseModel, TreeBaseModel):
secondary=True)
self.add_node(source_handle, handle, sort_key, handle)
else:
log.warn("Citation %s does not have a source" %
unicode(data[COLUMN_PAGE]),
exc_info=True)
log.warn("Citation %s does not have a source" %
unicode(data[COLUMN_PAGE]), exc_info=True)

View File

@ -1,6 +1,6 @@
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2011 Tim G L Lyons
# Copyright (C) 2011 Tim G L Lyons, Nick Hall
#
# 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
@ -239,12 +239,12 @@ class BaseCitationView(ListView):
def add(self, obj):
SelectSource = SelectorFactory('Source')
sel = SelectSource(self.dbstate,self.uistate)
sel = SelectSource(self.dbstate, self.uistate)
source = sel.run()
if source:
try:
EditCitation(self.dbstate, self.uistate, [], gen.lib.Citation(),
source)
source)
except Errors.WindowActiveError:
from QuestionDialog import WarningDialog
WarningDialog(_("Cannot share this reference"),
@ -256,7 +256,8 @@ class BaseCitationView(ListView):
def remove_object_from_handle(self, handle):
the_lists = Utils.get_citation_referents(handle, self.dbstate.db)
object = self.dbstate.db.get_citation_from_handle(handle)
query = DeleteCitationQuery(self.dbstate, self.uistate, object, the_lists)
query = DeleteCitationQuery(self.dbstate, self.uistate, object,
the_lists)
is_used = any(the_lists)
return (query, is_used, object)

View File

@ -17,7 +17,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: sourceview.py 17447 2011-05-07 18:42:31Z nick-h $
# $Id$
"""
Citation List View

View File

@ -17,7 +17,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Id: placetreeview.py 14176 2010-02-01 07:01:45Z bmcage $
# $Id$
"""
Citation Tree View

View File

@ -2,6 +2,7 @@
#
# Copyright (C) 2001-2006 Donald N. Allingham
# Copyright (C) 2008 Gary Burton
# 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
@ -239,8 +240,9 @@ class SourceView(ListView):
(person_list, family_list, event_list, place_list, source_list,
media_list, repo_list, citation_list) = the_lists
the_lists = (person_list, family_list, event_list, place_list, source_list,
media_list, repo_list, citation_list, citation_referents_list)
the_lists = (person_list, family_list, event_list, place_list,
source_list, media_list, repo_list, citation_list,
citation_referents_list)
LOG.debug('the_lists %s' % [the_lists])