From 9b9d50c4d2a37051b815929a44232fb5a0cdf12e Mon Sep 17 00:00:00 2001 From: Jonathan Golder Date: Thu, 24 Aug 2017 12:04:45 +0200 Subject: [PATCH] Improve detection of empty lines Search with RegEx as empty lines could also contain spaces Related Task: [FS#141](https://fs.golderweb.de/index.php?do=details&task_id=141) --- bots/markpages.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bots/markpages.py b/bots/markpages.py index 4e12620..81891c7 100644 --- a/bots/markpages.py +++ b/bots/markpages.py @@ -26,6 +26,7 @@ Bot to mark pages which were/are subjects of redundance discussions with templates """ +import re from datetime import datetime import pywikibot @@ -226,8 +227,8 @@ class MarkPagesBot( CurrentPageBot ): # sets 'current_page' on each treat() # Filter one linebreak if isinstance( self.current_wikicode.get( insert_after_index + 1), mwparser.nodes.text.Text ) and \ - self.current_wikicode.get( - insert_after_index + 1 ).value is "\n": + re.search( r"^\n\s+$", self.current_wikicode.get( + insert_after_index + 1 ).value ): insert_after_index += 1