Builders

../../_images/ERD_builder.drawio.png


Building from .json files

CRUDableEntityBuilder

class crudcreator.builder.CRUDableEntityBuilder.CRUDableEntityBuilder(
crudable_source: AbstractCRUDableEntityType | None,
)[source]

Enables you to build an entity type.

Parameters:

crudable_source (AbstractCRUDableEntityType | None) –

async from_file(
file_path: str,
subs_index: dict[str, Any],
addon_source: dict[str, Type[AbstractCRUDableEntityTypeSource]],
addon_proxy: dict[str, Type[AbstractCRUDableEntityTypeProxy]],
)[source]

Builds an entity type from a .json file that lists the source and proxies.

Parameters:
  • file_path (str) – The path to the .json file

  • subs_index (dict[str, Any]) – An index that indicates the corresponding Python object for variables in descriptors.

  • addon_source (dict[str, Type[AbstractCRUDableEntityTypeSource]]) – An index of the library user’s custom source modules.

  • addon_proxy (dict[str, Type[AbstractCRUDableEntityTypeProxy]]) – An index of the library user’s custom proxy modules.

get_built_entity() AbstractCRUDableEntityType[source]

Returns the constructed entity.

Return type:

AbstractCRUDableEntityType

SetBuilder

class crudcreator.builder.SetBuilder.SetBuilder[source]

Allows multiple entity types to be constructed. Useful when entities refer to each other.

async build(
list_entity_descriptor: list[EntityDescriptor],
subs_index: dict[str, Any],
addon_source: dict[str, AbstractCRUDableEntityTypeSource],
addon_proxy: dict[str, AbstractCRUDableEntityTypeProxy],
) list[AbstractCRUDableEntityType][source]

Builds multiple entity types from a list of .json files. Stores in an index references as it encounters them, which it merges with subs_index.

Parameters:
  • list_entity_descriptor (list[EntityDescriptor]) – The list of json files.

  • subs_index (dict[str, Any]) – An index that indicates the corresponding Python object for variables in descriptors.

  • addon_source (dict[str, AbstractCRUDableEntityTypeSource]) – An index of the library user’s custom source modules.

  • addon_proxy (dict[str, AbstractCRUDableEntityTypeProxy]) – An index of the library user’s custom proxy modules.

Return type:

list[AbstractCRUDableEntityType]



pydantic model crudcreator.builder.SetBuilder.EntityDescriptor[source]
field export: bool [Required][source]

Should the built entity be returned by the build function?

field path: str [Required][source]

The path of the json file from which to build the entity.

Descriptors

pydantic model crudcreator.AbstractDescriptor.AbstractDescriptor[source]

Describes a module, without having built it. Is an intermediate class used by CRUD constructors to build entity types. Library users should never have to use this class directly.

field addons: dict[str, Type[AbstractCRUDableEntityType]] [Required][source]

Index of personal modules implemented by the crudcreator user.

field name: str [Required][source]

Name of the module to be built.

field params: dict [Required][source]

Parameters of the module to be built.

field subs_index: dict[str, Any] [Required][source]

Index of Python objects associated with variables in the descriptor.

build() AbstractCRUDableEntityType[source]

To be overloaded. Builds the entity type associated with this descriptor.

Return type:

AbstractCRUDableEntityType

get_class() T[source]

Returns the class associated with the descriptor. Fetches the class from the index of modules pre-implemented by crudcreator. Otherwise, search in addons.

Return type:

T

get_index() dict[str, Any][source]

To be overloaded. Must return the index of modules pre-implemented by the library.

Return type:

dict[str, Any]

get_params() U[source]

Builds the parameters associated with the descriptor, after substituting variables with their Python object.

Return type:

U

get_params_class() Type[BaseModel][source]

Returns the pydantic model of the module parameters associated with the descriptor.

Return type:

Type[BaseModel]



pydantic model crudcreator.source.SourceDescriptor.SourceDescriptor[source]
field addons: dict[str, Type[AbstractCRUDableEntityTypeSource]] [Required][source]

Index of personal modules implemented by the crudcreator user.

field interface: dict [Required][source]
build() AbstractCRUDableEntityTypeSource[source]

To be overloaded. Builds the entity type associated with this descriptor.

Return type:

AbstractCRUDableEntityTypeSource

get_index() AbstractCRUDableEntityTypeSource[source]

To be overloaded. Must return the index of modules pre-implemented by the library.

Return type:

AbstractCRUDableEntityTypeSource



pydantic model crudcreator.proxy.ProxyDescriptor.ProxyDescriptor[source]
field addons: dict[str, Type[AbstractCRUDableEntityTypeProxy]] [Required][source]

Index of personal modules implemented by the crudcreator user.

field base: AbstractCRUDableEntityType | None = None[source]

The module for which this descriptor will be the proxy.

build() AbstractCRUDableEntityTypeProxy[source]

Builds the proxy associated with the descriptor.

Return type:

AbstractCRUDableEntityTypeProxy

get_index() AbstractCRUDableEntityTypeProxy[source]

To be overloaded. Must return the index of modules pre-implemented by the library.

Return type:

AbstractCRUDableEntityTypeProxy