SlackLog parsers

SlackLog parser reads a Slackware ChangeLog.txt and builds an in-memory representation of it using SlackLog models.

class slacklog.parsers.SlackLogParser[source]

Bases: object

Parser for recent (13.x) Slackware ChangeLogs.

quiet = False

If True, warnings about date parsing are not printed.

min_date = None

If set to a datetime.datetime object, any log entries whose timestamp is older are ignored (not parsed).

ENTRY = 0

Counter of entries (for debugging).

PKG = 0

Counter of packages (for debugging).

classmethod parse(data)[source]

Return the in-memory representation of the data.

Parameters:data (unicode) – the ChangeLog.txt content.
Returns:in-memory representation of data
Return type:slacklog.models.SlackLog
classmethod split_log_to_entries(data)[source]

Split the ChangeLog.txt into a list of unparsed entries.

Parameters:data (unicode) – the ChangeLog.txt content.
Returns:list of unparsed entries, separators removed.
Return type:[unicode]
classmethod parse_entry(data, log)[source]

Parse a single ChangeLog entry.

Parameters:
  • data (unicode) – ChangeLog entry content.
  • log – in-memory representation that is being parsed.
Type :

slacklog.models.SlackLog

Returns:

in-memory representation of the ChangeLog entry.

Return type:

slacklog.models.SlackLogEntry

classmethod parse_entry_timestamp(data)[source]

Parse ChangeLog entry timestamp from data.

Parameters:data (unicode) – ChangeLog entry content.
Returns:a two element list: timestamp and the rest of the entry.
Return type:[datetime.datetime, unicode]
classmethod parse_entry_description(data)[source]

Parse ChangeLog entry desctiption from data.

Parameters:data (unicode) – ChangeLog entry content (without timestamp).
Returns:a two element list: description and the rest of the entry.
Return type:[unicode, unicode]
classmethod split_entry_to_pkgs(data)[source]

Split ChangeLog entry content into a list of unparsed packages.

Parameters:data (unicode) – ChangeLog entry content (without timestamp or description).
Returns:a list of unparsed packages.
Return type:[unicode]
classmethod parse_pkg(data, entry)[source]

Parse a single package.

Parameters:
  • data (unicode) – Package name and description of the update.
  • entry – in-memory representation of the ChangeLog entry being parsed.
Type :

slacklog.models.SlackLogEntry

Returns:

in-memory representation of the package.

Return type:

slacklog.models.SlackLogPkg

classmethod parse_pkg_name(data)[source]

Parse package name from a package.

Parameters:data (unicode) – Package name and description.
Returns:a two element list: package name and package description.
Return type:[unicode, unicode]
classmethod parse_pkg_description(data)[source]

Parse package description from a package.

Parameters:data (unicode) – Package description.
Returns:Package description.
Return type:unicode
classmethod get_line(data)[source]

Consume one line from data.

Parameters:data (unicode) – Data.
Returns:a two element list: first line, rest of the data.
Return type:[unicode, unicode]
classmethod parse_date(data)[source]

Parse a time string into a timestamp.

Parameters:data (unicode) – Time string.
Returns:Timestamp in UTC timezone.
Return type:datetime.datetime

Previous topic

SlackLog models

Next topic

SlackLog formatters

This Page