* src/RelLib.py (NoteBase,PlaceBase): Add new classes.

* src/ReadGedcom.py: Use get_note for comments.
* src/ReadXML.py: Use get_note for comments.
* src/Sources.py: Use get_note for comments.
* src/WriteGedcom.py: Use get_note for comments.
* src/WriteXML.py: Use get_note for comments.
* src/plugins/Ancestors.py: Use get_note for comments.
* src/plugins/FtmStyleAncestors.py: Use get_note for comments.
* src/plugins/FtmStyleDescendants.py: Use get_note for comments.
* src/plugins/NavWebPage.py: Use get_note for comments.
* src/plugins/ScratchPad.py: Use get_note for comments.
* src/plugins/WebPage.py: Use get_note for comments.


svn: r4246
This commit is contained in:
Alex Roitman 2005-03-28 04:58:28 +00:00
parent 76095fbc96
commit b3fa7d644d
13 changed files with 218 additions and 229 deletions

View File

@ -7,6 +7,19 @@
* src/gramps_main.py (on_views_switch_page): Enable merge button;
(on_merge_activate): Call merge for sources.
* src/RelLib.py (NoteBase,PlaceBase): Add new classes.
* src/ReadGedcom.py: Use get_note for comments.
* src/ReadXML.py: Use get_note for comments.
* src/Sources.py: Use get_note for comments.
* src/WriteGedcom.py: Use get_note for comments.
* src/WriteXML.py: Use get_note for comments.
* src/plugins/Ancestors.py: Use get_note for comments.
* src/plugins/FtmStyleAncestors.py: Use get_note for comments.
* src/plugins/FtmStyleDescendants.py: Use get_note for comments.
* src/plugins/NavWebPage.py: Use get_note for comments.
* src/plugins/ScratchPad.py: Use get_note for comments.
* src/plugins/WebPage.py: Use get_note for comments.
2005-03-26 Alex Roitman <shura@gramps-project.org>
* src/RelLib.py (Source.replace_source_references): Add method.
* src/MergeData.py (MergeSources.merge): Use new handle replacement.

View File

@ -883,7 +883,7 @@ class GedcomParser:
return self.parse_note_base(matches,obj,level,old_note,obj.set_note)
def parse_comment(self,matches,obj,level,old_note):
return self.parse_note_base(matches,obj,level,old_note,obj.set_comments)
return self.parse_note_base(matches,obj,level,old_note,obj.set_note)
def parse_individual(self):
name_cnt = 0

View File

@ -1291,7 +1291,7 @@ class GrampsParser:
note = fix_spaces(self.scomments_list)
else:
note = tag
self.source_ref.set_comments(note)
self.source_ref.set_note(note)
def stop_last(self,tag):
if self.name:

View File

