GEPS023: merge branch (changes 17960-18546) into trunk
svn: r18548
This commit is contained in:
commit
c833073ba6
@ -128,6 +128,7 @@ src/Filters/Rules/Place/Makefile
|
||||
src/Filters/Rules/MediaObject/Makefile
|
||||
src/Filters/Rules/Repository/Makefile
|
||||
src/Filters/Rules/Note/Makefile
|
||||
src/Filters/Rules/Citation/Makefile
|
||||
src/Filters/SideBar/Makefile
|
||||
src/Simple/Makefile
|
||||
src/GrampsLocale/Makefile
|
||||
|
@ -1,9 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2001 Graham J. Williams
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Nick Hall
|
||||
# Copyright (C) 2010-2011 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
|
||||
@ -23,15 +25,15 @@
|
||||
-->
|
||||
|
||||
<!--
|
||||
This is the Document Type Definition file for v1.4.0
|
||||
This is the Document Type Definition file for v1.5.0
|
||||
of the GRAMPS XML genealogy data format.
|
||||
Please use the following formal public identifier to identify it:
|
||||
|
||||
"-//GRAMPS//DTD GRAMPS XML V1.4.0//EN"
|
||||
"-//GRAMPS//DTD GRAMPS XML V1.5.0//EN"
|
||||
|
||||
For example:
|
||||
<!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.4.0//EN"
|
||||
"http://gramps-project.org/xml/1.4.0/grampsxml.dtd"
|
||||
<!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.5.0//EN"
|
||||
"http://gramps-project.org/xml/1.5.0/grampsxml.dtd"
|
||||
[...]>
|
||||
-->
|
||||
|
||||
@ -46,6 +48,7 @@ DATABASE
|
||||
families
|
||||
events
|
||||
places
|
||||
citations
|
||||
sources
|
||||
objects
|
||||
repositories
|
||||
@ -56,10 +59,10 @@ DATABASE
|
||||
tags
|
||||
-->
|
||||
|
||||
<!ELEMENT database (header, name-formats?, tags?, events?, people?,
|
||||
families?, sources?, places?, objects?,
|
||||
repositories?, notes?, bookmarks?, namemaps?)>
|
||||
<!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.4.0/">
|
||||
<!ELEMENT database (header, name-formats?, tags?, events?, people?, families?,
|
||||
citations?, sources?, places?, objects?, repositories?,
|
||||
notes?, bookmarks?, namemaps?)>
|
||||
<!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.5.0/">
|
||||
|
||||
|
||||
<!-- ************************************************************
|
||||
@ -104,7 +107,7 @@ PEOPLE
|
||||
|
||||
<!ELEMENT person (gender, name*, eventref*, lds_ord*,
|
||||
objref*, address*, attribute*, url*, childof*,
|
||||
parentin*, personref*, noteref*, sourceref*, tagref*)>
|
||||
parentin*, personref*, noteref*, citationref*, tagref*)>
|
||||
<!ATTLIST person
|
||||
id CDATA #IMPLIED
|
||||
handle ID #REQUIRED
|
||||
@ -118,7 +121,7 @@ GENDER has values of M, F, or U.
|
||||
<!ELEMENT gender (#PCDATA)>
|
||||
|
||||
<!ELEMENT name (first?, call?, surname*, suffix?, title?, nick?, familynick?, group?,
|
||||
(daterange|datespan|dateval|datestr)?, noteref*, sourceref*)>
|
||||
(daterange|datespan|dateval|datestr)?, noteref*, citationref*)>
|
||||
<!ATTLIST name
|
||||
alt (0|1) #IMPLIED
|
||||
type CDATA #IMPLIED
|
||||
@ -149,7 +152,7 @@ GENDER has values of M, F, or U.
|
||||
<!ELEMENT parentin EMPTY>
|
||||
<!ATTLIST parentin hlink IDREF #REQUIRED>
|
||||
|
||||
<!ELEMENT personref (sourceref*, noteref*)>
|
||||
<!ELEMENT personref (citationref*, noteref*)>
|
||||
<!ATTLIST personref
|
||||
hlink IDREF #REQUIRED
|
||||
priv (0|1) #IMPLIED
|
||||
@ -157,8 +160,8 @@ GENDER has values of M, F, or U.
|
||||
>
|
||||
|
||||
<!ELEMENT address ((daterange|datespan|dateval|datestr)?, street?,
|
||||
locality?, city?, county?, state?, country?, postal?,
|
||||
phone?, noteref*, sourceref*)>
|
||||
locality?, city?, county?, state?, country?, postal?,
|
||||
phone?, noteref*,citationref*)>
|
||||
<!ATTLIST address priv (0|1) #IMPLIED>
|
||||
|
||||
<!ELEMENT street (#PCDATA)>
|
||||
@ -179,7 +182,7 @@ FAMILY
|
||||
<!ELEMENT families (family)*>
|
||||
|
||||
<!ELEMENT family (rel?, father?, mother?, eventref*, lds_ord*, objref*,
|
||||
childref*, attribute*, noteref*, sourceref*, tagref*)>
|
||||
childref*, attribute*, noteref*, citationref*, tagref*)>
|
||||
<!ATTLIST family
|
||||
id CDATA #IMPLIED
|
||||
handle ID #REQUIRED
|
||||
@ -193,7 +196,7 @@ FAMILY
|
||||
<!ELEMENT mother EMPTY>
|
||||
<!ATTLIST mother hlink IDREF #REQUIRED>
|
||||
|
||||
<!ELEMENT childref (sourceref*,noteref*)>
|
||||
<!ELEMENT childref (citationref*,noteref*)>
|
||||
<!ATTLIST childref
|
||||
hlink IDREF #REQUIRED
|
||||
priv (0|1) #IMPLIED
|
||||
@ -212,7 +215,7 @@ EVENT
|
||||
<!ELEMENT events (event)*>
|
||||
|
||||
<!ELEMENT event (type?, (daterange|datespan|dateval|datestr)?, place?, cause?,
|
||||
description?, attribute*, noteref*, sourceref*, objref*)>
|
||||
description?, attribute*, noteref*, citationref*, objref*)>
|
||||
<!ATTLIST event
|
||||
id CDATA #IMPLIED
|
||||
handle ID #REQUIRED
|
||||
@ -245,7 +248,7 @@ PLACES
|
||||
<!ELEMENT places (placeobj)*>
|
||||
|
||||
<!ELEMENT placeobj (ptitle?, coord?, location*, objref*, url*, noteref*,
|
||||
sourceref*)>
|
||||
citationref*)>
|
||||
<!ATTLIST placeobj
|
||||
id CDATA #IMPLIED
|
||||
handle ID #REQUIRED
|
||||
@ -281,7 +284,7 @@ OBJECTS
|
||||
<!ELEMENT objects (object)*>
|
||||
|
||||
<!ELEMENT object (file, attribute*, noteref*,
|
||||
(daterange|datespan|dateval|datestr)?, sourceref*, tagref*)>
|
||||
(daterange|datespan|dateval|datestr)?, citationref*, tagref*)>
|
||||
<!ATTLIST object
|
||||
id CDATA #IMPLIED
|
||||
handle ID #REQUIRED
|
||||
@ -358,6 +361,21 @@ TAGS
|
||||
change CDATA #REQUIRED
|
||||
>
|
||||
|
||||
<!-- ************************************************************
|
||||
CITATIONS
|
||||
-->
|
||||
|
||||
<!ELEMENT citations (citation)*>
|
||||
|
||||
<!ELEMENT citation ((daterange|datespan|dateval|datestr)?, page?, confidence?,
|
||||
noteref*, objref*, data_item*, sourceref)>
|
||||
<!ATTLIST citation
|
||||
id CDATA #IMPLIED
|
||||
handle ID #REQUIRED
|
||||
priv (0|1) #IMPLIED
|
||||
change CDATA #REQUIRED
|
||||
>
|
||||
|
||||
<!-- ************************************************************
|
||||
BOOKMARKS
|
||||
-->
|
||||
@ -430,11 +448,14 @@ SHARED ELEMENTS
|
||||
<!ELEMENT datestr EMPTY>
|
||||
<!ATTLIST datestr val CDATA #REQUIRED>
|
||||
|
||||
<!ELEMENT sourceref (spage? ,noteref*, (daterange|datespan|dateval|datestr)?)>
|
||||
<!ELEMENT citationref EMPTY>
|
||||
<!ATTLIST citationref
|
||||
hlink IDREF #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT sourceref EMPTY>
|
||||
<!ATTLIST sourceref
|
||||
hlink IDREF #REQUIRED
|
||||
priv (0|1) #IMPLIED
|
||||
conf CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT eventref (attribute*, noteref*)>
|
||||
@ -462,9 +483,10 @@ SHARED ELEMENTS
|
||||
hlink IDREF #REQUIRED
|
||||
>
|
||||
|
||||
<!ELEMENT spage (#PCDATA)>
|
||||
<!ELEMENT page (#PCDATA)>
|
||||
<!ELEMENT confidence (#PCDATA)>
|
||||
|
||||
<!ELEMENT attribute (sourceref*, noteref*)>
|
||||
<!ELEMENT attribute (citationref*, noteref*)>
|
||||
<!ATTLIST attribute
|
||||
priv (0|1) #IMPLIED
|
||||
type CDATA #REQUIRED
|
||||
@ -485,7 +507,7 @@ SHARED ELEMENTS
|
||||
description CDATA #IMPLIED
|
||||
>
|
||||
|
||||
<!ELEMENT objref (region?, attribute*, sourceref*, noteref*)>
|
||||
<!ELEMENT objref (region?, attribute*, citationref*, noteref*)>
|
||||
<!ATTLIST objref
|
||||
hlink IDREF #REQUIRED
|
||||
priv (0|1) #IMPLIED
|
||||
@ -506,7 +528,7 @@ SHARED ELEMENTS
|
||||
>
|
||||
|
||||
<!ELEMENT lds_ord ((daterange|datespan|dateval|datestr)?, temple?, place?,
|
||||
status?, sealed_to?, noteref*, sourceref*)>
|
||||
status?, sealed_to?, noteref*, citationref*)>
|
||||
<!ATTLIST lds_ord
|
||||
priv (0|1) #IMPLIED
|
||||
type CDATA #REQUIRED
|
||||
|
@ -4,7 +4,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2005-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Nick Hall
|
||||
# Copyright (C) 2010-2011 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
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
<grammar
|
||||
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
|
||||
ns="http://gramps-project.org/xml/1.4.0/"
|
||||
ns="http://gramps-project.org/xml/1.5.0/"
|
||||
xmlns="http://relaxng.org/ns/structure/1.0">
|
||||
|
||||
<start><element name="database">
|
||||
@ -87,6 +87,12 @@
|
||||
</element></zeroOrMore>
|
||||
</element></optional>
|
||||
|
||||
<optional><element name="citations">
|
||||
<zeroOrMore><element name="citation">
|
||||
<ref name="citation-content"/>
|
||||
</element></zeroOrMore>
|
||||
</element></optional>
|
||||
|
||||
<optional><element name="sources">
|
||||
<zeroOrMore><element name="source">
|
||||
<ref name="source-content"/>
|
||||
@ -196,8 +202,8 @@
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="tagref">
|
||||
<ref name="tagref-content"/>
|
||||
@ -248,8 +254,8 @@
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
</define>
|
||||
|
||||
@ -293,8 +299,8 @@
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
</define>
|
||||
|
||||
@ -380,8 +386,8 @@
|
||||
<optional><attribute name="frel">
|
||||
<ref name="child-rel"/>
|
||||
</attribute></optional>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
@ -394,8 +400,8 @@
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<optional><ref name="date-content"/></optional>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="tagref">
|
||||
<ref name="tagref-content"/>
|
||||
@ -416,14 +422,34 @@
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="objref">
|
||||
<ref name="objref-content"/>
|
||||
</element></zeroOrMore>
|
||||
</define>
|
||||
|
||||
<define name="citation-content">
|
||||
<ref name="primary-object"/>
|
||||
<optional><ref name="date-content"/></optional>
|
||||
<optional><element name="page"><text/></element></optional>
|
||||
<optional><element name="confidence"><text/></element></optional>
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="objref">
|
||||
<ref name="objref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="data_item">
|
||||
<attribute name="key"><text/></attribute>
|
||||
<attribute name="value"><text/></attribute>
|
||||
</element></zeroOrMore>
|
||||
<element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
</element>
|
||||
</define>
|
||||
|
||||
<define name="source-content">
|
||||
<ref name="primary-object"/>
|
||||
<optional><element name="stitle"><text/></element></optional>
|
||||
@ -472,8 +498,8 @@
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
</define>
|
||||
|
||||
@ -491,8 +517,8 @@
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<optional><ref name="date-content"/></optional>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="tagref">
|
||||
<ref name="tagref-content"/>
|
||||
@ -581,33 +607,14 @@
|
||||
</element></zeroOrMore>
|
||||
</define>
|
||||
|
||||
<define name="personref-content">
|
||||
<define name="citationref-content">
|
||||
<attribute name="hlink"><data type="IDREF"/></attribute>
|
||||
<optional><attribute name="priv">
|
||||
<ref name="priv-content"/>
|
||||
</attribute></optional>
|
||||
<attribute name="rel"><text/></attribute>
|
||||
<optional><zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
</element></zeroOrMore></optional>
|
||||
<optional><zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore></optional>
|
||||
</define>
|
||||
|
||||
|
||||
<define name="sourceref-content">
|
||||
<attribute name="hlink"><data type="IDREF"/></attribute>
|
||||
<optional><attribute name="priv">
|
||||
<ref name="priv-content"/>
|
||||
</attribute></optional>
|
||||
<optional><attribute name="conf"><text/></attribute></optional>
|
||||
<optional><element name="spage"><text/></element></optional>
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<optional><ref name="date-content"/></optional>
|
||||
</define>
|
||||
|
||||
|
||||
<define name="eventref-content">
|
||||
<attribute name="hlink"><data type="IDREF"/></attribute>
|
||||
<optional><attribute name="priv">
|
||||
@ -651,8 +658,8 @@
|
||||
</attribute></optional>
|
||||
<attribute name="type"><text/></attribute>
|
||||
<attribute name="value"><text/></attribute>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
@ -679,8 +686,8 @@
|
||||
<zeroOrMore><element name="attribute">
|
||||
<ref name="attribute-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<zeroOrMore><element name="noteref">
|
||||
<ref name="noteref-content"/>
|
||||
@ -709,8 +716,8 @@
|
||||
<ref name="noteref-content"/>
|
||||
</element></zeroOrMore>
|
||||
<optional><ref name="date-content"/></optional>
|
||||
<zeroOrMore><element name="sourceref">
|
||||
<ref name="sourceref-content"/>
|
||||
<zeroOrMore><element name="citationref">
|
||||
<ref name="citationref-content"/>
|
||||
</element></zeroOrMore>
|
||||
</define>
|
||||
|
||||
|
@ -99,6 +99,7 @@ src/gui/editors/objectentries.py
|
||||
src/gui/editors/editaddress.py
|
||||
src/gui/editors/editattribute.py
|
||||
src/gui/editors/editchildref.py
|
||||
src/gui/editors/editcitation.py
|
||||
src/gui/editors/editevent.py
|
||||
src/gui/editors/editeventref.py
|
||||
src/gui/editors/editfamily.py
|
||||
@ -116,7 +117,6 @@ src/gui/editors/editprimary.py
|
||||
src/gui/editors/editreporef.py
|
||||
src/gui/editors/editrepository.py
|
||||
src/gui/editors/editsource.py
|
||||
src/gui/editors/editsourceref.py
|
||||
src/gui/editors/editurl.py
|
||||
|
||||
# gui/editors/displaytabs - the GUI display tabs package
|
||||
@ -125,6 +125,7 @@ src/gui/editors/displaytabs/attrembedlist.py
|
||||
src/gui/editors/displaytabs/backreflist.py
|
||||
src/gui/editors/displaytabs/backrefmodel.py
|
||||
src/gui/editors/displaytabs/buttontab.py
|
||||
src/gui/editors/displaytabs/citationembedlist.py
|
||||
src/gui/editors/displaytabs/dataembedlist.py
|
||||
src/gui/editors/displaytabs/embeddedlist.py
|
||||
src/gui/editors/displaytabs/eventembedlist.py
|
||||
@ -139,7 +140,6 @@ src/gui/editors/displaytabs/notetab.py
|
||||
src/gui/editors/displaytabs/personeventembedlist.py
|
||||
src/gui/editors/displaytabs/personrefembedlist.py
|
||||
src/gui/editors/displaytabs/repoembedlist.py
|
||||
src/gui/editors/displaytabs/sourceembedlist.py
|
||||
src/gui/editors/displaytabs/surnametab.py
|
||||
src/gui/editors/displaytabs/webembedlist.py
|
||||
|
||||
@ -156,6 +156,7 @@ src/gui/plug/report/_styleeditor.py
|
||||
src/gui/plug/tool.py
|
||||
|
||||
# gui/selectors - the GUI selectors package
|
||||
src/gui/selectors/selectcitation.py
|
||||
src/gui/selectors/selectevent.py
|
||||
src/gui/selectors/selectfamily.py
|
||||
src/gui/selectors/selectnote.py
|
||||
@ -172,6 +173,7 @@ src/gui/views/pageview.py
|
||||
src/gui/views/tags.py
|
||||
|
||||
# gui/views/treemodels - the GUI views package
|
||||
src/gui/views/treemodels/citationtreemodel.py
|
||||
src/gui/views/treemodels/mediamodel.py
|
||||
src/gui/views/treemodels/peoplemodel.py
|
||||
src/gui/views/treemodels/placemodel.py
|
||||
@ -197,6 +199,7 @@ src/Simple/_SimpleTable.py
|
||||
src/config.py
|
||||
|
||||
# Merge package
|
||||
src/Merge/mergecitation.py
|
||||
src/Merge/mergeevent.py
|
||||
src/Merge/mergefamily.py
|
||||
src/Merge/mergemedia.py
|
||||
@ -264,6 +267,7 @@ src/plugins/gramplet/Backlinks.py
|
||||
src/plugins/gramplet/bottombar.gpr.py
|
||||
src/plugins/gramplet/CalendarGramplet.py
|
||||
src/plugins/gramplet/Children.py
|
||||
src/plugins/gramplet/Citations.py
|
||||
src/plugins/gramplet/DescendGramplet.py
|
||||
src/plugins/gramplet/EditExifMetadata.py
|
||||
src/plugins/gramplet/Events.py
|
||||
@ -271,17 +275,18 @@ src/plugins/gramplet/FanChartGramplet.py
|
||||
src/plugins/gramplet/FaqGramplet.py
|
||||
src/plugins/gramplet/GivenNameGramplet.py
|
||||
src/plugins/gramplet/gramplet.gpr.py
|
||||
src/plugins/gramplet/MetadataViewer.py
|
||||
#src/plugins/gramplet/MetadataViewer.py
|
||||
src/plugins/gramplet/Notes.py
|
||||
src/plugins/gramplet/PedigreeGramplet.py
|
||||
src/plugins/gramplet/PersonDetails.py
|
||||
src/plugins/gramplet/PersonResidence.py
|
||||
src/plugins/gramplet/PlaceDetails.py
|
||||
src/plugins/gramplet/PopulateGramplet.py
|
||||
src/plugins/gramplet/PopulateGramplet.gpr.py
|
||||
src/plugins/gramplet/QuickViewGramplet.py
|
||||
src/plugins/gramplet/RelativeGramplet.py
|
||||
src/plugins/gramplet/RepositoryDetails.py
|
||||
src/plugins/gramplet/SessionLogGramplet.py
|
||||
src/plugins/gramplet/Sources.py
|
||||
src/plugins/gramplet/StatsGramplet.py
|
||||
src/plugins/gramplet/SurnameCloudGramplet.py
|
||||
src/plugins/gramplet/ToDoGramplet.py
|
||||
@ -382,6 +387,7 @@ src/plugins/tool/ExtractCity.py
|
||||
src/plugins/tool/FindDupes.py
|
||||
src/plugins/tool/Leak.py
|
||||
src/plugins/tool/MediaManager.py
|
||||
src/plugins/tool/MergeCitations.py
|
||||
src/plugins/tool/NotRelated.py
|
||||
src/plugins/tool/OwnerEditor.py
|
||||
src/plugins/tool/PatchNames.py
|
||||
@ -396,6 +402,8 @@ src/plugins/tool/tools.gpr.py
|
||||
src/plugins/tool/Verify.py
|
||||
|
||||
#plugins/view directory
|
||||
src/plugins/view/citationtreeview.py
|
||||
src/plugins/view/citationlistview.py
|
||||
src/plugins/view/eventview.py
|
||||
src/plugins/view/familyview.py
|
||||
src/plugins/view/fanchartview.py
|
||||
@ -456,6 +464,7 @@ src/Filters/Rules/Person/_HasAlternateName.py
|
||||
src/Filters/Rules/Person/_HasAssociation.py
|
||||
src/Filters/Rules/Person/_HasAttribute.py
|
||||
src/Filters/Rules/Person/_HasBirth.py
|
||||
src/Filters/Rules/Person/_HasCitation.py
|
||||
src/Filters/Rules/Person/_HasCommonAncestorWithFilterMatch.py
|
||||
src/Filters/Rules/Person/_HasCommonAncestorWith.py
|
||||
src/Filters/Rules/Person/_HasDeath.py
|
||||
@ -473,7 +482,7 @@ src/Filters/Rules/Person/_HasNote.py
|
||||
src/Filters/Rules/Person/_HasNoteMatchingSubstringOf.py
|
||||
src/Filters/Rules/Person/_HasNoteRegexp.py
|
||||
src/Filters/Rules/Person/_HasRelationship.py
|
||||
src/Filters/Rules/Person/_HasSource.py
|
||||
src/Filters/Rules/Person/_HasSourceCount.py
|
||||
src/Filters/Rules/Person/_HasSourceOf.py
|
||||
src/Filters/Rules/Person/_HasTag.py
|
||||
src/Filters/Rules/Person/_HasTextMatchingSubstringOf.py
|
||||
@ -530,6 +539,7 @@ src/Filters/Rules/Family/_FamilyPrivate.py
|
||||
src/Filters/Rules/Family/_FatherHasIdOf.py
|
||||
src/Filters/Rules/Family/_FatherHasNameOf.py
|
||||
src/Filters/Rules/Family/_HasAttribute.py
|
||||
src/Filters/Rules/Family/_HasCitation.py
|
||||
src/Filters/Rules/Family/_HasEvent.py
|
||||
src/Filters/Rules/Family/_HasGallery.py
|
||||
src/Filters/Rules/Family/_HasIdOf.py
|
||||
@ -539,7 +549,7 @@ src/Filters/Rules/Family/_HasNoteMatchingSubstringOf.py
|
||||
src/Filters/Rules/Family/_HasNoteRegexp.py
|
||||
src/Filters/Rules/Family/_HasReferenceCountOf.py
|
||||
src/Filters/Rules/Family/_HasRelType.py
|
||||
src/Filters/Rules/Family/_HasSource.py
|
||||
src/Filters/Rules/Family/_HasSourceCount.py
|
||||
src/Filters/Rules/Family/_HasTag.py
|
||||
src/Filters/Rules/Family/_IsBookmarked.py
|
||||
src/Filters/Rules/Family/_MatchesFilter.py
|
||||
@ -559,6 +569,7 @@ src/Filters/Rules/Event/_AllEvents.py
|
||||
src/Filters/Rules/Event/_ChangedSince.py
|
||||
src/Filters/Rules/Event/_EventPrivate.py
|
||||
src/Filters/Rules/Event/_HasAttribute.py
|
||||
src/Filters/Rules/Event/_HasCitation.py
|
||||
src/Filters/Rules/Event/_HasData.py
|
||||
src/Filters/Rules/Event/_HasGallery.py
|
||||
src/Filters/Rules/Event/_HasIdOf.py
|
||||
@ -566,7 +577,7 @@ src/Filters/Rules/Event/_HasNote.py
|
||||
src/Filters/Rules/Event/_HasNoteMatchingSubstringOf.py
|
||||
src/Filters/Rules/Event/_HasNoteRegexp.py
|
||||
src/Filters/Rules/Event/_HasReferenceCountOf.py
|
||||
src/Filters/Rules/Event/_HasSource.py
|
||||
src/Filters/Rules/Event/_HasSourceCount.py
|
||||
src/Filters/Rules/Event/_HasType.py
|
||||
src/Filters/Rules/Event/_MatchesFilter.py
|
||||
src/Filters/Rules/Event/_MatchesPersonFilter.py
|
||||
@ -602,13 +613,29 @@ src/Filters/Rules/Source/_HasNoteMatchingSubstringOf.py
|
||||
src/Filters/Rules/Source/_HasReferenceCountOf.py
|
||||
src/Filters/Rules/Source/_HasRepository.py
|
||||
src/Filters/Rules/Source/_HasRepositoryCallNumberRef.py
|
||||
src/Filters/Rules/Source/_HasSource.py
|
||||
src/Filters/Rules/Source/_MatchesFilter.py
|
||||
src/Filters/Rules/Source/_MatchesRepositoryFilter.py
|
||||
src/Filters/Rules/Source/_MatchesTitleSubstringOf.py
|
||||
src/Filters/Rules/Source/_SourcePrivate.py
|
||||
src/Filters/Rules/Source/_RegExpIdOf.py
|
||||
|
||||
# Filters.Rules.Citation package
|
||||
src/Filters/Rules/Citation/_AllCitations.py
|
||||
src/Filters/Rules/Citation/_ChangedSince.py
|
||||
src/Filters/Rules/Citation/_CitationPrivate.py
|
||||
src/Filters/Rules/Citation/_HasGallery.py
|
||||
src/Filters/Rules/Citation/_HasIdOf.py
|
||||
src/Filters/Rules/Citation/_HasNote.py
|
||||
src/Filters/Rules/Citation/_HasNoteMatchingSubstringOf.py
|
||||
src/Filters/Rules/Citation/_HasNoteRegexp.py
|
||||
src/Filters/Rules/Citation/_HasReferenceCountOf.py
|
||||
src/Filters/Rules/Citation/_HasSource.py
|
||||
src/Filters/Rules/Citation/_MatchesFilter.py
|
||||
src/Filters/Rules/Citation/_MatchesPageSubstringOf.py
|
||||
src/Filters/Rules/Citation/_RegExpIdOf.py
|
||||
src/Filters/Rules/Citation/_MatchesRepositoryFilter.py
|
||||
src/Filters/Rules/Citation/_MatchesSourceFilter.py
|
||||
|
||||
# Filters.Rules.MediaObject package
|
||||
src/Filters/Rules/MediaObject/_AllMedia.py
|
||||
src/Filters/Rules/MediaObject/_ChangedSince.py
|
||||
@ -650,6 +677,7 @@ src/Filters/Rules/Note/_RegExpIdOf.py
|
||||
src/Filters/Rules/Note/_NotePrivate.py
|
||||
|
||||
# Filters.SideBar package
|
||||
src/Filters/SideBar/_CitationSidebarFilter.py
|
||||
src/Filters/SideBar/_EventSidebarFilter.py
|
||||
src/Filters/SideBar/_FamilySidebarFilter.py
|
||||
src/Filters/SideBar/_PersonSidebarFilter.py
|
||||
@ -677,6 +705,7 @@ src/glade/dateedit.glade
|
||||
src/glade/editsource.glade
|
||||
src/glade/styleeditor.glade
|
||||
src/glade/dbman.glade
|
||||
src/glade/editcitation.glade
|
||||
src/glade/editurl.glade
|
||||
src/glade/editrepository.glade
|
||||
src/glade/editreporef.glade
|
||||
@ -696,6 +725,7 @@ src/glade/editplace.glade
|
||||
src/glade/editsourceref.glade
|
||||
src/glade/editname.glade
|
||||
src/glade/editevent.glade
|
||||
src/glade/mergecitation.glade
|
||||
src/glade/mergedata.glade
|
||||
src/glade/mergeevent.glade
|
||||
src/glade/mergefamily.glade
|
||||
@ -720,6 +750,7 @@ src/plugins/tool/eventcmp.glade
|
||||
src/plugins/import/importgedcom.glade
|
||||
src/plugins/tool/leak.glade
|
||||
src/plugins/tool/finddupes.glade
|
||||
src/plugins/tool/mergecitations.glade
|
||||
src/plugins/tool/ownereditor.glade
|
||||
src/plugins/tool/patchnames.glade
|
||||
src/plugins/tool/phpgedview.glade
|
||||
|
@ -65,6 +65,7 @@ src/Filters/Rules/Note/__init__.py
|
||||
# Filters.Rules package
|
||||
src/Filters/Rules/_ChangedSinceBase.py
|
||||
src/Filters/Rules/_HasAttributeBase.py
|
||||
src/Filters/Rules/_HasCitationBase.py
|
||||
src/Filters/Rules/_HasEventBase.py
|
||||
src/Filters/Rules/_HasGalleryBase.py
|
||||
src/Filters/Rules/_HasLDSBase.py
|
||||
@ -73,6 +74,7 @@ src/Filters/Rules/_HasNoteRegexBase.py
|
||||
src/Filters/Rules/_HasNoteSubstrBase.py
|
||||
src/Filters/Rules/_HasReferenceCountBase.py
|
||||
src/Filters/Rules/_HasSourceBase.py
|
||||
src/Filters/Rules/_HasSourceCountBase.py
|
||||
src/Filters/Rules/_HasTagBase.py
|
||||
src/Filters/Rules/_HasTextMatchingRegexpOf.py
|
||||
src/Filters/Rules/__init__.py
|
||||
|
@ -2,6 +2,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
|
||||
@ -364,6 +365,18 @@ class SourceBookmarks(ListBookmarks) :
|
||||
def connect_signals(self):
|
||||
self.dbstate.db.connect('source-delete', self.remove_handles)
|
||||
|
||||
class CitationBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps."
|
||||
def __init__(self, dbstate, uistate, bookmarks, goto_handle):
|
||||
ListBookmarks.__init__(self, dbstate, uistate, bookmarks,
|
||||
goto_handle)
|
||||
|
||||
def make_label(self, handle):
|
||||
return Utils.navigation_label(self.dbstate.db, 'Citation', handle)
|
||||
|
||||
def connect_signals(self):
|
||||
self.dbstate.db.connect('citation-delete', self.remove_handles)
|
||||
|
||||
class MediaBookmarks(ListBookmarks) :
|
||||
"Handle the bookmarks interface for Gramps."
|
||||
|
||||
|
@ -19,7 +19,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# DateHandler/_Date_zh.py
|
||||
# $Id$
|
||||
# $Id: _Date_zh.py 18361 2011-10-23 03:13:50Z paul-franklin $
|
||||
#
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -65,6 +66,7 @@ class DbState(Callback):
|
||||
config.get('preferences.oprefix'),
|
||||
config.get('preferences.fprefix'),
|
||||
config.get('preferences.sprefix'),
|
||||
config.get('preferences.cprefix'),
|
||||
config.get('preferences.pprefix'),
|
||||
config.get('preferences.eprefix'),
|
||||
config.get('preferences.rprefix'),
|
||||
|
@ -4,6 +4,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 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
|
||||
@ -135,6 +136,7 @@ class _DdTargets(object):
|
||||
self.SOURCE_LINK = _DdType(self, 'source-link')
|
||||
self.URL = _DdType(self, 'url')
|
||||
self.SURNAME = _DdType(self, 'surname')
|
||||
self.CITATION_LINK = _DdType(self, 'citation-link')
|
||||
|
||||
# List of all types that are used between
|
||||
# gramps widgets but should not be exported
|
||||
@ -162,7 +164,8 @@ class _DdTargets(object):
|
||||
self.SOURCEREF,
|
||||
self.SOURCE_LINK,
|
||||
self.URL,
|
||||
self.SURNAME
|
||||
self.SURNAME,
|
||||
self.CITATION_LINK
|
||||
]
|
||||
|
||||
self.CHILD = _DdType(self, 'child')
|
||||
|
@ -4,6 +4,7 @@
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2008 Brian G. Matherly
|
||||
# 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
|
||||
@ -365,6 +366,7 @@ class DisplayState(gen.utils.Callback):
|
||||
'Event': _("No active event"),
|
||||
'Place': _("No active place"),
|
||||
'Source': _("No active source"),
|
||||
'Citation': _("No active citation"),
|
||||
'Repository': _("No active repository"),
|
||||
'Media': _("No active media"),
|
||||
'Note': _("No active note"),
|
||||
|
33
src/Filters/Rules/Citation/Makefile.am
Normal file
33
src/Filters/Rules/Citation/Makefile.am
Normal file
@ -0,0 +1,33 @@
|
||||
# This is the src/Filters/Rules/Citation level Makefile for Gramps
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules/Citation
|
||||
|
||||
pkgdata_PYTHON = \
|
||||
__init__.py \
|
||||
_AllCitations.py \
|
||||
_ChangedSince.py \
|
||||
_CitationPrivate.py \
|
||||
_HasGallery.py \
|
||||
_HasIdOf.py \
|
||||
_HasNote.py \
|
||||
_HasNoteMatchingSubstringOf.py \
|
||||
_HasNoteRegexp.py \
|
||||
_HasReferenceCountOf.py \
|
||||
_HasSource.py \
|
||||
_MatchesFilter.py \
|
||||
_MatchesPageSubstringOf.py \
|
||||
_MatchesRepositoryFilter.py \
|
||||
_MatchesSourceFilter.py \
|
||||
_RegExpIdOf.py
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules/Citation
|
||||
pkgpythondir = @pkgpythondir@/Filters/Rules/Citation
|
||||
|
||||
# Clean up all the byte-compiled files
|
||||
MOSTLYCLEANFILES = *pyc *pyo
|
||||
|
||||
GRAMPS_PY_MODPATH = "../../../"
|
||||
|
||||
pycheck:
|
||||
(export PYTHONPATH=$(GRAMPS_PY_MODPATH); \
|
||||
pychecker $(pkgdata_PYTHON));
|
47
src/Filters/Rules/Citation/_AllCitations.py
Normal file
47
src/Filters/Rules/Citation/_AllCitations.py
Normal file
@ -0,0 +1,47 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Everything import Everything
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Everyone
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class AllCitations(Everything):
|
||||
"""Matches every citation"""
|
||||
|
||||
name = _('Every citation')
|
||||
description = _('Matches every citation in the database')
|
50
src/Filters/Rules/Citation/_ChangedSince.py
Normal file
50
src/Filters/Rules/Citation/_ChangedSince.py
Normal file
@ -0,0 +1,50 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# ChangedSince
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ChangedSince(ChangedSinceBase):
|
||||
"""Rule that checks for citations changed since a specific time."""
|
||||
|
||||
labels = [ _('Changed after:'), _('but before:') ]
|
||||
name = _('Citations changed after <date time>')
|
||||
description = _("Matches citation records changed after a specified "
|
||||
"date-time (yyyy-mm-dd hh:mm:ss) or in the range, if a second "
|
||||
"date-time is given.")
|
45
src/Filters/Rules/Citation/_CitationPrivate.py
Normal file
45
src/Filters/Rules/Citation/_CitationPrivate.py
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._IsPrivate import IsPrivate
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Family marked private"
|
||||
#-------------------------------------------------------------------------
|
||||
class CitationPrivate(IsPrivate):
|
||||
"""Citation marked private"""
|
||||
|
||||
name = _('Citations marked private')
|
||||
description = _("Matches citations that are indicated as private")
|
47
src/Filters/Rules/Citation/_HasGallery.py
Executable file
47
src/Filters/Rules/Citation/_HasGallery.py
Executable file
@ -0,0 +1,47 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2008 Brian G. Matherly
|
||||
# Copyright (C) 2008 Jerome Rapinat
|
||||
# Copyright (C) 2008 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasGalleryBase import HasGalleryBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Sources who have media object reference"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasGallery(HasGalleryBase):
|
||||
"""Rule that checks for citation who has media object reference"""
|
||||
|
||||
name = _('Citations with <count> media')
|
||||
description = _("Matches citations with a certain number of items in the gallery")
|
47
src/Filters/Rules/Citation/_HasIdOf.py
Normal file
47
src/Filters/Rules/Citation/_HasIdOf.py
Normal file
@ -0,0 +1,47 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules import HasGrampsId
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasIdOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasIdOf(HasGrampsId):
|
||||
"""Rule that checks for a citation with a specific GRAMPS ID"""
|
||||
|
||||
name = _('Citation with <Id>')
|
||||
description = _("Matches a citation with a specified Gramps ID")
|
48
src/Filters/Rules/Citation/_HasNote.py
Executable file
48
src/Filters/Rules/Citation/_HasNote.py
Executable file
@ -0,0 +1,48 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2007 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# Copyright (C) 2008 Jerome Rapinat
|
||||
# Copyright (C) 2008 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasNoteBase import HasNoteBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Sources having notes"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasNote(HasNoteBase):
|
||||
"""Citations having notes"""
|
||||
|
||||
name = _('Citations having <count> notes')
|
||||
description = _("Matches citations having a certain number of notes")
|
47
src/Filters/Rules/Citation/_HasNoteMatchingSubstringOf.py
Normal file
47
src/Filters/Rules/Citation/_HasNoteMatchingSubstringOf.py
Normal file
@ -0,0 +1,47 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasNoteSubstrBase import HasNoteSubstrBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Events having notes that contain a substring"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasNoteMatchingSubstringOf(HasNoteSubstrBase):
|
||||
"""Citations having notes containing <substring>"""
|
||||
|
||||
name = _('Citations having notes containing <substring>')
|
||||
description = _("Matches citations whose notes contain text "
|
||||
"matching a substring")
|
||||
|
45
src/Filters/Rules/Citation/_HasNoteRegexp.py
Normal file
45
src/Filters/Rules/Citation/_HasNoteRegexp.py
Normal file
@ -0,0 +1,45 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasNoteRegexBase import HasNoteRegexBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Sources having notes that contain a substring"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasNoteRegexp(HasNoteRegexBase):
|
||||
|
||||
name = _('Citations having notes containing <regular expression>')
|
||||
description = _("Matches citations whose notes contain text "
|
||||
"matching a regular expression")
|
46
src/Filters/Rules/Citation/_HasReferenceCountOf.py
Normal file
46
src/Filters/Rules/Citation/_HasReferenceCountOf.py
Normal file
@ -0,0 +1,46 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2007 Stephane Charette
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasReferenceCountBase import HasReferenceCountBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Source objects with a certain reference count"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasReferenceCountOf(HasReferenceCountBase):
|
||||
"""Citation objects with a reference count of <count>"""
|
||||
|
||||
name = _('Citations with a reference count of <count>')
|
||||
description = _("Matches citations with a certain reference count")
|
||||
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -20,6 +21,9 @@
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Filter rule to match citation with a particular source.
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
@ -32,32 +36,27 @@ from gen.ggettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Rule import Rule
|
||||
from Filters.Rules._HasSourceBase import HasSourceBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasSource
|
||||
# HasEvent
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasSource(Rule):
|
||||
"""Rule that checks for a person with a particular value"""
|
||||
|
||||
class HasSource(HasSourceBase):
|
||||
"""Rule that checks for an citation with a particular value"""
|
||||
|
||||
labels = [ _('Title:'),
|
||||
_('Author:'),
|
||||
_('Publication:') ]
|
||||
name = _('Sources matching parameters')
|
||||
description = _("Matches sources with particular parameters")
|
||||
category = _('General filters')
|
||||
|
||||
def apply(self,db,source):
|
||||
if not self.match_substring(0,source.get_title()):
|
||||
return False
|
||||
|
||||
if not self.match_substring(1,source.get_author()):
|
||||
return False
|
||||
|
||||
if not self.match_substring(2,source.get_publication_info()):
|
||||
return False
|
||||
|
||||
return True
|
||||
description = _("Matches citations with a source of a particular "
|
||||
"value")
|
||||
category = _('Source filters')
|
||||
|
||||
def apply(self, dbase, citation):
|
||||
source = dbase.get_source_from_handle(
|
||||
citation.get_reference_handle())
|
||||
if HasSourceBase.apply(self, dbase, source):
|
||||
return True
|
||||
return False
|
48
src/Filters/Rules/Citation/_MatchesFilter.py
Normal file
48
src/Filters/Rules/Citation/_MatchesFilter.py
Normal file
@ -0,0 +1,48 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._MatchesFilterBase import MatchesFilterBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MatchesFilter
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MatchesFilter(MatchesFilterBase):
|
||||
"""Rule that checks against another filter"""
|
||||
|
||||
name = _('Citations matching the <filter>')
|
||||
description = _("Matches citations matched by the specified filter name")
|
||||
namespace = 'Citation'
|
54
src/Filters/Rules/Citation/_MatchesPageSubstringOf.py
Normal file
54
src/Filters/Rules/Citation/_MatchesPageSubstringOf.py
Normal file
@ -0,0 +1,54 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2011 Helge Herz
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Sources having a title that contain a substring"
|
||||
#-------------------------------------------------------------------------
|
||||
class MatchesPageSubstringOf(Rule):
|
||||
"""Citation Volume/Page title containing <substring>"""
|
||||
|
||||
labels = [ _('Substring:')]
|
||||
name = _('Citation Volume/Page containing <substring>')
|
||||
description = _("Matches citations whose Volume/Page contains a "
|
||||
"certain substring")
|
||||
category = _('General filters')
|
||||
|
||||
def apply(self, db, object):
|
||||
""" Apply the filter """
|
||||
title = object.get_page()
|
||||
if title.upper().find(self.list[0].upper()) != -1:
|
||||
return True
|
||||
return False
|
72
src/Filters/Rules/Citation/_MatchesRepositoryFilter.py
Normal file
72
src/Filters/Rules/Citation/_MatchesRepositoryFilter.py
Normal file
@ -0,0 +1,72 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2011 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules import MatchesFilterBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Sources which reference a repository by selection"
|
||||
#-------------------------------------------------------------------------
|
||||
class MatchesRepositoryFilter(MatchesFilterBase):
|
||||
"""Citations which have a source which references the selected repository"""
|
||||
|
||||
labels = [ _('Repository filter name:') ]
|
||||
name = _('Citations with a source with a repository reference '
|
||||
'matching the <repository filter>')
|
||||
description = _("Matches citations with sources with a repository "
|
||||
"reference that match a certain repository filter")
|
||||
category = _('General filters')
|
||||
|
||||
# we want to have this filter show repository filters
|
||||
namespace = 'Repository'
|
||||
|
||||
|
||||
def prepare(self, db):
|
||||
MatchesFilterBase.prepare(self, db)
|
||||
self.MRF_filt = self.find_filter()
|
||||
|
||||
def apply(self, db, object):
|
||||
if self.MRF_filt is None :
|
||||
return False
|
||||
|
||||
source_handle = object.source_handle
|
||||
source = db.get_source_from_handle(source_handle)
|
||||
repolist = [x.ref for x in source.get_reporef_list()]
|
||||
for repohandle in repolist:
|
||||
#check if repo in repository filter
|
||||
if self.MRF_filt.check(db, repohandle):
|
||||
return True
|
||||
return False
|
69
src/Filters/Rules/Citation/_MatchesSourceFilter.py
Normal file
69
src/Filters/Rules/Citation/_MatchesSourceFilter.py
Normal file
@ -0,0 +1,69 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
# Copyright (C) 2010 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules import MatchesFilterBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# MatchesFilter
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MatchesSourceFilter(MatchesFilterBase):
|
||||
"""
|
||||
Rule that checks against another filter.
|
||||
"""
|
||||
|
||||
labels = [_('Source filter name:')]
|
||||
name = _('Citations with source matching the <source filter>')
|
||||
description = _("Matches citations with sources that match the "
|
||||
"specified source filter name")
|
||||
category = _('General filters')
|
||||
|
||||
# we want to have this filter show source filters
|
||||
namespace = 'Source'
|
||||
|
||||
def prepare(self, db):
|
||||
MatchesFilterBase.prepare(self, db)
|
||||
self.MRF_filt = self.find_filter()
|
||||
|
||||
def apply(self, db, object):
|
||||
if self.MRF_filt is None :
|
||||
return False
|
||||
|
||||
source_handle = object.source_handle
|
||||
if self.MRF_filt.check(db, source_handle):
|
||||
return True
|
||||
return False
|
51
src/Filters/Rules/Citation/_RegExpIdOf.py
Normal file
51
src/Filters/Rules/Citation/_RegExpIdOf.py
Normal file
@ -0,0 +1,51 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._RegExpIdBase import RegExpIdBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasIdOf
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class RegExpIdOf(RegExpIdBase):
|
||||
"""
|
||||
Rule that checks for a citation whose GRAMPS ID
|
||||
matches regular expression.
|
||||
"""
|
||||
|
||||
name = _('Citations with <Id> matching regular expression')
|
||||
description = _("Matches citations whose Gramps ID matches "
|
||||
"the regular expression")
|
63
src/Filters/Rules/Citation/__init__.py
Normal file
63
src/Filters/Rules/Citation/__init__.py
Normal file
@ -0,0 +1,63 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2007 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Package providing filter rules for GRAMPS.
|
||||
"""
|
||||
|
||||
from Filters.Rules._HasCitationBase import HasCitationBase as HasCitation
|
||||
|
||||
from _AllCitations import AllCitations
|
||||
from _ChangedSince import ChangedSince
|
||||
from _CitationPrivate import CitationPrivate
|
||||
from _HasGallery import HasGallery
|
||||
from _HasIdOf import HasIdOf
|
||||
from _HasNote import HasNote
|
||||
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _HasNoteRegexp import HasNoteRegexp
|
||||
from _HasReferenceCountOf import HasReferenceCountOf
|
||||
from _HasSource import HasSource
|
||||
from _MatchesFilter import MatchesFilter
|
||||
from _MatchesPageSubstringOf import MatchesPageSubstringOf
|
||||
from _MatchesRepositoryFilter import MatchesRepositoryFilter
|
||||
from _MatchesSourceFilter import MatchesSourceFilter
|
||||
from _RegExpIdOf import RegExpIdOf
|
||||
|
||||
editor_rule_list = [
|
||||
AllCitations,
|
||||
ChangedSince,
|
||||
CitationPrivate,
|
||||
HasGallery,
|
||||
HasIdOf,
|
||||
HasNote,
|
||||
HasNoteMatchingSubstringOf,
|
||||
HasNoteRegexp,
|
||||
HasReferenceCountOf,
|
||||
HasSource,
|
||||
MatchesFilter,
|
||||
MatchesPageSubstringOf,
|
||||
MatchesRepositoryFilter,
|
||||
MatchesSourceFilter,
|
||||
RegExpIdOf
|
||||
]
|
@ -9,11 +9,12 @@ pkgdata_PYTHON = \
|
||||
_HasNoteRegexp.py\
|
||||
_RegExpIdOf.py\
|
||||
_AllEvents.py\
|
||||
_HasCitation.py \
|
||||
_HasData.py\
|
||||
_HasGallery.py \
|
||||
_HasIdOf.py\
|
||||
_HasNote.py \
|
||||
_HasSource.py \
|
||||
_HasSourceCount.py \
|
||||
_HasType.py\
|
||||
_HasNoteMatchingSubstringOf.py\
|
||||
_HasReferenceCountOf.py\
|
||||
|
61
src/Filters/Rules/Event/_HasCitation.py
Normal file
61
src/Filters/Rules/Event/_HasCitation.py
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Filter rule to match event with a particular citation.
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasCitationBase import HasCitationBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasEvent
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasCitation(HasCitationBase):
|
||||
"""Rule that checks for an event with a particular value"""
|
||||
|
||||
labels = [ _('Volume/Page:'),
|
||||
_('Date:'),
|
||||
_('Confidence level:')]
|
||||
name = _('Event with the <citation>')
|
||||
description = _("Matches events with a citation of a particular "
|
||||
"value")
|
||||
|
||||
def apply(self, dbase, event):
|
||||
for citation_handle in event.get_citation_list():
|
||||
citation = dbase.get_citation_from_handle(citation_handle)
|
||||
if HasCitationBase.apply(self, dbase, citation):
|
||||
return True
|
||||
return False
|
@ -19,9 +19,8 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# Filters/Rules/Event/_HasSource.py
|
||||
|
||||
# $Id$
|
||||
#
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -35,12 +34,12 @@ from gen.ggettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasSourceBase import HasSourceBase
|
||||
from Filters.Rules._HasSourceCountBase import HasSourceCountBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People having sources"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasSource(HasSourceBase):
|
||||
class HasSourceCount(HasSourceCountBase):
|
||||
"""Events with sources"""
|
||||
|
||||
name = _('Events with <count> sources')
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
# Copyright (C) 2010 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
|
||||
@ -49,7 +50,7 @@ class MatchesSourceFilter(MatchesSourceFilterBase):
|
||||
name = _('Events with source matching the <source filter>')
|
||||
description = _("Matches events with sources that match the "
|
||||
"specified source filter name")
|
||||
category = _('General filters')
|
||||
category = _('Citation/source filters')
|
||||
|
||||
# we want to have this filter show source filters
|
||||
namespace = 'Source'
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# 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
|
||||
@ -32,11 +33,12 @@ from _AllEvents import AllEvents
|
||||
from _HasGallery import HasGallery
|
||||
from _HasIdOf import HasIdOf
|
||||
from _RegExpIdOf import RegExpIdOf
|
||||
from _HasCitation import HasCitation
|
||||
from _HasNote import HasNote
|
||||
from _HasNoteRegexp import HasNoteRegexp
|
||||
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _HasReferenceCountOf import HasReferenceCountOf
|
||||
from _HasSource import HasSource
|
||||
from _HasSourceCount import HasSourceCount
|
||||
from _EventPrivate import EventPrivate
|
||||
from _MatchesFilter import MatchesFilter
|
||||
from _MatchesPersonFilter import MatchesPersonFilter
|
||||
@ -52,11 +54,12 @@ editor_rule_list = [
|
||||
HasIdOf,
|
||||
HasGallery,
|
||||
RegExpIdOf,
|
||||
HasCitation,
|
||||
HasNote,
|
||||
HasNoteRegexp,
|
||||
HasNoteMatchingSubstringOf,
|
||||
HasReferenceCountOf,
|
||||
HasSource,
|
||||
HasSourceCount,
|
||||
EventPrivate,
|
||||
MatchesFilter,
|
||||
MatchesPersonFilter,
|
||||
|
@ -8,6 +8,7 @@ pkgdata_PYTHON = \
|
||||
_FamilyPrivate.py\
|
||||
_HasEvent.py\
|
||||
_HasAttribute.py\
|
||||
_HasCitation.py \
|
||||
_HasGallery.py \
|
||||
_HasIdOf.py\
|
||||
_HasLDS.py \
|
||||
@ -16,7 +17,7 @@ pkgdata_PYTHON = \
|
||||
_HasNoteRegexp.py\
|
||||
_HasReferenceCountOf.py\
|
||||
_HasRelType.py\
|
||||
_HasSource.py \
|
||||
_HasSourceCount.py \
|
||||
_HasTag.py \
|
||||
__init__.py\
|
||||
_IsBookmarked.py\
|
||||
|
61
src/Filters/Rules/Family/_HasCitation.py
Normal file
61
src/Filters/Rules/Family/_HasCitation.py
Normal file
@ -0,0 +1,61 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Filter rule to match family with a particular citation.
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasCitationBase import HasCitationBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasEvent
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasCitation(HasCitationBase):
|
||||
"""Rule that checks for a family with a particular value"""
|
||||
|
||||
labels = [ _('Volume/Page:'),
|
||||
_('Date:'),
|
||||
_('Confidence level:')]
|
||||
name = _('Family with the <citation>')
|
||||
description = _("Matches families with a citation of a particular "
|
||||
"value")
|
||||
|
||||
def apply(self, dbase, family):
|
||||
for citation_handle in family.get_citation_list():
|
||||
citation = dbase.get_citation_from_handle(citation_handle)
|
||||
if HasCitationBase.apply(self, dbase, citation):
|
||||
return True
|
||||
return False
|
@ -35,12 +35,12 @@ from gen.ggettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasSourceBase import HasSourceBase
|
||||
from Filters.Rules._HasSourceCountBase import HasSourceCountBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Families having sources"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasSource(HasSourceBase):
|
||||
class HasSourceCount(HasSourceCountBase):
|
||||
"""Families with sources"""
|
||||
|
||||
name = _('Families with <count> sources')
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2002-2007 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# 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
|
||||
@ -41,8 +42,9 @@ from _RegExpIdOf import RegExpIdOf
|
||||
from _HasNote import HasNote
|
||||
from _HasNoteRegexp import HasNoteRegexp
|
||||
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _HasSource import HasSource
|
||||
from _HasSourceCount import HasSourceCount
|
||||
from _HasReferenceCountOf import HasReferenceCountOf
|
||||
from _HasCitation import HasCitation
|
||||
from _FamilyPrivate import FamilyPrivate
|
||||
from _HasAttribute import HasAttribute
|
||||
from _HasEvent import HasEvent
|
||||
@ -69,7 +71,8 @@ editor_rule_list = [
|
||||
HasNoteRegexp,
|
||||
HasNoteMatchingSubstringOf,
|
||||
HasReferenceCountOf,
|
||||
HasSource,
|
||||
HasSourceCount,
|
||||
HasCitation,
|
||||
FamilyPrivate,
|
||||
HasEvent,
|
||||
HasAttribute,
|
||||
|
@ -1,6 +1,6 @@
|
||||
# This is the src/Filters/Rules level Makefile for Gramps
|
||||
|
||||
SUBDIRS = Person Family Event Place Source MediaObject Repository Note
|
||||
SUBDIRS = Person Family Event Place Source MediaObject Repository Note Citation
|
||||
|
||||
pkgdatadir = $(datadir)/@PACKAGE@/Filters/Rules
|
||||
|
||||
@ -16,6 +16,7 @@ pkgdata_PYTHON = \
|
||||
_HasNoteRegexBase.py\
|
||||
_HasNoteSubstrBase.py\
|
||||
_HasReferenceCountBase.py \
|
||||
_HasSourceCountBase.py \
|
||||
_HasSourceBase.py \
|
||||
_HasTagBase.py \
|
||||
_HasTextMatchingRegexpOf.py\
|
||||
@ -25,9 +26,10 @@ pkgdata_PYTHON = \
|
||||
_RegExpIdBase.py\
|
||||
_Rule.py\
|
||||
_MatchesFilterBase.py\
|
||||
_MatchesEventFilterBase.py \
|
||||
_MatchesSourceConfidenceBase.py \
|
||||
_MatchesSourceFilterBase.py
|
||||
_MatchesEventFilterBase.py \
|
||||
_MatchesSourceConfidenceBase.py \
|
||||
_MatchesSourceFilterBase.py \
|
||||
_HasCitationBase.py
|
||||
|
||||
|
||||
pkgpyexecdir = @pkgpyexecdir@/Filters/Rules
|
||||
|
@ -13,6 +13,7 @@ pkgdata_PYTHON = \
|
||||
_HasAlternateName.py \
|
||||
_HasAssociation.py \
|
||||
_HasBirth.py \
|
||||
_HasCitation.py \
|
||||
_HasCommonAncestorWith.py \
|
||||
_HasCommonAncestorWithFilterMatch.py \
|
||||
_HasDeath.py \
|
||||
@ -29,7 +30,7 @@ pkgdata_PYTHON = \
|
||||
_HasNote.py \
|
||||
_HasNoteMatchingSubstringOf.py \
|
||||
_HasRelationship.py \
|
||||
_HasSource.py \
|
||||
_HasSourceCount.py \
|
||||
_HasSourceOf.py \
|
||||
_HasTag.py \
|
||||
_HasTextMatchingRegexpOf.py \
|
||||
|
60
src/Filters/Rules/Person/_HasCitation.py
Normal file
60
src/Filters/Rules/Person/_HasCitation.py
Normal file
@ -0,0 +1,60 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2006 Donald N. Allingham
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Filter rule to match persons with a particular citation.
|
||||
"""
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasCitationBase import HasCitationBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasEvent
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasCitation(HasCitationBase):
|
||||
"""Rule that checks for a person with a particular value"""
|
||||
|
||||
labels = [ _('Volume/Page:'),
|
||||
_('Date:'),
|
||||
_('Confidence level:')]
|
||||
name = _('People with the <citation>')
|
||||
description = _("Matches people with a citation of a particular "
|
||||
"value")
|
||||
|
||||
def apply(self, dbase, person):
|
||||
for citation_handle in person.get_citation_list():
|
||||
citation = dbase.get_citation_from_handle(citation_handle)
|
||||
if HasCitationBase.apply(self, dbase, citation):
|
||||
return True
|
||||
return False
|
@ -35,12 +35,12 @@ from gen.ggettext import gettext as _
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._HasSourceBase import HasSourceBase
|
||||
from Filters.Rules._HasSourceCountBase import HasSourceCountBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "People having sources"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasSource(HasSourceBase):
|
||||
class HasSourceCount(HasSourceCountBase):
|
||||
"""People with sources"""
|
||||
|
||||
name = _('People with <count> sources')
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -44,7 +45,7 @@ class HasSourceOf(Rule):
|
||||
|
||||
labels = [ _('Source ID:') ]
|
||||
name = _('People with the <source>')
|
||||
category = _('General filters')
|
||||
category = _('Citation/source filters')
|
||||
description = _('Matches people who have a particular source')
|
||||
|
||||
def prepare(self,db):
|
||||
@ -55,14 +56,22 @@ class HasSourceOf(Rule):
|
||||
|
||||
self.nosource = False
|
||||
try:
|
||||
self.source_handle = db.get_source_from_gramps_id(self.list[0]).get_handle()
|
||||
self.source_handle = db.get_source_from_gramps_id(
|
||||
self.list[0]).get_handle()
|
||||
except:
|
||||
self.source_handle = None
|
||||
|
||||
def apply(self, db, person):
|
||||
if not self.source_handle:
|
||||
if self.nosource:
|
||||
return len(person.get_source_references()) == 0
|
||||
# check whether the citation list is empty as a proxy for
|
||||
# there being no sources
|
||||
return len(person.get_all_citation_lists()) == 0
|
||||
else:
|
||||
return False
|
||||
return person.has_source_reference(self.source_handle)
|
||||
else:
|
||||
for citation_handle in person.get_all_citation_lists():
|
||||
citation = db.get_citation_from_handle(citation_handle)
|
||||
if citation.get_reference_handle() == self.source_handle:
|
||||
return True
|
||||
return False
|
||||
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -26,13 +27,15 @@
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
import logging
|
||||
LOG = logging.getLogger(".citationfilter")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Utils import get_source_referents
|
||||
from Utils import get_source_and_citation_referents
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -179,15 +182,30 @@ class HasTextMatchingSubstringOf(Rule):
|
||||
# search all sources and match all referents of a matching source
|
||||
for source in self.db.iter_sources():
|
||||
match = self.match_object(source)
|
||||
LOG.debug("cache_sources match %s string %s source %s" %
|
||||
(match, self.list[0], source.gramps_id))
|
||||
if not match:
|
||||
if any(reporef.get_reference_handle() in self.repo_map
|
||||
for reporef in source.get_reporef_list()
|
||||
):
|
||||
|
||||
match = True
|
||||
LOG.debug("cache_sources repomatch %s string %s source %s" %
|
||||
(match, self.list[0], source.gramps_id))
|
||||
(citation_list, citation_referents_list) = \
|
||||
get_source_and_citation_referents(source.handle, self.db)
|
||||
LOG.debug("the_lists %s %s" %
|
||||
(citation_list, citation_referents_list))
|
||||
for (citation_handle, refs) in citation_referents_list:
|
||||
citation = self.db.get_citation_from_handle(citation_handle)
|
||||
LOG.debug("cache_sources match %s matchcitation %s string %s"
|
||||
" source %s citation %s" %
|
||||
(match, self.match_object(citation),
|
||||
self.list[0], source.gramps_id,
|
||||
citation.gramps_id))
|
||||
if match or self.match_object(citation):
|
||||
# Update the maps to reflect the reference
|
||||
(person_list, family_list, event_list, place_list,
|
||||
source_list, media_list, repo_list
|
||||
) = get_source_referents(source.handle,self.db)
|
||||
(person_list, family_list, event_list, place_list,
|
||||
source_list, media_list, repo_list) = refs
|
||||
self.person_map.update(person_list)
|
||||
self.family_map.update(family_list)
|
||||
self.event_map.update(event_list)
|
||||
|
@ -18,7 +18,7 @@
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
# $Id: _IsRelatedWith.py 18338 2011-10-16 20:21:22Z paul-franklin $
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2002-2007 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# 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 _HasAlternateName import HasAlternateName
|
||||
from _HasAssociation import HasAssociation
|
||||
from _HasAttribute import HasAttribute
|
||||
from _HasBirth import HasBirth
|
||||
from _HasCitation import HasCitation
|
||||
from _HasCommonAncestorWith import HasCommonAncestorWith
|
||||
from _HasCommonAncestorWithFilterMatch import HasCommonAncestorWithFilterMatch
|
||||
from _HasDeath import HasDeath
|
||||
@ -50,7 +52,7 @@ from _HasNote import HasNote
|
||||
from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _HasNoteRegexp import HasNoteRegexp
|
||||
from _HasRelationship import HasRelationship
|
||||
from _HasSource import HasSource
|
||||
from _HasSourceCount import HasSourceCount
|
||||
from _HasSourceOf import HasSourceOf
|
||||
from _HasTag import HasTag
|
||||
from _HasTextMatchingRegexpOf import HasTextMatchingRegexpOf
|
||||
@ -132,12 +134,13 @@ editor_rule_list = [
|
||||
HasRelationship,
|
||||
HasDeath,
|
||||
HasBirth,
|
||||
HasCitation,
|
||||
HasEvent,
|
||||
HasFamilyEvent,
|
||||
HasAttribute,
|
||||
HasFamilyAttribute,
|
||||
HasTag,
|
||||
HasSource,
|
||||
HasSourceCount,
|
||||
HasSourceOf,
|
||||
HaveAltFamilies,
|
||||
HavePhotos,
|
||||
|
@ -12,7 +12,6 @@ pkgdata_PYTHON = \
|
||||
_HasReferenceCountOf.py\
|
||||
_AllSources.py\
|
||||
_HasIdOf.py\
|
||||
_HasSource.py\
|
||||
_HasNote.py \
|
||||
_HasNoteRegexp.py\
|
||||
_HasRepository.py\
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2002-2007 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# 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,6 +26,8 @@
|
||||
Package providing filter rules for GRAMPS.
|
||||
"""
|
||||
|
||||
from Filters.Rules._HasSourceBase import HasSourceBase as HasSource
|
||||
|
||||
from _AllSources import AllSources
|
||||
from _HasGallery import HasGallery
|
||||
from _HasIdOf import HasIdOf
|
||||
@ -35,7 +38,6 @@ from _HasNoteMatchingSubstringOf import HasNoteMatchingSubstringOf
|
||||
from _HasReferenceCountOf import HasReferenceCountOf
|
||||
from _SourcePrivate import SourcePrivate
|
||||
from _MatchesFilter import MatchesFilter
|
||||
from _HasSource import HasSource
|
||||
from _ChangedSince import ChangedSince
|
||||
from _HasRepository import HasRepository
|
||||
from _MatchesTitleSubstringOf import MatchesTitleSubstringOf
|
||||
|
78
src/Filters/Rules/_HasCitationBase.py
Normal file
78
src/Filters/Rules/_HasCitationBase.py
Normal file
@ -0,0 +1,78 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import DateHandler
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# HasCitation
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasCitationBase(Rule):
|
||||
"""Rule that checks for a citation with a particular value
|
||||
|
||||
First parameter is [Volume/page, Date, Confidence]
|
||||
"""
|
||||
|
||||
|
||||
labels = [ _('Volume/Page:'),
|
||||
_('Date:'),
|
||||
_('Confidence:') ]
|
||||
name = _('Citations matching parameters')
|
||||
description = _("Matches citations with particular parameters")
|
||||
category = _('Citation/source filters')
|
||||
|
||||
def prepare(self, db):
|
||||
self.date = None
|
||||
try:
|
||||
if self.list[1]:
|
||||
self.date = DateHandler.parser.parse(self.list[1])
|
||||
except:
|
||||
pass
|
||||
|
||||
def apply(self,db,citation):
|
||||
if not self.match_substring(0,citation.get_page()):
|
||||
return False
|
||||
|
||||
if self.date:
|
||||
if not citation.get_date_object().match(self.date):
|
||||
return False
|
||||
|
||||
if self.list[2]:
|
||||
if citation.get_confidence_level() < int(self.list[2]):
|
||||
return False
|
||||
|
||||
return True
|
52
src/Filters/Rules/_HasSourceBase.py
Executable file → Normal file
52
src/Filters/Rules/_HasSourceBase.py
Executable file → Normal file
@ -1,10 +1,8 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2007 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# Copyright (C) 2008 Jerome Rapinat
|
||||
# Copyright (C) 2008 Benny Malengier
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -20,9 +18,8 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
# Filters/Rules/_HasSourceBase.py
|
||||
|
||||
# $Id$
|
||||
#
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -39,32 +36,29 @@ from gen.ggettext import gettext as _
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Objects having sources"
|
||||
#
|
||||
# HasSource
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class HasSourceBase(Rule):
|
||||
"""Objects having notes"""
|
||||
"""Rule that checks for a source with a particular value"""
|
||||
|
||||
labels = [ _('Number of instances:'), _('Number must be:')]
|
||||
name = _('Objects with <count> sources')
|
||||
description = _("Matches objects that have a certain number of sources connected to it")
|
||||
category = _('General filters')
|
||||
|
||||
def prepare(self, db):
|
||||
# things we want to do just once, not for every handle
|
||||
if self.list[1] == 'lesser than':
|
||||
self.count_type = 0
|
||||
elif self.list[1] == 'greater than':
|
||||
self.count_type = 2
|
||||
else:
|
||||
self.count_type = 1 # "equal to"
|
||||
labels = [ _('Title:'),
|
||||
_('Author:'),
|
||||
_('Publication:') ]
|
||||
name = _('Sources matching parameters')
|
||||
description = _("Matches sources with particular parameters")
|
||||
category = _('Citation/source filters')
|
||||
|
||||
self.userSelectedCount = int(self.list[0])
|
||||
def apply(self,db,source):
|
||||
if not self.match_substring(0,source.get_title()):
|
||||
return False
|
||||
|
||||
def apply(self, db, obj):
|
||||
count = len(obj.get_source_references())
|
||||
if self.count_type == 0: # "lesser than"
|
||||
return count < self.userSelectedCount
|
||||
elif self.count_type == 2: # "greater than"
|
||||
return count > self.userSelectedCount
|
||||
# "equal to"
|
||||
return count == self.userSelectedCount
|
||||
if not self.match_substring(1,source.get_author()):
|
||||
return False
|
||||
|
||||
if not self.match_substring(2,source.get_publication_info()):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
70
src/Filters/Rules/_HasSourceCountBase.py
Executable file
70
src/Filters/Rules/_HasSourceCountBase.py
Executable file
@ -0,0 +1,70 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2002-2007 Donald N. Allingham
|
||||
# Copyright (C) 2007-2008 Brian G. Matherly
|
||||
# Copyright (C) 2008 Jerome Rapinat
|
||||
# Copyright (C) 2008 Benny Malengier
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Standard Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from Filters.Rules._Rule import Rule
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
# "Objects having sources"
|
||||
#-------------------------------------------------------------------------
|
||||
class HasSourceCountBase(Rule):
|
||||
"""Objects having sources"""
|
||||
|
||||
labels = [ _('Number of instances:'), _('Number must be:')]
|
||||
name = _('Objects with <count> sources')
|
||||
description = _("Matches objects that have a certain number of sources "
|
||||
"connected to it (actually citations are counted)")
|
||||
category = _('Citation/source filters')
|
||||
|
||||
def prepare(self, db):
|
||||
# things we want to do just once, not for every handle
|
||||
if self.list[1] == 'lesser than':
|
||||
self.count_type = 0
|
||||
elif self.list[1] == 'greater than':
|
||||
self.count_type = 2
|
||||
else:
|
||||
self.count_type = 1 # "equal to"
|
||||
|
||||
self.userSelectedCount = int(self.list[0])
|
||||
|
||||
def apply(self, db, obj):
|
||||
count = len(obj.get_citation_list())
|
||||
if self.count_type == 0: # "lesser than"
|
||||
return count < self.userSelectedCount
|
||||
elif self.count_type == 2: # "greater than"
|
||||
return count > self.userSelectedCount
|
||||
# "equal to"
|
||||
return count == self.userSelectedCount
|
@ -4,6 +4,7 @@
|
||||
# Copyright (C) 2011 Jerome Rapinat
|
||||
# Copyright (C) 2011 Douglas S. Blank
|
||||
# Copyright (C) 2011 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
|
||||
@ -47,11 +48,12 @@ class MatchesSourceConfidenceBase(Rule):
|
||||
labels = [_('Confidence level:')]
|
||||
name = _('Object with at least one direct source >= <confidence level>')
|
||||
description = _("Matches objects with at least one direct source with confidence level(s)")
|
||||
category = _('General filters')
|
||||
category = _('Citation/source filters')
|
||||
|
||||
def apply(self, db, obj):
|
||||
for source in obj.get_source_references():
|
||||
required_conf = int(self.list[0])
|
||||
if required_conf <= source.get_confidence_level():
|
||||
required_conf = int(self.list[0])
|
||||
for citation_handle in obj.get_citation_list():
|
||||
citation = db.get_citation_from_handle(citation_handle)
|
||||
if required_conf <= citation.get_confidence_level():
|
||||
return True
|
||||
return False
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2010 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
|
||||
@ -48,7 +49,7 @@ class MatchesSourceFilterBase(MatchesFilterBase):
|
||||
name = _('Objects with source matching the <source filter>')
|
||||
description = _("Matches objects with sources that match the "
|
||||
"specified source filter name")
|
||||
category = _('General filters')
|
||||
category = _('Citation/source filters')
|
||||
|
||||
# we want to have this filter show source filters
|
||||
namespace = 'Source'
|
||||
@ -61,9 +62,9 @@ class MatchesSourceFilterBase(MatchesFilterBase):
|
||||
if self.MSF_filt is None :
|
||||
return False
|
||||
|
||||
sourcelist = [x.ref for x in object.get_source_references()]
|
||||
for sourcehandle in sourcelist:
|
||||
#check if source in source filter
|
||||
for citation_handle in object.get_citation_list():
|
||||
citation = db.get_citation_from_handle(citation_handle)
|
||||
sourcehandle = citation.get_reference_handle()
|
||||
if self.MSF_filt.check(db, sourcehandle):
|
||||
return True
|
||||
return False
|
||||
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -22,6 +23,46 @@
|
||||
|
||||
"""
|
||||
Package providing filter rules for GRAMPS.
|
||||
|
||||
The following filters are provided in Filters/Rules.
|
||||
|
||||
Match given values:
|
||||
_HasCitationBase Citation with a particular value (HasCitation)
|
||||
also used for Person, Family and Event having a
|
||||
particular Citation
|
||||
_HasEventBase Event with a particular value (HasEvent)
|
||||
also used for Family and Person having a particular
|
||||
Event
|
||||
_HasSourceBase Source with a particular value (HasSource)
|
||||
also used for Citation having a particular Source
|
||||
|
||||
Match on sub-objects
|
||||
_ChangedSinceBase Object changed since date
|
||||
_HasAttributeBase Object has particular attribute value
|
||||
_HasGrampsId Object has a specific Gramps Id
|
||||
_HasNoteRegexBase Object has notes matching regular expression
|
||||
_HasNoteSubstrBase Object has note containing substring
|
||||
_HasTagBase Object has a particular tag
|
||||
_HasTextMatchingRegexpOf Object has text matching regular expression
|
||||
_HasTextMatchingSubstringOf Object has text containing substring
|
||||
_IsPrivate Object is marked as private
|
||||
_MatchesFilterBase Object matches another filter
|
||||
_RegExpldBase Object has Gramps Id matching regular expression
|
||||
|
||||
Match on related objects
|
||||
_MatchesFilterEventBase Object has an event that matches another filter
|
||||
_MatchesSourceConfidenceBase Object with specific confidence on direct sources
|
||||
_MatchesSourceFilterBase Object matches another filter on direct sources
|
||||
|
||||
Count based
|
||||
_HasGalleryBase Object has </>/= number of media objects
|
||||
_HasLDSBase Object has </>/= number of LDS sub-objects
|
||||
_HasNoteBase Object has </>/= number of notes
|
||||
_HasReferenceCountBase Object has </>/= number of references
|
||||
_HasSourceCountBase Object has </>/= number of sources
|
||||
|
||||
_Rule Base rule class
|
||||
_Everything Match every object in the database
|
||||
"""
|
||||
|
||||
# Need to expose this to be available for filter plugins:
|
||||
@ -39,5 +80,5 @@ from Filters.Rules._MatchesSourceConfidenceBase import MatchesSourceConfidenceBa
|
||||
from Filters.Rules._MatchesSourceFilterBase import MatchesSourceFilterBase
|
||||
from Filters.Rules._ChangedSinceBase import ChangedSinceBase
|
||||
|
||||
from Filters.Rules import (Person, Family, Event, Source, Place, MediaObject,
|
||||
Repository, Note)
|
||||
from Filters.Rules import (Person, Family, Event, Source, Citation, Place,
|
||||
MediaObject, Repository, Note)
|
||||
|
@ -9,6 +9,7 @@ pkgdata_PYTHON = \
|
||||
_SidebarFilter.py \
|
||||
_PersonSidebarFilter.py\
|
||||
_SourceSidebarFilter.py\
|
||||
_CitationSidebarFilter.py\
|
||||
_PlaceSidebarFilter.py\
|
||||
_MediaSidebarFilter.py\
|
||||
_RepoSidebarFilter.py\
|
||||
|
164
src/Filters/SideBar/_CitationSidebarFilter.py
Normal file
164
src/Filters/SideBar/_CitationSidebarFilter.py
Normal file
@ -0,0 +1,164 @@
|
||||
#
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.ggettext import gettext as _
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# gtk
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import gtk
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gui.widgets import MonitoredMenu
|
||||
import gen.lib
|
||||
from Filters.SideBar import SidebarFilter
|
||||
from Filters import GenericFilterFactory, build_filter_model, Rules
|
||||
from Filters.Rules.Citation import (RegExpIdOf, HasIdOf, HasCitation,
|
||||
HasNoteMatchingSubstringOf, HasNoteRegexp,
|
||||
MatchesFilter)
|
||||
from Utils import confidence
|
||||
GenericCitationFilter = GenericFilterFactory('Citation')
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# PersonSidebarFilter class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class CitationSidebarFilter(SidebarFilter):
|
||||
|
||||
def __init__(self, dbstate, uistate, clicked):
|
||||
self.clicked_func = clicked
|
||||
self.filter_id = gtk.Entry()
|
||||
self.filter_page = gtk.Entry()
|
||||
self.filter_date = gtk.Entry()
|
||||
|
||||
self.filter_conf = gtk.ComboBox()
|
||||
model = gtk.ListStore(str)
|
||||
for conf_value in sorted(confidence.keys()):
|
||||
model.append((confidence[conf_value],))
|
||||
self.filter_conf.set_model(model)
|
||||
self.filter_conf.set_active(2) # gen.lib.Citation.CONF_NORMAL
|
||||
|
||||
self.filter_note = gtk.Entry()
|
||||
|
||||
self.filter_regex = gtk.CheckButton(_('Use regular expressions'))
|
||||
|
||||
self.generic = gtk.ComboBox()
|
||||
|
||||
SidebarFilter.__init__(self, dbstate, uistate, "Citation")
|
||||
|
||||
def create_widget(self):
|
||||
cell = gtk.CellRendererText()
|
||||
cell.set_property('width', self._FILTER_WIDTH)
|
||||
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
|
||||
self.generic.pack_start(cell, True)
|
||||
self.generic.add_attribute(cell, 'text', 0)
|
||||
self.on_filters_changed('Citation')
|
||||
|
||||
cell = gtk.CellRendererText()
|
||||
cell.set_property('width', self._FILTER_WIDTH)
|
||||
cell.set_property('ellipsize', self._FILTER_ELLIPSIZE)
|
||||
self.filter_conf.pack_start(cell, True)
|
||||
self.filter_conf.add_attribute(cell, 'text', 0)
|
||||
|
||||
self.add_text_entry(_('ID'), self.filter_id)
|
||||
self.add_text_entry(_('Volume/Page'), self.filter_page)
|
||||
self.add_text_entry(_('Date'), self.filter_date)
|
||||
self.add_entry(_('Confidence'), self.filter_conf)
|
||||
self.add_text_entry(_('Note'), self.filter_note)
|
||||
self.add_filter_entry(_('Custom filter'), self.generic)
|
||||
self.add_entry(None, self.filter_regex)
|
||||
|
||||
def clear(self, obj):
|
||||
self.filter_id.set_text('')
|
||||
self.filter_page.set_text('')
|
||||
self.filter_date.set_text('')
|
||||
self.filter_conf.set_active(2)
|
||||
self.filter_note.set_text('')
|
||||
self.generic.set_active(0)
|
||||
|
||||
def get_filter(self):
|
||||
gid = unicode(self.filter_id.get_text()).strip()
|
||||
page = unicode(self.filter_page.get_text()).strip()
|
||||
date = unicode(self.filter_date.get_text()).strip()
|
||||
model = self.filter_conf.get_model()
|
||||
node = self.filter_conf.get_active_iter()
|
||||
conf_name = model.get_value(node, 0) # The value is actually the text
|
||||
conf = 2
|
||||
for i in confidence.keys():
|
||||
if confidence[i] == conf_name:
|
||||
conf = i
|
||||
break
|
||||
# conf = self.citn.get_confidence_level()
|
||||
note = unicode(self.filter_note.get_text()).strip()
|
||||
regex = self.filter_regex.get_active()
|
||||
gen = self.generic.get_active() > 0
|
||||
|
||||
empty = not (gid or page or date or conf or note or regex or gen)
|
||||
if empty:
|
||||
generic_filter = None
|
||||
else:
|
||||
generic_filter = GenericCitationFilter()
|
||||
if gid:
|
||||
if regex:
|
||||
rule = RegExpIdOf([gid])
|
||||
else:
|
||||
rule = HasIdOf([gid])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
rule = HasCitation([page, date, conf], use_regex=regex)
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
if note:
|
||||
if regex:
|
||||
rule = HasNoteRegexp([note])
|
||||
else:
|
||||
rule = HasNoteMatchingSubstringOf([note])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
if self.generic.get_active() != 0:
|
||||
model = self.generic.get_model()
|
||||
node = self.generic.get_active_iter()
|
||||
obj = unicode(model.get_value(node, 0))
|
||||
rule = MatchesFilter([obj])
|
||||
generic_filter.add_rule(rule)
|
||||
|
||||
return generic_filter
|
||||
|
||||
def on_filters_changed(self, name_space):
|
||||
if name_space == 'Citation':
|
||||
all_filter = GenericCitationFilter()
|
||||
all_filter.set_name(_("None"))
|
||||
all_filter.add_rule(Rules.Citation.AllCitations([]))
|
||||
self.generic.set_model(build_filter_model('Citation', [all_filter]))
|
||||
self.generic.set_active(0)
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -29,6 +30,7 @@ from _PersonSidebarFilter import PersonSidebarFilter
|
||||
from _FamilySidebarFilter import FamilySidebarFilter
|
||||
from _EventSidebarFilter import EventSidebarFilter
|
||||
from _SourceSidebarFilter import SourceSidebarFilter
|
||||
from _CitationSidebarFilter import CitationSidebarFilter
|
||||
from _PlaceSidebarFilter import PlaceSidebarFilter
|
||||
from _MediaSidebarFilter import MediaSidebarFilter
|
||||
from _RepoSidebarFilter import RepoSidebarFilter
|
||||
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -276,6 +277,20 @@ class GenericSourceFilter(GenericFilter):
|
||||
def find_from_handle(self, db, handle):
|
||||
return db.get_source_from_handle(handle)
|
||||
|
||||
class GenericCitationFilter(GenericFilter):
|
||||
|
||||
def __init__(self, source=None):
|
||||
GenericFilter.__init__(self, source)
|
||||
|
||||
def get_cursor(self, db):
|
||||
return db.get_citation_cursor()
|
||||
|
||||
def make_obj(self):
|
||||
return gen.lib.Citation()
|
||||
|
||||
def find_from_handle(self, db, handle):
|
||||
return db.get_citation_from_handle(handle)
|
||||
|
||||
class GenericPlaceFilter(GenericFilter):
|
||||
|
||||
def __init__(self, source=None):
|
||||
@ -342,6 +357,8 @@ def GenericFilterFactory(namespace):
|
||||
return GenericEventFilter
|
||||
elif namespace == 'Source':
|
||||
return GenericSourceFilter
|
||||
elif namespace == 'Citation':
|
||||
return GenericCitationFilter
|
||||
elif namespace == 'Place':
|
||||
return GenericPlaceFilter
|
||||
elif namespace == 'MediaObject':
|
||||
|
@ -12,6 +12,7 @@ pkgdata_PYTHON = \
|
||||
mergeevent.py \
|
||||
mergeplace.py \
|
||||
mergesource.py \
|
||||
mergecitation.py \
|
||||
mergerepository.py \
|
||||
mergemedia.py \
|
||||
mergenote.py
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2006 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
|
||||
@ -28,6 +29,7 @@ from mergefamily import *
|
||||
from mergeevent import *
|
||||
from mergeplace import *
|
||||
from mergesource import *
|
||||
from mergecitation import *
|
||||
from mergerepository import *
|
||||
from mergemedia import *
|
||||
from mergenote import *
|
||||
|
231
src/Merge/mergecitation.py
Normal file
231
src/Merge/mergecitation.py
Normal file
@ -0,0 +1,231 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2005 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Provide merge capabilities for citations.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib import (Person, Family, Event, Place, MediaObject, Repository)
|
||||
from gen.db import DbTxn
|
||||
from gen.ggettext import sgettext as _
|
||||
import const
|
||||
import GrampsDisplay
|
||||
import ManagedWindow
|
||||
import DateHandler
|
||||
from Errors import MergeError
|
||||
from Utils import confidence
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Gramps constants
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
WIKI_HELP_PAGE = '%s_-_Entering_and_Editing_Data:_Detailed_-_part_3' % \
|
||||
const.URL_MANUAL_PAGE
|
||||
WIKI_HELP_SEC = _('manual|Merge_Citations')
|
||||
_GLADE_FILE = 'mergecitation.glade'
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Merge Citations
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MergeCitations(ManagedWindow.ManagedWindow):
|
||||
"""
|
||||
Displays a dialog box that allows the citations to be combined into one.
|
||||
"""
|
||||
def __init__(self, dbstate, uistate, handle1, handle2):
|
||||
ManagedWindow.ManagedWindow.__init__(self, uistate, [], self.__class__)
|
||||
self.dbstate = dbstate
|
||||
database = dbstate.db
|
||||
self.citation1 = database.get_citation_from_handle(handle1)
|
||||
self.citation2 = database.get_citation_from_handle(handle2)
|
||||
|
||||
self.define_glade('mergecitation', _GLADE_FILE)
|
||||
self.set_window(self._gladeobj.toplevel,
|
||||
self.get_widget('citation_title'),
|
||||
_("Merge Citations"))
|
||||
|
||||
# Detailed Selection widgets
|
||||
page1 = self.citation1.get_page()
|
||||
page2 = self.citation2.get_page()
|
||||
entry1 = self.get_widget("page1")
|
||||
entry2 = self.get_widget("page2")
|
||||
entry1.set_text(page1)
|
||||
entry2.set_text(page2)
|
||||
if entry1.get_text() == entry2.get_text():
|
||||
for widget_name in ('page1', 'page2', 'page_btn1', 'page_btn2'):
|
||||
self.get_widget(widget_name).set_sensitive(False)
|
||||
|
||||
entry1 = self.get_widget("date1")
|
||||
entry2 = self.get_widget("date2")
|
||||
entry1.set_text(DateHandler.get_date(self.citation1))
|
||||
entry2.set_text(DateHandler.get_date(self.citation2))
|
||||
if entry1.get_text() == entry2.get_text():
|
||||
for widget_name in ('date1', 'date2', 'date_btn1',
|
||||
'date_btn2'):
|
||||
self.get_widget(widget_name).set_sensitive(False)
|
||||
|
||||
entry1 = self.get_widget("confidence1")
|
||||
entry2 = self.get_widget("confidence2")
|
||||
entry1.set_text(confidence[self.citation1.get_confidence_level()])
|
||||
entry2.set_text(confidence[self.citation2.get_confidence_level()])
|
||||
if entry1.get_text() == entry2.get_text():
|
||||
for widget_name in ('confidence1', 'confidence2', 'confidence_btn1',
|
||||
'confidence_btn2'):
|
||||
self.get_widget(widget_name).set_sensitive(False)
|
||||
|
||||
gramps1 = self.citation1.get_gramps_id()
|
||||
gramps2 = self.citation2.get_gramps_id()
|
||||
entry1 = self.get_widget("gramps1")
|
||||
entry2 = self.get_widget("gramps2")
|
||||
entry1.set_text(gramps1)
|
||||
entry2.set_text(gramps2)
|
||||
if entry1.get_text() == entry2.get_text():
|
||||
for widget_name in ('gramps1', 'gramps2', 'gramps_btn1',
|
||||
'gramps_btn2'):
|
||||
self.get_widget(widget_name).set_sensitive(False)
|
||||
|
||||
# Main window widgets that determine which handle survives
|
||||
rbutton1 = self.get_widget("handle_btn1")
|
||||
rbutton_label1 = self.get_widget("label_handle_btn1")
|
||||
rbutton_label2 = self.get_widget("label_handle_btn2")
|
||||
rbutton_label1.set_label(page1 + " [" + gramps1 + "]")
|
||||
rbutton_label2.set_label(page2 + " [" + gramps2 + "]")
|
||||
rbutton1.connect("toggled", self.on_handle1_toggled)
|
||||
|
||||
self.connect_button('citation_help', self.cb_help)
|
||||
self.connect_button('citation_ok', self.cb_merge)
|
||||
self.connect_button('citation_cancel', self.close)
|
||||
self.show()
|
||||
|
||||
def on_handle1_toggled(self, obj):
|
||||
"""first chosen citation changes"""
|
||||
if obj.get_active():
|
||||
self.get_widget("page_btn1").set_active(True)
|
||||
self.get_widget("date_btn1").set_active(True)
|
||||
self.get_widget("confidence_btn1").set_active(True)
|
||||
self.get_widget("gramps_btn1").set_active(True)
|
||||
else:
|
||||
self.get_widget("page_btn2").set_active(True)
|
||||
self.get_widget("date_btn2").set_active(True)
|
||||
self.get_widget("confidence_btn2").set_active(True)
|
||||
self.get_widget("gramps_btn2").set_active(True)
|
||||
|
||||
def cb_help(self, obj):
|
||||
"""Display the relevant portion of Gramps manual"""
|
||||
GrampsDisplay.help(webpage = WIKI_HELP_PAGE, section = WIKI_HELP_SEC)
|
||||
|
||||
def cb_merge(self, obj):
|
||||
"""
|
||||
Performs the merge of the citations when the merge button is clicked.
|
||||
"""
|
||||
self.uistate.set_busy_cursor(True)
|
||||
use_handle1 = self.get_widget("handle_btn1").get_active()
|
||||
if use_handle1:
|
||||
phoenix = self.citation1
|
||||
titanic = self.citation2
|
||||
unselect_path = (1,)
|
||||
else:
|
||||
phoenix = self.citation2
|
||||
titanic = self.citation1
|
||||
unselect_path = (0,)
|
||||
|
||||
if self.get_widget("page_btn1").get_active() ^ use_handle1:
|
||||
phoenix.set_page(titanic.get_page())
|
||||
if self.get_widget("date_btn1").get_active() ^ use_handle1:
|
||||
phoenix.set_date_object(titanic.get_date_object())
|
||||
if self.get_widget("confidence_btn1").get_active() ^ use_handle1:
|
||||
phoenix.get_confidence_level(titanic.get_confidence_level())
|
||||
if self.get_widget("gramps_btn1").get_active() ^ use_handle1:
|
||||
phoenix.set_gramps_id(titanic.get_gramps_id())
|
||||
|
||||
query = MergeCitationQuery(self.dbstate, phoenix, titanic)
|
||||
query.execute()
|
||||
self.uistate.viewmanager.active_page.selection.unselect_path(
|
||||
unselect_path)
|
||||
self.uistate.set_busy_cursor(False)
|
||||
self.close()
|
||||
|
||||
class MergeCitationQuery(object):
|
||||
"""
|
||||
Create database query to merge two citations.
|
||||
"""
|
||||
def __init__(self, dbstate, phoenix, titanic):
|
||||
self.database = dbstate.db
|
||||
self.phoenix = phoenix
|
||||
self.titanic = titanic
|
||||
|
||||
def execute(self):
|
||||
"""
|
||||
Merges to citations into a single citation.
|
||||
"""
|
||||
new_handle = self.phoenix.get_handle()
|
||||
old_handle = self.titanic.get_handle()
|
||||
|
||||
self.phoenix.merge(self.titanic)
|
||||
|
||||
with DbTxn(_("Merge Citation"), self.database) as trans:
|
||||
self.database.commit_citation(self.phoenix, trans)
|
||||
for (class_name, handle) in self.database.find_backlink_handles(
|
||||
old_handle):
|
||||
if class_name == Person.__name__:
|
||||
person = self.database.get_person_from_handle(handle)
|
||||
assert(person.has_citation_reference(old_handle))
|
||||
person.replace_citation_references(old_handle, new_handle)
|
||||
self.database.commit_person(person, trans)
|
||||
elif class_name == Family.__name__:
|
||||
family = self.database.get_family_from_handle(handle)
|
||||
assert(family.has_citation_reference(old_handle))
|
||||
family.replace_citation_references(old_handle, new_handle)
|
||||
self.database.commit_family(family, trans)
|
||||
elif class_name == Event.__name__:
|
||||
event = self.database.get_event_from_handle(handle)
|
||||
assert(event.has_citation_reference(old_handle))
|
||||
event.replace_citation_references(old_handle, new_handle)
|
||||
self.database.commit_event(event, trans)
|
||||
elif class_name == Place.__name__:
|
||||
place = self.database.get_place_from_handle(handle)
|
||||
assert(place.has_citation_reference(old_handle))
|
||||
place.replace_citation_references(old_handle, new_handle)
|
||||
self.database.commit_place(place, trans)
|
||||
elif class_name == MediaObject.__name__:
|
||||
obj = self.database.get_object_from_handle(handle)
|
||||
assert(obj.has_citation_reference(old_handle))
|
||||
obj.replace_citation_references(old_handle, new_handle)
|
||||
self.database.commit_media_object(obj, trans)
|
||||
elif class_name == Repository.__name__:
|
||||
repository = self.database.get_repository_from_handle(handle)
|
||||
assert(repository.has_citation_reference(old_handle))
|
||||
repository.replace_citation_references(old_handle,
|
||||
new_handle)
|
||||
self.database.commit_repository(repository, trans)
|
||||
else:
|
||||
raise MergeError("Encounter an object of type %s that has "
|
||||
"a citation reference." % class_name)
|
||||
self.database.remove_citation(old_handle, trans)
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2005 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -31,7 +32,7 @@ Provide merge capabilities for sources.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib import (Person, Family, Event, Place, Source, Repository,
|
||||
MediaObject)
|
||||
MediaObject, Citation)
|
||||
from gen.db import DbTxn
|
||||
from gen.ggettext import sgettext as _
|
||||
import const
|
||||
@ -206,41 +207,11 @@ class MergeSourceQuery(object):
|
||||
self.database.commit_source(self.phoenix, trans)
|
||||
for (class_name, handle) in self.database.find_backlink_handles(
|
||||
old_handle):
|
||||
if class_name == Person.__name__:
|
||||
person = self.database.get_person_from_handle(handle)
|
||||
assert(person.has_source_reference(old_handle))
|
||||
person.replace_source_references(old_handle, new_handle)
|
||||
self.database.commit_person(person, trans)
|
||||
elif class_name == Family.__name__:
|
||||
family = self.database.get_family_from_handle(handle)
|
||||
assert(family.has_source_reference(old_handle))
|
||||
family.replace_source_references(old_handle, new_handle)
|
||||
self.database.commit_family(family, trans)
|
||||
elif class_name == Event.__name__:
|
||||
event = self.database.get_event_from_handle(handle)
|
||||
assert(event.has_source_reference(old_handle))
|
||||
event.replace_source_references(old_handle, new_handle)
|
||||
self.database.commit_event(event, trans)
|
||||
elif class_name == Source.__name__:
|
||||
source = self.database.get_source_from_handle(handle)
|
||||
assert(source.has_source_reference(old_handle))
|
||||
source.replace_source_references(old_handle, new_handle)
|
||||
self.database.commit_source(source, trans)
|
||||
elif class_name == Place.__name__:
|
||||
place = self.database.get_place_from_handle(handle)
|
||||
assert(place.has_source_reference(old_handle))
|
||||
place.replace_source_references(old_handle, new_handle)
|
||||
self.database.commit_place(place, trans)
|
||||
elif class_name == MediaObject.__name__:
|
||||
obj = self.database.get_object_from_handle(handle)
|
||||
assert(obj.has_source_reference(old_handle))
|
||||
obj.replace_source_references(old_handle, new_handle)
|
||||
self.database.commit_media_object(obj, trans)
|
||||
elif class_name == Repository.__name__:
|
||||
repo = self.database.get_repository_from_handle(handle)
|
||||
assert(repo.has_source_reference(old_handle))
|
||||
repo.replace_source_references(old_handle, new_handle)
|
||||
self.database.commit_repository(repo, trans)
|
||||
if class_name == Citation.__name__:
|
||||
citation = self.database.get_citation_from_handle(handle)
|
||||
assert(citation.get_reference_handle() == old_handle)
|
||||
citation.set_reference_handle(new_handle)
|
||||
self.database.commit_citation(citation, trans)
|
||||
else:
|
||||
raise MergeError("Encounter an object of type %s that has "
|
||||
"a source reference." % class_name)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2007 B. Malengier
|
||||
# Copyright (C) 2008 Brian G. Matherly
|
||||
# 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
|
||||
@ -57,7 +58,8 @@ from gui.pluginmanager import GuiPluginManager
|
||||
from gen.plug import (CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_MEDIA,
|
||||
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MISC,
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY,
|
||||
CATEGORY_QR_NOTE)
|
||||
CATEGORY_QR_NOTE, CATEGORY_QR_CITATION,
|
||||
CATEGORY_QR_SOURCE_OR_CITATION)
|
||||
|
||||
def flatten(L):
|
||||
"""
|
||||
@ -119,7 +121,8 @@ def create_quickreport_menu(category,dbstate,uistate, handle) :
|
||||
It collects the reports of the requested category, which must be one of
|
||||
CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY,
|
||||
CATEGORY_QR_EVENT, CATEGORY_QR_SOURCE, CATEGORY_QR_MEDIA,
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY
|
||||
CATEGORY_QR_PLACE, CATEGORY_QR_REPOSITORY,
|
||||
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION
|
||||
It constructs the ui string of the quick report menu, and it's actions
|
||||
The action callback function is constructed, using the dbstate and the
|
||||
handle as input method.
|
||||
@ -166,7 +169,8 @@ def get_quick_report_list(qv_category=None):
|
||||
Returns a list of PluginData of quick views of category qv_category
|
||||
CATEGORY_QR_PERSON, CATEGORY_QR_FAMILY, CATEGORY_QR_EVENT,
|
||||
CATEGORY_QR_SOURCE, CATEGORY_QR_MISC, CATEGORY_QR_PLACE,
|
||||
CATEGORY_QR_REPOSITORY, CATEGORY_QR_MEDIA or None for all
|
||||
CATEGORY_QR_REPOSITORY, CATEGORY_QR_MEDIA,
|
||||
CATEGORY_QR_CITATION, CATEGORY_QR_SOURCE_OR_CITATION or None for all
|
||||
"""
|
||||
names = []
|
||||
pmgr = GuiPluginManager.get_instance()
|
||||
@ -254,6 +258,17 @@ def run_report(dbstate, uistate, category, handle, pdata, container=None,
|
||||
obj = dbstate.db.get_event_from_handle(handle)
|
||||
elif category == CATEGORY_QR_SOURCE :
|
||||
obj = dbstate.db.get_source_from_handle(handle)
|
||||
elif category == CATEGORY_QR_CITATION :
|
||||
obj = dbstate.db.get_citation_from_handle(handle)
|
||||
elif category == CATEGORY_QR_SOURCE_OR_CITATION :
|
||||
source = dbstate.db.get_source_from_handle(handle)
|
||||
citation = dbstate.db.get_citation_from_handle(handle)
|
||||
if (not source and not citation) or (source and citation):
|
||||
raise ValueError("selection must be either source or citation")
|
||||
if citation:
|
||||
obj = citation
|
||||
else:
|
||||
obj = source
|
||||
elif category == CATEGORY_QR_PLACE :
|
||||
obj = dbstate.db.get_place_from_handle(handle)
|
||||
elif category == CATEGORY_QR_MEDIA :
|
||||
|
@ -2,6 +2,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 modiy
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -87,6 +88,7 @@ for (name, file) in (
|
||||
('name', 'geo-show-person.png'),
|
||||
('repository', 'gramps-repository.png'),
|
||||
('source', 'gramps-source.png'),
|
||||
('citation', 'gramps-citation.png'),
|
||||
('text', 'gramps-font.png'),
|
||||
('url', 'gramps-geo.png'),
|
||||
):
|
||||
@ -104,7 +106,7 @@ def map2class(target):
|
||||
'personref': ScratchPersonRef,
|
||||
'childref': ScratchChildRef,
|
||||
'source-link': ScratchSourceLink,
|
||||
'srcref': ScratchSourceRef,
|
||||
'citation-link': ScratchCitation,
|
||||
'repo-link': ScratchRepositoryLink,
|
||||
'pevent': ScratchEvent,
|
||||
'eventref': ScratchEventRef,
|
||||
@ -119,6 +121,7 @@ def obj2class(target):
|
||||
d= {"Person": ScratchPersonLink,
|
||||
"Family": ScratchFamilyLink,
|
||||
'Source': ScratchSourceLink,
|
||||
'Citation': ScratchCitation,
|
||||
'Repository': ScratchRepositoryLink,
|
||||
'Event': ScratchEvent,
|
||||
'Media': ScratchMediaObj,
|
||||
@ -131,6 +134,7 @@ def obj2target(target):
|
||||
d = {"Person": 'person-link',
|
||||
"Family": 'family-link',
|
||||
'Source': 'source-link',
|
||||
'Citation': 'citation-link',
|
||||
'Repository': 'repo-link',
|
||||
'Event': 'pevent',
|
||||
'Media': 'mediaobj',
|
||||
@ -437,24 +441,25 @@ class ScratchFamilyAttribute(ScratchObjWrapper):
|
||||
self._title = str(self._obj.get_type())
|
||||
self._value = self._obj.get_value()
|
||||
|
||||
class ScratchSourceRef(ScratchObjWrapper):
|
||||
class ScratchCitation(ScratchHandleWrapper):
|
||||
|
||||
DROP_TARGETS = [DdTargets.SOURCEREF]
|
||||
DRAG_TARGET = DdTargets.SOURCEREF
|
||||
ICON = LINK_PIC
|
||||
DROP_TARGETS = [DdTargets.CITATION_LINK]
|
||||
DRAG_TARGET = DdTargets.CITATION_LINK
|
||||
ICON = ICONS["citation"]
|
||||
|
||||
def __init__(self, dbstate, obj):
|
||||
super(ScratchSourceRef, self).__init__(dbstate, obj)
|
||||
self._type = _("Source ref")
|
||||
if self._obj:
|
||||
base = self._db.get_source_from_handle(self._obj.get_reference_handle())
|
||||
if base:
|
||||
self._title = base.get_title()
|
||||
super(ScratchCitation, self).__init__(dbstate, obj)
|
||||
self._type = _("Citation")
|
||||
self._objclass = 'Citation'
|
||||
if self._handle:
|
||||
citation = self._db.get_citation_from_handle(self._handle)
|
||||
if citation:
|
||||
self._title = citation.get_gramps_id()
|
||||
notelist = map(self._db.get_note_from_handle,
|
||||
self._obj.get_note_list())
|
||||
citation.get_note_list())
|
||||
srctxtlist = [note for note in notelist
|
||||
if note.get_type() == gen.lib.NoteType.SOURCE_TEXT]
|
||||
page = self._obj.get_page()
|
||||
if note.get_type() == gen.lib.NoteType.SOURCE_TEXT]
|
||||
page = citation.get_page()
|
||||
if not page:
|
||||
page = _('not available|NA')
|
||||
text = ""
|
||||
@ -470,6 +475,14 @@ class ScratchSourceRef(ScratchObjWrapper):
|
||||
'sourcetext' : text,
|
||||
}
|
||||
|
||||
def is_valid(self):
|
||||
data = pickle.loads(self._obj)
|
||||
handle = data[2]
|
||||
obj = self._db.get_citation_from_handle(handle)
|
||||
if obj:
|
||||
return True
|
||||
return False
|
||||
|
||||
class ScratchRepoRef(ScratchObjWrapper):
|
||||
|
||||
DROP_TARGETS = [DdTargets.REPOREF]
|
||||
@ -968,7 +981,6 @@ class ScratchPadListView(object):
|
||||
self.register_wrapper_class(ScratchEvent)
|
||||
self.register_wrapper_class(ScratchPlace)
|
||||
self.register_wrapper_class(ScratchEventRef)
|
||||
self.register_wrapper_class(ScratchSourceRef)
|
||||
self.register_wrapper_class(ScratchRepoRef)
|
||||
self.register_wrapper_class(ScratchFamilyEvent)
|
||||
self.register_wrapper_class(ScratchUrl)
|
||||
@ -979,6 +991,7 @@ class ScratchPadListView(object):
|
||||
self.register_wrapper_class(ScratchMediaObj)
|
||||
self.register_wrapper_class(ScratchMediaRef)
|
||||
self.register_wrapper_class(ScratchSourceLink)
|
||||
self.register_wrapper_class(ScratchCitation)
|
||||
self.register_wrapper_class(ScratchPersonLink)
|
||||
self.register_wrapper_class(ScratchFamilyLink)
|
||||
self.register_wrapper_class(ScratchDropList)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2007 Donald N. Allingham
|
||||
# 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
|
||||
@ -849,6 +850,20 @@ class SimpleAccess(object):
|
||||
return source.get_title()
|
||||
return u''
|
||||
|
||||
def page(self, citation):
|
||||
"""
|
||||
Return the page of the citation.
|
||||
|
||||
@param citation: Source object
|
||||
@type citation: L{gen.lib.Citation}
|
||||
@return: title of the citation
|
||||
@rtype: unicode
|
||||
"""
|
||||
assert(isinstance(citation, (gen.lib.Citation, NoneType)))
|
||||
if citation:
|
||||
return citation.get_page()
|
||||
return u''
|
||||
|
||||
def author(self, source):
|
||||
"""
|
||||
Return the author of the source.
|
||||
@ -952,6 +967,8 @@ class SimpleAccess(object):
|
||||
return obj.desc
|
||||
elif isinstance(obj, gen.lib.Source):
|
||||
return self.title(obj)
|
||||
elif isinstance(obj, gen.lib.Citation):
|
||||
return self.page(obj)
|
||||
elif isinstance(obj, gen.lib.Place):
|
||||
return place_name(self.dbase, obj.handle)
|
||||
elif isinstance(obj, gen.lib.Repository):
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2008 Donald N. Allingham
|
||||
# Copyright (C) 2009 Douglas S. Blank
|
||||
# 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
|
||||
@ -352,6 +353,10 @@ class SimpleTable(object):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self.__link_col == col or link is None):
|
||||
link = ('Source', item.handle)
|
||||
elif isinstance(item, gen.lib.Citation):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self.__link_col == col or link is None):
|
||||
link = ('Citation', item.handle)
|
||||
elif isinstance(item, gen.lib.Event):
|
||||
retval.append(self.access.describe(item))
|
||||
if (self.__link_col == col or link is None):
|
||||
|
93
src/Utils.py
93
src/Utils.py
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 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
|
||||
@ -88,11 +89,11 @@ def format_gender( type):
|
||||
return gender.get(type[0], _("Invalid"))
|
||||
|
||||
confidence = {
|
||||
gen.lib.SourceRef.CONF_VERY_HIGH : _("Very High"),
|
||||
gen.lib.SourceRef.CONF_HIGH : _("High"),
|
||||
gen.lib.SourceRef.CONF_NORMAL : _("Normal"),
|
||||
gen.lib.SourceRef.CONF_LOW : _("Low"),
|
||||
gen.lib.SourceRef.CONF_VERY_LOW : _("Very Low"),
|
||||
gen.lib.Citation.CONF_VERY_HIGH : _("Very High"),
|
||||
gen.lib.Citation.CONF_HIGH : _("High"),
|
||||
gen.lib.Citation.CONF_NORMAL : _("Normal"),
|
||||
gen.lib.Citation.CONF_LOW : _("Low"),
|
||||
gen.lib.Citation.CONF_VERY_LOW : _("Very Low"),
|
||||
}
|
||||
|
||||
family_rel_descriptions = {
|
||||
@ -972,11 +973,78 @@ def get_source_referents(source_handle, db):
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Only Citations can refer to sources, so that is all we need to check
|
||||
"""
|
||||
_primaries = ('Citation',)
|
||||
|
||||
return (get_referents(source_handle, db, _primaries))
|
||||
|
||||
def get_citation_referents(citation_handle, db):
|
||||
""" Find objects that refer the citation.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given citation handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'MediaObject', 'Repository')
|
||||
|
||||
return (get_referents(source_handle, db, _primaries))
|
||||
return (get_referents(citation_handle, db, _primaries))
|
||||
|
||||
def get_source_and_citation_referents(source_handle, db):
|
||||
"""
|
||||
Find all citations that refer to the sources, and recursively, all objects
|
||||
that refer to the sources.
|
||||
|
||||
This function finds all primary objects that refer (directly or through
|
||||
secondary child-objects) to a given source handle in a given database.
|
||||
|
||||
Objects -> Citations -> Source
|
||||
e.g.
|
||||
Media object M1 -> Citation C1 -> Source S1
|
||||
Media object M2 -> Citation C1 -> Source S1
|
||||
Person object P1 -> Citation C2 -> Source S1
|
||||
|
||||
The returned structure is rather ugly, but provides all the information in
|
||||
a way that is consistent with the other Util functions.
|
||||
(
|
||||
tuple of objects that refer to the source - only first element is present
|
||||
([C1, C2],),
|
||||
list of citations with objects that refer to them
|
||||
[
|
||||
(C1,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([], [], [], [], [], [M1, M2]. [])
|
||||
)
|
||||
(C2,
|
||||
tuple of reference lists
|
||||
P, F, E, Pl, S, M, R
|
||||
([P1], [], [], [], [], []. [])
|
||||
)
|
||||
]
|
||||
)
|
||||
#47738: DEBUG: citationtreeview.py: line 428: source referents [(['bfe59e90dbb555d0d87'],)]
|
||||
#47743: DEBUG: citationtreeview.py: line 432: citation bfe59e90dbb555d0d87
|
||||
#47825: DEBUG: citationtreeview.py: line 435: citation_referents_list [[('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))]]
|
||||
#47827: DEBUG: citationtreeview.py: line 440: the_lists [((['bfe59e90dbb555d0d87'],), [('bfe59e90dbb555d0d87', ([], [], ['ba77932bf0b2d59eccb'], [], [], [], []))])]
|
||||
|
||||
"""
|
||||
the_lists = get_source_referents(source_handle, db)
|
||||
LOG.debug('source referents %s' % [the_lists])
|
||||
# now, for each citation, get the objects that refer to that citation
|
||||
citation_referents_list = []
|
||||
for citation in the_lists[0]:
|
||||
LOG.debug('citation %s' % citation)
|
||||
refs = get_citation_referents(citation, db)
|
||||
citation_referents_list += [(citation, refs)]
|
||||
LOG.debug('citation_referents_list %s' % [citation_referents_list])
|
||||
|
||||
(citation_list) = the_lists
|
||||
the_lists = (citation_list, citation_referents_list)
|
||||
|
||||
LOG.debug('the_lists %s' % [the_lists])
|
||||
return the_lists
|
||||
|
||||
def get_media_referents(media_handle, db):
|
||||
""" Find objects that refer the media object.
|
||||
@ -985,7 +1053,7 @@ def get_media_referents(media_handle, db):
|
||||
to a given media handle in a given database.
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place', 'Source')
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place', 'Source', 'Citation')
|
||||
|
||||
return (get_referents(media_handle, db, _primaries))
|
||||
|
||||
@ -997,7 +1065,7 @@ def get_note_referents(note_handle, db):
|
||||
|
||||
"""
|
||||
_primaries = ('Person', 'Family', 'Event', 'Place',
|
||||
'Source', 'MediaObject', 'Repository')
|
||||
'Source', 'Citation', 'MediaObject', 'Repository')
|
||||
|
||||
return (get_referents(note_handle, db, _primaries))
|
||||
|
||||
@ -1456,11 +1524,18 @@ def navigation_label(db, nav_type, handle):
|
||||
obj = db.get_source_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_title()
|
||||
elif nav_type == 'Citation':
|
||||
obj = db.get_citation_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_page()
|
||||
src = db.get_source_from_handle(obj.get_reference_handle())
|
||||
if src:
|
||||
label = src.get_title() + " " + label
|
||||
elif nav_type == 'Repository':
|
||||
obj = db.get_repository_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_name()
|
||||
elif nav_type == 'Media':
|
||||
elif nav_type == 'Media' or nav_type == 'MediaObject':
|
||||
obj = db.get_object_from_handle(handle)
|
||||
if obj:
|
||||
label = obj.get_description()
|
||||
|
@ -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$
|
||||
# $Id: user.py 18393 2011-10-31 16:46:50Z paul-franklin $
|
||||
#
|
||||
|
||||
"""
|
||||
|
@ -5,6 +5,7 @@
|
||||
# Copyright (C) 2005-2007 Donald N. Allingham
|
||||
# Copyright (C) 2008-2009 Gary Burton
|
||||
# Copyright (C) 2009 Doug Blank <doug.blank@gmail.com>
|
||||
# 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
|
||||
@ -177,13 +178,17 @@ register('interface.attribute-height', 350)
|
||||
register('interface.attribute-width', 600)
|
||||
register('interface.child-ref-height', 450)
|
||||
register('interface.child-ref-width', 600)
|
||||
register('interface.citation-height', 450)
|
||||
register('interface.citation-sel-height', 450)
|
||||
register('interface.citation-sel-width', 600)
|
||||
register('interface.citation-width', 600)
|
||||
register('interface.clipboard-height', 300)
|
||||
register('interface.clipboard-width', 300)
|
||||
register('interface.dont-ask', False)
|
||||
register('interface.view-categories',
|
||||
["Gramplets", "People", "Relationships", "Families",
|
||||
"Ancestry", "Events", "Places", "Geography", "Sources",
|
||||
"Repositories", "Media", "Notes"])
|
||||
"Citations", "Repositories", "Media", "Notes"])
|
||||
register('interface.edit-rule-width', 600)
|
||||
register('interface.edit-rule-height', 450)
|
||||
register('interface.event-height', 450)
|
||||
@ -266,6 +271,7 @@ register('paths.quick-backup-filename',
|
||||
|
||||
register('preferences.date-format', 0)
|
||||
register('preferences.calendar-format-report', 0)
|
||||
register('preferences.cprefix', 'C%04d')
|
||||
register('preferences.default-source', False)
|
||||
register('preferences.eprefix', 'E%04d')
|
||||
register('preferences.family-warn', True)
|
||||
|
@ -133,4 +133,7 @@
|
||||
<author uid="ander882" title="contributor">
|
||||
Craig J. Anderson <<html:a href="mailto:ander882@hotmail.com">ander882@hotmail.com</html:a>>
|
||||
</author>
|
||||
<author uid="kulath" title="author">
|
||||
Tim G L Lyons <<html:a href="mailto:tim.g.lyons@gmail.com">tim.g.lyons@gmail.com</html:a>>
|
||||
</author>
|
||||
</authors>
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 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
|
||||
@ -63,7 +64,7 @@ import cPickle as pickle
|
||||
#------------------------------------------------------------------------
|
||||
from gen.db.exceptions import DbException
|
||||
from gen.db.write import FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL, \
|
||||
EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, TAG_TBL, META
|
||||
EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, TAG_TBL, META, CITATIONS_TBL
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
#
|
||||
@ -204,6 +205,7 @@ def __build_tbl_map(database):
|
||||
( FAMILY_TBL, database.family_map.db),
|
||||
( PLACES_TBL, database.place_map.db),
|
||||
( SOURCES_TBL, database.source_map.db),
|
||||
( CITATIONS_TBL, database.citation_map.db),
|
||||
( REPO_TBL, database.repository_map.db),
|
||||
( NOTE_TBL, database.note_map.db),
|
||||
( MEDIA_TBL, database.media_map.db),
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# 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
|
||||
@ -611,6 +612,12 @@ class DbReadBase(object):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_raw_citation_data(self, handle):
|
||||
"""
|
||||
Return raw (serialized and pickled) Citation object from handle
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_raw_tag_data(self, handle):
|
||||
"""
|
||||
Return raw (serialized and pickled) Tag object from handle
|
||||
@ -736,6 +743,44 @@ class DbReadBase(object):
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_citation_bookmarks(self):
|
||||
"""
|
||||
Return the list of Citation handles in the bookmarks.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_citation_cursor(self):
|
||||
"""
|
||||
Return a reference to a cursor over Citation objects
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_citation_from_gramps_id(self, val):
|
||||
"""
|
||||
Find a Citation in the database from the passed gramps' ID.
|
||||
|
||||
If no such Citation exists, None is returned.
|
||||
Needs to be overridden by the derived class.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_citation_from_handle(self, handle):
|
||||
"""
|
||||
Find a Citation in the database from the passed gramps' ID.
|
||||
|
||||
If no such Citation exists, None is returned.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_citation_handles(self, sort_handles=False):
|
||||
"""
|
||||
Return a list of database handles, one handle for each Citation in
|
||||
the database.
|
||||
|
||||
If sort_handles is True, the list is sorted by Citation title.
|
||||
"""
|
||||
raise NotImplementedError
|
||||
|
||||
def get_surname_list(self):
|
||||
"""
|
||||
Return the list of locale-sorted surnames contained in the database.
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-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
|
||||
@ -42,9 +43,9 @@ __all__ = (
|
||||
'DBFLAGS_D',
|
||||
) +
|
||||
|
||||
('PERSON_KEY', 'FAMILY_KEY', 'SOURCE_KEY', 'EVENT_KEY',
|
||||
'MEDIA_KEY', 'PLACE_KEY', 'REPOSITORY_KEY', 'NOTE_KEY',
|
||||
'REFERENCE_KEY', 'TAG_KEY'
|
||||
('PERSON_KEY', 'FAMILY_KEY', 'SOURCE_KEY', 'CITATION_KEY',
|
||||
'EVENT_KEY', 'MEDIA_KEY', 'PLACE_KEY', 'REPOSITORY_KEY',
|
||||
'NOTE_KEY', 'REFERENCE_KEY', 'TAG_KEY'
|
||||
) +
|
||||
|
||||
('TXNADD', 'TXNUPD', 'TXNDEL')
|
||||
@ -84,5 +85,6 @@ REPOSITORY_KEY = 6
|
||||
REFERENCE_KEY = 7
|
||||
NOTE_KEY = 8
|
||||
TAG_KEY = 9
|
||||
CITATION_KEY = 10
|
||||
|
||||
TXNADD, TXNUPD, TXNDEL = 0, 1, 2
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# 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
|
||||
@ -52,8 +53,8 @@ import logging
|
||||
# GRAMPS libraries
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib import (MediaObject, Person, Family, Source, Event, Place,
|
||||
Repository, Note, Tag, GenderStats, Researcher,
|
||||
from gen.lib import (MediaObject, Person, Family, Source, Citation, Event,
|
||||
Place, Repository, Note, Tag, GenderStats, Researcher,
|
||||
NameOriginType)
|
||||
from gen.db.dbconst import *
|
||||
from gen.utils.callback import Callback
|
||||
@ -62,6 +63,7 @@ from Utils import create_id
|
||||
import Errors
|
||||
|
||||
LOG = logging.getLogger(DBLOGNAME)
|
||||
LOG = logging.getLogger(".citation")
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# constants
|
||||
@ -69,8 +71,9 @@ LOG = logging.getLogger(DBLOGNAME)
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.db.dbconst import *
|
||||
|
||||
_SIGBASE = ('person', 'family', 'source', 'event',
|
||||
'media', 'place', 'repository', 'reference', 'note', 'tag')
|
||||
_SIGBASE = ('person', 'family', 'source', 'citation',
|
||||
'event', 'media', 'place', 'repository',
|
||||
'reference', 'note', 'tag')
|
||||
|
||||
DBERRS = (db.DBRunRecoveryError, db.DBAccessError,
|
||||
db.DBPageNotFoundError, db.DBInvalidArgError)
|
||||
@ -153,9 +156,10 @@ class DbReadCursor(BsddbBaseCursor):
|
||||
class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
Read class for the GRAMPS databases. Implements methods necessary to read
|
||||
the various object classes. Currently, there are eight (8) classes:
|
||||
the various object classes. Currently, there are nine (9) classes:
|
||||
|
||||
Person, Family, Event, Place, Source, MediaObject, Repository and Note
|
||||
Person, Family, Event, Place, Source, Citation, MediaObject,
|
||||
Repository and Note
|
||||
|
||||
For each object class, there are methods to retrieve data in various ways.
|
||||
In the methods described below, <object> can be one of person, family,
|
||||
@ -240,6 +244,13 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"class_func": Source,
|
||||
"cursor_func": self.get_source_cursor,
|
||||
},
|
||||
'Citation':
|
||||
{
|
||||
"handle_func": self.get_citation_from_handle,
|
||||
"gramps_id_func": self.get_citation_from_gramps_id,
|
||||
"class_func": Citation,
|
||||
"cursor_func": self.get_citation_cursor,
|
||||
},
|
||||
'Event':
|
||||
{
|
||||
"handle_func": self.get_event_from_handle,
|
||||
@ -288,6 +299,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.set_object_id_prefix('O%04d')
|
||||
self.set_family_id_prefix('F%04d')
|
||||
self.set_source_id_prefix('S%04d')
|
||||
self.set_citation_id_prefix('C%04d')
|
||||
self.set_place_id_prefix('P%04d')
|
||||
self.set_event_id_prefix('E%04d')
|
||||
self.set_repository_id_prefix('R%04d')
|
||||
@ -296,6 +308,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.readonly = False
|
||||
self.rand = random.Random(time.time())
|
||||
self.smap_index = 0
|
||||
self.cmap_index = 0
|
||||
self.emap_index = 0
|
||||
self.pmap_index = 0
|
||||
self.fmap_index = 0
|
||||
@ -328,6 +341,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.fid_trans = {}
|
||||
self.pid_trans = {}
|
||||
self.sid_trans = {}
|
||||
self.cid_trans = {}
|
||||
self.oid_trans = {}
|
||||
self.rid_trans = {}
|
||||
self.nid_trans = {}
|
||||
@ -338,6 +352,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.family_map = {}
|
||||
self.place_map = {}
|
||||
self.source_map = {}
|
||||
self.citation_map = {}
|
||||
self.repository_map = {}
|
||||
self.note_map = {}
|
||||
self.media_map = {}
|
||||
@ -361,6 +376,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.event_bookmarks = DbBookmarks()
|
||||
self.place_bookmarks = DbBookmarks()
|
||||
self.source_bookmarks = DbBookmarks()
|
||||
self.citation_bookmarks = DbBookmarks()
|
||||
self.repo_bookmarks = DbBookmarks()
|
||||
self.media_bookmarks = DbBookmarks()
|
||||
self.note_bookmarks = DbBookmarks()
|
||||
@ -370,12 +386,13 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.txn = None
|
||||
self.has_changed = False
|
||||
|
||||
def set_prefixes(self, person, media, family, source, place, event,
|
||||
repository, note):
|
||||
def set_prefixes(self, person, media, family, source, citation, place,
|
||||
event, repository, note):
|
||||
self.set_person_id_prefix(person)
|
||||
self.set_object_id_prefix(media)
|
||||
self.set_family_id_prefix(family)
|
||||
self.set_source_id_prefix(source)
|
||||
self.set_citation_id_prefix(citation)
|
||||
self.set_place_id_prefix(place)
|
||||
self.set_event_id_prefix(event)
|
||||
self.set_repository_id_prefix(repository)
|
||||
@ -418,6 +435,9 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
def get_source_cursor(self, *args, **kwargs):
|
||||
return self.get_cursor(self.source_map, *args, **kwargs)
|
||||
|
||||
def get_citation_cursor(self, *args, **kwargs):
|
||||
return self.get_cursor(self.citation_map, *args, **kwargs)
|
||||
|
||||
def get_media_cursor(self, *args, **kwargs):
|
||||
return self.get_cursor(self.media_map, *args, **kwargs)
|
||||
|
||||
@ -451,6 +471,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
## self.event_bookmarks = None
|
||||
## self.place_bookmarks = None
|
||||
## self.source_bookmarks = None
|
||||
## self.citation_bookmarks = None
|
||||
## self.repo_bookmarks = None
|
||||
## self.media_bookmarks = None
|
||||
## self.note_bookmarks = None
|
||||
@ -471,6 +492,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.emit('family-rebuild')
|
||||
self.emit('place-rebuild')
|
||||
self.emit('source-rebuild')
|
||||
self.emit('citation-rebuild')
|
||||
self.emit('media-rebuild')
|
||||
self.emit('event-rebuild')
|
||||
self.emit('repository-rebuild')
|
||||
@ -533,6 +555,15 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.smap_index, self.sid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_citation_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Source object based off the
|
||||
source ID prefix.
|
||||
"""
|
||||
self.cmap_index, gid = self.__find_next_gramps_id(self.citation_prefix,
|
||||
self.cmap_index, self.cid_trans)
|
||||
return gid
|
||||
|
||||
def find_next_family_gramps_id(self):
|
||||
"""
|
||||
Return the next available GRAMPS' ID for a Family object based off the
|
||||
@ -613,6 +644,14 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
return self.get_from_handle(handle, Source, self.source_map)
|
||||
|
||||
def get_citation_from_handle(self, handle):
|
||||
"""
|
||||
Find a Citation in the database from the passed handle.
|
||||
|
||||
If no such Citation exists, None is returned.
|
||||
"""
|
||||
return self.get_from_handle(handle, Citation, self.citation_map)
|
||||
|
||||
def get_object_from_handle(self, handle):
|
||||
"""
|
||||
Find an Object in the database from the passed handle.
|
||||
@ -735,6 +774,15 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
return self.__get_obj_from_gramps_id(val, self.sid_trans, Source,
|
||||
self.source_map)
|
||||
|
||||
def get_citation_from_gramps_id(self, val):
|
||||
"""
|
||||
Find a Citation in the database from the passed gramps' ID.
|
||||
|
||||
If no such Citation exists, None is returned.
|
||||
"""
|
||||
return self.__get_obj_from_gramps_id(val, self.cid_trans, Citation,
|
||||
self.citation_map)
|
||||
|
||||
def get_object_from_gramps_id(self, val):
|
||||
"""
|
||||
Find a MediaObject in the database from the passed gramps' ID.
|
||||
@ -829,6 +877,12 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
return self.get_number_of_records(self.source_map)
|
||||
|
||||
def get_number_of_citations(self):
|
||||
"""
|
||||
Return the number of citations currently in the database.
|
||||
"""
|
||||
return self.get_number_of_records(self.citation_map)
|
||||
|
||||
def get_number_of_media_objects(self):
|
||||
"""
|
||||
Return the number of media objects currently in the database.
|
||||
@ -899,6 +953,20 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
return handle_list
|
||||
return []
|
||||
|
||||
def get_citation_handles(self, sort_handles=False):
|
||||
"""
|
||||
Return a list of database handles, one handle for each Citation in
|
||||
the database.
|
||||
|
||||
If sort_handles is True, the list is sorted by Citation Volume/Page.
|
||||
"""
|
||||
if self.db_is_open:
|
||||
handle_list = self.all_handles(self.citation_map)
|
||||
if sort_handles:
|
||||
handle_list.sort(key=self.__sortbycitation_key)
|
||||
return handle_list
|
||||
return []
|
||||
|
||||
def get_media_object_handles(self, sort_handles=False):
|
||||
"""
|
||||
Return a list of database handles, one handle for each MediaObject in
|
||||
@ -980,6 +1048,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
iter_event_handles = _f(get_event_cursor)
|
||||
iter_place_handles = _f(get_place_cursor)
|
||||
iter_source_handles = _f(get_source_cursor)
|
||||
iter_citation_handles = _f(get_citation_cursor)
|
||||
iter_media_object_handles = _f(get_media_cursor)
|
||||
iter_repository_handles = _f(get_repository_cursor)
|
||||
iter_note_handles = _f(get_note_cursor)
|
||||
@ -1005,6 +1074,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
iter_events = _f(get_event_cursor, Event)
|
||||
iter_places = _f(get_place_cursor, Place)
|
||||
iter_sources = _f(get_source_cursor, Source)
|
||||
iter_citations = _f(get_citation_cursor, Citation)
|
||||
iter_media_objects = _f(get_media_cursor, MediaObject)
|
||||
iter_repositories = _f(get_repository_cursor, Repository)
|
||||
iter_notes = _f(get_note_cursor, Note)
|
||||
@ -1016,6 +1086,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
PERSON_KEY: self.id_trans,
|
||||
FAMILY_KEY: self.fid_trans,
|
||||
SOURCE_KEY: self.sid_trans,
|
||||
CITATION_KEY: self.cid_trans,
|
||||
EVENT_KEY: self.eid_trans,
|
||||
MEDIA_KEY: self.oid_trans,
|
||||
PLACE_KEY: self.pid_trans,
|
||||
@ -1031,6 +1102,7 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
PERSON_KEY: self.id_trans,
|
||||
FAMILY_KEY: self.fid_trans,
|
||||
SOURCE_KEY: self.sid_trans,
|
||||
CITATION_KEY: self.cid_trans,
|
||||
EVENT_KEY: self.eid_trans,
|
||||
MEDIA_KEY: self.oid_trans,
|
||||
PLACE_KEY: self.pid_trans,
|
||||
@ -1119,6 +1191,17 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
self.source_prefix = self._validated_id_prefix(val, "S")
|
||||
self.sid2user_format = self.__id2user_format(self.source_prefix)
|
||||
|
||||
def set_citation_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS Citation ID values.
|
||||
|
||||
The string is expected to be in the form of a simple text string, or
|
||||
in a format that contains a C/Python style format string using %d,
|
||||
such as C%d or C%04d.
|
||||
"""
|
||||
self.citation_prefix = self._validated_id_prefix(val, "C")
|
||||
self.cid2user_format = self.__id2user_format(self.citation_prefix)
|
||||
|
||||
def set_object_id_prefix(self, val):
|
||||
"""
|
||||
Set the naming template for GRAMPS MediaObject ID values.
|
||||
@ -1230,6 +1313,10 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""Return the list of Person handles in the bookmarks."""
|
||||
return self.source_bookmarks
|
||||
|
||||
def get_citation_bookmarks(self):
|
||||
"""Return the list of Citation handles in the bookmarks."""
|
||||
return self.citation_bookmarks
|
||||
|
||||
def get_media_bookmarks(self):
|
||||
"""Return the list of Person handles in the bookmarks."""
|
||||
return self.media_bookmarks
|
||||
@ -1405,6 +1492,9 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
def get_raw_source_data(self, handle):
|
||||
return self.__get_raw_data(self.source_map, handle)
|
||||
|
||||
def get_raw_citation_data(self, handle):
|
||||
return self.__get_raw_data(self.citation_map, handle)
|
||||
|
||||
def get_raw_repository_data(self, handle):
|
||||
return self.__get_raw_data(self.repository_map, handle)
|
||||
|
||||
@ -1472,6 +1562,12 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
"""
|
||||
return self.__has_handle(self.source_map, handle)
|
||||
|
||||
def has_citation_handle(self, handle):
|
||||
"""
|
||||
Return True if the handle exists in the current Citation database.
|
||||
"""
|
||||
return self.__has_handle(self.citation_map, handle)
|
||||
|
||||
def has_tag_handle(self, handle):
|
||||
"""
|
||||
Return True if the handle exists in the current Tag database.
|
||||
@ -1498,6 +1594,15 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
source = unicode(self.source_map[str(key)][2])
|
||||
return locale.strxfrm(source)
|
||||
|
||||
def __sortbycitation(self, first, second):
|
||||
citation1 = unicode(self.citation_map[str(first)][3])
|
||||
citation2 = unicode(self.citation_map[str(second)][3])
|
||||
return locale.strcoll(citation1, citation2)
|
||||
|
||||
def __sortbycitation_key(self, key):
|
||||
citation = unicode(self.citation_map[str(key)][3])
|
||||
return locale.strxfrm(citation)
|
||||
|
||||
def __sortbymedia(self, first, second):
|
||||
media1 = self.media_map[str(first)][4]
|
||||
media2 = self.media_map[str(second)][4]
|
||||
@ -1573,6 +1678,10 @@ class DbBsddbRead(DbReadBase, Callback):
|
||||
'cursor_func': self.get_source_cursor,
|
||||
'class_func': Source,
|
||||
},
|
||||
'Citation': {
|
||||
'cursor_func': self.get_citation_cursor,
|
||||
'class_func': Citation,
|
||||
},
|
||||
'MediaObject': {
|
||||
'cursor_func': self.get_media_cursor,
|
||||
'class_func': MediaObject,
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2006 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
|
||||
@ -60,7 +61,7 @@ DBERRS = (db.DBRunRecoveryError, db.DBAccessError,
|
||||
db.DBPageNotFoundError, db.DBInvalidArgError)
|
||||
|
||||
_SIGBASE = ('person', 'family', 'source', 'event', 'media',
|
||||
'place', 'repository', 'reference', 'note', 'tag')
|
||||
'place', 'repository', 'reference', 'note', 'tag', 'citation')
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# DbUndo class
|
||||
@ -84,6 +85,8 @@ class DbUndo(object):
|
||||
self.redoq = deque()
|
||||
self.undo_history_timestamp = time.time()
|
||||
self.txn = None
|
||||
# N.B. the databases have to be in the same order as the numbers in
|
||||
# xxx_KEY in gen/db/dbconst.py
|
||||
self.mapbase = (
|
||||
self.db.person_map,
|
||||
self.db.family_map,
|
||||
@ -95,6 +98,7 @@ class DbUndo(object):
|
||||
self.db.reference_map,
|
||||
self.db.note_map,
|
||||
self.db.tag_map,
|
||||
self.db.citation_map,
|
||||
)
|
||||
|
||||
def clear(self):
|
||||
|
@ -2,6 +2,7 @@
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2004-2006 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
|
||||
@ -25,6 +26,8 @@ from __future__ import with_statement
|
||||
from gen.lib.markertype import MarkerType
|
||||
from gen.lib.tag import Tag
|
||||
import time
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
"""
|
||||
methods to upgrade a database from version 13 to current version
|
||||
@ -37,6 +40,507 @@ else:
|
||||
from gen.db import BSDDBTxn
|
||||
from gen.lib.nameorigintype import NameOriginType
|
||||
from gen.db.write import _mkname, SURNAMES
|
||||
from gen.db.dbconst import (PERSON_KEY, FAMILY_KEY, EVENT_KEY,
|
||||
MEDIA_KEY, PLACE_KEY, REPOSITORY_KEY)
|
||||
from QuestionDialog import (InfoDialog)
|
||||
|
||||
def gramps_upgrade_16(self):
|
||||
"""Upgrade database from version 15 to 16. This upgrade converts all
|
||||
SourceRef child objects to Citation Primary objects.
|
||||
|
||||
For each primary object that has a sourceref, what we have to do is:
|
||||
|
||||
(1) create each citation
|
||||
(2) update the object to reference the Citations
|
||||
(3) remove backlinks for references from object to Source
|
||||
(4) add backlinks for references from object to Citations
|
||||
(5) add backlinks for references from Citation to Source
|
||||
|
||||
the backlinks are all updated at the end by calling
|
||||
reindex_reference_map
|
||||
|
||||
"""
|
||||
length = (len(self.note_map) + len(self.person_map) +
|
||||
len(self.event_map) + len(self.family_map) +
|
||||
len(self.repository_map) + len(self.media_map) +
|
||||
len(self.place_map) + len(self.source_map)) + 10
|
||||
self.set_total(length)
|
||||
|
||||
# Setup data for upgrade statistics information dialogue
|
||||
keyorder = [PERSON_KEY, FAMILY_KEY, EVENT_KEY, MEDIA_KEY,
|
||||
PLACE_KEY, REPOSITORY_KEY]
|
||||
key2data = {
|
||||
PERSON_KEY : 0,
|
||||
FAMILY_KEY : 1,
|
||||
EVENT_KEY: 2,
|
||||
MEDIA_KEY: 3,
|
||||
PLACE_KEY: 4,
|
||||
REPOSITORY_KEY: 5,
|
||||
}
|
||||
key2string = {
|
||||
PERSON_KEY : _('%6d People upgraded with %6d citations in %6d secs\n'),
|
||||
FAMILY_KEY : _('%6d Families upgraded with %6d citations in %6d secs\n'),
|
||||
EVENT_KEY : _('%6d Events upgraded with %6d citations in %6d secs\n'),
|
||||
MEDIA_KEY : _('%6d Media Objects upgraded with %6d citations in %6d secs\n'),
|
||||
PLACE_KEY : _('%6d Places upgraded with %6d citations in %6d secs\n'),
|
||||
REPOSITORY_KEY : _('%6d Repositories upgraded with %6d citations in %6d secs\n'),
|
||||
}
|
||||
data_upgradeobject = [0] * 6
|
||||
|
||||
# Initialise the citation gramps ID number
|
||||
self.cmap_index = 0
|
||||
|
||||
# ---------------------------------
|
||||
# Modify Person
|
||||
# ---------------------------------
|
||||
start_num_citations = self.cmap_index
|
||||
start_time = time.time()
|
||||
for person_handle in self.person_map.keys():
|
||||
person = self.person_map[person_handle]
|
||||
(handle, gramps_id, gender, primary_name, alternate_names,
|
||||
death_ref_index, birth_ref_index, event_ref_list, family_list,
|
||||
parent_family_list, media_list, address_list, attribute_list,
|
||||
urls, lds_seal_list, source_list, note_list, change, tag_list,
|
||||
private, person_ref_list) = person
|
||||
if primary_name:
|
||||
primary_name = upgrade_name_16(self, primary_name)
|
||||
if alternate_names:
|
||||
alternate_names = upgrade_name_list_16(
|
||||
self, alternate_names)
|
||||
if address_list:
|
||||
address_list = upgrade_address_list_16(
|
||||
self, address_list)
|
||||
if media_list:
|
||||
media_list = upgrade_media_list_16(
|
||||
self, media_list)
|
||||
if attribute_list:
|
||||
attribute_list = upgrade_attribute_list_16(
|
||||
self, attribute_list)
|
||||
if lds_seal_list:
|
||||
lds_seal_list = upgrade_lds_seal_list_16(
|
||||
self, lds_seal_list)
|
||||
if source_list:
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
else:
|
||||
new_citation_list = []
|
||||
if person_ref_list:
|
||||
person_ref_list = upgrade_person_ref_list_16(
|
||||
self, person_ref_list)
|
||||
if event_ref_list:
|
||||
event_ref_list = upgrade_event_ref_list_16(self, event_ref_list)
|
||||
if primary_name or alternate_names or address_list or \
|
||||
media_list or attribute_list or lds_seal_list or source_list or \
|
||||
person_ref_list or event_ref_list:
|
||||
new_person = (handle, gramps_id, gender, primary_name,
|
||||
alternate_names, death_ref_index,
|
||||
birth_ref_index, event_ref_list, family_list,
|
||||
parent_family_list, media_list, address_list,
|
||||
attribute_list, urls, lds_seal_list,
|
||||
new_citation_list, note_list, change, tag_list,
|
||||
private, person_ref_list)
|
||||
with BSDDBTxn(self.env, self.person_map) as txn:
|
||||
txn.put(str(handle), new_person)
|
||||
self.update()
|
||||
|
||||
LOG.debug("%d persons upgraded with %d citations in %d seconds. " %
|
||||
(len(self.person_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time))
|
||||
data_upgradeobject[key2data[PERSON_KEY]] = (len(self.person_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time)
|
||||
|
||||
# ---------------------------------
|
||||
# Modify Media
|
||||
# ---------------------------------
|
||||
start_num_citations = self.cmap_index
|
||||
start_time = time.time()
|
||||
for media_handle in self.media_map.keys():
|
||||
media = self.media_map[media_handle]
|
||||
LOG.debug("upgrade media %s" % media[4])
|
||||
(handle, gramps_id, path, mime, desc,
|
||||
attribute_list, source_list, note_list, change,
|
||||
date, tag_list, private) = media
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_attribute_list = upgrade_attribute_list_16(
|
||||
self, attribute_list)
|
||||
|
||||
new_media = (handle, gramps_id, path, mime, desc,
|
||||
new_attribute_list, new_citation_list, note_list,
|
||||
change, date, tag_list, private)
|
||||
LOG.debug(" upgrade new_media %s" % [new_media])
|
||||
with BSDDBTxn(self.env, self.media_map) as txn:
|
||||
txn.put(str(handle), new_media)
|
||||
LOG.debug(" update ref map media %s" % [handle,
|
||||
self.get_object_from_handle(handle) ])
|
||||
self.update()
|
||||
|
||||
LOG.debug("Media upgrade %d citations upgraded in %d seconds" %
|
||||
(self.cmap_index - start_num_citations,
|
||||
int(time.time() - start_time)))
|
||||
data_upgradeobject[key2data[MEDIA_KEY]] = (len(self.media_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time)
|
||||
|
||||
# ---------------------------------
|
||||
# Modify Places
|
||||
# ---------------------------------
|
||||
start_num_citations = self.cmap_index
|
||||
start_time = time.time()
|
||||
for place_handle in self.place_map.keys():
|
||||
place = self.place_map[place_handle]
|
||||
(handle, gramps_id, title, long, lat,
|
||||
main_loc, alt_loc, urls, media_list, source_list, note_list,
|
||||
change, private) = place
|
||||
if source_list:
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
else:
|
||||
new_citation_list = []
|
||||
if media_list:
|
||||
media_list = upgrade_media_list_16(
|
||||
self, media_list)
|
||||
if source_list or media_list:
|
||||
new_place = (handle, gramps_id, title,
|
||||
long, lat, main_loc, alt_loc, urls,
|
||||
media_list, new_citation_list, note_list,
|
||||
change, private)
|
||||
with BSDDBTxn(self.env, self.place_map) as txn:
|
||||
txn.put(str(handle), new_place)
|
||||
self.update()
|
||||
|
||||
LOG.debug("%d places upgraded with %d citations in %d seconds. " %
|
||||
(len(self.place_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time))
|
||||
data_upgradeobject[key2data[PLACE_KEY]] = (len(self.place_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time)
|
||||
|
||||
# ---------------------------------
|
||||
# Modify Families
|
||||
# ---------------------------------
|
||||
start_num_citations = self.cmap_index
|
||||
start_time = time.time()
|
||||
for family_handle in self.family_map.keys():
|
||||
family = self.family_map[family_handle]
|
||||
(handle, gramps_id, father_handle, mother_handle,
|
||||
child_ref_list, the_type, event_ref_list, media_list,
|
||||
attribute_list, lds_seal_list, source_list, note_list,
|
||||
change, tag_list, private) = family
|
||||
if source_list:
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
else:
|
||||
new_citation_list = []
|
||||
if child_ref_list:
|
||||
child_ref_list = upgrade_child_ref_list_16(
|
||||
self, child_ref_list)
|
||||
if lds_seal_list:
|
||||
lds_seal_list = upgrade_lds_seal_list_16(
|
||||
self, lds_seal_list)
|
||||
if media_list:
|
||||
media_list = upgrade_media_list_16(
|
||||
self, media_list)
|
||||
if attribute_list:
|
||||
attribute_list = upgrade_attribute_list_16(
|
||||
self, attribute_list)
|
||||
if event_ref_list:
|
||||
event_ref_list = upgrade_event_ref_list_16(self, event_ref_list)
|
||||
if source_list or media_list or child_ref_list or \
|
||||
attribute_list or lds_seal_list or event_ref_list:
|
||||
new_family = (handle, gramps_id, father_handle, mother_handle,
|
||||
child_ref_list, the_type, event_ref_list, media_list,
|
||||
attribute_list, lds_seal_list, new_citation_list,
|
||||
note_list, change, tag_list, private)
|
||||
with BSDDBTxn(self.env, self.family_map) as txn:
|
||||
txn.put(str(handle), new_family)
|
||||
self.update()
|
||||
|
||||
LOG.debug("%d familys upgraded with %d citations in %d seconds. " %
|
||||
(len(self.family_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time))
|
||||
data_upgradeobject[key2data[FAMILY_KEY]] = (len(self.family_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time)
|
||||
# ---------------------------------
|
||||
# Modify Events
|
||||
# ---------------------------------
|
||||
upgrade_time = 0
|
||||
backlink_time = 0
|
||||
start_num_citations = self.cmap_index
|
||||
start_time = time.time()
|
||||
for event_handle in self.event_map.keys():
|
||||
t1 = time.time()
|
||||
event = self.event_map[event_handle]
|
||||
(handle, gramps_id, the_type, date, description, place,
|
||||
source_list, note_list, media_list, attribute_list,
|
||||
change, private) = event
|
||||
if source_list:
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
else:
|
||||
new_citation_list = []
|
||||
if attribute_list:
|
||||
attribute_list = upgrade_attribute_list_16(
|
||||
self, attribute_list)
|
||||
if media_list:
|
||||
media_list = upgrade_media_list_16(
|
||||
self, media_list)
|
||||
if source_list or attribute_list or media_list:
|
||||
new_event = (handle, gramps_id, the_type, date, description, place,
|
||||
new_citation_list, note_list, media_list,
|
||||
attribute_list,
|
||||
change, private)
|
||||
with BSDDBTxn(self.env, self.event_map) as txn:
|
||||
txn.put(str(handle), new_event)
|
||||
t2 = time.time()
|
||||
upgrade_time += t2 - t1
|
||||
t3 = time.time()
|
||||
backlink_time += t3 - t2
|
||||
self.update()
|
||||
|
||||
LOG.debug("%d events upgraded with %d citations in %d seconds. "
|
||||
"Backlinks took %d seconds" %
|
||||
(len(self.event_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
int(upgrade_time), int(backlink_time)))
|
||||
data_upgradeobject[key2data[EVENT_KEY]] = (len(self.event_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time)
|
||||
|
||||
# ---------------------------------
|
||||
# Modify Repositories
|
||||
# ---------------------------------
|
||||
start_num_citations = self.cmap_index
|
||||
start_time = time.time()
|
||||
for repository_handle in self.repository_map.keys():
|
||||
repository = self.repository_map[repository_handle]
|
||||
(handle, gramps_id, the_type, name, note_list,
|
||||
address_list, urls, change, private) = repository
|
||||
if address_list:
|
||||
address_list = upgrade_address_list_16(
|
||||
self, address_list)
|
||||
if address_list:
|
||||
new_repository = (handle, gramps_id, the_type, name, note_list,
|
||||
address_list, urls, change, private)
|
||||
with BSDDBTxn(self.env, self.repository_map) as txn:
|
||||
txn.put(str(handle), new_repository)
|
||||
self.update()
|
||||
|
||||
LOG.debug("%d repositorys upgraded with %d citations in %d seconds. " %
|
||||
(len(self.repository_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time))
|
||||
data_upgradeobject[key2data[REPOSITORY_KEY]] = (len(self.repository_map.keys()),
|
||||
self.cmap_index - start_num_citations,
|
||||
time.time() - start_time)
|
||||
# ---------------------------------
|
||||
|
||||
|
||||
# ---------------------------------
|
||||
# Example database from repository took:
|
||||
# 3403 events upgraded with 8 citations in 23 seconds. Backlinks took 1071 seconds
|
||||
# actually 4 of these citations were from:
|
||||
# Media upgrade 4 citations upgraded in 4 seconds
|
||||
# by only doing the backlinks when there might be something to do,
|
||||
# improved to:
|
||||
# 3403 events upgraded with 8 citations in 19 seconds. Backlinks took 1348 seconds
|
||||
# further improved by skipping debug logging:
|
||||
# 3403 events upgraded with 8 citations in 2 seconds. Backlinks took 167 seconds
|
||||
|
||||
#Number of new objects upgraded:
|
||||
# 2090 People upgraded with 2092 citations in 2148 secs
|
||||
# 734 Families upgraded with 735 citations in 768 secs
|
||||
# 3403 Events upgraded with 4 citations in 212 secs
|
||||
# 7 Media Objects upgraded with 4 citations in 3 secs
|
||||
# 852 Places upgraded with 0 citations in 39 secs
|
||||
|
||||
# with reduced diagnostics
|
||||
#Number of new objects upgraded:
|
||||
# 73 People upgraded with 76 citations in 74 secs
|
||||
# 35 Families upgraded with 36 citations in 31 secs
|
||||
# 3403 Events upgraded with 4 citations in 7 secs
|
||||
# 7 Media Objects upgraded with 4 citations in 3 secs
|
||||
# 852 Places upgraded with 0 citations in 1 secs
|
||||
|
||||
# without doing any backlinks
|
||||
#Number of new objects upgraded:
|
||||
# 73 People upgraded with 76 citations in 43 secs
|
||||
# 35 Families upgraded with 36 citations in 24 secs
|
||||
# 3403 Events upgraded with 4 citations in 6 secs
|
||||
# 7 Media Objects upgraded with 4 citations in 2 secs
|
||||
# 852 Places upgraded with 0 citations in 1 secs
|
||||
|
||||
# another run about the same code:
|
||||
#Number of new objects upgraded:
|
||||
# 73 People upgraded with 76 citations in 48 secs
|
||||
# 35 Families upgraded with 36 citations in 21 secs
|
||||
# 3403 Events upgraded with 4 citations in 9 secs
|
||||
# 7 Media Objects upgraded with 4 citations in 4 secs
|
||||
# 852 Places upgraded with 0 citations in 1 secs
|
||||
|
||||
# another run
|
||||
#Number of new objects upgraded:
|
||||
# 73 People upgraded with 76 citations in 36 secs
|
||||
# 35 Families upgraded with 36 citations in 18 secs
|
||||
# 3403 Events upgraded with 4 citations in 9 secs
|
||||
# 7 Media Objects upgraded with 4 citations in 2 secs
|
||||
# 852 Places upgraded with 0 citations in 1 secs
|
||||
|
||||
# without incorrect nestetd tranaction structure:
|
||||
#Number of new objects upgraded:
|
||||
# 73 People upgraded with 76 citations in 0 secs
|
||||
# 35 Families upgraded with 36 citations in 0 secs
|
||||
# 3403 Events upgraded with 4 citations in 0 secs
|
||||
# 7 Media Objects upgraded with 4 citations in 0 secs
|
||||
# 852 Places upgraded with 0 citations in 0 secs
|
||||
|
||||
#[[(73, 76, 0.12430405616760254), (35, 36, 0.042523860931396484), (3403, 4, 0.52303886413574219), (7, 4, 0.058229923248291016), (852, 0, 0.14816904067993164)]]
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Bump up database version. Separate transaction to save metadata.
|
||||
with BSDDBTxn(self.env, self.metadata) as txn:
|
||||
txn.put('version', 16)
|
||||
|
||||
LOG.debug([data_upgradeobject])
|
||||
txt = _("Number of new objects upgraded:\n")
|
||||
for key in keyorder:
|
||||
try:
|
||||
txt += key2string[key] % data_upgradeobject[key2data[key]]
|
||||
except:
|
||||
txt += key2string[key]
|
||||
txt += _("\n\nYou may want to run\n"
|
||||
"Tools -> Family Tree Processing -> Merge\n"
|
||||
"in order to merge citations that contain similar\n"
|
||||
"information")
|
||||
InfoDialog(_('Upgrade Statistics'), txt)
|
||||
|
||||
def upgrade_media_list_16(self, media_list):
|
||||
new_media_list = []
|
||||
for media in media_list:
|
||||
(privacy, source_list, note_list, attribute_list, ref, rect) = media
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_attribute_list = upgrade_attribute_list_16(
|
||||
self, attribute_list)
|
||||
new_media = (privacy, new_citation_list, note_list, new_attribute_list,
|
||||
ref, rect)
|
||||
new_media_list.append((new_media))
|
||||
return new_media_list
|
||||
|
||||
def upgrade_attribute_list_16(self, attribute_list):
|
||||
new_attribute_list = []
|
||||
for attribute in attribute_list:
|
||||
(privacy, source_list, note_list, the_type,
|
||||
value) = attribute
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_attribute = (privacy, new_citation_list, note_list,
|
||||
the_type, value)
|
||||
new_attribute_list.append((new_attribute))
|
||||
return new_attribute_list
|
||||
|
||||
def upgrade_child_ref_list_16(self, child_ref_list):
|
||||
new_child_ref_list = []
|
||||
for child_ref in child_ref_list:
|
||||
(privacy, source_list, note_list, ref, frel, mrel) = child_ref
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_child_ref = (privacy, new_citation_list, note_list, ref, frel, mrel)
|
||||
new_child_ref_list.append((new_child_ref))
|
||||
return new_child_ref_list
|
||||
|
||||
def upgrade_lds_seal_list_16(self, lds_seal_list):
|
||||
new_lds_seal_list = []
|
||||
for lds_seal in lds_seal_list:
|
||||
(source_list, note_list, date, type, place,
|
||||
famc, temple, status, private) = lds_seal
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_lds_seal = (new_citation_list, note_list, date, type, place,
|
||||
famc, temple, status, private)
|
||||
new_lds_seal_list.append((new_lds_seal))
|
||||
return new_lds_seal_list
|
||||
|
||||
def upgrade_address_list_16(self, address_list):
|
||||
new_address_list = []
|
||||
for address in address_list:
|
||||
(privacy, source_list, note_list, date, location) = address
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_address = (privacy, new_citation_list, note_list, date, location)
|
||||
new_address_list.append((new_address))
|
||||
return new_address_list
|
||||
|
||||
def upgrade_name_list_16(self, name_list):
|
||||
new_name_list = []
|
||||
for name in name_list:
|
||||
new_name = upgrade_name_16(self, name)
|
||||
new_name_list.append((new_name))
|
||||
return new_name_list
|
||||
|
||||
def upgrade_name_16(self, name):
|
||||
(privacy, source_list, note, date, first_name, surname_list, suffix,
|
||||
title, name_type, group_as, sort_as, display_as, call, nick,
|
||||
famnick) = name
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_name = (privacy, new_citation_list, note, date, first_name,
|
||||
surname_list, suffix, title, name_type, group_as, sort_as,
|
||||
display_as, call, nick, famnick)
|
||||
return new_name
|
||||
|
||||
def upgrade_person_ref_list_16(self, person_ref_list):
|
||||
new_person_ref_list = []
|
||||
for person_ref in person_ref_list:
|
||||
(privacy, source_list, note_list, ref, rel) = person_ref
|
||||
new_citation_list = convert_source_list_to_citation_list_16(
|
||||
self, source_list)
|
||||
new_person_ref = (privacy, new_citation_list, note_list, ref, rel)
|
||||
new_person_ref_list.append((new_person_ref))
|
||||
return new_person_ref_list
|
||||
|
||||
def upgrade_event_ref_list_16(self, event_ref_list):
|
||||
new_event_ref_list = []
|
||||
for event_ref in event_ref_list:
|
||||
(privacy, note_list, attribute_list, ref, role) = event_ref
|
||||
new_attribute_list = upgrade_attribute_list_16(
|
||||
self, attribute_list)
|
||||
new_event_ref = (privacy, note_list, new_attribute_list, ref, role)
|
||||
new_event_ref_list.append((new_event_ref))
|
||||
return new_event_ref_list
|
||||
|
||||
def convert_source_list_to_citation_list_16(self, source_list):
|
||||
citation_list = []
|
||||
for source in source_list:
|
||||
(date, private, note_list, confidence, ref, page) = source
|
||||
new_handle = self.create_id()
|
||||
new_media_list = []
|
||||
new_data_map = {}
|
||||
new_change = time.time()
|
||||
new_gramps_id = self.citation_prefix % self.cmap_index
|
||||
new_citation = (new_handle, new_gramps_id,
|
||||
date, page, confidence, ref, note_list, new_media_list,
|
||||
new_data_map, new_change, private)
|
||||
with BSDDBTxn(self.env, self.citation_map) as txn:
|
||||
txn.put(str(new_handle), new_citation)
|
||||
self.cmap_index += 1
|
||||
# # add backlinks for references from Citation to Source
|
||||
# with BSDDBTxn(self.env) as txn:
|
||||
# self.update_reference_map(
|
||||
# self.get_citation_from_handle(new_handle),
|
||||
# transaction,
|
||||
# txn.txn)
|
||||
citation_list.append((new_handle))
|
||||
return citation_list
|
||||
|
||||
def gramps_upgrade_15(self):
|
||||
"""Upgrade database from version 14 to 15. This upgrade adds:
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2008 Donald N. Allingham
|
||||
# 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
|
||||
@ -54,7 +55,7 @@ else:
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib import (GenderStats, Person, Family, Event, Place, Source,
|
||||
MediaObject, Repository, Note, Tag)
|
||||
Citation, MediaObject, Repository, Note, Tag)
|
||||
from gen.db import (DbBsddbRead, DbWriteBase, BSDDBTxn,
|
||||
DbTxn, BsddbBaseCursor, BsddbDowngradeError, DbVersionError,
|
||||
DbEnvironmentError, DbUpgradeRequiredError, find_surname,
|
||||
@ -66,8 +67,9 @@ import Errors
|
||||
import constfunc
|
||||
|
||||
_LOG = logging.getLogger(DBLOGNAME)
|
||||
LOG = logging.getLogger(".citation")
|
||||
_MINVERSION = 9
|
||||
_DBVERSION = 15
|
||||
_DBVERSION = 16
|
||||
|
||||
IDTRANS = "person_id"
|
||||
FIDTRANS = "family_id"
|
||||
@ -77,6 +79,7 @@ EIDTRANS = "event_id"
|
||||
RIDTRANS = "repo_id"
|
||||
NIDTRANS = "note_id"
|
||||
SIDTRANS = "source_id"
|
||||
CIDTRANS = "citation_id"
|
||||
TAGTRANS = "tag_name"
|
||||
SURNAMES = "surnames"
|
||||
NAME_GROUP = "name_group"
|
||||
@ -85,6 +88,7 @@ META = "meta_data"
|
||||
FAMILY_TBL = "family"
|
||||
PLACES_TBL = "place"
|
||||
SOURCES_TBL = "source"
|
||||
CITATIONS_TBL = "citation"
|
||||
MEDIA_TBL = "media"
|
||||
EVENTS_TBL = "event"
|
||||
PERSON_TBL = "person"
|
||||
@ -108,6 +112,7 @@ DBERRS = (db.DBRunRecoveryError, db.DBAccessError,
|
||||
CLASS_TO_KEY_MAP = {Person.__name__: PERSON_KEY,
|
||||
Family.__name__: FAMILY_KEY,
|
||||
Source.__name__: SOURCE_KEY,
|
||||
Citation.__name__: CITATION_KEY,
|
||||
Event.__name__: EVENT_KEY,
|
||||
MediaObject.__name__: MEDIA_KEY,
|
||||
Place.__name__: PLACE_KEY,
|
||||
@ -118,6 +123,7 @@ CLASS_TO_KEY_MAP = {Person.__name__: PERSON_KEY,
|
||||
KEY_TO_CLASS_MAP = {PERSON_KEY: Person.__name__,
|
||||
FAMILY_KEY: Family.__name__,
|
||||
SOURCE_KEY: Source.__name__,
|
||||
CITATION_KEY: Citation.__name__,
|
||||
EVENT_KEY: Event.__name__,
|
||||
MEDIA_KEY: MediaObject.__name__,
|
||||
PLACE_KEY: Place.__name__,
|
||||
@ -129,6 +135,7 @@ KEY_TO_NAME_MAP = {PERSON_KEY: 'person',
|
||||
FAMILY_KEY: 'family',
|
||||
EVENT_KEY: 'event',
|
||||
SOURCE_KEY: 'source',
|
||||
CITATION_KEY: 'citation',
|
||||
PLACE_KEY: 'place',
|
||||
MEDIA_KEY: 'media',
|
||||
REPOSITORY_KEY: 'repository',
|
||||
@ -195,7 +202,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
__signals__ = dict((obj+'-'+op, signal)
|
||||
for obj in
|
||||
['person', 'family', 'event', 'place',
|
||||
'source', 'media', 'note', 'repository', 'tag']
|
||||
'source', 'citation', 'media', 'note', 'repository', 'tag']
|
||||
for op, signal in zip(
|
||||
['add', 'update', 'delete', 'rebuild'],
|
||||
[(list,), (list,), (list,), None]
|
||||
@ -392,8 +399,9 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
return True
|
||||
|
||||
# See if we lack write access to any files in the directory
|
||||
for base in [FAMILY_TBL, PLACES_TBL, SOURCES_TBL, MEDIA_TBL,
|
||||
EVENTS_TBL, PERSON_TBL, REPO_TBL, NOTE_TBL, REF_MAP, META]:
|
||||
for base in [FAMILY_TBL, PLACES_TBL, SOURCES_TBL, CITATIONS_TBL,
|
||||
MEDIA_TBL, EVENTS_TBL, PERSON_TBL, REPO_TBL,
|
||||
NOTE_TBL, REF_MAP, META]:
|
||||
path = os.path.join(name, base + DBEXT)
|
||||
if os.path.isfile(path) and not os.access(path, os.W_OK):
|
||||
return True
|
||||
@ -499,6 +507,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
("family_map", FAMILY_TBL, db.DB_HASH),
|
||||
("place_map", PLACES_TBL, db.DB_HASH),
|
||||
("source_map", SOURCES_TBL, db.DB_HASH),
|
||||
("citation_map", CITATIONS_TBL, db.DB_HASH),
|
||||
("media_map", MEDIA_TBL, db.DB_HASH),
|
||||
("event_map", EVENTS_TBL, db.DB_HASH),
|
||||
("person_map", PERSON_TBL, db.DB_HASH),
|
||||
@ -600,6 +609,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.family_bookmarks.set(meta('family_bookmarks'))
|
||||
self.event_bookmarks.set(meta('event_bookmarks'))
|
||||
self.source_bookmarks.set(meta('source_bookmarks'))
|
||||
self.citation_bookmarks.set(meta('citation_bookmarks'))
|
||||
self.repo_bookmarks.set(meta('repo_bookmarks'))
|
||||
self.media_bookmarks.set(meta('media_bookmarks'))
|
||||
self.place_bookmarks.set(meta('place_bookmarks'))
|
||||
@ -646,6 +656,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
("eid_trans", EIDTRANS, db.DB_HASH, 0),
|
||||
("pid_trans", PIDTRANS, db.DB_HASH, 0),
|
||||
("sid_trans", SIDTRANS, db.DB_HASH, 0),
|
||||
("cid_trans", CIDTRANS, db.DB_HASH, 0),
|
||||
("oid_trans", OIDTRANS, db.DB_HASH, 0),
|
||||
("rid_trans", RIDTRANS, db.DB_HASH, 0),
|
||||
("nid_trans", NIDTRANS, db.DB_HASH, 0),
|
||||
@ -668,6 +679,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
(self.event_map, self.eid_trans, find_idmap),
|
||||
(self.place_map, self.pid_trans, find_idmap),
|
||||
(self.source_map, self.sid_trans, find_idmap),
|
||||
(self.citation_map, self.cid_trans, find_idmap),
|
||||
(self.media_map, self.oid_trans, find_idmap),
|
||||
(self.repository_map, self.rid_trans, find_idmap),
|
||||
(self.note_map, self.nid_trans, find_idmap),
|
||||
@ -684,6 +696,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
|
||||
self.secondary_connected = True
|
||||
self.smap_index = len(self.source_map)
|
||||
self.cmap_index = len(self.citation_map)
|
||||
self.emap_index = len(self.event_map)
|
||||
self.pmap_index = len(self.person_map)
|
||||
self.fmap_index = len(self.family_map)
|
||||
@ -710,6 +723,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
( self.eid_trans, EIDTRANS ),
|
||||
( self.rid_trans, RIDTRANS ),
|
||||
( self.nid_trans, NIDTRANS ),
|
||||
( self.cid_trans, CIDTRANS ),
|
||||
( self.tag_trans, TAGTRANS ),
|
||||
( self.reference_map_primary_map, REF_PRI),
|
||||
( self.reference_map_referenced_map, REF_REF),
|
||||
@ -959,6 +973,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
(self.get_event_cursor, Event),
|
||||
(self.get_place_cursor, Place),
|
||||
(self.get_source_cursor, Source),
|
||||
(self.get_citation_cursor, Citation),
|
||||
(self.get_media_cursor, MediaObject),
|
||||
(self.get_repository_cursor, Repository),
|
||||
(self.get_note_cursor, Note),
|
||||
@ -969,6 +984,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
# to loop through each of the primary object tables.
|
||||
|
||||
for cursor_func, class_func in primary_table:
|
||||
print "Rebuilding %s reference map" % class_func.__name__
|
||||
with cursor_func() as cursor:
|
||||
for found_handle, val in cursor:
|
||||
obj = class_func()
|
||||
@ -1003,6 +1019,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
txn.put('family_bookmarks', self.family_bookmarks.get())
|
||||
txn.put('event_bookmarks', self.event_bookmarks.get())
|
||||
txn.put('source_bookmarks', self.source_bookmarks.get())
|
||||
txn.put('citation_bookmarks', self.citation_bookmarks.get())
|
||||
txn.put('place_bookmarks', self.place_bookmarks.get())
|
||||
txn.put('repo_bookmarks', self.repo_bookmarks.get())
|
||||
txn.put('media_bookmarks', self.media_bookmarks.get())
|
||||
@ -1068,6 +1085,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.nid_trans.close()
|
||||
self.oid_trans.close()
|
||||
self.sid_trans.close()
|
||||
self.cid_trans.close()
|
||||
self.pid_trans.close()
|
||||
self.tag_trans.close()
|
||||
self.reference_map_primary_map.close()
|
||||
@ -1083,6 +1101,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.note_map.close()
|
||||
self.place_map.close()
|
||||
self.source_map.close()
|
||||
self.citation_map.close()
|
||||
self.media_map.close()
|
||||
self.event_map.close()
|
||||
self.tag_map.close()
|
||||
@ -1095,6 +1114,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.note_map = None
|
||||
self.place_map = None
|
||||
self.source_map = None
|
||||
self.citation_map = None
|
||||
self.media_map = None
|
||||
self.event_map = None
|
||||
self.tag_map = None
|
||||
@ -1112,6 +1132,7 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.note_map = None
|
||||
self.place_map = None
|
||||
self.source_map = None
|
||||
self.citation_map = None
|
||||
self.media_map = None
|
||||
self.event_map = None
|
||||
self.tag_map = None
|
||||
@ -1184,6 +1205,17 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.find_next_source_gramps_id if set_gid else None,
|
||||
self.commit_source)
|
||||
|
||||
def add_citation(self, citation, transaction, set_gid=True):
|
||||
"""
|
||||
Add a Citation to the database, assigning internal IDs if they have
|
||||
not already been defined.
|
||||
|
||||
If not set_gid, then gramps_id is not set.
|
||||
"""
|
||||
return self.__add_object(citation, transaction,
|
||||
self.find_next_citation_gramps_id if set_gid else None,
|
||||
self.commit_citation)
|
||||
|
||||
def add_event(self, event, transaction, set_gid=True):
|
||||
"""
|
||||
Add an Event to the database, assigning internal IDs if they have
|
||||
@ -1311,6 +1343,14 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
self.__do_remove(handle, transaction, self.source_map,
|
||||
SOURCE_KEY)
|
||||
|
||||
def remove_citation(self, handle, transaction):
|
||||
"""
|
||||
Remove the Citation specified by the database handle from the
|
||||
database, preserving the change in the passed transaction.
|
||||
"""
|
||||
self.__do_remove(handle, transaction, self.citation_map,
|
||||
CITATION_KEY)
|
||||
|
||||
def remove_event(self, handle, transaction):
|
||||
"""
|
||||
Remove the Event specified by the database handle from the
|
||||
@ -1548,6 +1588,20 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
if attr.type.is_custom() and str(attr.type)]
|
||||
self.media_attributes.update(attr_list)
|
||||
|
||||
def commit_citation(self, citation, transaction, change_time=None):
|
||||
"""
|
||||
Commit the specified Citation to the database, storing the changes as
|
||||
part of the transaction.
|
||||
"""
|
||||
self.commit_base(citation, self.citation_map, CITATION_KEY,
|
||||
transaction, change_time)
|
||||
|
||||
attr_list = []
|
||||
for mref in citation.media_list:
|
||||
attr_list += [str(attr.type) for attr in mref.attribute_list
|
||||
if attr.type.is_custom() and str(attr.type)]
|
||||
self.media_attributes.update(attr_list)
|
||||
|
||||
def commit_place(self, place, transaction, change_time=None):
|
||||
"""
|
||||
Commit the specified Place to the database, storing the changes as
|
||||
@ -1854,6 +1908,21 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
|
||||
upgrade.gramps_upgrade_14(self)
|
||||
if version < 15:
|
||||
upgrade.gramps_upgrade_15(self)
|
||||
if version < 16:
|
||||
upgrade.gramps_upgrade_16(self)
|
||||
|
||||
self.reset()
|
||||
self.set_total(6)
|
||||
self.__connect_secondary()
|
||||
# Open undo database
|
||||
self.__open_undodb()
|
||||
self.db_is_open = True
|
||||
self.reindex_reference_map(self.update)
|
||||
self.reset()
|
||||
# Close undo database
|
||||
self.__close_undodb()
|
||||
self.db_is_open = False
|
||||
|
||||
|
||||
_LOG.debug("Upgrade time: %d seconds" % int(time.time()-t))
|
||||
|
||||
|
@ -15,6 +15,8 @@ pkgdata_PYTHON = \
|
||||
calendar.py \
|
||||
childref.py \
|
||||
childreftype.py \
|
||||
citation.py \
|
||||
citationbase.py \
|
||||
const.py \
|
||||
datebase.py \
|
||||
date.py \
|
||||
@ -54,11 +56,9 @@ pkgdata_PYTHON = \
|
||||
repotype.py \
|
||||
researcher.py \
|
||||
secondaryobj.py \
|
||||
srcbase.py \
|
||||
srcmediatype.py \
|
||||
srcnote.py \
|
||||
src.py \
|
||||
srcref.py \
|
||||
surname.py \
|
||||
surnamebase.py \
|
||||
styledtext.py \
|
||||
|
@ -2,6 +2,7 @@
|
||||
# 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
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -35,7 +36,6 @@ from gen.lib.ldsord import LdsOrd
|
||||
from gen.lib.mediaref import MediaRef
|
||||
from gen.lib.name import Name
|
||||
from gen.lib.reporef import RepoRef
|
||||
from gen.lib.srcref import SourceRef
|
||||
from gen.lib.surname import Surname
|
||||
from gen.lib.url import Url
|
||||
from gen.lib.witness import Witness
|
||||
@ -52,6 +52,7 @@ from gen.lib.src import Source
|
||||
from gen.lib.mediaobj import MediaObject
|
||||
from gen.lib.repo import Repository
|
||||
from gen.lib.note import Note
|
||||
from gen.lib.citation import Citation
|
||||
|
||||
# Table objects
|
||||
from gen.lib.tag import Tag
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -32,7 +33,7 @@ Address class for GRAMPS.
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.datebase import DateBase
|
||||
from gen.lib.locationbase import LocationBase
|
||||
@ -43,7 +44,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# Address for Person/Repository
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
class Address(SecondaryObject, PrivacyBase, CitationBase, NoteBase, DateBase,
|
||||
LocationBase):
|
||||
"""Provide address information."""
|
||||
|
||||
@ -52,7 +53,7 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
Create a new Address instance, copying from the source if provided.
|
||||
"""
|
||||
PrivacyBase.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
DateBase.__init__(self, source)
|
||||
LocationBase.__init__(self, source)
|
||||
@ -62,7 +63,7 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (PrivacyBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
DateBase.serialize(self),
|
||||
LocationBase.serialize(self))
|
||||
@ -71,10 +72,10 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(privacy, source_list, note_list, date, location) = data
|
||||
(privacy, citation_list, note_list, date, location) = data
|
||||
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
DateBase.unserialize(self, date)
|
||||
LocationBase.unserialize(self, location)
|
||||
@ -96,7 +97,7 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_note_child_list(self):
|
||||
"""
|
||||
@ -105,7 +106,7 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
:returns: Returns the list of child secondary child objects that may refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
@ -115,7 +116,7 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -125,7 +126,8 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_referenced_note_handles()
|
||||
return self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
@ -158,4 +160,4 @@ class Address(SecondaryObject, PrivacyBase, SourceBase, NoteBase, DateBase,
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -32,7 +33,7 @@ Attribute class for GRAMPS.
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.attrtype import AttributeType
|
||||
from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
@ -42,7 +43,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# Attribute for Person/Family/MediaObject/MediaRef
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
class Attribute(SecondaryObject, PrivacyBase, CitationBase, NoteBase):
|
||||
"""
|
||||
Provide a simple key/value pair for describing properties.
|
||||
Used to store descriptive information.
|
||||
@ -63,7 +64,7 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
Create a new Attribute object, copying from the source if provided.
|
||||
"""
|
||||
PrivacyBase.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
|
||||
if source:
|
||||
@ -78,7 +79,7 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (PrivacyBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
self.type.serialize(), self.value)
|
||||
|
||||
@ -86,9 +87,9 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(privacy, source_list, note_list, the_type, self.value) = data
|
||||
(privacy, citation_list, note_list, the_type, self.value) = data
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
self.type.unserialize(the_type)
|
||||
return self
|
||||
@ -109,7 +110,7 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_note_child_list(self):
|
||||
"""
|
||||
@ -119,7 +120,7 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
@ -129,7 +130,7 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -139,7 +140,8 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_referenced_note_handles()
|
||||
return self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
@ -169,7 +171,7 @@ class Attribute(SecondaryObject, PrivacyBase, SourceBase, NoteBase):
|
||||
:rtype acquisition: Attribute
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
|
||||
def set_type(self, val):
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2006-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -31,7 +32,7 @@ Child Reference class for GRAMPS.
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.refbase import RefBase
|
||||
from gen.lib.childreftype import ChildRefType
|
||||
@ -42,7 +43,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# Person References for Person/Family
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
class ChildRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
"""
|
||||
Person reference class.
|
||||
|
||||
@ -53,7 +54,7 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
|
||||
def __init__(self, source=None):
|
||||
PrivacyBase.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
RefBase.__init__(self, source)
|
||||
if source:
|
||||
@ -68,7 +69,7 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (PrivacyBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
RefBase.serialize(self),
|
||||
self.frel.serialize(),
|
||||
@ -78,9 +79,9 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(privacy, source_list, note_list, ref, frel, mrel) = data
|
||||
(privacy, citation_list, note_list, ref, frel, mrel) = data
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
RefBase.unserialize(self, ref)
|
||||
self.frel = ChildRefType()
|
||||
@ -105,7 +106,7 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_note_child_list(self):
|
||||
"""
|
||||
@ -115,7 +116,7 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -125,7 +126,8 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
ret = self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
if self.ref:
|
||||
ret += [('Person', self.ref)]
|
||||
return ret
|
||||
@ -138,7 +140,7 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
@ -169,7 +171,7 @@ class ChildRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
if (self.mrel != acquisition.mrel) or (self.frel != acquisition.frel):
|
||||
if self.mrel == ChildRefType.UNKNOWN:
|
||||
self.set_mother_relation(acquisition.mrel)
|
||||
|
272
src/gen/lib/citation.py
Normal file
272
src/gen/lib/citation.py
Normal file
@ -0,0 +1,272 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Citation object for GRAMPS.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.primaryobj import PrimaryObject
|
||||
from gen.lib.mediabase import MediaBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.datebase import DateBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Citation class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Citation(MediaBase, NoteBase, PrimaryObject, DateBase):
|
||||
"""
|
||||
A record of a citation of a source of information.
|
||||
|
||||
In GEDCOM this is called a SOURCE_CITATION.
|
||||
The data provided in the <<SOURCE_CITATION>> structure is source-related
|
||||
information specific to the data being cited.
|
||||
"""
|
||||
|
||||
CONF_VERY_HIGH = 4
|
||||
CONF_HIGH = 3
|
||||
CONF_NORMAL = 2
|
||||
CONF_LOW = 1
|
||||
CONF_VERY_LOW = 0
|
||||
|
||||
def __init__(self):
|
||||
"""Create a new Citation instance."""
|
||||
PrimaryObject.__init__(self)
|
||||
MediaBase.__init__(self) # 7
|
||||
NoteBase.__init__(self) # 6
|
||||
DateBase.__init__(self) # 2
|
||||
self.source_handle = None # 5
|
||||
self.page = "" # 3
|
||||
self.confidence = Citation.CONF_NORMAL # 4
|
||||
self.datamap = {} # 8
|
||||
|
||||
def serialize(self, no_text_date = False):
|
||||
"""
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (self.handle, # 0
|
||||
self.gramps_id, # 1
|
||||
DateBase.serialize(self, no_text_date),# 2
|
||||
unicode(self.page), # 3
|
||||
self.confidence, # 4
|
||||
self.source_handle, # 5
|
||||
NoteBase.serialize(self), # 6
|
||||
MediaBase.serialize(self), # 7
|
||||
self.datamap, # 8
|
||||
self.change, # 9
|
||||
self.private) # 10
|
||||
|
||||
def unserialize(self, data):
|
||||
"""
|
||||
Convert the data held in a tuple created by the serialize method
|
||||
back into the data in a Citation structure.
|
||||
"""
|
||||
(self.handle, # 0
|
||||
self.gramps_id, # 1
|
||||
date, # 2
|
||||
self.page, # 3
|
||||
self.confidence, # 4
|
||||
self.source_handle, # 5
|
||||
note_list, # 6
|
||||
media_list, # 7
|
||||
self.datamap, # 8
|
||||
self.change, # 9
|
||||
self.private # 10
|
||||
) = data
|
||||
|
||||
DateBase.unserialize(self, date)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
MediaBase.unserialize(self, media_list)
|
||||
|
||||
def _has_handle_reference(self, classname, handle):
|
||||
"""
|
||||
Return True if the object has reference to a given handle of given
|
||||
primary object type.
|
||||
|
||||
:param classname: The name of the primary object class.
|
||||
:type classname: str
|
||||
:param handle: The handle to be checked.
|
||||
:type handle: str
|
||||
:returns: Returns whether the object has reference to this handle of
|
||||
this object type.
|
||||
:rtype: bool
|
||||
"""
|
||||
if classname == 'Note':
|
||||
return handle in [ref.ref for ref in self.note_list]
|
||||
elif classname == 'Media':
|
||||
return handle in [ref.ref for ref in self.media_list]
|
||||
elif classname == 'Source':
|
||||
return handle == self.get_reference_handle()
|
||||
return False
|
||||
|
||||
def _remove_handle_references(self, classname, handle_list):
|
||||
"""
|
||||
Remove all references in this object to object handles in the list.
|
||||
|
||||
:param classname: The name of the primary object class.
|
||||
:type classname: str
|
||||
:param handle_list: The list of handles to be removed.
|
||||
:type handle_list: str
|
||||
"""
|
||||
if classname == 'Source' and \
|
||||
self.get_reference_handle() in handle_list:
|
||||
self.set_reference_handle(None)
|
||||
|
||||
def _replace_handle_reference(self, classname, old_handle, new_handle):
|
||||
"""
|
||||
Replace all references to old handle with those to the new handle.
|
||||
|
||||
:param classname: The name of the primary object class.
|
||||
:type classname: str
|
||||
:param old_handle: The handle to be replaced.
|
||||
:type old_handle: str
|
||||
:param new_handle: The handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
if classname == 'Source' and \
|
||||
self.get_reference_handle() == old_handle:
|
||||
self.set_reference_handle(new_handle)
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Return the list of all textual attributes of the object.
|
||||
|
||||
:returns: Returns the list of all textual attributes of the object.
|
||||
:rtype: list
|
||||
"""
|
||||
return [self.page,
|
||||
self.gramps_id] + self.datamap.keys() + self.datamap.values()
|
||||
|
||||
def get_text_data_child_list(self):
|
||||
"""
|
||||
Return the list of child objects that may carry textual data.
|
||||
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list
|
||||
|
||||
def get_note_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer notes.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
Return the list of child objects which may, directly or through
|
||||
their children, reference primary objects.
|
||||
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Return the list of (classname, handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
if self.get_reference_handle():
|
||||
ret += [('Source', self.get_reference_handle())]
|
||||
return ret
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
Merge the content of acquisition into this source.
|
||||
|
||||
:param acquisition: The source to merge with the present source.
|
||||
:rtype acquisition: Source
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_media_list(acquisition)
|
||||
# merge confidence
|
||||
level_priority = [0, 4, 1, 3, 2]
|
||||
idx = min(level_priority.index(self.confidence),
|
||||
level_priority.index(acquisition.confidence))
|
||||
self.confidence = level_priority[idx]
|
||||
my_datamap = self.get_data_map()
|
||||
acquisition_map = acquisition.get_data_map()
|
||||
for key in acquisition.get_data_map():
|
||||
if key not in my_datamap:
|
||||
self.datamap[key] = acquisition_map[key]
|
||||
# N.B. a Citation can refer to only one 'Source', so the
|
||||
# 'Source' from acquisition cannot be merged in
|
||||
|
||||
def get_data_map(self):
|
||||
"""Return the data map of attributes for the source."""
|
||||
return self.datamap
|
||||
|
||||
def set_data_map(self, datamap):
|
||||
"""Set the data map of attributes for the source."""
|
||||
self.datamap = datamap
|
||||
|
||||
def set_data_item(self, key, value):
|
||||
"""Set the particular data item in the attribute data map."""
|
||||
self.datamap[key] = value
|
||||
|
||||
def set_confidence_level(self, val):
|
||||
"""Set the confidence level."""
|
||||
self.confidence = val
|
||||
|
||||
def get_confidence_level(self):
|
||||
"""Return the confidence level."""
|
||||
return self.confidence
|
||||
|
||||
def set_page(self, page):
|
||||
"""Set the page indicator of the Citation."""
|
||||
self.page = page
|
||||
|
||||
def get_page(self):
|
||||
"""Get the page indicator of the Citation."""
|
||||
return self.page
|
||||
|
||||
def set_reference_handle(self, val):
|
||||
self.source_handle = val
|
||||
|
||||
def get_reference_handle(self):
|
||||
return self.source_handle
|
236
src/gen/lib/citationbase.py
Normal file
236
src/gen/lib/citationbase.py
Normal file
@ -0,0 +1,236 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
CitationBase class for GRAMPS.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# CitationBase class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class CitationBase(object):
|
||||
"""
|
||||
Base class for storing citations.
|
||||
|
||||
Starting in 3.4, the objects may have multiple citations.
|
||||
Internally, this class maintains a list of Citation handles,
|
||||
as a citation_list attribute of the CitationBase object.
|
||||
This class is analogous to the notebase class.
|
||||
Both these have no attributes of their own; in this respect, they differ
|
||||
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
|
||||
"""
|
||||
def __init__(self, source=None):
|
||||
"""
|
||||
Create a new CitationBase, copying from source if not None.
|
||||
|
||||
:param source: Object used to initialize the new object
|
||||
:type source: CitationBase
|
||||
"""
|
||||
self.citation_list = list(source.citation_list) if source else []
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return self.citation_list
|
||||
|
||||
def unserialize(self, data):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
self.citation_list = list(data)
|
||||
|
||||
def add_citation(self, handle):
|
||||
"""
|
||||
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
|
||||
:type handle: str
|
||||
|
||||
:returns: True if handle was added, False if it already was in the list
|
||||
:rtype: bool
|
||||
"""
|
||||
if handle in self.citation_list:
|
||||
return False
|
||||
else:
|
||||
self.citation_list.append(handle)
|
||||
return True
|
||||
|
||||
def remove_citation_references(self, citation_handle_list):
|
||||
"""
|
||||
Remove the specified handles from the list of citation handles, and all
|
||||
secondary child objects.
|
||||
|
||||
:param citation_handle_list: The list of citation handles to be removed
|
||||
:type handle: list
|
||||
"""
|
||||
LOG.debug('enter remove_citation handle: %s self: %s citation_list: %s'
|
||||
% (citation_handle_list, self, self.citation_list))
|
||||
for handle in citation_handle_list:
|
||||
if handle in 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())
|
||||
for item in self.get_citation_child_list():
|
||||
item.remove_citation_references(citation_handle_list)
|
||||
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
All methods which inherit from CitationBase and have other child objects
|
||||
with citations, should return here a list of child objects which are
|
||||
CitationBase
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return []
|
||||
|
||||
def get_citation_list(self):
|
||||
"""
|
||||
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
|
||||
"""
|
||||
return self.citation_list
|
||||
|
||||
def get_all_citation_lists(self):
|
||||
"""
|
||||
Return the list of :class:`~gen.lib.citation.Citation` handles
|
||||
associated with the object or with child objects.
|
||||
|
||||
:returns: The list of :class:`~gen.lib.citation.Citation` handles
|
||||
:rtype: list
|
||||
"""
|
||||
list = self.citation_list
|
||||
|
||||
for item in self.get_citation_child_list():
|
||||
list += item.get_citation_list()
|
||||
return list
|
||||
|
||||
def has_citation_reference(self, citation_handle):
|
||||
"""
|
||||
Return True if the object or any of its child objects has reference
|
||||
to this citation handle.
|
||||
|
||||
:param citation_handle: The citation handle to be checked.
|
||||
:type citation_handle: str
|
||||
:returns: Returns whether the object or any of its child objects has
|
||||
reference to this citation handle.
|
||||
:rtype: bool
|
||||
"""
|
||||
for citation_ref in self.citation_list:
|
||||
if citation_ref == citation_handle:
|
||||
return True
|
||||
|
||||
LOG.debug("citation child list %s" % self.get_citation_child_list())
|
||||
for item in self.get_citation_child_list():
|
||||
if item.has_citation_reference(citation_handle):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def set_citation_list(self, citation_list):
|
||||
"""
|
||||
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
|
||||
:type citation_list: list
|
||||
"""
|
||||
self.citation_list = citation_list
|
||||
|
||||
def _merge_citation_list(self, acquisition):
|
||||
"""
|
||||
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.
|
||||
:rtype acquisition: CitationBase
|
||||
"""
|
||||
for addendum in acquisition.citation_list:
|
||||
self.add_citation(addendum)
|
||||
|
||||
def get_referenced_citation_handles(self):
|
||||
"""
|
||||
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.
|
||||
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return [('Citation', handle) for handle in self.citation_list]
|
||||
|
||||
def replace_citation_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replace references to citation handles in the list of this object and
|
||||
all child objects and merge equivalent entries.
|
||||
|
||||
:param old_handle: The citation handle to be replaced.
|
||||
:type old_handle: str
|
||||
:param new_handle: The citation handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
refs_list = self.citation_list[:]
|
||||
new_ref = None
|
||||
if new_handle in self.citation_list:
|
||||
new_ref = new_handle
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in xrange(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
if new_ref:
|
||||
self.citation_list.pop(idx)
|
||||
refs_list.pop(idx)
|
||||
else:
|
||||
self.citation_list[idx] = new_handle
|
||||
|
||||
for item in self.get_citation_child_list():
|
||||
item.replace_citation_references(old_handle, new_handle)
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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,13 +26,21 @@
|
||||
Event object for GRAMPS.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# standard python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.primaryobj import PrimaryObject
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.mediabase import MediaBase
|
||||
from gen.lib.attrbase import AttributeBase
|
||||
@ -44,7 +53,7 @@ from gen.lib.eventtype import EventType
|
||||
# Event class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
class Event(CitationBase, NoteBase, MediaBase, AttributeBase,
|
||||
DateBase, PlaceBase, PrimaryObject):
|
||||
"""
|
||||
The Event record is used to store information about some type of
|
||||
@ -67,7 +76,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
"""
|
||||
|
||||
PrimaryObject.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
MediaBase.__init__(self, source)
|
||||
AttributeBase.__init__(self)
|
||||
@ -102,7 +111,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
return (self.handle, self.gramps_id, self.__type.serialize(),
|
||||
DateBase.serialize(self, no_text_date),
|
||||
self.__description, self.place,
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
MediaBase.serialize(self),
|
||||
AttributeBase.serialize(self),
|
||||
@ -119,7 +128,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
"""
|
||||
(self.handle, self.gramps_id, the_type, date,
|
||||
self.__description, self.place,
|
||||
source_list, note_list, media_list, attribute_list,
|
||||
citation_list, note_list, media_list, attribute_list,
|
||||
self.change, self.private) = data
|
||||
|
||||
self.__type = EventType()
|
||||
@ -127,7 +136,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
DateBase.unserialize(self, date)
|
||||
MediaBase.unserialize(self, media_list)
|
||||
AttributeBase.unserialize(self, attribute_list)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
return self
|
||||
|
||||
@ -190,14 +199,14 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list + self.source_list + self.attribute_list
|
||||
return self.media_list + self.attribute_list
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list + self.attribute_list
|
||||
@ -210,7 +219,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list + self.attribute_list + self.source_list
|
||||
return self.media_list + self.attribute_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -220,7 +229,8 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
ret = self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
if self.place:
|
||||
ret.append(('Place', self.place))
|
||||
return ret
|
||||
@ -233,7 +243,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_sourcref_child_list() + self.source_list
|
||||
return self.get_citation_child_list()
|
||||
|
||||
def is_empty(self):
|
||||
"""
|
||||
@ -266,12 +276,13 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
self.__description != other.__description \
|
||||
or self.private != other.private or \
|
||||
(not self.get_date_object().is_equal(other.get_date_object())) or \
|
||||
len(self.get_source_references()) != len(other.get_source_references()):
|
||||
len(self.get_citation_list()) != \
|
||||
len(other.get_citation_list()):
|
||||
return False
|
||||
|
||||
index = 0
|
||||
olist = other.get_source_references()
|
||||
for a in self.get_source_references():
|
||||
olist = other.get_citation_list()
|
||||
for a in self.get_citation_list():
|
||||
if not a.is_equal(olist[index]):
|
||||
return False
|
||||
index += 1
|
||||
@ -290,7 +301,7 @@ class Event(SourceBase, NoteBase, MediaBase, AttributeBase,
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_attribute_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
self._merge_media_list(acquisition)
|
||||
|
||||
def set_type(self, the_type):
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -107,12 +108,12 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
|
||||
"""
|
||||
return self.attribute_list
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list
|
||||
@ -149,48 +150,48 @@ class EventRef(SecondaryObject, PrivacyBase, NoteBase, AttributeBase, RefBase):
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_sourcref_child_list()
|
||||
return self.get_citation_child_list()
|
||||
|
||||
def has_source_reference(self, src_handle) :
|
||||
def has_citation_reference(self, citation_handle) :
|
||||
"""
|
||||
Return True if any of the child objects has reference to this source
|
||||
Return True if any of the child objects has reference to this citation
|
||||
handle.
|
||||
|
||||
:param src_handle: The source handle to be checked.
|
||||
:type src_handle: str
|
||||
:param citation_handle: The citation handle to be checked.
|
||||
:type citation_handle: str
|
||||
:returns: Returns whether any of it's child objects has reference to
|
||||
this source handle.
|
||||
this citation handle.
|
||||
:rtype: bool
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
if item.has_source_reference(src_handle):
|
||||
for item in self.get_citation_child_list():
|
||||
if item.has_citation_reference(citation_handle):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def remove_source_references(self, src_handle_list):
|
||||
def remove_citation_references(self, citation_handle_list):
|
||||
"""
|
||||
Remove references to all source handles in the list in all child
|
||||
Remove references to all citation handles in the list in all child
|
||||
objects.
|
||||
|
||||
:param src_handle_list: The list of source handles to be removed.
|
||||
:type src_handle_list: list
|
||||
:param citation_handle_list: The list of citation handles to be removed.
|
||||
:type citation_handle_list: list
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.remove_source_references(src_handle_list)
|
||||
for item in self.get_citation_child_list():
|
||||
item.remove_citation_references(citation_handle_list)
|
||||
|
||||
def replace_source_references(self, old_handle, new_handle):
|
||||
def replace_citation_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replace references to source handles in the list in this object and
|
||||
Replace references to citation handles in the list in this object and
|
||||
all child objects and merge equivalent entries.
|
||||
|
||||
:param old_handle: The source handle to be replaced.
|
||||
:param old_handle: The citation handle to be replaced.
|
||||
:type old_handle: str
|
||||
:param new_handle: The source handle to replace the old one with.
|
||||
:param new_handle: The citation handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.replace_source_references(old_handle, new_handle)
|
||||
for item in self.get_citation_child_list():
|
||||
item.replace_citation_references(old_handle, new_handle)
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
|
@ -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
|
||||
@ -32,6 +33,8 @@ Family object for GRAMPS.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from warnings import warn
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -39,7 +42,7 @@ from warnings import warn
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.primaryobj import PrimaryObject
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.mediabase import MediaBase
|
||||
from gen.lib.attrbase import AttributeBase
|
||||
@ -55,7 +58,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# Family class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
class Family(CitationBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
TagBase, PrimaryObject):
|
||||
"""
|
||||
The Family record is the GRAMPS in-memory representation of the
|
||||
@ -82,7 +85,7 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
including the database handle.
|
||||
"""
|
||||
PrimaryObject.__init__(self)
|
||||
SourceBase.__init__(self)
|
||||
CitationBase.__init__(self)
|
||||
NoteBase.__init__(self)
|
||||
MediaBase.__init__(self)
|
||||
AttributeBase.__init__(self)
|
||||
@ -121,7 +124,7 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
MediaBase.serialize(self),
|
||||
AttributeBase.serialize(self),
|
||||
LdsOrdBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
self.change, TagBase.serialize(self), self.private)
|
||||
|
||||
@ -132,7 +135,7 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.father_handle, self.mother_handle,
|
||||
child_ref_list, the_type, event_ref_list, media_list,
|
||||
attribute_list, lds_seal_list, source_list, note_list,
|
||||
attribute_list, lds_seal_list, citation_list, note_list,
|
||||
self.change, tag_list, self.private) = data
|
||||
|
||||
self.type = FamilyRelType()
|
||||
@ -143,7 +146,7 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
for cr in child_ref_list]
|
||||
MediaBase.unserialize(self, media_list)
|
||||
AttributeBase.unserialize(self, attribute_list)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
LdsOrdBase.unserialize(self, lds_seal_list)
|
||||
TagBase.unserialize(self, tag_list)
|
||||
@ -270,15 +273,14 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
:rtype: list
|
||||
"""
|
||||
add_list = filter(None, self.lds_ord_list)
|
||||
return self.media_list + self.attribute_list + \
|
||||
self.source_list + add_list
|
||||
return self.media_list + self.attribute_list + add_list
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
check_list = self.media_list + self.attribute_list + \
|
||||
@ -295,7 +297,7 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
:rtype: list
|
||||
"""
|
||||
check_list = self.media_list + self.attribute_list + \
|
||||
self.lds_ord_list + self.child_ref_list + self.source_list + \
|
||||
self.lds_ord_list + self.child_ref_list + \
|
||||
self.event_ref_list
|
||||
return check_list
|
||||
|
||||
@ -307,7 +309,8 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
ret = self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
ret += [('Person', handle) for handle
|
||||
in ([ref.ref for ref in self.child_ref_list] +
|
||||
[self.father_handle, self.mother_handle])
|
||||
@ -323,7 +326,7 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_sourcref_child_list() + self.source_list
|
||||
return self.get_citation_child_list()
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -343,7 +346,7 @@ class Family(SourceBase, NoteBase, MediaBase, AttributeBase, LdsOrdBase,
|
||||
self._merge_child_ref_list(acquisition)
|
||||
self._merge_attribute_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
self._merge_tag_list(acquisition)
|
||||
|
||||
def set_relationship(self, relationship_type):
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -39,7 +40,7 @@ from warnings import warn
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.datebase import DateBase
|
||||
from gen.lib.placebase import PlaceBase
|
||||
@ -51,7 +52,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# LDS Ordinance class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
class LdsOrd(SecondaryObject, CitationBase, NoteBase,
|
||||
DateBase, PlaceBase, PrivacyBase):
|
||||
"""
|
||||
Class that contains information about LDS Ordinances.
|
||||
@ -116,7 +117,7 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
|
||||
def __init__(self, source=None):
|
||||
"""Create a LDS Ordinance instance."""
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
DateBase.__init__(self, source)
|
||||
PlaceBase.__init__(self, source)
|
||||
@ -137,7 +138,7 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
"""
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (SourceBase.serialize(self),
|
||||
return (CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
DateBase.serialize(self),
|
||||
self.type, self.place,
|
||||
@ -147,9 +148,9 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(source_list, note_list, date, self.type, self.place,
|
||||
(citation_list, note_list, date, self.type, self.place,
|
||||
self.famc, self.temple, self.status, self.private) = data
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
DateBase.unserialize(self, date)
|
||||
return self
|
||||
@ -171,7 +172,7 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_note_child_list(self):
|
||||
"""
|
||||
@ -181,7 +182,7 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -191,7 +192,8 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
ret = self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
if self.place:
|
||||
ret += [('Place', self.place)]
|
||||
if self.famc:
|
||||
@ -206,7 +208,7 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
@ -241,7 +243,7 @@ class LdsOrd(SecondaryObject, SourceBase, NoteBase,
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
|
||||
def get_type(self):
|
||||
"""
|
||||
|
@ -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
|
||||
@ -32,6 +33,8 @@ Media object for GRAMPS.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
import os
|
||||
import logging
|
||||
LOG = logging.getLogger(".citation")
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
@ -39,7 +42,7 @@ import os
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.primaryobj import PrimaryObject
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.datebase import DateBase
|
||||
from gen.lib.attrbase import AttributeBase
|
||||
@ -50,7 +53,7 @@ from gen.lib.tagbase import TagBase
|
||||
# MediaObject class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
class MediaObject(CitationBase, NoteBase, DateBase, AttributeBase,
|
||||
TagBase, PrimaryObject):
|
||||
"""
|
||||
Container for information about an image file, including location,
|
||||
@ -68,7 +71,7 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
:type source: MediaObject
|
||||
"""
|
||||
PrimaryObject.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
DateBase.__init__(self, source)
|
||||
AttributeBase.__init__(self, source)
|
||||
@ -105,7 +108,7 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
"""
|
||||
return (self.handle, self.gramps_id, self.path, self.mime, self.desc,
|
||||
AttributeBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
self.change,
|
||||
DateBase.serialize(self, no_text_date),
|
||||
@ -121,11 +124,11 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
:type data: tuple
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.path, self.mime, self.desc,
|
||||
attribute_list, source_list, note_list, self.change,
|
||||
attribute_list, citation_list, note_list, self.change,
|
||||
date, tag_list, self.private) = data
|
||||
|
||||
AttributeBase.unserialize(self, attribute_list)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
DateBase.unserialize(self, date)
|
||||
TagBase.unserialize(self, tag_list)
|
||||
@ -146,14 +149,14 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
return self.attribute_list
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer to citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer to citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list
|
||||
@ -166,7 +169,7 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
return self.attribute_list + self.citation_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -177,7 +180,8 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_referenced_note_handles() + \
|
||||
self.get_referenced_tag_handles()
|
||||
self.get_referenced_tag_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
@ -187,7 +191,7 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
return self.get_citation_child_list()
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -201,8 +205,9 @@ class MediaObject(SourceBase, NoteBase, DateBase, AttributeBase,
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_attribute_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
self._merge_tag_list(acquisition)
|
||||
self.merge_citation_list(acquisition)
|
||||
|
||||
def set_mime_type(self, mime_type):
|
||||
"""
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -32,7 +33,7 @@ Media Reference class for GRAMPS.
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.refbase import RefBase
|
||||
from gen.lib.attrbase import AttributeBase
|
||||
@ -43,12 +44,12 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# MediaObject References for Person/Place/Source
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
class MediaRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase,
|
||||
AttributeBase):
|
||||
"""Media reference class."""
|
||||
def __init__(self, source=None):
|
||||
PrivacyBase.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
RefBase.__init__(self, source)
|
||||
AttributeBase.__init__(self, source)
|
||||
@ -63,7 +64,7 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (PrivacyBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
AttributeBase.serialize(self),
|
||||
RefBase.serialize(self),
|
||||
@ -73,9 +74,9 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(privacy, source_list, note_list,attribute_list,ref,self.rect) = data
|
||||
(privacy, citation_list, note_list,attribute_list,ref,self.rect) = data
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
AttributeBase.unserialize(self, attribute_list)
|
||||
RefBase.unserialize(self, ref)
|
||||
@ -88,14 +89,14 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
return self.attribute_list
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer Citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer Citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list
|
||||
@ -108,7 +109,7 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
return self.attribute_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -118,7 +119,8 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
ret = self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
if self.ref:
|
||||
ret += [('MediaObject', self.ref)]
|
||||
return ret
|
||||
@ -131,7 +133,7 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.attribute_list + self.source_list
|
||||
return self.get_citation_child_list()
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
@ -162,7 +164,7 @@ class MediaRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase,
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_attribute_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
|
||||
def set_rectangle(self, coord):
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -32,7 +33,7 @@ Name class for GRAMPS.
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.datebase import DateBase
|
||||
from gen.lib.surnamebase import SurnameBase
|
||||
@ -44,7 +45,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# Personal Name
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
class Name(SecondaryObject, PrivacyBase, SurnameBase, CitationBase, NoteBase,
|
||||
DateBase):
|
||||
"""
|
||||
Provide name information about a person.
|
||||
@ -73,18 +74,18 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
"""
|
||||
PrivacyBase.__init__(self, source)
|
||||
SurnameBase.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
DateBase.__init__(self, source)
|
||||
if data:
|
||||
(privacy, source_list, note, date,
|
||||
(privacy, citation_list, note, date,
|
||||
self.first_name, surname_list, self.suffix, self.title, name_type,
|
||||
self.group_as, self.sort_as, self.display_as, self.call,
|
||||
self.nick, self.famnick) = data
|
||||
self.type = NameType(name_type)
|
||||
SurnameBase.unserialize(self, surname_list)
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note)
|
||||
DateBase.unserialize(self, date)
|
||||
elif source:
|
||||
@ -115,7 +116,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (PrivacyBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
DateBase.serialize(self),
|
||||
self.first_name,
|
||||
@ -140,14 +141,14 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(privacy, source_list, note_list, date,
|
||||
(privacy, citation_list, note_list, date,
|
||||
self.first_name, surname_list, self.suffix, self.title, name_type,
|
||||
self.group_as, self.sort_as, self.display_as, self.call,
|
||||
self.nick, self.famnick) = data
|
||||
self.type = NameType(name_type)
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
SurnameBase.unserialize(self, surname_list)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
DateBase.unserialize(self, date)
|
||||
return self
|
||||
@ -169,7 +170,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list + self.surname_list
|
||||
return self.surname_list
|
||||
|
||||
def get_note_child_list(self):
|
||||
"""
|
||||
@ -179,7 +180,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
@ -189,7 +190,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -199,7 +200,8 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_referenced_note_handles()
|
||||
return self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
@ -238,7 +240,7 @@ class Name(SecondaryObject, PrivacyBase, SurnameBase, SourceBase, NoteBase,
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_surname_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
|
||||
def set_group_as(self, name):
|
||||
"""
|
||||
|
@ -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
|
||||
@ -32,7 +33,7 @@ Person object for GRAMPS.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.primaryobj import PrimaryObject
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.mediabase import MediaBase
|
||||
from gen.lib.attrbase import AttributeBase
|
||||
@ -53,7 +54,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# Person class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
class Person(CitationBase, NoteBase, AttributeBase, MediaBase,
|
||||
AddressBase, UrlBase, LdsOrdBase, TagBase, PrimaryObject):
|
||||
"""
|
||||
The Person record is the GRAMPS in-memory representation of an
|
||||
@ -85,7 +86,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
handle.
|
||||
"""
|
||||
PrimaryObject.__init__(self)
|
||||
SourceBase.__init__(self)
|
||||
CitationBase.__init__(self)
|
||||
NoteBase.__init__(self)
|
||||
MediaBase.__init__(self)
|
||||
AttributeBase.__init__(self)
|
||||
@ -149,7 +150,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
AttributeBase.serialize(self), # 12
|
||||
UrlBase.serialize(self), # 13
|
||||
LdsOrdBase.serialize(self), # 14
|
||||
SourceBase.serialize(self), # 15
|
||||
CitationBase.serialize(self), # 15
|
||||
NoteBase.serialize(self), # 16
|
||||
self.change, # 17
|
||||
TagBase.serialize(self), # 18
|
||||
@ -181,7 +182,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
attribute_list, # 12
|
||||
urls, # 13
|
||||
lds_ord_list, # 14
|
||||
source_list, # 15
|
||||
citation_list, # 15
|
||||
note_list, # 16
|
||||
self.change, # 17
|
||||
tag_list, # 18
|
||||
@ -202,7 +203,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
AddressBase.unserialize(self, address_list)
|
||||
AttributeBase.unserialize(self, attribute_list)
|
||||
UrlBase.unserialize(self, urls)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
TagBase.unserialize(self, tag_list)
|
||||
return self
|
||||
@ -369,18 +370,17 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
self.address_list +
|
||||
self.attribute_list +
|
||||
self.urls +
|
||||
self.source_list +
|
||||
self.event_ref_list +
|
||||
add_list +
|
||||
self.person_ref_list
|
||||
)
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return ([self.primary_name] +
|
||||
@ -408,7 +408,6 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
self.attribute_list +
|
||||
self.lds_ord_list +
|
||||
self.person_ref_list +
|
||||
self.source_list +
|
||||
self.event_ref_list
|
||||
)
|
||||
|
||||
@ -422,7 +421,8 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
"""
|
||||
return [('Family', handle) for handle in
|
||||
(self.family_list + self.parent_family_list)] + (
|
||||
self.get_referenced_note_handles() +
|
||||
self.get_referenced_note_handles() +
|
||||
self.get_referenced_citation_handles() +
|
||||
self.get_referenced_tag_handles()
|
||||
)
|
||||
|
||||
@ -434,8 +434,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
#don't count double, notes can be found in sourcref
|
||||
return self.get_sourcref_child_list() + self.source_list
|
||||
return (self.get_citation_child_list())
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
@ -462,7 +461,7 @@ class Person(SourceBase, NoteBase, AttributeBase, MediaBase,
|
||||
self._merge_url_list(acquisition)
|
||||
self._merge_person_ref_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
self._merge_tag_list(acquisition)
|
||||
|
||||
map(self.add_parent_family_handle,
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2006-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -32,7 +33,7 @@ Person Reference class for GRAMPS.
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.refbase import RefBase
|
||||
from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
@ -42,7 +43,7 @@ from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
# Person References for Person/Family
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
class PersonRef(SecondaryObject, PrivacyBase, CitationBase, NoteBase, RefBase):
|
||||
"""
|
||||
Person reference class.
|
||||
|
||||
@ -53,7 +54,7 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
|
||||
def __init__(self, source=None):
|
||||
PrivacyBase.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
RefBase.__init__(self, source)
|
||||
if source:
|
||||
@ -66,7 +67,7 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (PrivacyBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
RefBase.serialize(self),
|
||||
self.rel)
|
||||
@ -75,9 +76,9 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(privacy, source_list, note_list, ref, self.rel) = data
|
||||
(privacy, citation_list, note_list, ref, self.rel) = data
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
RefBase.unserialize(self, ref)
|
||||
return self
|
||||
@ -98,7 +99,7 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
:returns: Returns the list of child objects that may carry textual data.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_note_child_list(self):
|
||||
"""
|
||||
@ -108,7 +109,7 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -118,7 +119,8 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
ret = self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
if self.ref:
|
||||
ret += [('Person', self.ref)]
|
||||
return ret
|
||||
@ -131,7 +133,7 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
return []
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
@ -162,7 +164,7 @@ class PersonRef(SecondaryObject, PrivacyBase, SourceBase, NoteBase, RefBase):
|
||||
:param acquisition: PersonRef
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
|
||||
def set_relation(self, rel):
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -31,7 +32,7 @@ Place object for GRAMPS.
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.primaryobj import PrimaryObject
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.mediabase import MediaBase
|
||||
from gen.lib.urlbase import UrlBase
|
||||
@ -44,7 +45,7 @@ _EMPTY_LOC = Location().serialize()
|
||||
# Place class
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
class Place(CitationBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
"""
|
||||
Contains information related to a place, including multiple address
|
||||
information (since place names can change with time), longitude, latitude,
|
||||
@ -59,7 +60,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
:type source: Place
|
||||
"""
|
||||
PrimaryObject.__init__(self, source)
|
||||
SourceBase.__init__(self, source)
|
||||
CitationBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
MediaBase.__init__(self, source)
|
||||
UrlBase.__init__(self, source)
|
||||
@ -104,7 +105,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
main_loc, [al.serialize() for al in self.alt_loc],
|
||||
UrlBase.serialize(self),
|
||||
MediaBase.serialize(self),
|
||||
SourceBase.serialize(self),
|
||||
CitationBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
self.change, self.private)
|
||||
|
||||
@ -118,7 +119,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
:type data: tuple
|
||||
"""
|
||||
(self.handle, self.gramps_id, self.title, self.long, self.lat,
|
||||
main_loc, alt_loc, urls, media_list, source_list, note_list,
|
||||
main_loc, alt_loc, urls, media_list, citation_list, note_list,
|
||||
self.change, self.private) = data
|
||||
|
||||
if main_loc is None:
|
||||
@ -128,7 +129,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
self.alt_loc = [Location().unserialize(al) for al in alt_loc]
|
||||
UrlBase.unserialize(self, urls)
|
||||
MediaBase.unserialize(self, media_list)
|
||||
SourceBase.unserialize(self, source_list)
|
||||
CitationBase.unserialize(self, citation_list)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
return self
|
||||
|
||||
@ -149,16 +150,16 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
:rtype: list
|
||||
"""
|
||||
|
||||
ret = self.media_list + self.source_list + self.alt_loc + self.urls
|
||||
ret = self.media_list + self.alt_loc + self.urls
|
||||
if self.main_loc:
|
||||
ret.append(self.main_loc)
|
||||
return ret
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: List of child secondary child objects that may refer sources.
|
||||
:returns: List of child secondary child objects that may refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list
|
||||
@ -171,7 +172,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
refer notes.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list + self.source_list
|
||||
return self.media_list
|
||||
|
||||
def get_handle_referents(self):
|
||||
"""
|
||||
@ -181,7 +182,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list + self.source_list
|
||||
return self.get_citation_child_list()
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -191,7 +192,8 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.get_referenced_note_handles()
|
||||
return self.get_referenced_note_handles() + \
|
||||
self.get_referenced_citation_handles()
|
||||
|
||||
def merge(self, acquisition):
|
||||
""" Merge the content of acquisition into this place.
|
||||
@ -204,7 +206,7 @@ class Place(SourceBase, NoteBase, MediaBase, UrlBase, PrimaryObject):
|
||||
self._merge_media_list(acquisition)
|
||||
self._merge_url_list(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
self._merge_source_reference_list(acquisition)
|
||||
self._merge_citation_list(acquisition)
|
||||
|
||||
def set_title(self, title):
|
||||
"""
|
||||
|
@ -2,6 +2,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
|
||||
@ -31,7 +32,7 @@ Basic Primary Object class for GRAMPS.
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.tableobj import TableObject
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.srcbase import SourceBase
|
||||
from gen.lib.citationbase import CitationBase
|
||||
from gen.lib.mediabase import MediaBase
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
@ -130,15 +131,6 @@ class BasicPrimaryObject(TableObject, PrivacyBase):
|
||||
"""
|
||||
pass
|
||||
|
||||
def has_source_reference(self, handle):
|
||||
"""
|
||||
Indicate if the object has a source references.
|
||||
|
||||
In the base class, no such references exist. Derived classes should
|
||||
override this if they provide source references.
|
||||
"""
|
||||
return False
|
||||
|
||||
def has_media_reference(self, handle):
|
||||
"""
|
||||
Indicate if the object has a media references.
|
||||
@ -148,7 +140,7 @@ class BasicPrimaryObject(TableObject, PrivacyBase):
|
||||
"""
|
||||
return False
|
||||
|
||||
def remove_source_references(self, handle_list):
|
||||
def remove_citation_references(self, handle_list):
|
||||
"""
|
||||
Remove the specified source references from the object.
|
||||
|
||||
@ -166,7 +158,7 @@ class BasicPrimaryObject(TableObject, PrivacyBase):
|
||||
"""
|
||||
pass
|
||||
|
||||
def replace_source_references(self, old_handle, new_handle):
|
||||
def replace_citation_references(self, old_handle, new_handle):
|
||||
pass
|
||||
|
||||
def replace_media_references(self, old_handle, new_handle):
|
||||
@ -214,8 +206,8 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
of this object type.
|
||||
:rtype: bool
|
||||
"""
|
||||
if classname == 'Source' and isinstance(self, SourceBase):
|
||||
return self.has_source_reference(handle)
|
||||
if classname == 'Citation' and isinstance(self, CitationBase):
|
||||
return self.has_citation_reference(handle)
|
||||
elif classname == 'MediaObject' and isinstance(self, MediaBase):
|
||||
return self.has_media_reference(handle)
|
||||
else:
|
||||
@ -230,8 +222,8 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
:param handle_list: The list of handles to be removed.
|
||||
:type handle_list: str
|
||||
"""
|
||||
if classname == 'Source' and isinstance(self, SourceBase):
|
||||
self.remove_source_references(handle_list)
|
||||
if classname == 'Citation' and isinstance(self, CitationBase):
|
||||
self.remove_citation_references(handle_list)
|
||||
elif classname == 'MediaObject' and isinstance(self, MediaBase):
|
||||
self.remove_media_references(handle_list)
|
||||
else:
|
||||
@ -248,8 +240,8 @@ class PrimaryObject(BasicPrimaryObject):
|
||||
:param new_handle: The handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
if classname == 'Source' and isinstance(self, SourceBase):
|
||||
self.replace_source_references(old_handle, new_handle)
|
||||
if classname == 'Citation' and isinstance(self, CitationBase):
|
||||
self.replace_citation_references(old_handle, new_handle)
|
||||
elif classname == 'MediaObject' and isinstance(self, MediaBase):
|
||||
self.replace_media_references(old_handle, new_handle)
|
||||
else:
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -99,12 +100,12 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject):
|
||||
"""
|
||||
return self.address_list + self.urls
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.address_list
|
||||
@ -127,7 +128,7 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject):
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.address_list
|
||||
return self.get_citation_child_list()
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -139,46 +140,44 @@ class Repository(NoteBase, AddressBase, UrlBase, PrimaryObject):
|
||||
"""
|
||||
return self.get_referenced_note_handles()
|
||||
|
||||
def has_source_reference(self, src_handle) :
|
||||
def has_citation_reference(self, citation_handle) :
|
||||
"""
|
||||
Return True if any of the child objects has reference to this source
|
||||
Return True if any of the child objects has reference to this citation
|
||||
handle.
|
||||
|
||||
Note: for most objects, this is inherited from citationbase, which
|
||||
checks both the object and the child objects. However, uniquely,
|
||||
Repositories do not have citations for the primary object, but only for
|
||||
child (secondary) objects. Hence, this function has to be implemented
|
||||
directly in the primary object; it only checks the child objects.
|
||||
|
||||
:param src_handle: The source handle to be checked.
|
||||
:type src_handle: str
|
||||
:param citation_handle: The citation handle to be checked.
|
||||
:type citation_handle: str
|
||||
:returns: Returns whether any of it's child objects has reference to
|
||||
this source handle.
|
||||
this citation handle.
|
||||
:rtype: bool
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
if item.has_source_reference(src_handle):
|
||||
for item in self.get_citation_child_list():
|
||||
if item.has_citation_reference(citation_handle):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def remove_source_references(self, src_handle_list):
|
||||
def replace_citation_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Remove references to all source handles in the list in all child
|
||||
objects.
|
||||
|
||||
:param src_handle_list: The list of source handles to be removed.
|
||||
:type src_handle_list: list
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.remove_source_references(src_handle_list)
|
||||
|
||||
def replace_source_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replace references to source handles in the list in this object and
|
||||
Replace references to citation handles in the list in this object and
|
||||
all child objects and merge equivalent entries.
|
||||
|
||||
Note: the same comment about citationbase in has_citation_reference
|
||||
applies here too.
|
||||
|
||||
:param old_handle: The source handle to be replaced.
|
||||
:param old_handle: The citation handle to be replaced.
|
||||
:type old_handle: str
|
||||
:param new_handle: The source handle to replace the old one with.
|
||||
:param new_handle: The citation handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.replace_source_references(old_handle, new_handle)
|
||||
for item in self.get_citation_child_list():
|
||||
item.replace_citation_references(old_handle, new_handle)
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
|
@ -3,6 +3,7 @@
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
# 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
|
||||
@ -151,12 +152,12 @@ class Source(MediaBase, NoteBase, PrimaryObject):
|
||||
"""
|
||||
return self.media_list + self.reporef_list
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
def get_citation_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
Return the list of child secondary objects that may refer citations.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
refer citations.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list
|
||||
@ -179,7 +180,7 @@ class Source(MediaBase, NoteBase, PrimaryObject):
|
||||
:returns: Returns the list of objects referencing primary objects.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.media_list + self.reporef_list
|
||||
return self.get_citation_child_list() + self.reporef_list
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
@ -191,47 +192,6 @@ class Source(MediaBase, NoteBase, PrimaryObject):
|
||||
"""
|
||||
return self.get_referenced_note_handles()
|
||||
|
||||
def has_source_reference(self, src_handle) :
|
||||
"""
|
||||
Return True if any of the child objects has reference to this source
|
||||
handle.
|
||||
|
||||
:param src_handle: The source handle to be checked.
|
||||
:type src_handle: str
|
||||
:returns: Returns whether any of it's child objects has reference to
|
||||
this source handle.
|
||||
:rtype: bool
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
if item.has_source_reference(src_handle):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def remove_source_references(self, src_handle_list):
|
||||
"""
|
||||
Remove references to all source handles in the list in all child
|
||||
objects.
|
||||
|
||||
:param src_handle_list: The list of source handles to be removed.
|
||||
:type src_handle_list: list
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.remove_source_references(src_handle_list)
|
||||
|
||||
def replace_source_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replace references to source_handles in the list in this object and
|
||||
all child objects and merge equivalent entries.
|
||||
|
||||
:param old_handle: The source handle to be replaced.
|
||||
:type old_handle: str
|
||||
:param new_handle: The source handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.replace_source_references(old_handle, new_handle)
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
Merge the content of acquisition into this source.
|
||||
|
@ -1,194 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2006 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
SourceBase class for GRAMPS.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.srcref import SourceRef
|
||||
from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# SourceBase classes
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SourceBase(object):
|
||||
"""
|
||||
Base class for storing source references.
|
||||
"""
|
||||
|
||||
def __init__(self, source=None):
|
||||
"""
|
||||
Create a new SourceBase, copying from source if not None.
|
||||
|
||||
:param source: Object used to initialize the new object
|
||||
:type source: SourceBase
|
||||
"""
|
||||
|
||||
self.source_list = map(SourceRef, source.source_list) if source else []
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return [sref.serialize() for sref in self.source_list]
|
||||
|
||||
def unserialize(self, data):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
self.source_list = [SourceRef().unserialize(item) for item in data]
|
||||
|
||||
def add_source_reference(self, src_ref) :
|
||||
"""
|
||||
Add a source reference to this object.
|
||||
|
||||
:param src_ref: The source reference to be added to the
|
||||
SourceNote's list of source references.
|
||||
:type src_ref: :class:`~gen.lib.srcref.SourceRef`
|
||||
"""
|
||||
self.source_list.append(src_ref)
|
||||
|
||||
def get_source_references(self) :
|
||||
"""
|
||||
Return the list of source references associated with the object.
|
||||
|
||||
:returns: Returns the list of :class:`~gen.lib.srcref.SourceRef` objects associated with
|
||||
the object.
|
||||
:rtype: list
|
||||
"""
|
||||
return self.source_list
|
||||
|
||||
def get_sourcref_child_list(self):
|
||||
"""
|
||||
Return the list of child secondary objects that may refer sources.
|
||||
|
||||
:returns: Returns the list of child secondary child objects that may
|
||||
refer sources.
|
||||
:rtype: list
|
||||
"""
|
||||
return []
|
||||
|
||||
def has_source_reference(self, src_handle) :
|
||||
"""
|
||||
Return True if the object or any of it's child objects has reference
|
||||
to this source handle.
|
||||
|
||||
:param src_handle: The source handle to be checked.
|
||||
:type src_handle: str
|
||||
:returns: Returns whether the object or any of it's child objects has
|
||||
reference to this source handle.
|
||||
:rtype: bool
|
||||
"""
|
||||
for src_ref in self.source_list:
|
||||
# Using direct access here, not the getter method -- efficiency!
|
||||
if src_ref.ref == src_handle:
|
||||
return True
|
||||
|
||||
for item in self.get_sourcref_child_list():
|
||||
if item.has_source_reference(src_handle):
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def remove_source_references(self, src_handle_list):
|
||||
"""
|
||||
Remove references to all source handles in the list in this object
|
||||
and all child objects.
|
||||
|
||||
:param src_handle_list: The list of source handles to be removed.
|
||||
:type src_handle_list: list
|
||||
"""
|
||||
new_source_list = [src_ref for src_ref in self.source_list
|
||||
if src_ref.ref not in src_handle_list]
|
||||
self.source_list = new_source_list
|
||||
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.remove_source_references(src_handle_list)
|
||||
|
||||
def replace_source_references(self, old_handle, new_handle):
|
||||
"""
|
||||
Replace references to source handles in the list in this object and
|
||||
all child objects and merge equivalent entries.
|
||||
|
||||
:param old_handle: The source handle to be replaced.
|
||||
:type old_handle: str
|
||||
:param new_handle: The source handle to replace the old one with.
|
||||
:type new_handle: str
|
||||
"""
|
||||
refs_list = [ src_ref.ref for src_ref in self.source_list ]
|
||||
new_ref = None
|
||||
if new_handle in refs_list:
|
||||
new_ref = self.source_list[refs_list.index(new_handle)]
|
||||
n_replace = refs_list.count(old_handle)
|
||||
for ix_replace in xrange(n_replace):
|
||||
idx = refs_list.index(old_handle)
|
||||
self.source_list[idx].ref = new_handle
|
||||
refs_list[idx] = new_handle
|
||||
if new_ref:
|
||||
src_ref = self.source_list[idx]
|
||||
equi = new_ref.is_equivalent(src_ref)
|
||||
if equi != DIFFERENT:
|
||||
if equi == EQUAL:
|
||||
new_ref.merge(src_ref)
|
||||
self.source_list.pop(idx)
|
||||
refs_list.pop(idx)
|
||||
|
||||
for item in self.get_sourcref_child_list():
|
||||
item.replace_source_references(old_handle, new_handle)
|
||||
|
||||
def set_source_reference_list(self, src_ref_list) :
|
||||
"""
|
||||
Assign the passed list to the object's list of source references.
|
||||
|
||||
:param src_ref_list: List of source references to ba associated
|
||||
with the object
|
||||
:type src_ref_list: list of :class:`~gen.lib.srcref.SourceRef` instances
|
||||
"""
|
||||
self.source_list = src_ref_list
|
||||
|
||||
def _merge_source_reference_list(self, acquisition):
|
||||
"""
|
||||
Merge the list of source references from acquisition with our own.
|
||||
|
||||
:param acquisition: the source references list of this object will be
|
||||
merged with the current source references list.
|
||||
:rtype acquisition: SourceRef
|
||||
"""
|
||||
srcref_list = self.source_list[:]
|
||||
for addendum in acquisition.get_source_references():
|
||||
for srcref in srcref_list:
|
||||
equi = srcref.is_equivalent(addendum)
|
||||
if equi == IDENTICAL:
|
||||
break
|
||||
elif equi == EQUAL:
|
||||
srcref.merge(addendum)
|
||||
break
|
||||
else:
|
||||
self.source_list.append(addendum)
|
@ -1,176 +0,0 @@
|
||||
#
|
||||
# Gramps - a GTK+/GNOME based genealogy program
|
||||
#
|
||||
# Copyright (C) 2000-2007 Donald N. Allingham
|
||||
# Copyright (C) 2010 Michiel D. Nauta
|
||||
#
|
||||
# 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
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#
|
||||
|
||||
# $Id$
|
||||
|
||||
"""
|
||||
Source Reference class for GRAMPS.
|
||||
"""
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Python modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from warnings import warn
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# GRAMPS modules
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
from gen.lib.secondaryobj import SecondaryObject
|
||||
from gen.lib.datebase import DateBase
|
||||
from gen.lib.privacybase import PrivacyBase
|
||||
from gen.lib.notebase import NoteBase
|
||||
from gen.lib.refbase import RefBase
|
||||
from gen.lib.const import IDENTICAL, EQUAL, DIFFERENT
|
||||
|
||||
#-------------------------------------------------------------------------
|
||||
#
|
||||
# Source References for all primary objects
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
class SourceRef(SecondaryObject, DateBase, PrivacyBase, NoteBase, RefBase):
|
||||
"""
|
||||
Source reference, containing detailed information about how a referenced
|
||||
source relates to it.
|
||||
"""
|
||||
|
||||
CONF_VERY_HIGH = 4
|
||||
CONF_HIGH = 3
|
||||
CONF_NORMAL = 2
|
||||
CONF_LOW = 1
|
||||
CONF_VERY_LOW = 0
|
||||
|
||||
def __init__(self, source=None):
|
||||
"""Create a new SourceRef, copying from the source if present."""
|
||||
DateBase.__init__(self, source)
|
||||
PrivacyBase.__init__(self, source)
|
||||
NoteBase.__init__(self, source)
|
||||
RefBase.__init__(self, source)
|
||||
if source:
|
||||
self.confidence = source.confidence
|
||||
self.page = source.page
|
||||
else:
|
||||
self.confidence = SourceRef.CONF_NORMAL
|
||||
self.page = ""
|
||||
|
||||
def serialize(self):
|
||||
"""
|
||||
Convert the object to a serialized tuple of data.
|
||||
"""
|
||||
return (DateBase.serialize(self),
|
||||
PrivacyBase.serialize(self),
|
||||
NoteBase.serialize(self),
|
||||
self.confidence,
|
||||
RefBase.serialize(self),
|
||||
self.page)
|
||||
|
||||
def unserialize(self, data):
|
||||
"""
|
||||
Convert a serialized tuple of data to an object.
|
||||
"""
|
||||
(date, privacy, note_list,
|
||||
self.confidence, ref, self.page) = data
|
||||
DateBase.unserialize(self, date)
|
||||
PrivacyBase.unserialize(self, privacy)
|
||||
NoteBase.unserialize(self, note_list)
|
||||
RefBase.unserialize(self, ref)
|
||||
return self
|
||||
|
||||
def get_text_data_list(self):
|
||||
"""
|
||||
Return the list of all textual attributes of the object.
|
||||
|
||||
:returns: Returns the list of all textual attributes of the object.
|
||||
:rtype: list
|
||||
"""
|
||||
return [self.page]
|
||||
|
||||
def get_referenced_handles(self):
|
||||
"""
|
||||
Return the list of (classname, handle) tuples for all directly
|
||||
referenced primary objects.
|
||||
|
||||
:returns: List of (classname, handle) tuples for referenced objects.
|
||||
:rtype: list
|
||||
"""
|
||||
ret = self.get_referenced_note_handles()
|
||||
if self.ref:
|
||||
ret += [('Source', self.ref)]
|
||||
return ret
|
||||
|
||||
def is_equivalent(self, other):
|
||||
"""
|
||||
Return if this source reference is equivalent, that is agreees in
|
||||
reference, source page and date, to other.
|
||||
|
||||
:param other: The source reference to compare this one to.
|
||||
:rtype other: SourceRef
|
||||
;returns: Constant indicating degree of equivalence.
|
||||
:rtype: int
|
||||
"""
|
||||
if self.ref != other.ref or \
|
||||
self.page != other.page or \
|
||||
self.get_date_object() != other.get_date_object():
|
||||
return DIFFERENT
|
||||
else:
|
||||
if self.is_equal(other):
|
||||
return IDENTICAL
|
||||
else:
|
||||
return EQUAL
|
||||
|
||||
def merge(self, acquisition):
|
||||
"""
|
||||
Merge the content of acquisition into this source reference.
|
||||
|
||||
:param acquisition: The source reference to merge with the present one.
|
||||
:rtype acquisition: SourceRef
|
||||
"""
|
||||
self._merge_privacy(acquisition)
|
||||
self._merge_note_list(acquisition)
|
||||
# merge confidence
|
||||
level_priority = [0, 4, 1, 3, 2]
|
||||
idx = min(level_priority.index(self.confidence),
|
||||
level_priority.index(acquisition.confidence))
|
||||
self.confidence = level_priority[idx]
|
||||
|
||||
def set_confidence_level(self, val):
|
||||
"""Set the confidence level."""
|
||||
self.confidence = val
|
||||
|
||||
def get_confidence_level(self):
|
||||
"""Return the confidence level."""
|
||||
return self.confidence
|
||||
|
||||
def set_page(self, page):
|
||||
"""Set the page indicator of the SourceRef."""
|
||||
self.page = page
|
||||
|
||||
def get_page(self):
|
||||
"""Get the page indicator of the SourceRef."""
|
||||
return self.page
|
||||
|
||||
def are_equal(self, other):
|
||||
"""Deprecated function - use is_equal instead."""
|
||||
warn( "Use is_equal instead of are_equal", DeprecationWarning, 2)
|
||||
return self.is_equal(other)
|
@ -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
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user