blogpost submodule

This module is used to represent all kinds of informations about blogposts.

class abclinuxuapi.blogpost.Rating

Bases: abclinuxuapi.blogpost.Rating

Container holding informations about rating.

rating

int – Percentual rating of the blogpost.

base

int – How many people voted.

class abclinuxuapi.blogpost.Tag(tag, norm=None)

Bases: str

Each blog may have many tags. This is container for informations about each tag.

tag

str – Human readable content of the tag.

norm

str – norm machine-readable version of tag.

url
class abclinuxuapi.blogpost.Blogpost(url, lazy=True, **kwargs)

Bases: object

Informations about blogposts.

url

str – Absolute URL of the blogpost.

uid

int – Unique identificator of the blogpost.

title

str – Tile of the blogpost.

intro

str – Perex. This is parsed only when returned from User.

text

str – Full text of the blogpost.

tags

list – List of Tag objects.

rating

objRating object with informations about rating.

has_tux

bool – Does this blog have a tux? Only good blogs get tux.

comments

list – List of Comment objects. Not used until pull() is called, or lazy parameter of __init__() is set to True.

comments_n

int – Number of comments. This information is in some cases known before the blog is parsed, just from perex.

readed

int – How many times was the blog readed?

object_ts

int – Timestamp of the creation of this object.

created_ts

int – Timestamp of the creation of the blogpost.

last_modified_ts

int – Timestamp of the last modification of blogpost.

Parameters:
  • url (str) – Url of the blogpost.
  • lazy (bool, default True) – True == don’t call pull() right now.
static from_html(html, lazy=True)

Convert HTML string to Blogpost instance.

Parameters:
  • html (str) – Input data.
  • lazy (bool, default True) – Be lazy (don’t pull data by yourself from the site). Call pull() for active download of all required informations.
Returns:

Blogpost instance.

Return type:

obj

pull()

Download page with blogpost. Parse text, comments and everything else.

Until this is called, following attributes are not known/parsed:

get_image_urls()

Get list of links to all images used in this blog.

Returns:List of str containing absolute URL of the image.
Return type:list
classmethod possible_tags()

Get list of all possible tags which may be set.

Returns:List of Tag objects.
Return type:list
add_tag(tag)

Add new tag to the blogpost.

Parameters:

tag (Tag) – Tag instance. See possible_tags for list of all possible tags.

Raises:
  • KeyError – In case, that tag is not instance of Tag.
  • ValueError – In case that uid is not set.
Returns:

List of Tag objects.

Return type:

list

remove_tag(tag, throw=False)

Remove tag from the tags currently assigned to blogpost.

Parameters:
  • tag (Tag) – Tag instance. See possible_tags for list of all possible tags.
  • throw (bool) – Raise error in case you are trying to remove tag that is not assigned to blogpost.
Raises:
  • KeyError – In case, that tag is not instance of Tag.
  • IndexError – In case that you are trying to remove tag which is not assigned to blogpost.
  • ValueError – In case that uid is not set.
Returns:

List of Tag objects.

Return type:

list