dictIO.dictReader module#

class dictIO.dictReader.DictReader#

Bases: object

Reader for dictionaries in dictIO dict 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[str] | None = None, parser: Parser | None = None) CppDict#

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

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

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:

CppDict

Raises:

FileNotFoundError – if source_file does not exist