Browse Source

SortKeyName should be used for Interpret not for Title

develop
Jonathan Golder 6 years ago
parent
commit
038dd6e36a
1 changed files with 39 additions and 14 deletions
  1. +39
    -14
      countrylist.py

+ 39
- 14
countrylist.py View File

@ -278,20 +278,6 @@ missing!" )
for ref in self._titel_raw.ifilter_tags(matches="ref"):
self._titel_raw.remove( ref )
# Handle SortKeyName and SortKey
for template in self._titel_raw.ifilter_templates(
matches="SortKey" ):
if template.name == "SortKeyName":
titel = "[[" + template.get(1) + " " + template.get(2)
if template.has(3):
titel += "|" + template.get(3)
titel += "]]"
self._title_raw.replace( template, titel )
else:
if template.has(2):
self._title_raw.replace( template, template.get(2) )
# Remove whitespace
self._titel_raw = str(self._titel_raw).strip()
else:
@ -364,6 +350,45 @@ missing!" )
for ref in self._interpret_raw.ifilter_tags(matches="ref"):
self._interpret_raw.remove( ref )
# Handle SortKeyName and SortKey
for template in self._interpret_raw.ifilter_templates(
matches="SortKey" ):
if template.name == "SortKeyName":
# Differing Link-Destination is provided as param 3
if template.has(3):
# Construct link out of Template, Params:
# 1 = Surname
# 2 = Name
# 3 = Link-Dest
interpret_link = mwparser.nodes.wikilink.Wikilink(
str(template.get(3).value),
str(template.get(1).value) + " " +
str(template.get(2).value) )
# Default Link-Dest [[Surname Name]]
else:
interpret_link = mwparser.nodes.wikilink.Wikilink(
str(template.get(1).value) + " " +
str(template.get(2).value) )
# Replace Template with link
self._interpret_raw.replace( template, interpret_link )
# SortKey
else:
# Replace SortKey with text from param 2 if present
if template.has(2):
self._interpret_raw.replace( template,
template.get(2).value)
# Else Remove SortKey (text should follow behind SortKey)
else:
self._interpret_raw.replace( template, None)
# Normally won't be needed as there should be only one
# SortKey-Temlate but ... its a wiki
break
# Remove whitespace
self._interpret_raw = str(self._interpret_raw).strip()
else:


Loading…
Cancel
Save