# Encoding: UTF-8 """Rewrite markdown links from [Label]{category:thing} to just {category:thing} There was a version of this script that rewrote stuff from an even earlier format. Git log should find it without problems. This is an unmaintained one-shot script, only included in the repo for reference. """ from functools import partial import sys import re from sqlalchemy.orm.exc import MultipleResultsFound from sqlalchemy.sql.expression import func from pokedex.db import connect, tables, util sanity_re = re.compile(ur"^[-A-Za-z0-9 é\[\]{}.%':;,×/()\"|–`—!*♂♀\\]$") # RE that matches anything that might look like a link fuzzy_link_re = re.compile(r""" \[ [^]]+ \]? \{ [^}]+ \}""", re.VERBOSE) # Very specific RE that matches links that appear in source Markdown strings strict_link_re = re.compile(r""" \[ (?P