annotate bin/url @ 10280:bae4827d5de8

<fizzie> ` sed -i -e \'s/|tmp//;10i\\\' -e \' elif re.match(r"tmp/(?:|$)",f):\' -e \'10i\\\' -e \' print ("http://www2.codu.org/projects/hackbot/" + urllib.quote(f))\' bin/url
author HackBot
date Thu, 16 Feb 2017 02:23:44 +0000
parents c989a1669243
children 76a97128bd0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9075
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
1 #!/usr/bin/env python
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
2 import sys, os.path, re, urllib
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
3 if len(sys.argv) <= 1:
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
4 print "http://codu.org/projects/hackbot/fshg/"
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
5 else:
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
6 f = os.path.abspath(sys.argv[1])
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
7 f = re.sub(r"^/+hackenv/", "", f)
10280
bae4827d5de8 <fizzie> ` sed -i -e \'s/|tmp//;10i\\\' -e \' elif re.match(r"tmp/(?:|$)",f):\' -e \'10i\\\' -e \' print ("http://www2.codu.org/projects/hackbot/" + urllib.quote(f))\' bin/url
HackBot
parents: 9075
diff changeset
8 if re.match(r"/|(?:\.hg)(?:/|$)",f):
9075
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
9 sys.exit("File is outside web-viewable filesystem repository.")
10280
bae4827d5de8 <fizzie> ` sed -i -e \'s/|tmp//;10i\\\' -e \' elif re.match(r"tmp/(?:|$)",f):\' -e \'10i\\\' -e \' print ("http://www2.codu.org/projects/hackbot/" + urllib.quote(f))\' bin/url
HackBot
parents: 9075
diff changeset
10 elif re.match(r"tmp/(?:|$)",f):
bae4827d5de8 <fizzie> ` sed -i -e \'s/|tmp//;10i\\\' -e \' elif re.match(r"tmp/(?:|$)",f):\' -e \'10i\\\' -e \' print ("http://www2.codu.org/projects/hackbot/" + urllib.quote(f))\' bin/url
HackBot
parents: 9075
diff changeset
11 print ("http://www2.codu.org/projects/hackbot/" + urllib.quote(f))
9075
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
12 else:
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
13 print ("http://codu.org/projects/hackbot/fshg/index.cgi/file/tip/" +
c989a1669243 <fizzie> revert 58b9ee8f97a7
HackBot
parents:
diff changeset
14 urllib.quote(f))