* src/const.py.in: Add notes_formats list.
* src/RelLib.py: Support format for the notes. * src/WriteXML.py: Support format for the notes. * src/GrampsParser.py: Support format for the notes. svn: r2492
This commit is contained in:
parent
2d71af3791
commit
4e66fd7b70
@ -10,6 +10,10 @@
|
||||
it is taken care of by parse_address() now;
|
||||
(parse_address): Parse PHON field, provided it immediately follows
|
||||
ADDR structure.
|
||||
* src/const.py.in: Add notes_formats list.
|
||||
* src/RelLib.py: Support format for the notes.
|
||||
* src/WriteXML.py: Support format for the notes.
|
||||
* src/GrampsParser.py: Support format for the notes.
|
||||
|
||||
2003-12-08 Don Allingham <dallingham@users.sourceforge.net>
|
||||
* src/RelLib.py: Add phone to address, postal code and phone to
|
||||
|
@ -429,6 +429,9 @@ class GrampsParser:
|
||||
|
||||
def start_note(self,attrs):
|
||||
self.in_note = 1
|
||||
self.note = RelLib.Note()
|
||||
if attrs.has_key("format"):
|
||||
self.note.setFormat(int(attrs['format']))
|
||||
|
||||
def start_sourceref(self,attrs):
|
||||
self.source_ref = RelLib.SourceRef()
|
||||
@ -807,35 +810,35 @@ class GrampsParser:
|
||||
self.in_note = 0
|
||||
if self.use_p:
|
||||
self.use_p = 0
|
||||
note = fix_spaces(self.note_list)
|
||||
text = fix_spaces(self.note_list)
|
||||
else:
|
||||
note = tag
|
||||
text = tag
|
||||
self.note.set(text)
|
||||
|
||||
if self.address:
|
||||
self.address.setNote(note)
|
||||
self.address.setNoteObj(self.note)
|
||||
elif self.ord:
|
||||
self.ord.setNote(note)
|
||||
self.ord.setNoteObj(self.note)
|
||||
elif self.attribute:
|
||||
self.attribute.setNote(note)
|
||||
self.attribute.setNoteObj(self.note)
|
||||
elif self.object:
|
||||
self.object.setNote(note)
|
||||
self.object.setNoteObj(self.note)
|
||||
elif self.objref:
|
||||
self.objref.setNote(note)
|
||||
self.objref.setNoteObj(self.note)
|
||||
elif self.photo:
|
||||
self.photo.setNote(note)
|
||||
self.photo.setNoteObj(self.note)
|
||||
elif self.name:
|
||||
self.name.setNote(note)
|
||||
self.name.setNoteObj(self.note)
|
||||
elif self.source:
|
||||
self.source.setNote(note)
|
||||
self.source.setNoteObj(self.note)
|
||||
elif self.event:
|
||||
self.event.setNote(note)
|
||||
self.event.setNoteObj(self.note)
|
||||
elif self.person:
|
||||
self.person.setNote(note)
|
||||
self.person.setNoteObj(self.note)
|
||||
elif self.family:
|
||||
self.family.setNote(note)
|
||||
self.family.setNoteObj(self.note)
|
||||
elif self.placeobj:
|
||||
self.placeobj.setNote(note)
|
||||
self.note_list = []
|
||||
self.placeobj.setNoteObj(self.note)
|
||||
|
||||
def stop_research(self,tag):
|
||||
self.owner.set(self.resname, self.resaddr, self.rescity, self.resstate,
|
||||
|
@ -540,6 +540,7 @@ class Note:
|
||||
def __init__(self,text = ""):
|
||||
"""create a new Note object from the passed string"""
|
||||
self.text = text
|
||||
self.format = 0
|
||||
|
||||
def set(self,text):
|
||||
"""set the note contents to the passed string"""
|
||||
@ -553,6 +554,14 @@ class Note:
|
||||
"""adds the text to the note's contents"""
|
||||
self.text = self.text + text
|
||||
|
||||
def setFormat(self,format):
|
||||
"""set the format to the passed value"""
|
||||
self.format = format
|
||||
|
||||
def getFormat(self):
|
||||
"""return the note's format"""
|
||||
return self.format
|
||||
|
||||
class Photo(SourceNote):
|
||||
"""Containter for information about an image file, including location,
|
||||
description and privacy"""
|
||||
|
@ -257,7 +257,7 @@ class XmlWriter:
|
||||
self.write_line("postal",address.getPostal(),4)
|
||||
self.write_line("phone",address.getPhone(),4)
|
||||
if address.getNote() != "":
|
||||
self.write_note("note",address.getNote(),4)
|
||||
self.write_note("note",address.getNoteObj(),4)
|
||||
for s in address.getSourceRefList():
|
||||
self.dump_source_ref(s,4)
|
||||
self.g.write(' </address>\n')
|
||||
@ -280,7 +280,7 @@ class XmlWriter:
|
||||
for family in person.getFamilyList():
|
||||
self.write_ref("parentin",family,3)
|
||||
|
||||
self.write_note("note",person.getNote(),3)
|
||||
self.write_note("note",person.getNoteObj(),3)
|
||||
for s in person.getSourceRefList():
|
||||
self.dump_source_ref(s,4)
|
||||
|
||||
@ -314,7 +314,7 @@ class XmlWriter:
|
||||
for person in family.getChildList():
|
||||
self.write_ref("child",person,3)
|
||||
self.write_attribute_list(family.getAttributeList())
|
||||
self.write_note("note",family.getNote(),3)
|
||||
self.write_note("note",family.getNoteObj(),3)
|
||||
for s in family.getSourceRefList():
|
||||
self.dump_source_ref(s,3)
|
||||
self.g.write(" </family>\n")
|
||||
@ -335,7 +335,7 @@ class XmlWriter:
|
||||
self.write_line("spubinfo",source.getPubInfo(),3)
|
||||
self.write_line("sabbrev",source.getAbbrev(),3)
|
||||
if source.getNote() != "":
|
||||
self.write_note("note",source.getNote(),3)
|
||||
self.write_note("note",source.getNoteObj(),3)
|
||||
self.write_photo_list(source.getPhotoList())
|
||||
self.g.write(" </source>\n")
|
||||
self.g.write(" </sources>\n")
|
||||
@ -379,14 +379,28 @@ class XmlWriter:
|
||||
l = l.replace('<','<')
|
||||
return l.replace('"','"')
|
||||
|
||||
def write_note(self,val,note,indent=0):
|
||||
if not note:
|
||||
def write_note(self,val,noteobj,indent=0):
|
||||
if not noteobj:
|
||||
return
|
||||
text = noteobj.get()
|
||||
if not text:
|
||||
return
|
||||
if indent != 0:
|
||||
self.g.write(" " * indent)
|
||||
|
||||
self.g.write("<%s>" % val)
|
||||
self.g.write(self.fix(string.rstrip(note)))
|
||||
format = noteobj.getFormat()
|
||||
self.g.write('<%s format="%d">' % (val,format))
|
||||
self.g.write(self.fix(string.rstrip(text)))
|
||||
self.g.write("</%s>\n" % val)
|
||||
|
||||
def write_text(self,val,text,indent=0):
|
||||
if not text:
|
||||
return
|
||||
if indent != 0:
|
||||
self.g.write(" " * indent)
|
||||
|
||||
self.g.write('<%s>' % val)
|
||||
self.g.write(self.fix(string.rstrip(text)))
|
||||
self.g.write("</%s>\n" % val)
|
||||
|
||||
def dump_event(self,event,index=1):
|
||||
@ -427,7 +441,7 @@ class XmlWriter:
|
||||
self.write_line("cause",event.getCause(),index+1)
|
||||
self.write_line("description",event.getDescription(),index+1)
|
||||
if event.getNote():
|
||||
self.write_note("note",event.getNote(),index+1)
|
||||
self.write_note("note",event.getNoteObj(),index+1)
|
||||
|
||||
for s in event.getSourceRefList():
|
||||
self.dump_source_ref(s,index+1)
|
||||
@ -451,7 +465,7 @@ class XmlWriter:
|
||||
if ord.getFamily():
|
||||
self.g.write('%s<sealed_to ref="%s"/>\n' % (sp2,self.fix(ord.getFamily().getId())))
|
||||
if ord.getNote() != "":
|
||||
self.write_note("note",ord.getNote(),index+1)
|
||||
self.write_note("note",ord.getNoteObj(),index+1)
|
||||
for s in ord.getSourceRefList():
|
||||
self.dump_source_ref(s,index+1)
|
||||
self.g.write('%s</lds_ord>\n' % sp)
|
||||
@ -473,8 +487,8 @@ class XmlWriter:
|
||||
else:
|
||||
self.g.write('<sourceref ref="%s" conf="%d">\n' % (source.getId(),q))
|
||||
self.write_line("spage",p,index+1)
|
||||
self.write_note("scomments",c,index+1)
|
||||
self.write_note("stext",t,index+1)
|
||||
self.write_text("scomments",c,index+1)
|
||||
self.write_text("stext",t,index+1)
|
||||
self.write_date(d,index+1)
|
||||
self.g.write("%s</sourceref>\n" % (" " * index))
|
||||
|
||||
@ -564,7 +578,7 @@ class XmlWriter:
|
||||
self.write_line("suffix",name.getSuffix(),index+1)
|
||||
self.write_line("title",name.getTitle(),index+1)
|
||||
if name.getNote() != "":
|
||||
self.write_note("note",name.getNote(),index+1)
|
||||
self.write_note("note",name.getNoteObj(),index+1)
|
||||
for s in name.getSourceRefList():
|
||||
self.dump_source_ref(s,index+1)
|
||||
|
||||
@ -642,7 +656,7 @@ class XmlWriter:
|
||||
self.g.write('>\n')
|
||||
for s in attr.getSourceRefList():
|
||||
self.dump_source_ref(s,indent+1)
|
||||
self.write_note("note",attr.getNote(),4)
|
||||
self.write_note("note",attr.getNoteObj(),4)
|
||||
self.g.write('%s</attribute>\n' % sp)
|
||||
|
||||
def write_photo_list(self,list,indent=3):
|
||||
@ -658,7 +672,7 @@ class XmlWriter:
|
||||
else:
|
||||
self.g.write(">\n")
|
||||
self.write_attribute_list(proplist,indent+1)
|
||||
self.write_note("note",photo.getNote(),indent+1)
|
||||
self.write_note("note",photo.getNoteObj(),indent+1)
|
||||
self.g.write('%s</objref>\n' % sp)
|
||||
|
||||
def write_url_list(self,list):
|
||||
@ -701,7 +715,7 @@ class XmlWriter:
|
||||
self.write_photo_list(place.getPhotoList())
|
||||
self.write_url_list(place.getUrlList())
|
||||
if note != "":
|
||||
self.write_note("note",note,3)
|
||||
self.write_note("note",place.getNoteObj(),3)
|
||||
for s in place.getSourceRefList():
|
||||
self.dump_source_ref(s,3)
|
||||
self.g.write(" </placeobj>\n")
|
||||
@ -728,7 +742,7 @@ class XmlWriter:
|
||||
self.g.write('>\n')
|
||||
self.write_attribute_list(alist)
|
||||
if note != "":
|
||||
self.write_note("note",note,3)
|
||||
self.write_note("note",object.getNoteObj(),3)
|
||||
for s in slist:
|
||||
self.dump_source_ref(s,3)
|
||||
self.g.write(" </object>\n")
|
||||
|
@ -976,3 +976,8 @@ InverseNameTypesMap = {
|
||||
}
|
||||
|
||||
logical_functions = ['or', 'and', 'xor', 'one']
|
||||
|
||||
notes_formats = [
|
||||
_("Flowed"),
|
||||
_("Preformatted"),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user