weboob.capabilities.paste

exception weboob.capabilities.paste.PasteNotFound

Bases: weboob.capabilities.base.UserError

Raised when a paste is not found.

class weboob.capabilities.paste.BasePaste(_id, title=NotLoaded, language=NotLoaded, contents=NotLoaded, public=NotLoaded, url=None)

Bases: weboob.capabilities.base.BaseObject

Represents a pasted text.
Variables:
  • title – (unicode) Title of paste
  • language – (unicode) Language of the paste
  • contents – (unicode) Content of the paste
  • public – (bool) Is this paste public?
classmethod id2url(_id)

Overloaded in child classes provided by backends.

page_url

Get URL to page of this paste.

class weboob.capabilities.paste.CapPaste

Bases: weboob.capabilities.base.Capability

This capability represents the ability for a website backend to store plain text.

can_post(contents, title=None, public=None, max_age=None)

Checks if the paste can be pasted by this backend. Some properties are considered required (public/private, max_age) while others are just bonuses (language).

contents: Can be used to check encodability, maximum length, etc. title: Can be used to check length, allowed characters. Should not be required. public: True must be public, False must be private, None do not care. max_age: Maximum time to live in seconds.

A score of 0 means the backend is not suitable. A score of 1 means the backend is suitable. Higher scores means it is more suitable than others with a lower score.

Return type:int
Returns:score
get_paste(url)

Get a Paste from an ID or URL.

Parameters:_id (str) – the paste id. It can be an ID or a page URL.
Return type:BasePaste
Raises:PasteNotFound
new_paste(*args, **kwargs)

Get a new paste object for posting it with the backend. The parameters should be passed to the object init.

Return type:BasePaste
post_paste(paste, max_age=None)

Post a paste.

Parameters:paste (BasePaste) – a Paste object