trestle.core.parser
trestle.core.parser
¤
Model parsing for use when models themselves must be inferred and are not known.
Under most use cases trestle.core.base_model.OscalBaseModel provides functionality for loading Oscal models from files. However, under some circumstances the model internals are unknown. Use of this module should be avoided unless the BaseModel functionality is inadequate.
Attributes¤
logger = logging.getLogger(__name__)
module-attribute
¤
Classes¤
Functions¤
parse_dict(data, model_name)
¤
Load a model from the data dict.
This functionality is provided for situations when the OSCAL data type is not known ahead of time. Here the model has been loaded into memory using json loads or similar and passed as a dict.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data | Dict[str, Any] | Oscal data loaded into memory as a dictionary with the | required |
model_name | str | should be of the form 'module.class' from trestle.oscal.* modules | required |
Returns:
Type | Description |
---|---|
OscalBaseModel | The oscal model of the desired model. |
Source code in trestle/core/parser.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
root_key(data)
¤
Find root model name in the data.
Source code in trestle/core/parser.py
67 68 69 70 71 72 |
|
to_full_model_name(root_key)
¤
Find model name from the root_key in the file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
root_key | str | root key such as 'system-security-plan' from a top level OSCAL model. | required |
Source code in trestle/core/parser.py
75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
handler: python