Mercurial > repo
annotate bin/url @ 12508:335a2a849232 draft default tip
<wib_jonas> `` f=/hackenv/bin/dateu; >$f echo $\'#!/bin/bash\\nset -e\\nif (( 1 < $# )); then echo "dateu error: too many command-line arguments. Usage: dateu datetimestring"; exit 2; fi\\nexec date -u ${1:+-d "$1"} "+%Y-%m-%d %H:%M:%S.%3N %z %Z %B %-e %A %G-W%V-%u"\'; chmod a+x "$f"
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Wed, 03 Jul 2024 18:15:24 +0100 |
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)) |