class documentation

class Importer:

View In Hierarchy

Importer class to import various objects, configurations etc.

It is mainly run before the CSE is actually started or restarted.

Method assignAttributePolicies Assign the imported attribute policies to each of the resources. This injects the imported attribute policies into all the Python Resource classes.
Method importAttributePolicies Import the resource attribute policies.
Method importConfigDocs Import the configuration documentation from the resource path.
Method importEnumPolicies Import the enumeration types policies.
Method importFlexContainerPolicies Import the attribute and hierarchy policies for flexContainer specializations.
Method importPolicies Import the attribute, enum, flexContainer policies, and documentation.
Method importResourcePolicies Import the resource type policies from the resource paths.
Method importScripts Import the scripts from the resource path and additional directories specified in the configuration.
Method initialize Initialization of an Importer instance.
Method readJSONFromFile Read and parse a JSON data structure from a file filename.
Method removePolicyImports Remove all previous imported scripts and definitions.
Method removeScripts Internally remove all imported scripts.
Method replaceMacro No summary
Class Variable __slots__ Slots for Importer class.
Class Variable dispatcher Injected Dispatcher instance.
Class Variable factory Injected Factory instance.
Class Variable scriptManager ScriptManager instance.
Class Variable validator Injected Validator instance.
Instance Variable extendedScriptPaths Extended list of script paths, which is used for importing scripts.
Instance Variable isImporting Boolean flag to indicate whether the importer is currently importing resources.
Instance Variable macroMatch Regular expression to match macros in scripts.
Instance Variable resourcePath Path to the directory from where to import resources, policies, scripts etc.
Instance Variable rtDir Path to the directory from where to import additional resources, policies, scripts etc.
Method _expandEnumValues Expand an enum values list by parsing the range definitions and return a list of integer values.
Method _finishImporting Finish the importing process, e.g. re-enable access control.
Method _parseAttribute Parse a single attribute definitions for common as well as for flexContainer attributes.
Method _prepareImporting Prepare the importing process.
Class Variable _enumValues Imported enumeration values.
Instance Variable _oldEnabbleAcpChecks Used to store the old value of the enableAcpChecks configuration setting during importing.
def assignAttributePolicies(self) -> bool:

Assign the imported attribute policies to each of the resources. This injects the imported attribute policies into all the Python Resource classes.

Returns
boolTrue if there were no errors during the assignment, False otherwise.
def importAttributePolicies(self, path: str) -> bool:

Import the resource attribute policies.

Parameters
path:strPath to a directory from where to import attribute policies.
Returns
boolTrue if the policies were successfully imported, False otherwise.
def importConfigDocs(self) -> bool:

Import the configuration documentation from the resource path.

Returns
boolTrue if the documentation was successfully imported, False otherwise.
def importEnumPolicies(self, path: str) -> bool:

Import the enumeration types policies.

Parameters
path:strPath to a directory from where to import enumeration policies.
Returns
boolTrue if the policies were successfully imported, False otherwise.
def importFlexContainerPolicies(self, path: str) -> bool:

Import the attribute and hierarchy policies for flexContainer specializations.

Parameters
path:strPath to a directory from where to import flexContainer policies.
Returns
boolTrue if the policies were successfully imported, False otherwise.
def importPolicies(self) -> bool:

Import the attribute, enum, flexContainer policies, and documentation.

Returns
boolBoolean indicating success or failure
def importResourcePolicies(self):

Import the resource type policies from the resource paths.

def importScripts(self) -> bool:

Import the scripts from the resource path and additional directories specified in the configuration.

def initialize(self):

Initialization of an Importer instance.

def readJSONFromFile(self, filename: str) -> JSON | JSONLIST | None:

Read and parse a JSON data structure from a file filename.

Parameters
filename:strThe full filename of the input file.
Returns
JSON | JSONLIST | NoneReturn the parsed structure, or None in case of an error.
def removePolicyImports(self):

Remove all previous imported scripts and definitions.

def removeScripts(self):

Internally remove all imported scripts.

def replaceMacro(self, macro: str, filename: str) -> str:
__slots__: tuple[str, ...] =

Slots for Importer class.

dispatcher: Dispatcher =

Injected Dispatcher instance.

factory: Factory =

Injected Factory instance.

scriptManager: ScriptManager =

ScriptManager instance.

validator: Validator =

Injected Validator instance.

extendedScriptPaths: list[str] =

Extended list of script paths, which is used for importing scripts.

isImporting: bool =

Boolean flag to indicate whether the importer is currently importing resources.

macroMatch =

Regular expression to match macros in scripts.

resourcePath =

Path to the directory from where to import resources, policies, scripts etc.

rtDir =

Path to the directory from where to import additional resources, policies, scripts etc.

def _expandEnumValues(self, evalues: list[int | str], typeShortname: str, fn: str) -> list[int] | None:

Expand an enum values list by parsing the range definitions and return a list of integer values.

Parameters
evalues:list[int | str]A list of integer values or range definitions (e.g. "1..10") to expand.
typeShortname:strThe type and attribute name (for logging purposes).
fn:strThe filename where the enum values are defined (for logging purposes).
Returns
list[int] | NoneA list of integer values, or None in case of an error.
def _finishImporting(self):

Finish the importing process, e.g. re-enable access control.

def _parseAttribute(self, attr: JSON, fn: str, typeShortname: str | None = None, sname: str | None = None, checkListType: bool | None = True) -> AttributePolicy | None:

Parse a single attribute definitions for common as well as for flexContainer attributes.

Parameters
attr:JSONJSON dictionary with the attribute definition to parse.
fn:strFilename that contains the attribute definition.
typeShortname:str | NoneDomain and attribute name. Mandatory for a flexContainer specialization, optional otherwise.
sname:str | NoneShortname of the attribute.
checkListType:bool | NoneUndocumented
Returns
AttributePolicy | NoneThe parsed definition in an AttributePolicy.
def _prepareImporting(self):

Prepare the importing process.

_enumValues: dict[str, dict[int, str]] =

Imported enumeration values.

_oldEnabbleAcpChecks: bool | None =

Used to store the old value of the enableAcpChecks configuration setting during importing.