File: fix_internal_links.py

package info (click to toggle)
emcee 3.1.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,460 kB
  • sloc: python: 2,496; makefile: 146; sh: 20
file content (23 lines) | stat: -rw-r--r-- 408 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import re
import sys

if len(sys.argv) <= 1:
    sys.exit(0)


def subber(m):
    return m.group(0).replace("``", "`")


prog = re.compile(r":(.+):``(.+)``")

for fn in sys.argv[1:]:
    print("Fixing links in {0}".format(fn))
    with open(fn, "r") as f:
        txt = f.read()
    txt = prog.sub(subber, txt)
    with open(fn, "w") as f:
        f.write(txt)