Module that provide util functions

Class Peekable Undocumented
Function collate A helper function to iterate over multiple iterables yielding the same type of elements in a sorted way.
def collate(iterables, key=lambda a: a, reverse=False):

A helper function to iterate over multiple iterables yielding the same type of elements in a sorted way.

Examples

This is very useful to iterate over search results from multiple search queries. For example, iterating over all contexts where the associated symbol name contains 'acpi'.

>>> acpi_iterables = [reven_server.trace.search.symbol(symbol) for symbol in reven_server.ossi.symbols('acpi')]
>>> for ctx in collate(acpi_iterables):
>>>     print('#{}: {}'.format(ctx.transition_after().id, ctx.ossi.location().symbol))
#1471900994: HalAcpiGetTableDispatch
#1471900999: HalpAcpiGetTable
#1471901083: HalpAcpiGetTableWork
#1471901099: HalpAcpiGetCachedTable
#1471901168: HalpAcpiGetTableFromBios
#1471903841: HalAcpiGetTableDispatch
#1471903846: HalpAcpiGetTable
#1471903930: HalpAcpiGetTableWork
#1471903946: HalpAcpiGetCachedTable
#1471903989: HalpAcpiIsCachedTableCompromised
...

Alternatively, using a kind of tag on iterable elements.

>>> from itertools import repeat
>>> acpi_iterables = [zip(reven_server.trace.search.symbol(symbol), repeat(symbol.name))                           for symbol in reven_server.ossi.symbols('acpi')]
>>> for ctx, symbol in collate(acpi_iterables, key=lambda ctx_symbol: ctx_symbol[0]):
>>>     print('#{}: {}'.format(ctx.transition_after().id, symbol))
#1471900994: HalAcpiGetTableDispatch
#1471900999: HalpAcpiGetTable
#1471901083: HalpAcpiGetTableWork
#1471901099: HalpAcpiGetCachedTable
#1471901168: HalpAcpiGetTableFromBios
#1471903841: HalAcpiGetTableDispatch
#1471903846: HalpAcpiGetTable
#1471903930: HalpAcpiGetTableWork
#1471903946: HalpAcpiGetCachedTable
#1471903989: HalpAcpiIsCachedTableCompromised
...

Information

ParametersiterablesA list of iterable yielding the same type of elements.
keyA lambda function that defines the key used to sort iterable elements.
reverseWhether increasing or decreasing order.
ReturnsA generator of sorted iterable elements.
API Documentation for reven2, generated by pydoctor at 2020-09-17 15:57:23.