Mercurial > repo
annotate bin/url @ 11467:380e297c7ae5 draft
<fizzie> sled bin/url//s,hackego.esolangs.org/fshg,hack.esolangs.org/repo,g;s,/index\\.cgi,,
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Sun, 08 Apr 2018 18:06:28 +0100 |
parents | 31fc0eb7ea45 |
children | ff752d36eb0e |
rev | line source |
---|---|
9075 | 1 #!/usr/bin/env python |
2 import sys, os.path, re, urllib | |
3 if len(sys.argv) <= 1: | |
11467
380e297c7ae5
<fizzie> sled bin/url//s,hackego.esolangs.org/fshg,hack.esolangs.org/repo,g;s,/index\\.cgi,,
HackEso <hackeso@esolangs.org>
parents:
10391
diff
changeset
|
4 print "https://hack.esolangs.org/repo/" |
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: |
11467
380e297c7ae5
<fizzie> sled bin/url//s,hackego.esolangs.org/fshg,hack.esolangs.org/repo,g;s,/index\\.cgi,,
HackEso <hackeso@esolangs.org>
parents:
10391
diff
changeset
|
13 print ("https://hack.esolangs.org/repo/file/tip/" + |
9075 | 14 urllib.quote(f)) |