5012: Move custom rule configuration file into the version directory and provide upgrade from previous version
svn: r18114
This commit is contained in:
parent
b6f9bb0b73
commit
368d2432d5
@ -108,6 +108,8 @@ class FilterParser(handler.ContentHandler):
|
|||||||
|
|
||||||
def endElement(self, tag):
|
def endElement(self, tag):
|
||||||
if tag == "rule" and self.r is not None:
|
if tag == "rule" and self.r is not None:
|
||||||
|
if len(self.r.labels) != len(self.a):
|
||||||
|
self.__upgrade()
|
||||||
if len(self.r.labels) < len(self.a):
|
if len(self.r.labels) < len(self.a):
|
||||||
print _("WARNING: Too many arguments in filter '%s'!\n"\
|
print _("WARNING: Too many arguments in filter '%s'!\n"\
|
||||||
"Trying to load with subset of arguments.") %\
|
"Trying to load with subset of arguments.") %\
|
||||||
@ -134,6 +136,20 @@ class FilterParser(handler.ContentHandler):
|
|||||||
def characters(self, data):
|
def characters(self, data):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def __upgrade(self):
|
||||||
|
"""
|
||||||
|
Upgrade argument lists to latest version.
|
||||||
|
"""
|
||||||
|
# HasPlace rule has extra locality field in v3.3
|
||||||
|
if self.r == Rules.Place.HasPlace and len(self.a) == 8:
|
||||||
|
self.a = self.a[0:2] + [u''] + self.a[4:8] + [self.a[3]] + \
|
||||||
|
[self.a[2]]
|
||||||
|
# HasNameOf rule has new fields for surnames in v3.3
|
||||||
|
if self.r == Rules.Person.HasNameOf and len(self.a) == 7:
|
||||||
|
self.a = self.a[0:2] + [self.a[3]] + [self.a[2]] + [self.a[6]] + \
|
||||||
|
[u''] + [self.a[4]] + [u'', u''] + [self.a[5]] + \
|
||||||
|
[u'', u'0']
|
||||||
|
|
||||||
#-------------------------------------------------------------------------
|
#-------------------------------------------------------------------------
|
||||||
#
|
#
|
||||||
# Name to class mappings
|
# Name to class mappings
|
||||||
|
@ -145,7 +145,7 @@ IMAGE_DIR = os.path.join(ROOT_DIR, "images")
|
|||||||
VERSION_DIR = os.path.join(
|
VERSION_DIR = os.path.join(
|
||||||
HOME_DIR, "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1]))
|
HOME_DIR, "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1]))
|
||||||
|
|
||||||
CUSTOM_FILTERS = os.path.join(HOME_DIR, "custom_filters.xml")
|
CUSTOM_FILTERS = os.path.join(VERSION_DIR, "custom_filters.xml")
|
||||||
REPORT_OPTIONS = os.path.join(HOME_DIR, "report_options.xml")
|
REPORT_OPTIONS = os.path.join(HOME_DIR, "report_options.xml")
|
||||||
TOOL_OPTIONS = os.path.join(HOME_DIR, "tool_options.xml")
|
TOOL_OPTIONS = os.path.join(HOME_DIR, "tool_options.xml")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user