From ba5f112989d19dcf13736ee7318f388e939830eb Mon Sep 17 00:00:00 2001 From: Jeremy Orem Date: Thu, 16 Jul 2009 14:39:06 -0700 Subject: [PATCH] initial commit --- README | 1 + pastebinit.py | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 pastebinit.py diff --git a/README b/README index e69de29..2484514 100644 --- a/README +++ b/README @@ -0,0 +1 @@ +Ex: ./pastebinit.py -f python -u myname -e f < pastebinit.py diff --git a/pastebinit.py b/pastebinit.py new file mode 100644 index 0000000..9ae6aa9 --- /dev/null +++ b/pastebinit.py @@ -0,0 +1,26 @@ +#!/usr/bin/python + +import sys +from optparse import OptionParser +from urllib import urlopen, urlencode + +parser = OptionParser() + +parser.add_option("-u", "--username", dest="username", default="anonymous") +parser.add_option("-f", "--format", dest="format", default="text", help="defines data format e.g, php") +parser.add_option("-e", "--expiry", dest="expiry", default="m", help="valid options are d, m, f (day, month, forever)") + +(options, args) = parser.parse_args() + +PASTEBIN_URL = 'http://pastebin.mozilla.org/' + +pastebin_data = { + 'code2': sys.stdin.read(), + 'expiry': options.expiry, + 'format': options.format, + 'parent_pid': '', + 'paste': 'Send', + 'poster': options.username +} + +print urlopen(PASTEBIN_URL, urlencode(pastebin_data)).geturl()