:mod:`lodgeitlib` – programmatic access to the lodgeit ====================================================== .. automodule:: lodgeitlib :synopsis: Client library to Lodgeit Pastebins :platform: Unix, Windows Paste retrival and creation --------------------------- .. autodata:: pocoo_pastebin .. autodata:: bpaste_pastebin .. data:: lodgeit Deprecated alias for :data:`pocoo_pastebin` .. autodata:: PASTEBINS .. autoclass:: Lodgeit .. attribute:: url The url of the pastebin web interface. Used as base url to create paste urls. Consider this read only. .. attribute:: service_url The url of the JSON-RPC service of this pastebin. Consider this read only. .. autoattribute:: hostname .. attribute:: caching Whether paste caching is enabled or not. .. automethod:: new_paste .. automethod:: get_paste_by_id .. automethod:: get_last_paste .. automethod:: get_recent_pastes .. automethod:: id_from_url .. autoattribute:: languages .. autoattribute:: has_languages .. automethod:: reset_languages .. autoexception:: UnsupportedLanguageError Paste data ---------- .. autoclass:: Paste .. attribute:: lodgeit The :class:`lodgeit` instance, by which this paste was fetched. .. attribute:: id The id of this paste as integer. .. attribute:: code The pasted code as unicode string. .. attribute:: datetime The :class:`~datetime.datetime` of publication of the paste. .. attribute:: language The programming language, the paste was written in, as unicode string. .. attribute:: parent_id The id of the parent paste as integer, or ``None``, if this paste has no parent. .. attribute:: relative_url The relative url of this paste. This url is relative to the :attr:`~Lodgeit.url` of the :attr:`lodgeit`, that fetched this paste. .. autoattribute:: url .. autoattribute:: language_desc .. automethod:: get_parent Usage example ------------- >>> from lodgeitlib import pocoo_pastebin >>> code = u'print "Hello „World“"' >>> paste_id = pocoo_pastebin.new_paste(code, 'python', private=True) >>> paste_id 'C76X4sCbP3FEUCDBbFGa' >>> paste = pocoo_pastebin.get_paste_by_id(paste_id) >>> print paste.code print "Hello „World“" >>> paste.language_desc 'Python' >>> paste.parent_id >>> paste.get_parent() >>> paste.url 'http://paste.pocoo.org/show/C76X4sCbP3FEUCDBbFGa/' >>> pocoo_pastebin.id_from_url(paste.url) 'C76X4sCbP3FEUCDBbFGa'