9075
|
1 #!/usr/bin/env python
|
|
2 import sys, os.path, re, urllib
|
|
3 if len(sys.argv) <= 1:
|
10391
|
4 print "https://hackego.esolangs.org/fshg/"
|
9075
|
5 else:
|
|
6 f = os.path.abspath(sys.argv[1])
|
|
7 f = re.sub(r"^/+hackenv/", "", f)
|
10283
|
8 if re.match(r"/|\.hg(?:/|$)",f):
|
9075
|
9 sys.exit("File is outside web-viewable filesystem repository.")
|
10281
|
10 elif re.match(r"tmp(?:/|$)",f):
|
10391
|
11 print ("https://hackego.esolangs.org/" + urllib.quote(f))
|
9075
|
12 else:
|
10391
|
13 print ("https://hackego.esolangs.org/fshg/index.cgi/file/tip/" +
|
9075
|
14 urllib.quote(f))
|