move quoting hack to wiki loader

The bad quotes around the type for special phrases
specifically occure in the Wiki pages, so it should be
removed by the loader and not in the generic SpecialPhrase
object.
This commit is contained in:
Sarah Hoffmann
2022-05-30 14:32:36 +02:00
parent cce0e5ea38
commit e828d0d3f7
4 changed files with 15 additions and 21 deletions

View File

@@ -37,6 +37,8 @@ class SPWikiLoader:
self.occurence_pattern = re.compile(
r'\| *([^\|]+) *\|\| *([^\|]+) *\|\| *([^\|]+) *\|\| *([^\|]+) *\|\| *([\-YN])'
)
# Hack around a bug where building=yes was imported with quotes into the wiki
self.type_fix_pattern = re.compile(r'\"|"')
self._load_languages()
@@ -52,7 +54,10 @@ class SPWikiLoader:
matches = self.occurence_pattern.findall(loaded_xml)
for match in matches:
yield SpecialPhrase(match[0], match[1], match[2], match[3])
yield SpecialPhrase(match[0],
match[1],
self.type_fix_pattern.sub('', match[2]),
match[3])
def _load_languages(self):

View File

@@ -10,8 +10,6 @@
This class is a model used to transfer a special phrase through
the process of load and importation.
"""
import re
class SpecialPhrase():
"""
Model representing a special phrase.
@@ -20,7 +18,7 @@ class SpecialPhrase():
self.p_label = p_label.strip()
self.p_class = p_class.strip()
# Hack around a bug where building=yes was imported with quotes into the wiki
self.p_type = re.sub(r'\"|"', '', p_type.strip())
self.p_type = p_type.strip()
# Needed if some operator in the wiki are not written in english
p_operator = p_operator.strip().lower()
self.p_operator = '-' if p_operator not in ('near', 'in') else p_operator