From 3723aba5781d0647cb21bdc0c89e64736614b6fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Fri, 26 Aug 2016 19:17:16 +0200 Subject: [PATCH] Add a method to get link to related reddisc To generate notices or other stuff it is necessary to add links to the related reddisc. This method returns a wikilink to text the redfam's reddisc. Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=81 FS#81] Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=81 FS#81] --- lib/redfam.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/redfam.py b/lib/redfam.py index 37162c4..4da1ea4 100644 --- a/lib/redfam.py +++ b/lib/redfam.py @@ -462,6 +462,31 @@ class RedFamWorker( RedFam ): self._status = 3 + def get_disc_link( self ): + """ + Constructs and returns the link to Redundancy discussion + + @returns Link to diskussion + @rtype str + """ + + # We need to Replace Links with their linktext + anchor_code = mwparser.parse( self._mysql.data[ 'heading' ].strip() ) + for link in anchor_code.ifilter_wikilinks(): + if link.text: + text = link.text + else: + text = link.title + + anchor_code.replace( link, text ) + + # Whitespace is replaced with underscores + anchor_code.replace( " ", "_" ) + + # We try it with out any more parsing as mw will do while parsing page + return ( self.redpagetitle + "#" + + str(anchor_code).strip() ) + @classmethod def list_by_status( cls, status ): """