diff options
Diffstat (limited to 'install-files/essential-files/usr/bin/brpaste')
-rw-r--r-- | install-files/essential-files/usr/bin/brpaste | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/install-files/essential-files/usr/bin/brpaste b/install-files/essential-files/usr/bin/brpaste new file mode 100644 index 00000000..15f976b9 --- /dev/null +++ b/install-files/essential-files/usr/bin/brpaste @@ -0,0 +1,29 @@ +#!/usr/bin/python + +import urllib2 +import os +import json + +URL = 'http://paste.baserock.org/documents' + +def run(*args): + if args: + content = [open(x).read() for x in args] + extensions = [os.path.splitext(x)[1] for x in args] + else: + content = [sys.stdin.read()] + extensions = [None] + + for i, each in enumerate(content): + req = urllib2.Request(URL, each) + response = urllib2.urlopen(req) + the_page = response.read() + key = json.loads(the_page)['key'] + url = "http://paste.baserock.org/%s" % key + if extensions[i]: + url += extensions[i] + print url + +if __name__ == '__main__': + import sys + sys.exit(run(*sys.argv[1:])) |