Mercurial > repo
comparison bin/raw-url @ 11470:bb65cc75888c draft
<fizzie> sled bin/raw-url//s,hackego\\.esolangs\\.org,hack.esolangs.org,g;s,/fshg,/repo,g;s,/index\\.cgi,,
author | HackEso <hackeso@esolangs.org> |
---|---|
date | Sun, 08 Apr 2018 18:26:27 +0100 |
parents | 024b7442d847 |
children | adabeafee531 |
comparison
equal
deleted
inserted
replaced
11469:5a1e15fb9528 | 11470:bb65cc75888c |
---|---|
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://hackego.esolangs.org/fshg/" | 4 print "http://hack.esolangs.org/repo/" |
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://hackego.esolangs.org/" + urllib.quote(f)) | 11 print ("http://hack.esolangs.org/" + urllib.quote(f)) |
12 else: | 12 else: |
13 print ("http://hackego.esolangs.org/fshg/index.cgi/raw-file/tip/" + | 13 print ("http://hack.esolangs.org/repo/raw-file/tip/" + |
14 urllib.quote(f)) | 14 urllib.quote(f)) |