Difference between revisions of "User:CommanderC/changelog-fix.py"

From CrawlWiki
Jump to: navigation, search
(Created page with "<pre> <nowiki> #!/usr/bin/python # cat dcss-changelog.txt | changelog-fix.py > wiki-changelog.txt import sys import re if __name__ == '__main__': data = sys.stdin.read() ...")
 
(No difference)

Latest revision as of 17:10, 19 July 2014


#!/usr/bin/python
# cat dcss-changelog.txt | changelog-fix.py > wiki-changelog.txt
import sys
import re
if __name__ == '__main__':
    data = sys.stdin.read()
    while True:
        m = re.search(r'^( +)-', data, flags=re.M)
        if not m:
            break
        data = data[:m.start()] + '*'*(len(m.group(1))//2) + '*' + data[m.end():]
    data = re.sub(r'\n +', r' ', data, flags=re.M)
        
    print(data, end='')