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.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
Noneindices 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).