citation_bot/fix_blockquote.py

20 lines
524 B
Python
Raw Normal View History

2022-07-14 15:33:11 +02:00
import re, os
regex = r"(?<=(?<=>).)( \[\[CiteRef::atlasofsurveillance2022\]\]<\/blockquote>\n\n<blockquote>)"
files = [f for f in os.listdir('.') if os.path.isfile(f) and f.endswith('.mw')]
for f in files:
with open(f, 'r') as fp:
contents = fp.read()
# You can manually specify the number of replacements by changing the 4th argument
result = re.sub(regex, "", contents, 0, re.MULTILINE)
if contents != result:
print (f)
with open(f, 'w') as fp:
fp.write(result)