Mercurial > repo
annotate bin/raw-url @ 10513:28c4c6b6e9bd
<wob_jonas> `` sed -i \'s/M3/Saw Gerrera|Shmi|Sio Bibble|Sith Lord Jar Jar|Supreme Leader Snoke|Taun We|Watto|Wedge Antilles|Willard|Yoda|Zam Wessel|the Dianoga|the Rancor|the Sarlacc/\' bin/starwars && cat bin/starwars
author | HackBot |
---|---|
date | Sun, 26 Mar 2017 02:00:49 +0000 |
parents | 024b7442d847 |
children | bb65cc75888c |
rev | line source |
---|---|
4570
5a4571b62410
<oerjan> cp bin/{,raw-}url; sed -i \'s/raw-//\' bin/url
HackBot
parents:
diff
changeset
|
1 #!/usr/bin/env python |
10317
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
2 import sys, os.path, re, urllib |
4570
5a4571b62410
<oerjan> cp bin/{,raw-}url; sed -i \'s/raw-//\' bin/url
HackBot
parents:
diff
changeset
|
3 if len(sys.argv) <= 1: |
10317
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
4 print "http://hackego.esolangs.org/fshg/" |
4570
5a4571b62410
<oerjan> cp bin/{,raw-}url; sed -i \'s/raw-//\' bin/url
HackBot
parents:
diff
changeset
|
5 else: |
10317
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
6 f = os.path.abspath(sys.argv[1]) |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
7 f = re.sub(r"^/+hackenv/", "", f) |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
8 if re.match(r"/|\.hg(?:/|$)",f): |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
9 sys.exit("File is outside web-viewable filesystem repository.") |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
10 elif re.match(r"tmp(?:/|$)",f): |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
11 print ("http://hackego.esolangs.org/" + urllib.quote(f)) |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
12 else: |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
13 print ("http://hackego.esolangs.org/fshg/index.cgi/raw-file/tip/" + |
024b7442d847
<fizzie> ` sed -e \'s,index.cgi/file,index.cgi/raw-file,\' < bin/url > bin/raw-url # this one didn\'t even support tmp/
HackBot
parents:
4570
diff
changeset
|
14 urllib.quote(f)) |