view bin/url @ 10304:7d14a8891360

<oerjan> sled bin/slashlearn//2s,\'.*\',\'Usage: `le/[/]rn <key>//<wisdom>\',
author HackBot
date Fri, 17 Feb 2017 02:40:08 +0000
parents 7c07682dcc25
children a145f334de50
line wrap: on
line source

#!/usr/bin/env python
import sys, os.path, re, urllib
if len(sys.argv) <= 1:
    print "http://codu.org/projects/hackbot/fshg/"
else:
    f = os.path.abspath(sys.argv[1])
    f = re.sub(r"^/+hackenv/", "", f)
    if re.match(r"/|\.hg(?:/|$)",f):
        sys.exit("File is outside web-viewable filesystem repository.")
    elif re.match(r"tmp(?:/|$)",f):
        print ("http://www2.codu.org/projects/hackbot/" + urllib.quote(f))
    else:
        print ("http://codu.org/projects/hackbot/fshg/index.cgi/file/tip/" +
            urllib.quote(f))