queenbee.base.basemodel module

Queenbee utility functions.

class queenbee.base.basemodel.BaseModel(*, type: ConstrainedStrValue = 'BaseModel', annotations: Dict[str, Any] = None)[source]

Bases: BaseModelNoType

BaseModel with functionality to return the object as a yaml string.

annotations: Dict[str, Any]
classmethod ensure_type_match(v)[source]
classmethod replace_none_value(v)[source]
type: ConstrainedStrValue
class queenbee.base.basemodel.BaseModelNoType[source]

Bases: BaseModel

BaseModel 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

to_dict(exclude_unset=False, by_alias=True, **kwargs)[source]

Get a dictionary from the model

Keyword Arguments:
  • values (exclude_unset {bool} -- Boolean toggle to add or remove any unset/None) – (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, indent=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, exclude_unset=False, **kwargs)[source]

Write a YAML file of the model

Parameters:

written (filepath {str} -- Path to the file to be) –

Keyword Arguments:
  • values (exclude_unset {bool} -- Boolean toggle to add or remove any unset/None) –

  • (default – {False})

yaml(exclude_unset=False, **kwargs)[source]

Get a YAML string from the model

Keyword Arguments:
  • values (exclude_unset {bool} -- Boolean toggle to add or remove any unset/None) –

  • (default – {False})

Returns:

str – A yaml string representing the model