@ -298,7 +298,92 @@ class PrimaryObject(BaseObject):
def _replace_handle_reference(self,classname,old_handle,new_handle):
pass
class SourceNote(BaseObject):
class NoteBase:
"""
Base class for storing notes.
"""
def __init__(self,source=None):
"""
Create a new NoteBase, copying from source if not None
@param source: Object used to initialize the new object
@type source: NoteBase
"""
if source and source.note:
self.note = Note(source.note.get())
else:
self.note = None
def set_note(self,text):
"""
Assigns the specified text to the associated note.
@param text: Text of the note
@type text: str
"""
if self.note == None:
self.note = Note()
self.note.set(text)
def get_note(self):
"""
Returns the text of the current note.
@returns: the text of the current note
@rtype: str
"""
if self.note == None:
return ""
else:
return self.note.get()
def set_note_format(self,val):
"""
Sets the note's format to the given value. The format indicates
whether the text is flowed (wrapped) or preformatted.
@param val: True indicates the text is flowed
@type val: bool
"""
if self.note:
self.note.set_format(val)
def get_note_format(self):
"""
Returns the current note's format
@returns: True indicates that the note should be flowed (wrapped)
@rtype: bool
"""
if self.note == None:
return False
else:
return self.note.get_format()
def set_note_object(self,note_obj):
"""
Replaces the current L{Note} object associated with the object
@param note_obj: New L{Note} object to be assigned
@type note_obj: L{Note}
"""
self.note = note_obj
def get_note_object(self):
"""
Returns the L{Note} instance associated with the object.
@returns: L{Note} object assocated with the object
@rtype: L{Note}
"""
return self.note
def unique_note(self):
"""Creates a unique instance of the current note"""
self.note = Note(self.note.get())
class SourceNote(BaseObject,NoteBase):
"""
Base class for storing source references and notes
"""
@ -311,13 +396,11 @@ class SourceNote(BaseObject):
@type source: SourceNote
"""
self.source_list = []
self.note = None
NoteBase.__init__(self,source)
if source:
self.source_list = [SourceRef(sref) for sref in source.source_list]
if source.note:
self.note = Note(source.note.get())
else:
self.source_list = []
def add_source_reference(self,src_ref) :
"""
@ -411,74 +494,6 @@ class SourceNote(BaseObject):
"""
self.source_list = src_ref_list
def set_note(self,text):
"""
Assigns the specified text to the associated note.
@param text: Text of the note
@type text: str
"""
if self.note == None:
self.note = Note()
self.note.set(text)
def get_note(self):
"""
Returns the text of the current note.
@returns: the text of the current note
@rtype: str
"""
if self.note == None:
return ""
else:
return self.note.get()
def set_note_format(self,val):
"""
Sets the note's format to the given value. The format indicates
whether the text is flowed (wrapped) or preformatted.
@param val: True indicates the text is flowed
@type val: bool
"""
if self.note:
self.note.set_format(val)
def get_note_format(self):
"""
Returns the current note's format
@returns: True indicates that the note should be flowed (wrapped)
@rtype: bool
"""
if self.note == None:
return False
else:
return self.note.get_format()
def set_note_object(self,note_obj):
"""
Replaces the current L{Note} object associated with the object
@param note_obj: New L{Note} object to be assigned
@type note_obj: L{Note}
"""
self.note = note_obj
def get_note_object(self):
"""
Returns the L{Note} instance associated with the object.
@returns: L{Note} object assocated with the object
@rtype: L{Note}
"""
return self.note
def unique_note(self):
"""Creates a unique instance of the current note"""
self.note = Note(self.note.get())
class MediaBase:
"""
Base class for storing media references
@ -753,6 +768,42 @@ class AttributeBase:
"""
self.attribute_list = attribute_list
class PlaceBase:
"""
Base class for place-aware objects.
"""
def __init__(self,source=None):
"""
Initialize a PlaceBase. If the source is not None, then object
is initialized from values of the source object.
@param source: Object used to initialize the new object
@type source: PlaceBase
"""
if source:
self.place = source.place
else:
self.place = ""
def set_place_handle(self,place_handle):
"""
Sets the database handle for L{Place} associated with the object.
@param place_handle: L{Place} database handle
@type place_handle: str
"""
self.place = place_handle
def get_place_handle(self):
"""
Returns the database handle of the L{Place} assocated with
the Event.
@returns: L{Place} database handle
@rtype: str
"""
return self.place
class PrivateSourceNote(SourceNote,PrivacyBase):
"""
Same as SourceNote, plus the privacy capabilities.
@ -1873,7 +1924,7 @@ class Family(PrimaryObject,SourceNote,MediaBase,AttributeBase):
"""
self.event_list = event_list
class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase):
class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase,PlaceBase):
"""
Introduction
============
@ -1897,9 +1948,9 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase):
PrivateSourceNote.__init__(self,source)
MediaBase.__init__(self,source)
DateBase.__init__(self,source)
PlaceBase.__init__(self,source)
if source:
self.place = source.place
self.description = source.description
self.name = source.name
self.cause = source.cause
@ -1908,7 +1959,6 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase):
else:
self.witness = None
else:
self.place = ""
self.description = ""
self.name = ""
self.cause = ""
@ -2116,26 +2166,6 @@ class Event(PrimaryObject,PrivateSourceNote,MediaBase,DateBase):
"""
return self.name
def set_place_handle(self,place_handle):
"""
Sets the database handle for L{Place} associated with the
Event.
@param place_handle: L{Place} database handle
@type place_handle: str
"""
self.place = place_handle
def get_place_handle(self):
"""
Returns the database handle of the L{Place} assocated with
the Event.
@returns: L{Place} database handle
@rtype: str
"""
return self.place
def set_cause(self,cause):
"""
Sets the cause of the Event to the passed string. The string
@ -2591,13 +2621,14 @@ class MediaObject(PrimaryObject,SourceNote,DateBase,AttributeBase):
"""returns the description of the image"""
return self.desc
class Source(PrimaryObject,MediaBase):
class Source(PrimaryObject,MediaBase,NoteBase):
"""A record of a source of information"""
def __init__(self):
"""creates a new Source instance"""
PrimaryObject.__init__(self)
MediaBase.__init__(self)
NoteBase.__init__(self)
self.title = ""
self.author = ""
self.pubinfo = ""
@ -2720,34 +2751,6 @@ class Source(PrimaryObject,MediaBase):
"""
return self.title
def set_note(self,text):
"""sets the text of the note attached to the Source"""
self.note.set(text)
def get_note(self):
"""returns the text of the note attached to the Source"""
return self.note.get()
def set_note_format(self,val):
"""Set the note's format to the given value"""
self.note.set_format(val)
def get_note_format(self):
"""Return the current note's format"""
return self.note.get_format()
def set_note_object(self,obj):
"""sets the Note instance attached to the Source"""
self.note = obj
def get_note_object(self):
"""returns the Note instance attached to the Source"""
return self.note
def unique_note(self):
"""Creates a unique instance of the current note"""
self.note = Note(self.note.get())
def set_author(self,author):
"""sets the author of the Source"""
self.author = author
@ -2772,7 +2775,7 @@ class Source(PrimaryObject,MediaBase):
"""returns the title abbreviation of the Source"""
return self.abbrev
class LdsOrd(SourceNote,DateBase):
class LdsOrd(SourceNote,DateBase,PlaceBase):
"""
Class that contains information about LDS Ordinances. LDS
ordinances are similar to events, but have very specific additional
@ -2784,17 +2787,16 @@ class LdsOrd(SourceNote,DateBase):
"""Creates a LDS Ordinance instance"""
SourceNote.__init__(self,source)
DateBase.__init__(self,source)
PlaceBase.__init__(self,source)
if source:
self.famc = source.famc
self.temple = source.temple
self.status = source.status
self.place = source.place
else:
self.famc = None
self.temple = ""
self.status = 0
self.place = None
def get_text_data_list(self):
"""
@ -2817,14 +2819,6 @@ class LdsOrd(SourceNote,DateBase):
check_list.append(self.note)
return check_list
def set_place_handle(self,place):
"""sets the Place database handle of the ordinance"""
self.place = place
def get_place_handle(self):
"""returns the Place handle of the ordinance"""
return self.place
def set_family_handle(self,family):
"""Sets the Family database handle associated with the LDS ordinance"""
self.famc = family
@ -3707,7 +3701,7 @@ class Witness(BaseObject,PrivacyBase):
def get_comment(self):
return self.comment
class SourceRef(BaseObject,DateBase,PrivacyBase):
class SourceRef(BaseObject,DateBase,PrivacyBase,NoteBase):
"""Source reference, containing detailed information about how a
referenced source relates to it"""
@ -3715,17 +3709,17 @@ class SourceRef(BaseObject,DateBase,PrivacyBase):
"""creates a new SourceRef, copying from the source if present"""
DateBase.__init__(self,source)
PrivacyBase.__init__(self,source)
NoteBase.__init__(self,source)
if source:
self.confidence = source.confidence
self.ref = source.ref
self.page = source.page
self.comments = Note(source.comments.get())
self.text = source.text
else:
self.confidence = CONF_NORMAL
self.ref = None
self.page = ""
self.comments = Note()
self.note = Note()
self.text = ""
def get_text_data_list(self):
@ -3744,7 +3738,7 @@ class SourceRef(BaseObject,DateBase,PrivacyBase):
@return: Returns the list of child objects that may carry textual data.
@rtype: list
"""
return [self.comments]
return [self.note]
def set_confidence_level(self,val):
"""Sets the confidence level"""
@ -3778,18 +3772,6 @@ class SourceRef(BaseObject,DateBase,PrivacyBase):
"""returns the text related to the SourceRef"""
return self.text
def set_note_object(self,note):
"""Change the Note instance to obj"""
self.comments = note
def set_comments(self,comments):
"""sets the comments about the SourceRef"""
self.comments.set(comments)
def get_comments(self):
"""returns the comments about the SourceRef"""
return self.comments.get()
def are_equal(self,other):
"""returns True if the passed SourceRef is equal to the current"""
if self.ref and other.ref:
@ -3802,7 +3784,7 @@ class SourceRef(BaseObject,DateBase,PrivacyBase):
return False
if self.get_text() != other.get_text():
return False
if self.get_comments() != other.get_comments():
if self.get_note() != other.get_note():
return False
if self.confidence != other.confidence:
return False
@ -3812,10 +3794,6 @@ class SourceRef(BaseObject,DateBase,PrivacyBase):
else:
return False
def unique_note(self):
"""Creates a unique instance of the current note"""
self.comments = Note(self.comments.get())
class GenderStats:
"""
Class for keeping track of statistics related to Given Name vs.

