Home Download Buy Blog Forum Support

A pastie package?

A pastie package?

Postby gordon on Mon Apr 07, 2008 3:43 pm

One feature that textmate has that I've always been a bit envious of is the ability to send a snippet to a pastie service, and then automatically send the link to IRC. I'd very much like to have this, but I don't know Python anywhere near well enough. Does anyone know if there is a Python lib for pastie services? Would anyone else be interested in such a thing? I'll try my hand at it, I'm just hoping for some pushes in the right direction here and there.

Here's the url to textmate's feature:

http://blog.macromates.com/2006/pasting-services/
gordon
 
Posts: 10
Joined: Mon Mar 24, 2008 3:47 pm

Re: A pastie package?

Postby jps on Tue Apr 08, 2008 12:21 am

I don't know of any Python pastebin APIs, but it's generally just a matter of submitting to a post url, and capturing the redirect that comes back. It shouldn't be too bad to cook something up via urllib - there's a bunch of introductory material around on how to work with urllib too.

Pasting the resulting URL into another program could be a bit funky, but just copying it to the clipboard is a good start - I'll add some API calls for that.
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: A pastie package?

Postby jps on Tue Apr 08, 2008 1:14 am

Wow, nice!

re: syntax files, you can get the syntax used for the current buffer by querying view.options().get('syntax'), it'll return a value like "Packagas/Python/Python.tmLanguage".
jps
Site Admin
 
Posts: 3077
Joined: Wed Mar 19, 2008 12:33 pm

Re: A pastie package?

Postby kib2 on Tue Apr 08, 2008 8:18 am

Hi,

Have you tried http://paste.pocoo.org/ ?
There's an API for Python : http://paste.pocoo.org/help/xmlrpc/ witch seems quiet good and simple using XMLRPC.
kib2
 
Posts: 38
Joined: Sun Mar 23, 2008 8:30 am
Location: France

Re: A pastie package?

Postby gordon on Tue Apr 08, 2008 1:06 pm

sublimator wrote:Done.... link has been updated with syntax detection....


Wow! Asked for and implemented in less than a day. I was impressed before, but I'm a believer now. You've also given me a reason to learn Python :D
gordon
 
Posts: 10
Joined: Mon Mar 24, 2008 3:47 pm

Re: A pastie package?

Postby gordon on Fri Apr 11, 2008 3:22 pm

sublimator wrote:Looks like doing some automatic irc stuff would be pretty easy:

http://www.oreilly.com/pub/h/1968
http://www.devshed.com/c/a/Python/Python-and-IRC/


I was thinking more along the lines of interacting with the IRC client, than a Python IRC client. I think I could do this with Pidgin using DBus. But what you've done works well enough until I have more time to learn Python.

Thanks
gordon
 
Posts: 10
Joined: Mon Mar 24, 2008 3:47 pm

Re: A pastie package?

Postby gordon on Mon Apr 21, 2008 4:01 am

The threads don't seem to like me. Any ideas how I should fix this?

Exception in thread Thread-1:
Traceback (most recent call last):
File ".\threading.py", line 486, in __bootstrap_inner
File ".\threading.py", line 446, in run
File ".\pastie.py", line 28, in pastie
File "mechanize-0.1.7b-py2.5.egg\mechanize\_mechanize.py", line 127, in __init__
File "mechanize-0.1.7b-py2.5.egg\mechanize\_html.py", line 562, in __init__
File "mechanize-0.1.7b-py2.5.egg\mechanize\_html.py", line 111, in __init__
IOError: zipimport: can not open file mechanize-0.1.7b-py2.5.egg
gordon
 
Posts: 10
Joined: Mon Mar 24, 2008 3:47 pm

Re: A pastie package?

Postby gordon on Thu Apr 24, 2008 4:40 pm

Hmm, it still fails, but with better output this time ;) It actually writes the traceback to the clipboard for me, which is very cool.

Traceback (most recent call last):
File ".\pastie.py", line 67, in pastie
pastie = Browser()
File "mechanize-0.1.7b-py2.5.egg\mechanize\_mechanize.py", line 127, in __init__
File "mechanize-0.1.7b-py2.5.egg\mechanize\_html.py", line 562, in __init__
File "mechanize-0.1.7b-py2.5.egg\mechanize\_html.py", line 111, in __init__
IOError: zipimport: can not open file mechanize-0.1.7b-py2.5.egg

Thanks
gordon
 
Posts: 10
Joined: Mon Mar 24, 2008 3:47 pm

Re: A pastie package?

Postby gordon on Fri Apr 25, 2008 3:54 pm

That change you made did the trick. Thanks so much for your patience. This makes my day. :D
gordon
 
Posts: 10
Joined: Mon Mar 24, 2008 3:47 pm

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: Exabot [Bot] and 7 guests