Mercurial > repo
comparison bin/url @ 10315:a145f334de50
<fizzie> sled bin/url//s,www2.codu.org/projects/hackbot,hackego.esolangs.org,;s,codu.org/projects/hackbot,hackego.esolangs.org,
author | HackBot |
---|---|
date | Sat, 18 Feb 2017 18:59:30 +0000 |
parents | 7c07682dcc25 |
children | 31fc0eb7ea45 |
comparison
equal
deleted
inserted
replaced
10314:d459aeaa2e74 | 10315:a145f334de50 |
---|---|
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 import sys, os.path, re, urllib | 2 import sys, os.path, re, urllib |
3 if len(sys.argv) <= 1: | 3 if len(sys.argv) <= 1: |
4 print "http://codu.org/projects/hackbot/fshg/" | 4 print "http://hackego.esolangs.org/fshg/" |
5 else: | 5 else: |
6 f = os.path.abspath(sys.argv[1]) | 6 f = os.path.abspath(sys.argv[1]) |
7 f = re.sub(r"^/+hackenv/", "", f) | 7 f = re.sub(r"^/+hackenv/", "", f) |
8 if re.match(r"/|\.hg(?:/|$)",f): | 8 if re.match(r"/|\.hg(?:/|$)",f): |
9 sys.exit("File is outside web-viewable filesystem repository.") | 9 sys.exit("File is outside web-viewable filesystem repository.") |
10 elif re.match(r"tmp(?:/|$)",f): | 10 elif re.match(r"tmp(?:/|$)",f): |
11 print ("http://www2.codu.org/projects/hackbot/" + urllib.quote(f)) | 11 print ("http://hackego.esolangs.org/" + urllib.quote(f)) |
12 else: | 12 else: |
13 print ("http://codu.org/projects/hackbot/fshg/index.cgi/file/tip/" + | 13 print ("http://hackego.esolangs.org/fshg/index.cgi/file/tip/" + |
14 urllib.quote(f)) | 14 urllib.quote(f)) |