View File

@ -496,7 +496,7 @@ class SourceEditor:
text.get_buffer().set_text(self.source_ref.get_text())
scom = self.get_widget("scomment")
scom.get_buffer().set_text(self.source_ref.get_comments())
scom.get_buffer().set_text(self.source_ref.get_note())
src = self.db.get_source_from_handle(self.source_ref.get_base_handle())
self.active_source = src
if src:
@ -557,7 +557,7 @@ class SourceEditor:
self.source_ref.set_page(page)
self.source_ref.set_date_object(self.date_obj)
self.source_ref.set_text(text)
self.source_ref.set_comments(comments)
self.source_ref.set_note(comments)
self.source_ref.set_confidence_level(conf)
self.source_ref.set_privacy(self.private.get_active())

View File

@ -1,7 +1,7 @@
#
# Gramps - a GTK+/GNOME based genealogy program
#
# Copyright (C) 2000-2004 Donald N. Allingham
# Copyright (C) 2000-2005 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
@ -27,9 +27,9 @@
#
#-------------------------------------------------------------------------
import os
import string
import time
import re
from gettext import gettext as _
#-------------------------------------------------------------------------
#
@ -53,8 +53,6 @@ import Errors
import ansel_utf8
import Utils
import NameDisplay
from gettext import gettext as _
from QuestionDialog import ErrorDialog
def keep_utf8(s):
@ -274,7 +272,7 @@ def fmtline(text,limit,level,endl):
if len(text) > 0:
new_text.append(text)
app = "%s%d CONC " % (endl,level+1)
return string.join(new_text,app)
return app.join(new_text)
#-------------------------------------------------------------------------
#
@ -887,7 +885,7 @@ class GedcomWriter:
else:
self.writeln("1 EVEN")
self.writeln("2 TYPE %s" % self.cnvtxt(name))
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(attr.get_value()),'\r',' '))
self.writeln("2 PLAC %s" % self.cnvtxt(attr.get_value()).replace('\r',' '))
if attr.get_note():
self.write_long_text("NOTE",2,self.cnvtxt(attr.get_note()))
for srcref in attr.get_source_references():
@ -918,7 +916,7 @@ class GedcomWriter:
text = addr_append(text,addr.get_country())
text = addr_append(text,addr.get_phone())
if text:
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(text),'\r',' '))
self.writeln("2 PLAC %s" % self.cnvtxt(text).replace('\r',' '))
if addr.get_note():
self.write_long_text("NOTE",2,self.cnvtxt(addr.get_note()))
for srcref in addr.get_source_references():
@ -1009,7 +1007,7 @@ class GedcomWriter:
while ll > 0:
brkpt = 70
if ll > brkpt:
while (ll > brkpt and line[brkpt] in string.whitespace):
while (ll > brkpt and line[brkpt].isspace()):
brkpt = brkpt+1
if ll == brkpt:
self.writeln("%s %s" % (prefix,line))
@ -1038,7 +1036,7 @@ class GedcomWriter:
while ll > 0:
brkpt = 70
if ll > brkpt:
while (ll > brkpt and line[brkpt] not in string.whitespace):
while (ll > brkpt and not line[brkpt].isspace()):
brkpt = brkpt+1
if ll == brkpt:
self.writeln("%s %s" % (prefix,line))
@ -1061,7 +1059,7 @@ class GedcomWriter:
self.print_date("2 DATE",dateobj)
if event.get_place_handle():
place_name = self.db.get_place_from_handle(event.get_place_handle()).get_title()
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(place_name),'\r',' '))
self.writeln("2 PLAC %s" % self.cnvtxt(place_name).replace('\r',' '))
if event.get_cause():
self.writeln("2 CAUS %s" % self.cnvtxt(event.get_cause()))
if event.get_note():
@ -1081,7 +1079,7 @@ class GedcomWriter:
self.writeln('%d TEMP %s' % (index+1,ord.get_temple()))
if ord.get_place_handle():
place_name = self.db.get_place_from_handle(ord.get_place_handle()).get_title()
self.writeln("2 PLAC %s" % string.replace(self.cnvtxt(place_name),'\r',' '))
self.writeln("2 PLAC %s" % self.cnvtxt(place_name).replace('\r',' '))
if ord.get_status() != 0:
self.writeln("2 STAT %s" % self.cnvtxt(statlist[ord.get_status()]))
if ord.get_note():
@ -1189,8 +1187,8 @@ class GedcomWriter:
ref_text = ref.get_text()
self.write_long_text("TEXT",level+1,self.cnvtxt(ref_text))
if ref.get_comments():
self.write_long_text("NOTE",level+1,self.cnvtxt(ref.get_comments()))
if ref.get_note():
self.write_long_text("NOTE",level+1,self.cnvtxt(ref.get_note()))
def fid(self,id):
family = self.db.get_family_from_handle (id)

