gemseo.core.grammars.factory module#
A factory to instantiate a derived class of BaseGrammar
.
- class GrammarFactory[source]#
Bases:
BaseFactory
[BaseGrammar
]A factory of
BaseGrammar
.- Return type:
Any
- create(class_name, name, search_file=False, discipline_class=None, directory_path='', file_name_suffix='', **options)[source]#
Create a grammar.
- Parameters:
class_name (str) -- The name of a class deriving from
BaseGrammar
.name (str) -- The name to be given to the grammar.
search_file (bool) --
Whether to search for a JSON grammar file. This argument is considered to be
False
when the optionfile_path
is given.By default it is set to False.
discipline_class (type[Discipline] | None) -- The class of the discipline used for searching the grammar in the parent classes. This argument is used when
search_file
isTrue
.directory_path (Path | str) --
The path to the directory where to search for JSON grammar files. This argument is used when
search_file
isTrue
.By default it is set to "".
file_name_suffix (str) --
The suffix of the JSON grammar file. This argument is used when
search_file
isTrue
.By default it is set to "".
**options (Any) -- The options to be passed to the initialization.
- Returns:
The instance of the class.
- Raises:
TypeError -- If the class cannot be instantiated.
- Return type: