DictReader

class dictIO.dict_reader.DictReader

Bases: object

Reader for dictionaries in dictIO native file format, as well as JSON and XML.

__init__() None

Methods

__init__()

read(source_file, *[, includes, order, ...])

Read a dictionary file in dictIO native file format, as well as JSON and XML.

static read(source_file: str | PathLike[str], *, includes: bool = True, order: bool = False, comments: bool = True, scope: MutableSequence[Any] | None = None, parser: Parser | None = None) SDict[Any, Any]

Read a dictionary file in dictIO native file format, as well as JSON and XML.

Reads a dict file, parses it and transforms its content into a dictIO dict object (SDict). Following file formats are supported and interpreted through source_file’s file ending: no file ending -> dictIO native dict file ‘.cpp’ -> dictIO native dict file ‘.foam’ -> Foam dictionary file ‘.json’ -> Json dictionary file ‘.xml’ -> XML file Return type is in all cases SDict

Parameters:
  • source_file (Union[str, os.PathLike[str]]) – dict file to be read

  • includes (bool, optional) – merge sub-dicts being referenced through #include directives, by default True

  • order (bool, optional) – sort the read dict, by default False

  • comments (bool, optional) – reads comments from source file, by default True

  • scope (MutableSequence[str], optional) – scope the dict will be reduced to after reading, by default None

  • parser (Parser, optional) – Parser object to be used, by default None

Returns:

the read dict

Return type:

SDict[Any, Any]

Raises:

FileNotFoundError – if source_file does not exist