From af44323930490bae9e66419632fb2a73ef02c0ce Mon Sep 17 00:00:00 2001 From: Jonathan Golder Date: Mon, 10 Apr 2017 20:40:39 +0200 Subject: [PATCH] Cut Titel and Interpret on first linebreak For some asian countries there is the original name following after a linebreak. This is not needed in overview, so cat it of. Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=118 FS#118] --- countrylist.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/countrylist.py b/countrylist.py index 574609e..737c2fa 100644 --- a/countrylist.py +++ b/countrylist.py @@ -284,6 +284,9 @@ missing!" ) if self.entry.has( "Titel" ): self._titel_raw = self.entry.get("Titel").value + # Only use part before possible ") and everything after them in given wikicode + """ + # Catch wrong typed param + if not isinstance(wikicode, mwparser.wikicode.Wikicode): + raise TypeError(str(type(self)) + "._remove_lines() expects " + + "parameter 'wikicode' of type " + + "'mwparserfromhell.wikicode.Wikicode', " + + str(type(wikicode)) + " was given!") + + # Find first linebreak + br = next(wikicode.ifilter_tags(matches="br"), None) + + # If there is one, get its position and slice nodes-list + if br: + brpos = wikicode.nodes.index(br) + wikicode.nodes = wikicode.nodes[0:brpos] + def __str__( self ): """ Returns str repression for Object