Skip to content

Commit

Permalink
Reworked regexp definition by Daniel Bartlett
Browse files Browse the repository at this point in the history
  • Loading branch information
stgraber committed Feb 25, 2007
1 parent 51580e5 commit 7180330
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions pastebinit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/python
# Written by Stephane Graber <stgraber@stgraber.org>
# Daniel Bartlett <dan@f-box.org>
# Last modification : Sun Feb 25 11:25:00 CET 2007
# Last modification : Sun Feb 25 13:23:00 CET 2007

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -31,7 +31,8 @@ class pasteURLopener(urllib.FancyURLopener):
def getParameters(website, content, user, version, format, title, username, password):
"Return the parameters array for the selected pastebin"
params={}
if website == "http://paste.stgraber.org":
# pastebin.com v0.50
if re.search("http://((([a-zA-Z0-9\-_\.]*)(pastebin\.com))|(paste.stgraber.org))", website):
params['poster'] = user
params['code2'] = content
params['version'] = version
Expand All @@ -41,6 +42,7 @@ def getParameters(website, content, user, version, format, title, username, pass
params['remember'] = "0" #Do you want a cookie ?
params['expiry'] = "f" #The expiration, f = forever
params['regexp'] = "None"
# pastebin.com v0.60
elif re.search("http://([a-zA-Z0-9\-_\.]*)1t2\.us", website):
params['poster'] = user
params['code2'] = content
Expand All @@ -53,15 +55,6 @@ def getParameters(website, content, user, version, format, title, username, pass
params['username'] = username
params['password'] = password
params['regexp'] = "None"
elif re.search("http://([a-zA-Z0-9\-_\.]*)pastebin\.com", website):
params['poster'] = user
params['code2'] = content
params['parent_pid'] = "" #For reply, "" means homepage (new thread)
params['format'] = format #The format, for syntax hilighting
params['paste'] = "Send"
params['remember'] = "0" #Do you want a cookie ?
params['expiry'] = "f" #The expiration, f = forever
params['regexp'] = "None"
elif website == "http://pastebin.ca":
params['name'] = user
params['content'] = content
Expand All @@ -70,7 +63,7 @@ def getParameters(website, content, user, version, format, title, username, pass
params['s'] = "Submit Post"
params['regexp'] = '">http://pastebin.ca/(.*)</a></p><p>'
else:
sys.exit("Unknown website, please post a bugreport to request this pastebin to be added ("+website+")")
sys.exit("Unknown website, please post a bugreport to request this pastebin to be added (" + website + ")")
return params

# Display usage instructions
Expand Down Expand Up @@ -99,7 +92,7 @@ filename = ""
content = ""

#Check if some datas were passed by pipe, if yes directly assign content
l_r = select.select([sys.stdin],[],[],0)
l_r = select.select([sys.stdin], [], [], 0)
try :
content=l_r[0][0].read()
filename="-"
Expand All @@ -108,7 +101,6 @@ except:

# Check number of arguments
if len(sys.argv) == 1 and filename == "":
print "Error no arguments specified!\n"
Usage()
sys.exit(1)

Expand Down Expand Up @@ -159,7 +151,7 @@ params['regexp'] = None #Remove the regexp from what will be sent
params = urllib.urlencode(params) #Convert to a format usable with the HTML POST

url_opener = pasteURLopener()
page = url_opener.open(website+'/',params) #Send the informations and be redirected to the final page
page = url_opener.open(website + '/', params) #Send the informations and be redirected to the final page

try:
if reLink != "None": #Check if we have to apply a regexp
Expand Down

0 comments on commit 7180330

Please sign in to comment.