Mercurial > repo
annotate bin/url @ 10372:f04f06041b47
<oerjan> ` echo hum>test; echo erm>test2
author | HackBot |
---|---|
date | Tue, 07 Mar 2017 23:22:53 +0000 |
parents | a145f334de50 |
children | 31fc0eb7ea45 |
rev | line source |
---|---|
9075 | 1 #!/usr/bin/env python |
2 import sys, os.path, re, urllib | |
3 if len(sys.argv) <= 1: | |
10315
a145f334de50
<fizzie> sled bin/url//s,www2.codu.org/projects/hackbot,hackego.esolangs.org,;s,codu.org/projects/hackbot,hackego.esolangs.org,
HackBot
parents:
10283
diff
changeset
|
4 print "http://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): |
10315
a145f334de50
<fizzie> sled bin/url//s,www2.codu.org/projects/hackbot,hackego.esolangs.org,;s,codu.org/projects/hackbot,hackego.esolangs.org,
HackBot
parents:
10283
diff
changeset
|
11 print ("http://hackego.esolangs.org/" + urllib.quote(f)) |
9075 | 12 else: |
10315
a145f334de50
<fizzie> sled bin/url//s,www2.codu.org/projects/hackbot,hackego.esolangs.org,;s,codu.org/projects/hackbot,hackego.esolangs.org,
HackBot
parents:
10283
diff
changeset
|
13 print ("http://hackego.esolangs.org/fshg/index.cgi/file/tip/" + |
9075 | 14 urllib.quote(f)) |