User:Arzg/Summary transclude

The following Python script can be used to automatically transclude episodes summaries. It was developed for https://en.wikipedia.org/w/index.php?title=List_of_Littlest_Pet_Shop_episodes&amp;diff=817205549&amp;oldid=817184922 in which the article in question (List of Littlest Pet Shop episodes) contained a number of plagiarised summaries. Clean versions were available, but a number of other parts of the page were changed in the mean time; a bulk revert would lose too many good changes. Thus, this script was born.

Put the latest markup in latest.text, the last good markup in clean.txt, and run the script with Python3 in the same directory. It may be necessary to remove / add stub summaries, in case the number has not matched up. If there are episodes to be excluded, change ShortSummary in latest to HhortSummary. I definitely have creative names :)

import re

latest = open(&quot;latest.txt&quot;).read clean = open(&quot;clean.txt&quot;).read

sumgex = &quot;^ | ShortSummary   = (.*)&quot;

clean_summaries = re.findall(sumgex, clean) dirty_summaries = re.findall(sumgex, latest)

for (dirty_summary, clean_summary) in zip(dirty_summaries, clean_summaries): latest = latest.replace(dirty_summary, clean_summary)

print(latest.replace(&quot;Hhort&quot;, &quot;Short&quot;))

If the above script does not work, try the older revision from the page history. If that works but not this one, revert this edit ;)