sec_parser.utils
The utils subpackage contains utility functions and helpers used across the sec_parser project.
Subpackages
Submodules
Exceptions
Inappropriate argument value (of correct type). |
Functions
|
is_unary_tree determines if a BeautifulSoup tag forms a unary tree. |
|
|
Given a class, find the class that is one step below |
Package Contents
- sec_parser.utils.is_unary_tree(tag: bs4.Tag) bool
is_unary_tree determines if a BeautifulSoup tag forms a unary tree. In a unary tree, each node has at most one child.
Unary trees can contain NavigableString leaves. However, if a non-leaf node contains a non-empty NavigableString, the tree is not considered unary.
Additionally, if the some tag is a ‘table’, the function will return True regardless of its children. This is because in the context of this application, ‘table’ tags are always considered unary.
- exception sec_parser.utils.ValueNotSetError
Bases:
ValueErrorInappropriate argument value (of correct type).
- sec_parser.utils.get_value_or_env_var(value: str | None, env_var: str, default: str | None = None, exc: type[Exception] = ValueNotSetError) str
- sec_parser.utils.get_direct_subclass_of_base_class(cls: type, base_class: type) type
Given a class, find the class that is one step below the specified base_class in its inheritance hierarchy.