2006-07-27 Alex Roitman <shura@gramps-project.org>
* 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). svn: r7085
This commit is contained in:
parent
1d9e6da05a
commit
787fe452e1
15
ChangeLog
15
ChangeLog
@ -1,3 +1,18 @@
|
|||||||
|
2006-07-27 Alex Roitman <shura@gramps-project.org>
|
||||||
|
* 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 <zfoldvar@users.sourceforge.net>
|
2006-07-27 Zsolt Foldvari <zfoldvar@users.sourceforge.net>
|
||||||
* src/ViewManager.py (post_load_newdb): Upgrade path for different
|
* src/ViewManager.py (post_load_newdb): Upgrade path for different
|
||||||
grdb custom name format table versions
|
grdb custom name format table versions
|
||||||
|
@ -24,15 +24,15 @@
|
|||||||
-->
|
-->
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
This is the Document Type Definition file for v1.1.0
|
This is the Document Type Definition file for v1.1.1
|
||||||
of the GRAMPS XML genealogy data format.
|
of the GRAMPS XML genealogy data format.
|
||||||
Please use the following formal public identifier to identify it:
|
Please use the following formal public identifier to identify it:
|
||||||
|
|
||||||
"-//GRAMPS//DTD GRAMPS XML V1.1.0//EN"
|
"-//GRAMPS//DTD GRAMPS XML V1.1.1//EN"
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
<!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.1.0//EN"
|
<!DOCTYPE database PUBLIC "-//GRAMPS//DTD GRAMPS XML V1.1.1//EN"
|
||||||
"http://gramps-project.org/xml/1.1.0/grampsxml.dtd"
|
"http://gramps-project.org/xml/1.1.1/grampsxml.dtd"
|
||||||
[...]>
|
[...]>
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -51,9 +51,9 @@ DATABASE
|
|||||||
bookmarks
|
bookmarks
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!ELEMENT database (header, events?, people?, families?, sources?,
|
<!ELEMENT database (header, events?, people?, families?, sources?, places?,
|
||||||
places?, objects?, repositories?, bookmarks?)>
|
objects?, repositories?, bookmark?, name-formats?)>
|
||||||
<!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.1.0/">
|
<!ATTLIST database xmlns CDATA #FIXED "http://gramps-project.org/xml/1.1.1/">
|
||||||
|
|
||||||
<!-- ************************************************************
|
<!-- ************************************************************
|
||||||
HEADER
|
HEADER
|
||||||
@ -312,6 +312,19 @@ BOOKMARKS
|
|||||||
hlink IDREF #REQUIRED
|
hlink IDREF #REQUIRED
|
||||||
>
|
>
|
||||||
|
|
||||||
|
<!-- ************************************************************
|
||||||
|
NAME FORMATS
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!ELEMENT name-formats (format)*>
|
||||||
|
<!ELEMENT format EMPTY>
|
||||||
|
<!ATTLIST format
|
||||||
|
number CDATA #REQUIRED
|
||||||
|
name CDATA #REQUIRED
|
||||||
|
fmt_str CDATA #REQUIRED
|
||||||
|
active (0|1) #IMPLIED
|
||||||
|
>
|
||||||
|
|
||||||
<!-- ************************************************************
|
<!-- ************************************************************
|
||||||
SHARED ELEMENTS
|
SHARED ELEMENTS
|
||||||
-->
|
-->
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
<grammar
|
<grammar
|
||||||
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
|
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
|
||||||
ns="http://gramps-project.org/xml/1.1.0/"
|
ns="http://gramps-project.org/xml/1.1.1/"
|
||||||
xmlns="http://relaxng.org/ns/structure/1.0">
|
xmlns="http://relaxng.org/ns/structure/1.0">
|
||||||
|
|
||||||
<start><element name="database">
|
<start><element name="database">
|
||||||
@ -98,6 +98,11 @@
|
|||||||
</element></zeroOrMore>
|
</element></zeroOrMore>
|
||||||
</element></optional>
|
</element></optional>
|
||||||
|
|
||||||
|
<optional><element name="name-formats">
|
||||||
|
<zeroOrMore><element name="format">
|
||||||
|
<ref name="format-content"/>
|
||||||
|
</element></zeroOrMore>
|
||||||
|
</element></optional>
|
||||||
</element></start>
|
</element></start>
|
||||||
|
|
||||||
<define name="researcher-content">
|
<define name="researcher-content">
|
||||||
@ -431,6 +436,16 @@
|
|||||||
<attribute name="hlink"><data type="IDREF"/></attribute>
|
<attribute name="hlink"><data type="IDREF"/></attribute>
|
||||||
</define>
|
</define>
|
||||||
|
|
||||||
|
<define name="format-content">
|
||||||
|
<attribute name="number"><text/></attribute>
|
||||||
|
<attribute name="name"><text/></attribute>
|
||||||
|
<attribute name="fmt_str"><text/></attribute>
|
||||||
|
<optional><attribute name="active"><choice>
|
||||||
|
<value>0</value>
|
||||||
|
<value>1</value>
|
||||||
|
</choice></attribute></optional>
|
||||||
|
</define>
|
||||||
|
|
||||||
<define name="note-content">
|
<define name="note-content">
|
||||||
<optional><attribute name="format"><choice>
|
<optional><attribute name="format"><choice>
|
||||||
<value>0</value>
|
<value>0</value>
|
||||||
|
@ -384,6 +384,12 @@ class GrampsBSDDB(GrampsDbBase,UpdateCallback):
|
|||||||
def _load_metadata(self):
|
def _load_metadata(self):
|
||||||
# name display formats
|
# name display formats
|
||||||
self.name_formats = self.metadata.get('name_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
|
# bookmarks
|
||||||
self.bookmarks = self.metadata.get('bookmarks',[])
|
self.bookmarks = self.metadata.get('bookmarks',[])
|
||||||
self.family_bookmarks = self.metadata.get('family_bookmarks',[])
|
self.family_bookmarks = self.metadata.get('family_bookmarks',[])
|
||||||
|
@ -844,7 +844,8 @@ class GrampsParser(UpdateCallback):
|
|||||||
number = int(attrs['number'])
|
number = int(attrs['number'])
|
||||||
name = attrs['name']
|
name = attrs['name']
|
||||||
fmt_str = attrs['fmt_str']
|
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):
|
def start_person(self,attrs):
|
||||||
self.update(self.p.CurrentLineNumber)
|
self.update(self.p.CurrentLineNumber)
|
||||||
|
@ -70,7 +70,7 @@ except:
|
|||||||
_gzip_ok = 0
|
_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):
|
def write_name_formats(self):
|
||||||
if len(self.db.name_formats) > 0:
|
if len(self.db.name_formats) > 0:
|
||||||
self.g.write(" <name-formats>\n")
|
self.g.write(" <name-formats>\n")
|
||||||
for number,name,fmt_str in self.db.name_formats:
|
for number,name,fmt_str,active in self.db.name_formats:
|
||||||
self.g.write('%s<format number="%d" name="%s" fmt_str="%s"/>\n'
|
self.g.write('%s<format number="%d" name="%s" '
|
||||||
% (' ',number,name,fmt_str) )
|
'fmt_str="%s" active="%d"/>\n'
|
||||||
|
% (' ',number,name,fmt_str,int(active)) )
|
||||||
self.g.write(" </name-formats>\n")
|
self.g.write(" </name-formats>\n")
|
||||||
|
|
||||||
def fix(self,line):
|
def fix(self,line):
|
||||||
|
@ -119,19 +119,8 @@ class NameDisplay:
|
|||||||
self.raw_fn_array[0] = self.raw_fn_array[idx]
|
self.raw_fn_array[0] = self.raw_fn_array[idx]
|
||||||
|
|
||||||
def register_custom_formats(self,formats):
|
def register_custom_formats(self,formats):
|
||||||
# magic is needed due to different name format table structure
|
self.CUSTOM_FORMATS = formats[:]
|
||||||
# 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.set_format_fn()
|
self.set_format_fn()
|
||||||
return changed
|
|
||||||
|
|
||||||
def update_custom_formats(self,num,name,str,act):
|
def update_custom_formats(self,num,name,str,act):
|
||||||
i = 0
|
i = 0
|
||||||
|
@ -768,9 +768,7 @@ class ViewManager:
|
|||||||
self.state.db.set_researcher(owner)
|
self.state.db.set_researcher(owner)
|
||||||
|
|
||||||
self.setup_bookmarks()
|
self.setup_bookmarks()
|
||||||
|
NameDisplay.displayer.register_custom_formats(self.state.db.name_formats)
|
||||||
if NameDisplay.displayer.register_custom_formats(self.state.db.name_formats):
|
|
||||||
self.state.db.name_formats = NameDisplay.displayer.CUSTOM_FORMATS
|
|
||||||
fmt_default = Config.get(Config.NAME_FORMAT)
|
fmt_default = Config.get(Config.NAME_FORMAT)
|
||||||
if fmt_default < 0:
|
if fmt_default < 0:
|
||||||
NameDisplay.displayer.set_format_default(fmt_default)
|
NameDisplay.displayer.set_format_default(fmt_default)
|
||||||
|
Loading…
Reference in New Issue
Block a user