erdantic.plugins¶
ModelFieldExtractor
¶
Bases: Protocol[_ModelType_contra]
Protocol class for a field extractor function for a plugin.
Source code in erdantic/plugins/__init__.py
43 44 45 46 |
|
ModelPredicate
¶
Bases: Protocol[_ModelType_co]
Protocol class for a predicate function for a plugin.
Source code in erdantic/plugins/__init__.py
37 38 39 40 |
|
get_field_extractor_fn
¶
get_field_extractor_fn(key: str) -> ModelFieldExtractor
Get the field extractor function for a plugin by its key.
Source code in erdantic/plugins/__init__.py
85 86 87 88 89 90 |
|
get_predicate_fn
¶
get_predicate_fn(key: str) -> ModelPredicate
Get the predicate function for a plugin by its key.
Source code in erdantic/plugins/__init__.py
77 78 79 80 81 82 |
|
identify_field_extractor_fn
¶
identify_field_extractor_fn(
tp: type,
) -> Optional[ModelFieldExtractor]
Identify the field extractor function for a model type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tp |
type
|
A type annotation. |
required |
Returns:
Type | Description |
---|---|
ModelFieldExtractor | None
|
The field extractor function for a known model type, or None if the model type is not recognized by any registered plugins. |
Source code in erdantic/plugins/__init__.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
|
list_plugins
¶
List the keys of all registered plugins.
Source code in erdantic/plugins/__init__.py
72 73 74 |
|
register_plugin
¶
register_plugin(
key: str,
predicate_fn: ModelPredicate[_ModelType],
get_fields_fn: ModelFieldExtractor[_ModelType],
)
Register a plugin for a specific model class type.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
An identifier for this plugin. |
required |
predicate_fn |
ModelPredicate
|
A predicate function to determine if an object is a class of the model that is supported by this plugin. |
required |
get_fields_fn |
ModelFieldExtractor
|
A function to extract fields from a model class that is supported by this plugin. |
required |
Source code in erdantic/plugins/__init__.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
|