From 18d221a7e7c25a024e07c1859f0364e2632fa487 Mon Sep 17 00:00:00 2001 From: Don Allingham Date: Mon, 8 Oct 2001 03:10:06 +0000 Subject: [PATCH] Improved ANSEL support svn: r452 --- gramps/src/GrampsParser.py | 8 ++++--- gramps/src/RelLib.py | 3 ++- gramps/src/WriteXML.py | 37 ++++++++++++++++++------------- gramps/src/latin_ansel.py | 7 +++--- gramps/src/plugins/ReadGedcom.py | 4 ---- gramps/src/plugins/WriteGedcom.py | 2 +- 6 files changed, 33 insertions(+), 28 deletions(-) diff --git a/gramps/src/GrampsParser.py b/gramps/src/GrampsParser.py index 497341485..ca2a0b08d 100644 --- a/gramps/src/GrampsParser.py +++ b/gramps/src/GrampsParser.py @@ -416,7 +416,9 @@ class GrampsParser(handler.ContentHandler): else: self.source_ref.confidence = self.conf self.source_ref.setBase(source) - if self.event: + if self.photo: + self.photo.addSourceRef(self.source_ref) + elif self.event: self.event.addSourceRef(self.source_ref) elif self.address: self.address.addSourceRef(self.source_ref) @@ -426,8 +428,6 @@ class GrampsParser(handler.ContentHandler): self.attribute.addSourceRef(self.source_ref) elif self.placeobj: self.placeobj.addSourceRef(self.source_ref) - else: - print "Sorry, I'm lost" #--------------------------------------------------------------------- # @@ -808,6 +808,8 @@ class GrampsParser(handler.ContentHandler): if self.address: self.address.setNote(note) + elif self.photo: + self.photo.setNote(note) elif self.attribute: self.attribute.setNote(note) elif self.name: diff --git a/gramps/src/RelLib.py b/gramps/src/RelLib.py index b4da08d6e..c49d8a30b 100644 --- a/gramps/src/RelLib.py +++ b/gramps/src/RelLib.py @@ -336,12 +336,13 @@ class Note: """return the note contents""" return self.text -class Photo: +class Photo(SourceNote): """Containter for information about an image file, including location, description and privacy""" def __init__(self,source=None): """Create a new Photo object, copying from the source if provided""" + SourceNote.__init__(self,source) self.attrlist = [] if source: self.path = source.path diff --git a/gramps/src/WriteXML.py b/gramps/src/WriteXML.py index 60965b9e6..a9f68b6ff 100644 --- a/gramps/src/WriteXML.py +++ b/gramps/src/WriteXML.py @@ -64,7 +64,7 @@ def fix(line): # # #------------------------------------------------------------------------- -def writeNote(g,val,note,indent=0): +def write_note(g,val,note,indent=0): if not note: return if indent != 0: @@ -118,7 +118,7 @@ def dump_my_event(g,name,event,index=1): write_line(g,"cause",cause,index+1) write_line(g,"description",description,index+1) if event.getNote() != "": - writeNote(g,"note",event.getNote(),index+1) + write_note(g,"note",event.getNote(),index+1) for s in event.getSourceRefList(): dump_source_ref(g,s,index+1) @@ -146,8 +146,8 @@ def dump_source_ref(g,source_ref,index=1): else: g.write('\n' % (source.getId(),q)) write_line(g,"spage",p,index+1) - writeNote(g,"scomments",c,index+1) - writeNote(g,"stext",t,index+1) + write_note(g,"scomments",c,index+1) + write_note(g,"stext",t,index+1) write_line(g,"sdate",d,index+1) g.write("%s\n" % (" " * index)) @@ -214,7 +214,7 @@ def dump_name(g,label,name,index=1): write_line(g,"suffix",name.getSuffix(),index+1) write_line(g,"title",name.getTitle(),index+1) if name.getNote() != "": - writeNote(g,"note",name.getNote(),index+1) + write_note(g,"note",name.getNote(),index+1) for s in name.getSourceRefList(): dump_source_ref(g,s,index+1) @@ -277,7 +277,7 @@ def write_attribute_list(g, list, indent=3): write_line(g,"attr_value",attr.getValue(),4) for s in attr.getSourceRefList(): dump_source_ref(g,s,index+1) - writeNote(g,"note",attr.getNote(),4) + write_note(g,"note",attr.getNote(),4) g.write('%s\n' % sp) else: g.write('%s' % (sp,attr.getType())) @@ -285,7 +285,8 @@ def write_attribute_list(g, list, indent=3): g.write('\n') -def write_photo_list(g,list): +def write_photo_list(g,list,indent=3): + sp = ' '*indent for photo in list: path = photo.getPath() if strip_photo: @@ -295,15 +296,19 @@ def write_photo_list(g,list): if len(path) >= l: if fileroot == path[0:l]: path = path[l+1:] - g.write(' \n") else: g.write(">\n") - write_attribute_list(g,proplist,4) - g.write(' \n') + write_attribute_list(g,proplist,indent+1) + write_note(g,"note",photo.getNote(),indent+1) + for s in photo.getSourceRefList(): + dump_source_ref(g,s,indent+1) + g.write('%s\n' % sp) def write_url_list(g, list): @@ -332,7 +337,7 @@ def write_place_obj(g,place): write_photo_list(g,place.getPhotoList()) write_url_list(g, place.getUrlList()) if place.getNote() != "": - writeNote(g,"note",place.getNote(),3) + write_note(g,"note",place.getNote(),3) for s in place.getSourceRefList(): dump_source_ref(g,s,index+1) g.write(" \n") @@ -448,7 +453,7 @@ def write_xml_data(database, g, callback, sp): write_line(g,"country",address.getCountry(),4) write_line(g,"postal",address.getPostal(),4) if address.getNote() != "": - writeNote(g,"note",address.getNote(),4) + write_note(g,"note",address.getNote(),4) for s in address.getSourceRefList(): dump_source_ref(g,s,index+1) g.write(' \n') @@ -472,7 +477,7 @@ def write_xml_data(database, g, callback, sp): for family in person.getFamilyList(): write_ref(g,"parentin",family,3) - writeNote(g,"note",person.getNote(),3) + write_note(g,"note",person.getNote(),3) g.write(" \n") g.write(" \n") @@ -501,7 +506,7 @@ def write_xml_data(database, g, callback, sp): for person in family.getChildList(): write_ref(g,"child",person,3) write_attribute_list(g,family.getAttributeList()) - writeNote(g,"note",family.getNote(),3) + write_note(g,"note",family.getNote(),3) g.write(" \n") g.write(" \n") @@ -514,7 +519,7 @@ def write_xml_data(database, g, callback, sp): write_line(g,"spubinfo",source.getPubInfo(),3) write_line(g,"scallno",source.getCallNumber(),3) if source.getNote() != "": - writeNote(g,"note",source.getNote(),3) + write_note(g,"note",source.getNote(),3) write_photo_list(g,source.getPhotoList()) g.write(" \n") g.write(" \n") diff --git a/gramps/src/latin_ansel.py b/gramps/src/latin_ansel.py index 414f449bd..12fec2670 100644 --- a/gramps/src/latin_ansel.py +++ b/gramps/src/latin_ansel.py @@ -1,4 +1,4 @@ -# + # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2000 Donald N. Allingham @@ -63,12 +63,13 @@ _t1 = { } _s0 = { - 0xCF : 0xDF, 0xA4 : 0xDE, 0xB4 : 0xFE, 0xA2 : 0xD8, + 0xCF : 0xDF, 0xA4 : 0xDE, 0xB4 : 0xFE, 0xA2 : 0xD8, 0xC0 : 0xB0, 0xB3 : 0xF8, 0xA5 : 0xC6, 0xB5 : 0xE6, 0xBA : 0xF0 } _t0 = { 0xDF : chr(0xCF), 0xDE : chr(0xA4), 0xFE : chr(0xB4), 0xD8 : chr(0xA2), - 0xF8 : chr(0xB3), 0xC6 : chr(0xA5), 0xE6 : chr(0xB5), 0xBA : chr(0xF0) } + 0xF8 : chr(0xB3), 0xC6 : chr(0xA5), 0xE6 : chr(0xB5), 0xBA : chr(0xF0), + 0xB0 : chr(0xC0) } #------------------------------------------------------------------------- # diff --git a/gramps/src/plugins/ReadGedcom.py b/gramps/src/plugins/ReadGedcom.py index 90e8986b8..435432377 100644 --- a/gramps/src/plugins/ReadGedcom.py +++ b/gramps/src/plugins/ReadGedcom.py @@ -134,11 +134,7 @@ def importData(database, filename): GnomeErrorDialog(_("%s could not be opened\n") % filename) return - import time - t1 = time.time() g.parse_gedcom_file() - t2 = time.time() - print t2-t1 statusTop.get_widget("close").set_sensitive(1) diff --git a/gramps/src/plugins/WriteGedcom.py b/gramps/src/plugins/WriteGedcom.py index 3575efa55..a169d282e 100644 --- a/gramps/src/plugins/WriteGedcom.py +++ b/gramps/src/plugins/WriteGedcom.py @@ -525,7 +525,7 @@ def exportData(database, filename, pbar, fbar, sbar): if cnvtxt == latin_to_ansel: g.write("1 CHAR ANSEL\n"); else: - g.write("1 CHAR UNICODE\n"); + g.write("1 CHAR UTF-8\n"); g.write("1 SUBM @SUBM@\n") g.write("1 FILE %s\n" % filename) g.write("1 GEDC\n")