transformer_factory
trestle.transforms.transformer_factory
¤
Define the TransformerFactory and corresponding transformer classes it creates.
Classes¤
FromOscalTransformer
¤
Bases: TransformerBase
Abstract interface for transformers from OSCAL.
Source code in trestle/transforms/transformer_factory.py
49 50 51 52 53 54 |
|
ResultsTransformer
¤
Bases: TransformerBase
Abstract interface for transformers that specifically return Results.
Source code in trestle/transforms/transformer_factory.py
65 66 67 68 69 70 |
|
ToOscalTransformer
¤
Bases: TransformerBase
Abstract interface for transformers to OSCAL.
Source code in trestle/transforms/transformer_factory.py
57 58 59 60 61 62 |
|
TransformerBase
¤
Bases: ABC
Abstract base interface for all transformers.
Source code in trestle/transforms/transformer_factory.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
|
Functions¤
get_timestamp()
staticmethod
¤
Get the default timestamp value.
Source code in trestle/transforms/transformer_factory.py
39 40 41 42 |
|
set_timestamp(value)
staticmethod
¤
Set the default timestamp value.
Source code in trestle/transforms/transformer_factory.py
33 34 35 36 37 |
|
transform(blob)
abstractmethod
¤
Transform the blob into a general OscalBaseModel.
Source code in trestle/transforms/transformer_factory.py
44 45 46 |
|
TransformerFactory
¤
Perform registration and creation of transformers.
Source code in trestle/transforms/transformer_factory.py
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
Functions¤
__init__()
¤
Initialize the transformers dictionary as empty.
Source code in trestle/transforms/transformer_factory.py
76 77 78 |
|
get(name)
¤
Create an instance of the desired transformer based its name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the transformer. |
required |
Returns:
Type | Description |
---|---|
TransformerBase
|
An instance of the desired transformer. |
Raises:
Type | Description |
---|---|
TrestleError
|
if the name does not exist in the registry. |
Source code in trestle/transforms/transformer_factory.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
|
register_transformer(name, transformer)
¤
Register the transformer.
This registers transformers in the factory so they may be created by name.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
The name of the transformer. |
required |
transformer
|
TransformerBase
|
The transformer class to be registered. |
required |
Returns:
Type | Description |
---|---|
None
|
None |
Source code in trestle/transforms/transformer_factory.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
|
handler: python