woob.capabilities.paste

exception PasteNotFound[source]

Bases: UserError

Raised when a paste is not found.

class BasePaste(_id, title=NotLoaded, language=NotLoaded, contents=NotLoaded, public=NotLoaded, url=None)[source]

Bases: BaseObject

Represents a pasted text.

Variables:
  • url – (str) url

  • title – (str) Title of paste

  • language – (str) Language of the paste

  • contents – (str) Content of the paste

  • public – (bool) Is this paste public?

classmethod id2url(_id)[source]

Overloaded in child classes provided by backends.

property page_url

Get URL to page of this paste.

class CapPaste[source]

Bases: Capability

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

new_paste(*args, **kwargs)[source]

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

Return type:

BasePaste

can_post(contents, title=None, public=None, max_age=None)[source]

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)[source]

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

post_paste(paste, max_age=None)[source]

Post a paste.

Parameters:

paste (BasePaste) – a Paste object