User:Benc/Scripts/section reverser.py

From Wikipedia, the free encyclopedia
# 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