Mercurial > repo
annotate bin/url @ 11952:bf859c78a439 draft
<kmc> addquote <ais523> (one nice thing about asking in #esoteric rather than #perl is that you don\'t have to attempt to justify what you\'re doing)
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Sun, 22 Sep 2019 02:09:55 +0000 |
parents | ff752d36eb0e |
children |
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): |
11468
ff752d36eb0e
<fizzie> sled bin/url//s,https://hackego.esolangs.org/,https://hack.esolangs.org/,
HackEso <hackeso@esolangs.org>
parents:
11467
diff
changeset
|
11 print ("https://hack.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)) |