diff --git a/ChangeLog b/ChangeLog index 69942f0cd..49f1b097b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,18 @@ +2006-07-27 Alex Roitman + * src/GrampsDb/_GrampsBSDDB.py (_load_metadata): Upgrade custom + name formats. + * src/GrampsDb/_ReadXML.py (start_format): Attempt parsing the + active state for the custom name format. + * src/GrampsDb/_WriteXML.py (write_name_formats): Write 4-tuple + custom name formats; + (_xml_version): Output as version 1.1.1. + * data/grampsxml.rng: Update XML description for 1.1.1. + * data/grampsxml.dtd: Update XML description for 1.1.1. + * src/ViewManager.py (post_load_newdb): Revert changes (done on + the lower level). + * src/NameDisplay.py (register_custom_formats): Revert changes (done on + the lower level). + 2006-07-27 Zsolt Foldvari * src/ViewManager.py (post_load_newdb): Upgrade path for different grdb custom name format table versions diff --git a/data/grampsxml.dtd b/data/grampsxml.dtd index bf4f11e80..113846a27 100644 --- a/data/grampsxml.dtd +++ b/data/grampsxml.dtd @@ -24,15 +24,15 @@ --> @@ -51,9 +51,9 @@ DATABASE bookmarks --> - - + + + + + + + diff --git a/data/grampsxml.rng b/data/grampsxml.rng index 640c654c0..33bf497be 100644 --- a/data/grampsxml.rng +++ b/data/grampsxml.rng @@ -31,7 +31,7 @@ @@ -98,6 +98,11 @@ + + + + + @@ -431,6 +436,16 @@ + + + + + + 0 + 1 + + + 0 diff --git a/src/GrampsDb/_GrampsBSDDB.py b/src/GrampsDb/_GrampsBSDDB.py index b1f9c8b24..b2d7658de 100644 --- a/src/GrampsDb/_GrampsBSDDB.py +++ b/src/GrampsDb/_GrampsBSDDB.py @@ -384,6 +384,12 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback): def _load_metadata(self): # name display formats self.name_formats = self.metadata.get('name_formats',[]) + # upgrade formats if they were saved in the old way + for format_ix in range(len(self.name_formats)): + format = self.name_formats[format_ix] + if len(format) == 3: + format = format + (True,) + self.name_formats[format_ix] = format # bookmarks self.bookmarks = self.metadata.get('bookmarks',[]) self.family_bookmarks = self.metadata.get('family_bookmarks',[]) diff --git a/src/GrampsDb/_ReadXML.py b/src/GrampsDb/_ReadXML.py index dfbb5d8d7..452c70ce5 100644 --- a/src/GrampsDb/_ReadXML.py +++ b/src/GrampsDb/_ReadXML.py @@ -844,7 +844,8 @@ class GrampsParser(UpdateCallback): number = int(attrs['number']) name = attrs['name'] fmt_str = attrs['fmt_str'] - self.db.name_formats.append((number,name,fmt_str)) + active = bool(attrs.get('active',True)) + self.db.name_formats.append((number,name,fmt_str,active)) def start_person(self,attrs): self.update(self.p.CurrentLineNumber) diff --git a/src/GrampsDb/_WriteXML.py b/src/GrampsDb/_WriteXML.py index b9e095cca..860e4e5c7 100644 --- a/src/GrampsDb/_WriteXML.py +++ b/src/GrampsDb/_WriteXML.py @@ -70,7 +70,7 @@ except: _gzip_ok = 0 -_xml_version = "1.1.0" +_xml_version = "1.1.1" #------------------------------------------------------------------------- # @@ -356,9 +356,10 @@ class XmlWriter(UpdateCallback): def write_name_formats(self): if len(self.db.name_formats) > 0: self.g.write(" \n") - for number,name,fmt_str in self.db.name_formats: - self.g.write('%s\n' - % (' ',number,name,fmt_str) ) + for number,name,fmt_str,active in self.db.name_formats: + self.g.write('%s\n' + % (' ',number,name,fmt_str,int(active)) ) self.g.write(" \n") def fix(self,line): diff --git a/src/NameDisplay.py b/src/NameDisplay.py index 1f54850cd..6142fb0d0 100644 --- a/src/NameDisplay.py +++ b/src/NameDisplay.py @@ -119,19 +119,8 @@ class NameDisplay: self.raw_fn_array[0] = self.raw_fn_array[idx] def register_custom_formats(self,formats): - # magic is needed due to different name format table structure - # in different revisions: - # r <= 7082: (number, name, format_string) - # r >= 7083: (number, name, format_string, active) - self.CUSTOM_FORMATS = [] - changed = False - for format in formats: - if len(format) == 3: - format = format + (1,) - changed = True - self.CUSTOM_FORMATS.append(format) + self.CUSTOM_FORMATS = formats[:] self.set_format_fn() - return changed def update_custom_formats(self,num,name,str,act): i = 0 diff --git a/src/ViewManager.py b/src/ViewManager.py index 7dcb0196d..2b5976609 100644 --- a/src/ViewManager.py +++ b/src/ViewManager.py @@ -768,9 +768,7 @@ class ViewManager: self.state.db.set_researcher(owner) self.setup_bookmarks() - - if NameDisplay.displayer.register_custom_formats(self.state.db.name_formats): - self.state.db.name_formats = NameDisplay.displayer.CUSTOM_FORMATS + NameDisplay.displayer.register_custom_formats(self.state.db.name_formats) fmt_default = Config.get(Config.NAME_FORMAT) if fmt_default < 0: NameDisplay.displayer.set_format_default(fmt_default)