SlackLog parsers¶
SlackLog parser takes a unicode representation of a Slackware ChangeLog.txt and produces an in-memory representation of it.
The in-memory representation is an instance of SlackLog
.
-
class
slacklog.parsers.
SlackLogParser
[source]¶ Bases:
object
Parser for Slackware ChangeLog.txt files. This implementation works for 12.x and newer Slackware versions.
-
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: SlackLog
– in-memory representation of data
-
split_log_to_entries
(data)[source]¶ Split the ChangeLog.txt into a list of unparsed entries.
Parameters: data – unicode
–the ChangeLog.txt content.Returns: [ unicode
] – list of unparsed entries, separators removed.
-
parse_entry
(data, log)[source]¶ Parse a single ChangeLog entry.
Parameters: - data –
unicode
– ChangeLog entry content. - log –
SlackLog
– in-memory representation that is being parsed.
Returns: SlackLogEntry
– in-memory representation of the ChangeLog entry.- data –
-
gen_entry_checksum
(data)[source]¶ Generate ChangeLog entry checksum from data.
Parameters: data – unicode
– ChangeLog entry content.Returns: unicode
– Entry checksum.
-
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 –
unicode
– Parent entry identifier orNone
Returns: unicode
– Entry identifier.- data –
-
parse_entry_timestamp
(data)[source]¶ Parse ChangeLog entry timestamp from data.
Parameters: data – unicode
– ChangeLog entry content.Returns: [ datetime.datetime
,tzinfo
,bool
,unicode
] – a four element list: timestamp in UTC, original timezone,True
if the timestamp had a 12-hour clock, and the rest of the entry.
-
parse_entry_description
(data)[source]¶ Parse ChangeLog entry description from data.
Parameters: data – unicode
– ChangeLog entry content (without timestamp).Returns: [ unicode
,unicode
] – a two element list: description and the rest of the entry.
-
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: [ unicode
] – a list of unparsed packages.
-
parse_pkg
(data, entry)[source]¶ Parse a single package.
Parameters: - data –
unicode
– Package name and description of the update. - entry –
SlackLogEntry
– in-memory representation of the ChangeLog entry being parsed.
Returns: SlackLogPkg
– in-memory representation of the package.- data –
-
parse_pkg_name
(data)[source]¶ Parse package name from a package.
Parameters: data – unicode
– Package name and description.Returns: [ unicode
,unicode
] – a two element list: package name and package description.
-
parse_pkg_description
(data)[source]¶ Parse package description from a package.
Parameters: data – unicode
– Package description.Returns: unicode
– Package description.
-
get_line
(data)[source]¶ Consume one line from data.
Parameters: data – unicode
– Data.Returns: [ unicode
,unicode
] – a two element list: first line, rest of the data.
-