http://www.mediawiki.org/wiki/Special:Code/pywikipedia/10026
Revision: 10026
Author: valhallasw
Date: 2012-03-18 17:26:49 +0000 (Sun, 18 Mar 2012)
Log Message:
-----------
Applies r10024 to the rewrite
Modified Paths:
--------------
branches/rewrite/pywikibot/textlib.py
Modified: branches/rewrite/pywikibot/textlib.py
===================================================================
--- branches/rewrite/pywikibot/textlib.py 2012-03-18 17:23:48 UTC (rev 10025)
+++ branches/rewrite/pywikibot/textlib.py 2012-03-18 17:26:49 UTC (rev 10026)
@@ -934,3 +934,14 @@
text += u'|%s=%s\n' % (item, params[item])
return u'{{%s\n%s}}' % (template, text)
+
+#----------------------------------
+# Page parsing functionality
+#----------------------------------
+
+def does_text_contain_section(pagetext, section):
+ """ Determines whether the page text contains the given
+ section title.
+ """
+ m = re.search("=+[ ']*%s[ ']*=+" % re.escape(section), pagetext)
+ return bool(m)