anyconfig.api._open

A API to open files by detecting those type automatically.

anyconfig.api._open.open(path, mode=None, ac_parser=None, **options)

Open given file path with appropriate open flag.

Parameters:
  • path (Union[str, Path, IO, IOInfo]) – Configuration file path

  • mode (Optional[str]) – Can be ‘r’ and ‘rb’ for reading (default) or ‘w’, ‘wb’ for writing. Please note that even if you specify ‘r’ or ‘w’, it will be changed to ‘rb’ or ‘wb’ if selected backend, xml and configobj for example, for given config file prefer that.

  • options – Optional keyword arguments passed to the internal file opening APIs of each backends such like ‘buffering’ optional parameter passed to builtin ‘open’ function.

Return type:

IO

Returns:

A file object or None on any errors

Raises:

ValueError, UnknownProcessorTypeError, UnknownFileTypeError