SlackLog formatters

SlackLog formatter takes an in-memory representation of a Slackware ChangeLog.txt and produces a different representation of it.

class slacklog.formatters.SlackLogFormatter[source]

Bases: object

Base class for SlackLog formatters.

This class is ment for subclassing.

max_entries = None

If not None, must be an int representing how many entries are formatted from the beginning of the log. Rest of the entries are ignored.

max_pkgs = None

If not None, must be an int representing how many packages are formatted from the beginning of each entry. Rest of the packages are ignored.

classmethod format(log)[source]

Return unicode representation of the in-memory representation of the log.

Default implementation calls format_log_preamble(), followed by a call to format_entry() for each log entry, and finally calls format_log_postamble().

The return value is the concatenation of the return values of the mentioned functions.

Parameters:log – in-memory representation of the log.
Type :slacklog.models.SlackLog
Returns:Unicode representation of the log.
Type :unicode
classmethod format_log_preamble(log)[source]

Return unicode representation of the log preamble, the part before entries.

Default implementation returns empty string.

Parameters:log – in-memory representation of the log.
Type :slacklog.models.SlackLog
Returns:Unicode representation of log preamble.
Type :unicode
classmethod format_log_postamble(log)[source]

Return unicode representation of the log postamble, the part after all entries.

Default implementation returns empty string.

Parameters:log – in-memory representation of the log.
Type :slacklog.models.SlackLog
Returns:Unicode representation of log postamble.
Type :unicode
classmethod format_entry(entry, is_first, is_last)[source]

Return unicode representation of a single log entry.

Default implementation calls format_entry_separator() with arguments is_first and is_last, followed by a call to format_entry_preamble(), followed by a call to format_pkg() for each package in this log entry, finally followed by a call to format_entry_postamble().

The return value is the concatenation of the return values of the mentioned functions.

Parameters:
  • entry – in-memory representation of the log entry.
  • is_first (bool) – True if this is first entry, False otherwise.
  • is_last (bool) – True if this is last entry, False otherwise.
Type :

slacklog.models.SlackLogEntry

Returns:

Unicode representation of log entry.

Type :

unicode

classmethod format_entry_separator(is_first, is_last)[source]

Return unicode representation of the log entry separator.

Default implementation returns an empty string.

Parameters:
  • is_first (bool) – True if this is first entry, False otherwise.
  • is_last (bool) – True if this is last entry, False otherwise.
Returns:

Unicode representation of log entry separator.

Type :

unicode

classmethod format_entry_preamble(entry)[source]

Return unicode representation of the log entry preamble, the part before packages.

Default implementation returns an empty string.

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry preamble.
Type :unicode
classmethod format_entry_postamble(entry)[source]

Return unicode representation of the log entry postamble, the part after packages.

Default implementation returns an empty string.

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry postamble.
Type :unicode
classmethod format_pkg(pkg, is_first, is_last)[source]

Return unicode representation of a single log entry package.

Default implementation calls format_pkg_separator(), followed by a call to format_pkg_preamble(), and finally calls format_pkg_postamble().

The return value is the concatenation of the return values of the mentioned functions.

Parameters:
  • pkg – in-memory representation of the log entry package
  • is_first (bool) – True if this is first package, False otherwise.
  • is_last (bool) – True if this is last package, False otherwise.
Type :

slacklog.models.SlackLogPkg

Returns:

Unicode representation of log entry package.

Type :

unicode

classmethod format_pkg_separator(is_first, is_last)[source]

Return unicode representation of the log entry package separator.

Default implementation returns an empty string.

Parameters:
  • is_first (bool) – True if this is first package, False otherwise.
  • is_last (bool) – True if this is last package, False otherwise.
Returns:

Unicode representation of log entry package separator.

Type :

unicode

classmethod format_pkg_preamble(pkg)[source]

Return unicode representation of the log entry package preamble.

Default implementation returns an empty string.

Parameters:pkg – in-memory representation of the log entry package
Type :slacklog.models.SlackLogPkg
Returns:Unicode representation of log entry package preamble.
Type :unicode
classmethod format_pkg_postamble(pkg)[source]

Return unicode representation of the log entry package postamble.

Default implementation returns an empty string.

Parameters:pkg – in-memory representation of the log entry package
Type :slacklog.models.SlackLogPkg
Returns:Unicode representation of log entry package postamble.
Type :unicode
classmethod format_list(list_of_items, item_formatter, max_items=None)[source]

Return unicode representation of a list of objects.

This method is not ment for subclassing.

Parameters:
  • list_of_items – List of items to format.
  • item_formatter – Function that formats one item.
Type :

list

Type :

A callable that takes one item as the first positional argument, two booleans is_first and is_last as second and third positional arguments, and returns a unicode string.

Returns:

Formatted data.

Return type:

unicode

class slacklog.formatters.SlackLogTxtFormatter[source]

Bases: slacklog.formatters.SlackLogFormatter

Concrete SlackLog formatter that tries to regenerate the original ChangeLog.txt.

classmethod format_entry_separator(is_first, is_last)[source]

Overrides SlackLogFormatter.format_entry_separator().

Parameters:
  • is_first (bool) – True if this is first entry, False otherwise.
  • is_last (bool) – True if this is last entry, False otherwise.
Returns:

Unicode representation of log entry separator.

Type :

unicode

classmethod format_entry_preamble(entry)[source]

Overrides SlackLogFormatter.format_entry_preamble().

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry preamble.
Type :unicode
classmethod format_pkg_preamble(pkg)[source]

