anyconfig.ioinfo

ioinfo module to provide functions to create IOInfo objects.

IOInfo objects wrap pathlib.Path and io objects.

Changed in version 0.12.0.

  • Restructure and migrate some utility functions in .utils into this module.

Changed in version 0.10.1.

  • simplify inspect_io_obj and make; detect type in make, remove the member opener from ioinfo object, etc.

New in version 0.9.5.

  • Add functions to make and process input and output object holding some attributes like input and output type (path, stream or pathlib.Path object), path, opener, etc.

class anyconfig.ioinfo.IOInfo(src: Path | IO, type: str, path: str, extension: str)

Bases: NamedTuple

Equivalent to collections.namedtuple.

src: Union[Path, IO]

Alias for field number 0

type: str

Alias for field number 1

path: str

Alias for field number 2

extension: str

Alias for field number 3

anyconfig.ioinfo.is_stream(obj)

Test if given object obj is an IOInfo object with stream type.

Return type:

bool

anyconfig.ioinfo.make(obj)

Make and return a datatypes.IOInfo object from obj.

Return type:

IOInfo

anyconfig.ioinfo.makes(obj, marker='*')

Make and return a list of datatypes.IOInfo objects.

Return type:

List[IOInfo]

anyconfig.ioinfo.get_encoding()

Get the (prefered) encoding or ‘utf-8’.

Return type:

str