Sublime Forum

A pastie package?

#1

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:

blog.macromates.com/2006/pasting-services/

0 Likes

#2

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.

0 Likes

#3

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”.

0 Likes

#4

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.

0 Likes

#5

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 :smiley:

0 Likes

#6

[quote=“sublimator”]Looks like doing some automatic irc stuff would be pretty easy:

oreilly.com/pub/h/1968
devshed.com/c/a/Python/Python-and-IRC/[/quote]

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

0 Likes

#7

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

0 Likes

#8

Hmm, it still fails, but with better output this time :wink: 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

0 Likes

#9

That change you made did the trick. Thanks so much for your patience. This makes my day. :smiley:

0 Likes