gtirb.util module
General utilities usable by any other GTIRB submoudle.
-
class gtirb.util.AddrRange(*args, **kwargs)[source]
Bases: Protocol
An object spanning a range of addresses.
-
__init__(*args, **kwargs)
-
__protocol_attrs__ = {'address', 'size'}
-
property address: int | None
-
property size: int | None
-
exception gtirb.util.DeserializationError[source]
Bases: GtirbError
-
gtirb.util.DictLike
Any value that can be passed to the constructor of dict
;
that is, a mapping or iterable yielding key-value tuples.
alias of Union
[Mapping
[K
, V
], Iterable
[Tuple
[K
, V
]]]
-
class gtirb.util.DictWrapper(*args)[source]
Bases: MutableMapping
[K
, V
]
-
__delitem__(i)[source]
- Return type:
None
-
__getitem__(i)[source]
- Return type:
typing.TypeVar
(V
)
-
__init__(*args)[source]
-
__iter__()[source]
- Return type:
typing.Iterator
[typing.TypeVar
(K
)]
-
__len__()[source]
- Return type:
int
-
__setitem__(i, v)[source]
- Return type:
None
-
exception gtirb.util.GtirbError[source]
Bases: Exception
-
class gtirb.util.IndexedContainer(*args, **kwargs)[source]
Bases: Protocol
[T_contra
]
Container wth an index that can be updated.
-
__init__(*args, **kwargs)
-
__protocol_attrs__ = {'_index_add', '_index_discard'}
-
class gtirb.util.ListWrapper(*args)[source]
Bases: MutableSequence
[T
]
-
__delitem__(i)[source]
- Return type:
None
-
__getitem__(i)[source]
- Return type:
typing.Union
[typing.TypeVar
(T
), typing.MutableSequence
[typing.TypeVar
(T
)]]
-
__init__(*args)[source]
-
__len__()[source]
- Return type:
int
-
__setitem__(i, v)[source]
- Return type:
None
-
append(v)[source]
S.append(value) – append value to the end of the sequence
- Return type:
None
-
extend(other)[source]
S.extend(iterable) – extend sequence by appending elements from the iterable
- Return type:
None
-
insert(i, v)[source]
S.insert(index, value) – insert value before index
- Return type:
None
-
remove(v)[source]
S.remove(value) – remove first occurrence of value.
Raise ValueError if the value is not present.
- Return type:
None
-
class gtirb.util.OffsetRange(*args, **kwargs)[source]
Bases: Protocol
An object spanning a range of offsets.
-
__init__(*args, **kwargs)
-
__protocol_attrs__ = {'offset', 'size'}
-
property offset: int
-
property size: int
-
class gtirb.util.ParentGetter(*args, **kwargs)[source]
Bases: Protocol
[T_contra
]
Interface for getting an _IndexedContainer for an instance.
-
__call__(instance)[source]
Call self as a function.
- Return type:
typing.Optional
[gtirb.util.IndexedContainer
[typing.TypeVar
(T_contra
, contravariant=True)]]
-
__init__(*args, **kwargs)
-
__protocol_attrs__ = {'__call__'}
-
class gtirb.util.SetWrapper(*args)[source]
Bases: MutableSet
[T
]
-
__contains__(v)[source]
- Return type:
bool
-
__init__(*args)[source]
-
__ior__(other)[source]
- Return type:
typing.TypeVar
(_SetWrapperSelf
, bound= SetWrapper[typing.Any])
-
__iter__()[source]
- Return type:
typing.Iterator
[typing.TypeVar
(T
)]
-
__len__()[source]
- Return type:
int
-
__or__(other)[source]
- Return type:
typing.Set
[typing.Union
[typing.TypeVar
(T
), typing.TypeVar
(S
)]]
-
add(v)[source]
Add an element.
- Return type:
None
-
clear()[source]
This is slow (creates N new iterators!) but effective.
- Return type:
None
-
discard(v)[source]
Remove an element. Do not raise an exception if absent.
- Return type:
None
-
pop()[source]
Return the popped value. Raise KeyError if empty.
- Return type:
typing.TypeVar
(T
)
-
update(*others)[source]
- Return type:
None
-
gtirb.util.get_desired_range(addrs)[source]
- Return type:
range
-
gtirb.util.nodes_at(nodes, addrs)[source]
- Return type:
typing.Iterable
[typing.TypeVar
(AddrRangeT
, bound= gtirb.util.AddrRange
)]
-
gtirb.util.nodes_on(nodes, addrs)[source]
- Return type:
typing.Iterable
[typing.TypeVar
(AddrRangeT
, bound= gtirb.util.AddrRange
)]
-
gtirb.util.symbolic_expressions_at(nodes, addrs)[source]
- Return type:
typing.Iterable
[typing.TypeVar
(T_cov
, covariant=True)]