Revision: 5207
Author: nicdumz
Date: 2008-04-12 10:44:10 +0000 (Sat, 12 Apr 2008)
Log Message:
-----------
Applying my patch 1898557, better indenting for noreferences.py
Modified Paths:
--------------
trunk/pywikipedia/noreferences.py
Modified: trunk/pywikipedia/noreferences.py
===================================================================
--- trunk/pywikipedia/noreferences.py 2008-04-12 10:39:08 UTC (rev 5206)
+++ trunk/pywikipedia/noreferences.py 2008-04-12 10:44:10 UTC (rev 5207)
@@ -254,7 +254,7 @@
# Create a new section for the references tag
for section in wikipedia.translate(page.site(), placeBeforeSections):
# Find out where to place the new section
- sectionR = re.compile(r'\r\n=+ *%s *=+\r\n' % section)
+ sectionR = re.compile(r'\r\n(?P<ident>=+) *%s *=+\r\n' %
section)
index = 0
while index < len(oldText):
match = sectionR.search(oldText, index)
@@ -265,7 +265,8 @@
else:
wikipedia.output(u'Adding references section before %s
section...\n' % section)
index = match.start()
- self.createReferenceSection(page, index)
+ ident = match.group('ident')
+ self.createReferenceSection(page, index, ident)
return
else:
break
@@ -296,9 +297,9 @@
index = len(tmpText)
self.createReferenceSection(page, index)
- def createReferenceSection(self, page, index):
+ def createReferenceSection(self, page, index, ident = '=='):
oldText = page.get()
- newSection = u'\n== %s ==\n\n<references/>\n' %
wikipedia.translate(page.site(), referencesSections)[0]
+ newSection = u'\n%s %s %s\n\n<references/>\n' % (ident,
wikipedia.translate(page.site(), referencesSections)[0], ident)
newText = oldText[:index] + newSection + oldText[index:]
self.save(page, newText)
Show replies by date