pocketutils.core.input_output

Module Contents

class pocketutils.core.input_output.DevNull

Pretends to write but doesn’t.

class pocketutils.core.input_output.LogWriter(level: Union[int, str])

A call to a logger at some level, pretending to be a writer. Has a write method, as well as flush and close methods that do nothing.

class pocketutils.core.input_output.Capture(cio)

A lazy string-like object that wraps around a StringIO result. It’s too hard to fully subclass a string while keeping it lazy.

class pocketutils.core.input_output.OpenMode(mode: str)

Extended file open modes with a superset of meanings. The underlying string contains a Python open()-compatible string.

  • ‘r’ means read

  • ‘w’ and ‘o’ both mean overwrite

  • ‘a’ means append

  • ‘x’ means “safe” – complain if it exists (neither overwrite nor append)

  • ‘b’ means binary

  • ‘z’ means compressed with gzip; works in both binary and text modes

  • ‘d’ means detect gzip

Initialize self. See help(type(self)) for accurate signature.