Mercurial > repo
changeset 10318:8c93629c5394
<fizzie> fetch bin/edit http://hackego.esolangs.org/get/bin/edit
author | HackBot |
---|---|
date | Sat, 18 Feb 2017 21:38:25 +0000 |
parents | 024b7442d847 |
children | 7acac7360270 |
files | bin/edit |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/edit Sat Feb 18 19:02:24 2017 +0000 +++ b/bin/edit Sat Feb 18 21:38:25 2017 +0000 @@ -1,9 +1,12 @@ #!/usr/bin/env python -import sys, os, urllib +import sys, os.path, re, urllib if len(sys.argv) < 2: - print "usage: edit <path>" - sys.exit(1) + sys.exit('http://hackego.esolangs.org/edit/') -print "http://slbkbs.org:5196/edit?path=" + urllib.quote(os.path.realpath(sys.argv[1])) +f = os.path.realpath(sys.argv[1]) +f = re.sub(r"^/+hackenv/", "", f) +if re.match(r"/|\.hg(?:/|ignore$|$)",f): + sys.exit("File is not editable.") +print 'http://hackego.esolangs.org/edit/' + urllib.quote(f)