Skip to content

analyzer.py

ofrak.component.analyzer

Analyzer (AbstractComponent, Generic, ABC)

Analyzers are discrete components that gather and analyze specific information from the target Resource. Analyzers return custom processed data results.

analyze(self, resource, config) async

Analyze a resource for to extract specific ResourceAttributes.

Users should not call this method directly; rather, they should run Resource.run or Resource.analyze.

Parameters:

Name Type Description Default
resource Resource

The resource that is being analyzed

required
config ~CC

Optional config for analyzing. If an implementation provides a default, this default will always be used when config would otherwise be None. Note that a copy of the default config will be passed, so the default config values cannot be modified persistently by a component run.

required

Returns:

Type Description
~AnalyzerReturnType

The analysis results

Source code in ofrak/component/analyzer.py
@abstractmethod
async def analyze(self, resource: Resource, config: CC) -> AnalyzerReturnType:
    """
    Analyze a resource for to extract specific
    [ResourceAttributes][ofrak.model.resource_model.ResourceAttributes].

    Users should not call this method directly; rather, they should run
    [Resource.run][ofrak.resource.Resource.run] or
    [Resource.analyze][ofrak.resource.Resource.analyze].

    :param resource: The resource that is being analyzed
    :param config: Optional config for analyzing. If an implementation provides a default,
    this default will always be used when config would otherwise be None. Note that a copy of
    the default config will be passed, so the default config values cannot be modified
    persistently by a component run.
    :return: The analysis results
    """
    raise NotImplementedError()

AnalyzerError (RuntimeError)

Base exception raised by analyzers.