View File

@ -539,7 +539,7 @@ class XmlWriter:
source = self.db.get_source_from_handle(source_ref.get_base_handle())
if source:
p = source_ref.get_page()
c = source_ref.get_comments()
c = source_ref.get_note()
t = source_ref.get_text()
d = source_ref.get_date_object()
q = source_ref.get_confidence_level()

View File

@ -624,7 +624,7 @@ class ComprehensiveAncestorsReport (Report.Report):
ind = len (self.sources)
citation += "[%d" % ind
comments = ref.get_comments ()
comments = ref.get_note ()
if comments and comments.find ('\n') == -1:
citation += " - %s" % comments.rstrip ('.')

View File

@ -164,7 +164,7 @@ class FtmAncestorReport(Report.Report):
self.doc.write_text(' ')
self.doc.write_text(item)
item = srcref.get_comments()
item = srcref.get_note()
if item:
self.doc.write_text('; ')
self.doc.write_text(_('Comments:'))

View File

@ -194,7 +194,7 @@ class FtmDescendantReport(Report.Report):
self.doc.write_text(' ')
self.doc.write_text(item)
item = srcref.get_comments()
item = srcref.get_note()
if item:
self.doc.write_text('; ')
self.doc.write_text(_('Comments:'))

View File

@ -421,7 +421,7 @@ class ScratchPadWindow:
_("Title"),escape(base.get_title()),
_("Page"), escape(srcref.get_page()),
_("Text"), escape(srcref.get_text()),
_("Comment"), escape(srcref.get_comments()))
_("Comment"), escape(srcref.get_note()))
return s

View File

@ -237,7 +237,7 @@ class IndividualPage:
self.write_info(sref.get_page())
if self.usecomments:
self.write_info(sref.get_text())
self.write_info(sref.get_comments())
self.write_info(sref.get_note())
self.doc.end_paragraph()
def write_info(self,info):