Welcome to bop’s documentation!

bop - parses results from Boa’s less than helpful text output

bop.parse(string_iter, weighted=False)

Given an iterator that yields strings (like a file object), returns the parsed results. The results may be returned as a list if there are no discernible string keys; results are returned as a (possibly nested) dictionary otherwise.

If weighted is True, indicates that the values are affixed with a comma-separate weight, like so:

licenses[] = GNU General Public License version 2.0 (GPLv2), 78

You must explicitly set weighted=True to parse this kind of data. Weighted data is always returned as a dictionary, with the “identifier” as the keys, and the weight as the values.

Parameters:
  • string_iter – A string or an iterator that yields strings, such as a file object.
  • weighted (bool) – Whether the output consists of weights.
Returns:

parsed Boa output

Return type:

dict or list