collaboration.util module

Class

Description

binaryninja.collaboration.util.LazyT

Lazily loaded objects (but FFI) Pretend this class is templated, because the C++ version is

binaryninja.collaboration.util.nop

Function that just returns True, used as default for callbacks

binaryninja.collaboration.util.split_progress

Split a single progress function into equally sized subparts. This function takes the original…

binaryninja.collaboration.util.wrap_conflict_handler

Wraps a conflict handler function in a ConflictHandler object so you can be lazy and just use a…

binaryninja.collaboration.util.wrap_name_changeset

Wraps a changeset naming function in a ctypes function for passing to the FFI

binaryninja.collaboration.util.wrap_progress

Wraps a progress function in a ctypes function for passing to the FFI

LazyT

class LazyT[source]

Bases: object

Lazily loaded objects (but FFI) Pretend this class is templated, because the C++ version is

__init__(ctor: Callable[[], object] | None = None, handle=None)[source]

Create a new LazyT that will be initialized with the result of the given function, when it is first needed.

Parameters:
  • ctor (Callable[[], object] | None) – Function to construct object

  • handle – FFI handle for internal use

get(expected_type=<class 'object'>)[source]

Access the lazily loaded object. Will construct it if this is the first usage.

Parameters:

expected_type – Expected type of result, ctypes will try to cast to it

Returns:

Result object

nop

class nop[source]

Bases:

Function that just returns True, used as default for callbacks

Returns:

True

split_progress

class split_progress[source]

Bases:

Split a single progress function into equally sized subparts. This function takes the original progress function and returns a new function whose signature is the same but whose output is shortened to correspond to the specified subparts.

The length of a subpart is proportional to the sum of all the weights. E.g. If subpart = 1 and subpartWeights = { 0.25, 0.5, 0.25 }, this will return a function that calls progress_func and maps its progress to the range [0.25, 0.75]

Internally this works by calling progress_func with total = 1000000 and doing math on the current value

Parameters:
  • progress_func – Original progress function (usually updates a UI)

  • subpart – Index of subpart whose function to return, from 0 to (subpartWeights.size() - 1)

  • subpart_weights – Weights of subparts, described above

Returns:

A function that will call progress_func() within a modified progress region

wrap_conflict_handler

class wrap_conflict_handler[source]

Bases:

Wraps a conflict handler function in a ConflictHandler object so you can be lazy and just use a lambda

Parameters:

handler – Python conflict handler function

Returns:

Wrapped ConflictHandler object

wrap_name_changeset

class wrap_name_changeset[source]

Bases:

Wraps a changeset naming function in a ctypes function for passing to the FFI

Parameters:

name_changeset_func – Python changeset naming function

Returns:

Wrapped ctypes function

wrap_progress

class wrap_progress[source]

Bases:

Wraps a progress function in a ctypes function for passing to the FFI

Parameters:

progress_func – Python progress function

Returns:

Wrapped ctypes function