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 = None

If True, warnings about date parsing are not printed.

min_date = None

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

ENTRY = None

Counter of entries (for debugging).

PKG = None

Counter of packages (for debugging).

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
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]
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

gen_entry_checksum(data)[source]

Generate ChangeLog entry checksum from data.

Parameters:data (unicode) – ChangeLog entry content.
Returns:Entry checksum.
Return type:unicode
gen_entry_identifier(data, checksum, parent)[source]

Generate ChangeLog entry identifier from data, checksum, and/or parent identifier.

Parameters:
  • data (unicode) – ChangeLog entry content.
  • checksum (unicode) – ChangeLog entry checksum.
  • parent – Parent entry identifier or None
Returns:

Entry identifier.

Return type:

unicode

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

Parse ChangeLog entry description 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]
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]
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

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

Parse package description from a package.

Parameters:data (unicode) – Package description.
Returns:Package description.
Return type:unicode
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]
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
parse_date_with_timezone(data)[source]

Parse a time string into a timestamp.

Parameters:data (unicode) – Time string.
Returns:a two element list: Timestamp in UTC timezone, and the original timezone.
Return type:datetime.datetime