queenbee.base.basemodel module¶
Queenbee utility functions.
- class queenbee.base.basemodel.BaseModel(*, type: ~typing.Annotated[str, _PydanticGeneralMetadata(pattern='^BaseModel$')] = 'BaseModel', annotations: ~typing.Dict[str, ~typing.Any] = <factory>)[source]¶
Bases:
BaseModelNoTypeBaseModel with functionality to return the object as a yaml string.
- annotations: Dict[str, Any]¶
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- type: str¶
- class queenbee.base.basemodel.BaseModelNoType[source]¶
Bases:
BaseModelBaseModel with functionality to return the object as a yaml string.
This BaseModel does not enforce adding a type. This is useful for subclasses in extensions.
- classmethod from_file(filepath)[source]¶
Create a model from a file
- Parameters:
read (filepath {str} -- Path to the file to)
- Returns:
cls – An instance of the pydantic class
- model_config: ClassVar[ConfigDict] = {}¶
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- to_dict(exclude_defaults: bool = False, by_alias: bool = True, exclude_none: bool = False, **kwargs)[source]¶
Get a dictionary from the model
- Keyword Arguments:
their (exclude_defaults {bool} -- Whether to exclude fields that are set to) – default values. (default: {False})
names (by_alias {bool} -- Boolean toggle to use attribute alias or attribute) – as key (default: {True})
- Returns:
dict – A python dictionary representing the model
- to_json(filepath: str, indent: int = None, **kwargs)[source]¶
Write a JSON file of the model
- Parameters:
written (filepath {str} -- Path to the file to be)
- Keyword Arguments:
(default (indent {int} -- indent amount) – {None})
- to_yaml(filepath: str, exclude_defaults: bool = False, exclude_none: bool = True, **kwargs)[source]¶
Write a YAML file of the model
- Parameters:
written (filepath {str} -- Path to the file to be)
- Keyword Arguments:
their (exclude_defaults {bool} -- Whether to exclude fields that are set to)
(default (default values.) – {False})
- yaml(exclude_defaults: bool = False, exclude_none: bool = False, **kwargs)[source]¶
Get a YAML string from the model
- Keyword Arguments:
their (exclude_defaults {bool} -- Whether to exclude fields that are set to)
(default (default values.) – {False})
- Returns:
str – A yaml string representing the model