discodop.util

Misc code to avoid cyclic imports.

Functions

ishead(tree) Test whether this node is the head of the parent constituent.
openread(filename[, encoding]) Open stdin/text file for reading; decompress .gz files on-the-fly.
slice_bounds(seq, slice_obj[, allow_step]) Calculate the effective (start, stop) bounds of a slice.
which(program) Return first match for program in search path.
workerfunc(func) Wrap a multiprocessing worker function to produce a full traceback.

Classes

OrderedSet([iterable]) A frozen, ordered set which maintains a regular list/tuple and set.
discodop.util.ishead(tree)[source]

Test whether this node is the head of the parent constituent.

discodop.util.which(program)[source]

Return first match for program in search path.

discodop.util.workerfunc(func)[source]

Wrap a multiprocessing worker function to produce a full traceback.

discodop.util.openread(filename, encoding='utf8')[source]

Open stdin/text file for reading; decompress .gz files on-the-fly.

discodop.util.slice_bounds(seq, slice_obj, allow_step=False)[source]

Calculate the effective (start, stop) bounds of a slice.

Takes into account None indices and negative indices.

Returns:tuple (start, stop, 1), s.t. 0 <= start <= stop <= len(seq)
Raises:ValueError – if slice_obj.step is not None.
Parameters:allow_step – If true, then the slice object may have a non-None step. If it does, then return a tuple (start, stop, step).
class discodop.util.OrderedSet(iterable=None)[source]

A frozen, ordered set which maintains a regular list/tuple and set.

The set is indexable. Equality is defined _without_ regard for order.