You are not logged in Log in Join
You are here: Home » Members » mcdonc » Scripts » C:\cygwin\home\chrism\ZWN\linkmaker.py

Log in
Name

Password

 

C:\cygwin\home\chrism\ZWN\linkmaker.py

File details
Size
1 K
File type
text/plain

File contents

from string import letters
import re, sys

url_expr=re.compile(r'((http|https|ftp|mailto|file|about)[:/]+?[%s0-9_\@\.\,\?\!\/\:\;\-\#\~\=\&\%%]+)' % letters)

def makelinks(file):
    while 1:
        line = file.readline()
        if not line: break
        line = url_expr.sub(r'"\1":\1', line)
        sys.stdout.write(line)
            
if __name__ == '__main__':
    f = open(sys.argv[1])
    makelinks(f)