diff --git a/src/Filters/_FilterParser.py b/src/Filters/_FilterParser.py index 146e99d2e..98e1f9e3d 100644 --- a/src/Filters/_FilterParser.py +++ b/src/Filters/_FilterParser.py @@ -108,6 +108,8 @@ class FilterParser(handler.ContentHandler): def endElement(self, tag): 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): print _("WARNING: Too many arguments in filter '%s'!\n"\ "Trying to load with subset of arguments.") %\ @@ -134,6 +136,20 @@ class FilterParser(handler.ContentHandler): def characters(self, data): 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 diff --git a/src/const.py.in b/src/const.py.in index 4505fa95e..e87dfbdd8 100644 --- a/src/const.py.in +++ b/src/const.py.in @@ -145,7 +145,7 @@ IMAGE_DIR = os.path.join(ROOT_DIR, "images") VERSION_DIR = os.path.join( 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") TOOL_OPTIONS = os.path.join(HOME_DIR, "tool_options.xml")