Overrides SlackLogFormatter.format_pkg_preamble().

Parameters:pkg – in-memory representation of the log entry package
Type :slacklog.models.SlackLogPkg
Returns:Unicode representation of log entry package preamble.
Type :unicode
class slacklog.formatters.SlackLogRssFormatter[source]

Bases: slacklog.formatters.SlackLogFormatter

Concrete SlackLog formatter that generates an RSS feed.

slackware = None

unicode description of the distro version. E.g. ‘Slackware 13.37’ or ‘Slackware64 current’.

unicode. Full URL of the RSS feed.

unicode. Full URL of the WWW version of the feed.

description = None

unicode description of the feed.

language = None

unicode language identifier. E.g. ‘en’.

managingEditor = None

unicode. Email, and possibly name, of the feed manager. E.g. 'jane@doe.net (Jane Doe)’.

webMaster = None

unicode. Email, and possibly name, of the webmaster. E.g. 'john@doe.net (John Doe)’.

classmethod format_log_preamble(log)[source]

Overrides SlackLogFormatter.format_log_preamble().

Parameters:log – in-memory representation of the log.
Type :slacklog.models.SlackLog
Returns:Unicode representation of log preamble.
Type :unicode
classmethod format_log_postamble(log)[source]

Overrides SlackLogFormatter.format_log_postamble().

Parameters:log – in-memory representation of the log.
Type :slacklog.models.SlackLog
Returns:Unicode representation of log postamble.
Type :unicode
classmethod format_entry_preamble(entry)[source]

Overrides SlackLogFormatter.format_entry_preamble().

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry preamble.
Type :unicode
classmethod format_entry_postamble(entry)[source]

Overrides SlackLogFormatter.format_entry_postamble().

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry postamble.
Type :unicode
classmethod format_pkg_preamble(pkg)[source]

Overrides SlackLogFormatter.format_pkg_preamble().

Parameters:pkg – in-memory representation of the log entry package
Type :slacklog.models.SlackLogPkg
Returns:Unicode representation of log entry package preamble.
Type :unicode
class slacklog.formatters.SlackLogPyblosxomFormatter[source]

Bases: slacklog.formatters.SlackLogFormatter

Concrete SlackLog formatter that generates Pyblosxom blog entries.

quiet = False

If True,

slackware = None

unicode description of the distro version. E.g. ‘Slackware 13.37’ or ‘Slackware64 current’.

datadir = None

Blog entry directory.

extension = 'txt'

Blog entry filename extension.

encoding = 'utf-8'

Blog entry file encoding.

tags_separator = ','

Separator for tags.

pkg_separator = ':'

Separator for packages.

pyfilemtime = False

If True, a pyfilemtime compatible filenames are generated.

overwrite = False

If True, already existing blog entries are overwritten.

backup = True

If True, already existing blog entries are copied to backups before overwriting.

entry_preamble = u'<div class="slackLogEntry">\n'

unicode. HTML to insert before the entry.

entry_postamble = u'</div>\n'

unicode. HTML to insert after the entry.

entry_desc_preamble = u'<div class="slackLogEntryDesc">'

unicode. HTML to insert before the entry description.

entry_desc_postamble = u'</div>\n'

unicode. HTML to insert after the entry description.

entry_pkgs_preamble = u'<div class="slackLogEntryPkgs">\n'

unicode. HTML to insert before the list of packages.

entry_pkgs_postamble = u'</div>\n'

unicode. HTML to insert after the list of packages.

pkg_preamble = u'<div class="slackLogPkg">'

unicode. HTML to insert before a package.

pkg_postamble = u'</div>\n'

unicode. HTML to insert after a package.

pkg_name_preamble = u'<span class="slackLogPkgName">'

unicode. HTML to insert before package name.

pkg_name_postamble = u'</span>'

unicode. HTML to insert after package name.

pkg_desc_preamble = u'<span class="slackLogPkgDesc">'

unicode. HTML to insert before package description.

pkg_desc_postamble = u'</span>'

unicode. HTML to insert after package description.

classmethod format_entry(entry, is_first, is_last)[source]

Overrides SlackLogFormatter.format_entry().

Parameters:
  • entry – in-memory representation of the log entry.
  • is_first (bool) – True if this is first entry, False otherwise.
  • is_last (bool) – True if this is last entry, False otherwise.
Type :

slacklog.models.SlackLogEntry

Returns:

Unicode representation of log entry.

Type :

unicode

classmethod format_entry_preamble(entry)[source]

Overrides SlackLogFormatter.format_entry_preamble().

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry preamble.
Type :unicode
classmethod format_entry_postamble(entry)[source]

Overrides SlackLogFormatter.format_entry_postamble().

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry postamble.
Type :unicode
classmethod format_pkg_preamble(pkg)[source]

Overrides SlackLogFormatter.format_pkg_preamble().

Parameters:pkg – in-memory representation of the log entry package
Type :slacklog.models.SlackLogPkg
Returns:Unicode representation of log entry package preamble.
Type :unicode
classmethod format_entry_basename(entry)[source]

Return basename for the log entry.

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry name
Type :unicode
classmethod format_entry_title(entry)[source]

Return log entry title.

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry title
Type :unicode
classmethod format_entry_tags(entry)[source]

Return log entry tags.

Parameters:entry – in-memory representation of the log entry.
Type :slacklog.models.SlackLogEntry
Returns:Unicode representation of log entry tags
Type :unicode

Previous topic

SlackLog parsers

This Page