User:Benc/Scripts/section reverser.py

From Wikipedia, the free encyclopedia
Revision as of 08:46, 19 August 2004 by imported>Benc
(diff) ← Previous revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
# section_reverser.py
# Author: Benc
# Purpose: quick hack to reverse a long list of sections.
#          DOES NOT WORK IF THERE ARE SUBSECTIONS!

# Below: cut and paste the page source that you want reversed.
txt="""

"""

# Remove leading and trailing whitespace; change to array by '=='
txt = string.strip(txt).split('==')

heading = None
result = []
for cur in txt:
	if heading == None:
		heading = cur
	else:
		result.append('==' + heading + '==' + cur)
		heading = None

result.reverse()
#result = result[:10] # uncomment this line if you only first 10

for section in result:
	print section,



  ←back to main page    talk