Package gen :: Package lib :: Module srcref
[frames] | no frames]

Source Code for Module gen.lib.srcref

  1  # 
  2  # Gramps - a GTK+/GNOME based genealogy program 
  3  # 
  4  # Copyright (C) 2000-2007  Donald N. Allingham 
  5  # 
  6  # This program is free software; you can redistribute it and/or modify 
  7  # it under the terms of the GNU General Public License as published by 
  8  # the Free Software Foundation; either version 2 of the License, or 
  9  # (at your option) any later version. 
 10  # 
 11  # This program is distributed in the hope that it will be useful, 
 12  # but WITHOUT ANY WARRANTY; without even the implied warranty of 
 13  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 14  # GNU General Public License for more details. 
 15  # 
 16  # You should have received a copy of the GNU General Public License 
 17  # along with this program; if not, write to the Free Software 
 18  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
 19  # 
 20   
 21  # $Id: srcref.py 10103 2008-02-24 13:55:55Z acraphae $ 
 22   
 23  """ 
 24  Source Reference class for GRAMPS. 
 25  """ 
 26   
 27  #------------------------------------------------------------------------- 
 28  # 
 29  # Python modules 
 30  # 
 31  #------------------------------------------------------------------------- 
 32  from warnings import warn 
 33   
 34  #------------------------------------------------------------------------- 
 35  # 
 36  # GRAMPS modules 
 37  # 
 38  #------------------------------------------------------------------------- 
 39  from gen.lib.secondaryobj import SecondaryObject 
 40  from gen.lib.datebase import DateBase 
 41  from gen.lib.privacybase import PrivacyBase 
 42  from gen.lib.notebase import NoteBase 
 43  from gen.lib.refbase import RefBase 
 44   
 45  #------------------------------------------------------------------------- 
 46  # 
 47  # Source References for all primary objects 
 48  # 
 49  #------------------------------------------------------------------------- 
50 -class SourceRef(SecondaryObject, DateBase, PrivacyBase, NoteBase, RefBase):
51 """ 52 Source reference, containing detailed information about how a referenced 53 source relates to it. 54 """ 55 56 CONF_VERY_HIGH = 4 57 CONF_HIGH = 3 58 CONF_NORMAL = 2 59 CONF_LOW = 1 60 CONF_VERY_LOW = 0 61
62 - def __init__(self, source=None):
63 """Create a new SourceRef, copying from the source if present.""" 64 DateBase.__init__(self, source) 65 PrivacyBase.__init__(self, source) 66 NoteBase.__init__(self, source) 67 RefBase.__init__(self, source) 68 if source: 69 self.confidence = source.confidence 70 self.page = source.page 71 else: 72 self.confidence = SourceRef.CONF_NORMAL 73 self.page = ""
74
75 - def serialize(self):
76 """ 77 Convert the object to a serialized tuple of data. 78 """ 79 return (DateBase.serialize(self), 80 PrivacyBase.serialize(self), 81 NoteBase.serialize(self), 82 self.confidence, 83 RefBase.serialize(self), 84 self.page)
85
86 - def unserialize(self, data):
87 """ 88 Convert a serialized tuple of data to an object. 89 """ 90 (date, privacy, note_list, 91 self.confidence, ref, self.page) = data 92 DateBase.unserialize(self, date) 93 PrivacyBase.unserialize(self, privacy) 94 NoteBase.unserialize(self, note_list) 95 RefBase.unserialize(self, ref) 96 return self
97
98 - def get_text_data_list(self):
99 """ 100 Return the list of all textual attributes of the object. 101 102 @return: Returns the list of all textual attributes of the object. 103 @rtype: list 104 """ 105 return [self.page]
106
107 - def get_referenced_handles(self):
108 """ 109 Return the list of (classname, handle) tuples for all directly 110 referenced primary objects. 111 112 @return: List of (classname, handle) tuples for referenced objects. 113 @rtype: list 114 """ 115 ret = self.get_referenced_note_handles() 116 if self.ref: 117 ret += [('Source', self.ref)] 118 return ret
119
120 - def set_confidence_level(self, val):
121 """Set the confidence level.""" 122 self.confidence = val
123
124 - def get_confidence_level(self):
125 """Return the confidence level.""" 126 return self.confidence
127
128 - def set_page(self, page):
129 """Set the page indicator of the SourceRef.""" 130 self.page = page
131
132 - def get_page(self):
133 """Get the page indicator of the SourceRef.""" 134 return self.page
135
136 - def are_equal(self, other):
137 """Deprecated function - use are_equal instead.""" 138 warn( "Use is_equal instead of are_equal", DeprecationWarning, 2) 139 return self.is_equal(other)
140