Skip to content

parsedmarc.source.util 🔗

Utitily Sources

These Sources are not intended to be used in production.

MalformedAggregateReportGenerator 🔗

MalformedAggregateReportGenerator(
    name: str = "default",
    parser: ReportParser | None = None,
    config: dict[str, Any] | None = None,
)

Bases: UtilitySource

Source that produces malformed AggregateReports

Useful for testing.

New in 9.0.

PARAMETER DESCRIPTION
name

profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces

TYPE: str DEFAULT: 'default'

parser

parser to use when generating reports

TYPE: ReportParser | None DEFAULT: None

config

config for this instance

TYPE: dict[str, Any] | None DEFAULT: None

outstanding_jobs property 🔗

outstanding_jobs: MappingProxyType[str, Job]

Read only view of outstanding jobs

state property 🔗

state: AppState

Read only Source state

ack_job 🔗

ack_job(job: Job, status: JobStatus) -> None

Acknowledge a completed job

Child classes should override this method to implement their own logic.

Child classes MUST still call super().ack_job(job, status).

PARAMETER DESCRIPTION
job

the job to acknowledge

TYPE: Job

status

indicates how the job was processed

TYPE: JobStatus

cleanup 🔗

cleanup() -> None

Perform cleanup on this source.

This method is called as a part of self.shutdown.

Child classes can override this method to implement their own logic. It is still recomended to call super().cleanup().

register_job 🔗

register_job(job: Job) -> None

Register a job to this source so we can keep track of it

PARAMETER DESCRIPTION
job

the job to register

TYPE: Job

setup 🔗

setup() -> None

Perform setup actions to ensure this Source is ready to produce.

Child classes can override this method to implement their own logic.

Child classes should
  • check that self._state == AppState.SHUTDOWN
  • set self._state = AppState.SETTING_UP
  • do their setup actions
  • if an error occurs set self._state = AppState.SETUP_ERROR
  • otherwise set self._state = AppState.RUNNING

shutdown 🔗

shutdown(
    timeout: int | float = 120, force: bool = False
) -> None

Attempt to gracefully shutdown this source.

PARAMETER DESCRIPTION
timeout

Giveup after this many seonds (TODO)

TYPE: int | float DEFAULT: 120

force

If a timeout would occur, instead force shutdown.

TYPE: bool DEFAULT: False

sleep 🔗

sleep() -> None

Sleep for the configured time

validate_config 🔗

validate_config() -> None

Validate the config of this instance

Child classes can override this method to implement their own logic. It is still recomended to call super().validate_config().

MalformedForensicReportGenerator 🔗

MalformedForensicReportGenerator(
    name: str = "default",
    parser: ReportParser | None = None,
    config: dict[str, Any] | None = None,
)

Bases: UtilitySource

Source that produces malformed ForensicReports

Useful for testing.

New in 9.0.

PARAMETER DESCRIPTION
name

profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces

TYPE: str DEFAULT: 'default'

parser

parser to use when generating reports

TYPE: ReportParser | None DEFAULT: None

config

config for this instance

TYPE: dict[str, Any] | None DEFAULT: None

outstanding_jobs property 🔗

outstanding_jobs: MappingProxyType[str, Job]

Read only view of outstanding jobs

state property 🔗

state: AppState

Read only Source state

ack_job 🔗

ack_job(job: Job, status: JobStatus) -> None

Acknowledge a completed job

Child classes should override this method to implement their own logic.

Child classes MUST still call super().ack_job(job, status).

PARAMETER DESCRIPTION
job

the job to acknowledge

TYPE: Job

status

indicates how the job was processed

TYPE: JobStatus

cleanup 🔗

cleanup() -> None

Perform cleanup on this source.

This method is called as a part of self.shutdown.

Child classes can override this method to implement their own logic. It is still recomended to call super().cleanup().

register_job 🔗

register_job(job: Job) -> None

Register a job to this source so we can keep track of it

PARAMETER DESCRIPTION
job

the job to register

TYPE: Job

setup 🔗

setup() -> None

Perform setup actions to ensure this Source is ready to produce.

Child classes can override this method to implement their own logic.

Child classes should
  • check that self._state == AppState.SHUTDOWN
  • set self._state = AppState.SETTING_UP
  • do their setup actions
  • if an error occurs set self._state = AppState.SETUP_ERROR
  • otherwise set self._state = AppState.RUNNING

shutdown 🔗

shutdown(
    timeout: int | float = 120, force: bool = False
) -> None

Attempt to gracefully shutdown this source.

PARAMETER DESCRIPTION
timeout

Giveup after this many seonds (TODO)

TYPE: int | float DEFAULT: 120

force

If a timeout would occur, instead force shutdown.

TYPE: bool DEFAULT: False

sleep 🔗

sleep() -> None

Sleep for the configured time

validate_config 🔗

validate_config() -> None

Validate the config of this instance

Child classes can override this method to implement their own logic. It is still recomended to call super().validate_config().

RandomAggregateReportGenerator 🔗

RandomAggregateReportGenerator(
    name: str = "default",
    parser: ReportParser | None = None,
    config: dict[str, Any] | None = None,
)

Bases: UtilitySource

Source that produces random AggregateReports

Useful for testing.

Note: reports are randomly generates which means that although unlikely it is possible that duplicate reports will be generated.

New in 9.0.

PARAMETER DESCRIPTION
name

profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces

TYPE: str DEFAULT: 'default'

parser

parser to use when generating reports

TYPE: ReportParser | None DEFAULT: None

config

config for this instance

TYPE: dict[str, Any] | None DEFAULT: None

outstanding_jobs property 🔗

outstanding_jobs: MappingProxyType[str, Job]

Read only view of outstanding jobs

state property 🔗

state: AppState

Read only Source state

ack_job 🔗

ack_job(job: Job, status: JobStatus) -> None

Acknowledge a completed job

Child classes should override this method to implement their own logic.

Child classes MUST still call super().ack_job(job, status).

PARAMETER DESCRIPTION
job

the job to acknowledge

TYPE: Job

status

indicates how the job was processed

TYPE: JobStatus

cleanup 🔗

cleanup() -> None

Perform cleanup on this source.

This method is called as a part of self.shutdown.

Child classes can override this method to implement their own logic. It is still recomended to call super().cleanup().

register_job 🔗

register_job(job: Job) -> None

Register a job to this source so we can keep track of it

PARAMETER DESCRIPTION
job

the job to register

TYPE: Job

setup 🔗

setup() -> None

Perform setup actions to ensure this Source is ready to produce.

Child classes can override this method to implement their own logic.

Child classes should
  • check that self._state == AppState.SHUTDOWN
  • set self._state = AppState.SETTING_UP
  • do their setup actions
  • if an error occurs set self._state = AppState.SETUP_ERROR
  • otherwise set self._state = AppState.RUNNING

shutdown 🔗

shutdown(
    timeout: int | float = 120, force: bool = False
) -> None

Attempt to gracefully shutdown this source.

PARAMETER DESCRIPTION
timeout

Giveup after this many seonds (TODO)

TYPE: int | float DEFAULT: 120

force

If a timeout would occur, instead force shutdown.

TYPE: bool DEFAULT: False

sleep 🔗

sleep() -> None

Sleep for the configured time

validate_config 🔗

validate_config() -> None

Validate the config of this instance

Child classes can override this method to implement their own logic. It is still recomended to call super().validate_config().

RandomForensicReportGenerator 🔗

RandomForensicReportGenerator(
    name: str = "default",
    parser: ReportParser | None = None,
    config: dict[str, Any] | None = None,
)

Bases: UtilitySource

Source that produces random ForensicReports

Useful for testing.

Note: reports are randomly generates which means that although unlikely it is possible that duplicate reports will be generated.

New in 9.0.

PARAMETER DESCRIPTION
name

profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces

TYPE: str DEFAULT: 'default'

parser

parser to use when generating reports

TYPE: ReportParser | None DEFAULT: None

config

config for this instance

TYPE: dict[str, Any] | None DEFAULT: None

outstanding_jobs property 🔗

outstanding_jobs: MappingProxyType[str, Job]

Read only view of outstanding jobs

state property 🔗

state: AppState

Read only Source state

ack_job 🔗

ack_job(job: Job, status: JobStatus) -> None

Acknowledge a completed job

Child classes should override this method to implement their own logic.

Child classes MUST still call super().ack_job(job, status).

PARAMETER DESCRIPTION
job

the job to acknowledge

TYPE: Job

status

indicates how the job was processed

TYPE: JobStatus

cleanup 🔗

cleanup() -> None

Perform cleanup on this source.

This method is called as a part of self.shutdown.

Child classes can override this method to implement their own logic. It is still recomended to call super().cleanup().

register_job 🔗

register_job(job: Job) -> None

Register a job to this source so we can keep track of it

PARAMETER DESCRIPTION
job

the job to register

TYPE: Job

setup 🔗

setup() -> None

Perform setup actions to ensure this Source is ready to produce.

Child classes can override this method to implement their own logic.

Child classes should
  • check that self._state == AppState.SHUTDOWN
  • set self._state = AppState.SETTING_UP
  • do their setup actions
  • if an error occurs set self._state = AppState.SETUP_ERROR
  • otherwise set self._state = AppState.RUNNING

shutdown 🔗

shutdown(
    timeout: int | float = 120, force: bool = False
) -> None

Attempt to gracefully shutdown this source.

PARAMETER DESCRIPTION
timeout

Giveup after this many seonds (TODO)

TYPE: int | float DEFAULT: 120

force

If a timeout would occur, instead force shutdown.

TYPE: bool DEFAULT: False

sleep 🔗

sleep() -> None

Sleep for the configured time

validate_config 🔗

validate_config() -> None

Validate the config of this instance

Child classes can override this method to implement their own logic. It is still recomended to call super().validate_config().

ReportConfig 🔗

Bases: UtilityConfig

Report Config.

New in 9.0.

StaticAggregateReportGenerator 🔗

StaticAggregateReportGenerator(
    name: str = "default",
    parser: ReportParser | None = None,
    config: dict[str, Any] | None = None,
)

Bases: UtilitySource

Source that produces the same AggregateReport every time

Useful for duplicate report testing

Config

report: dict[str, Any]: static report to use instead of the default one.

New in 9.0.

PARAMETER DESCRIPTION
name

profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces

TYPE: str DEFAULT: 'default'

parser

parser to use when generating reports

TYPE: ReportParser | None DEFAULT: None

config

config for this instance

TYPE: dict[str, Any] | None DEFAULT: None

outstanding_jobs property 🔗

outstanding_jobs: MappingProxyType[str, Job]

Read only view of outstanding jobs

state property 🔗

state: AppState

Read only Source state

ack_job 🔗

ack_job(job: Job, status: JobStatus) -> None

Acknowledge a completed job

Child classes should override this method to implement their own logic.

Child classes MUST still call super().ack_job(job, status).

PARAMETER DESCRIPTION
job

the job to acknowledge

TYPE: Job

status

indicates how the job was processed

TYPE: JobStatus

cleanup 🔗

cleanup() -> None

Perform cleanup on this source.

This method is called as a part of self.shutdown.

Child classes can override this method to implement their own logic. It is still recomended to call super().cleanup().

register_job 🔗

register_job(job: Job) -> None

Register a job to this source so we can keep track of it

PARAMETER DESCRIPTION
job

the job to register

TYPE: Job

setup 🔗

setup() -> None

Perform setup actions to ensure this Source is ready to produce.

Child classes can override this method to implement their own logic.

Child classes should
  • check that self._state == AppState.SHUTDOWN
  • set self._state = AppState.SETTING_UP
  • do their setup actions
  • if an error occurs set self._state = AppState.SETUP_ERROR
  • otherwise set self._state = AppState.RUNNING

shutdown 🔗

shutdown(
    timeout: int | float = 120, force: bool = False
) -> None

Attempt to gracefully shutdown this source.

PARAMETER DESCRIPTION
timeout

Giveup after this many seonds (TODO)

TYPE: int | float DEFAULT: 120

force

If a timeout would occur, instead force shutdown.

TYPE: bool DEFAULT: False

sleep 🔗

sleep() -> None

Sleep for the configured time

validate_config 🔗

validate_config() -> None

Validate the config of this instance

Child classes can override this method to implement their own logic. It is still recomended to call super().validate_config().

StaticForensicReportGenerator 🔗

StaticForensicReportGenerator(
    name: str = "default",
    parser: ReportParser | None = None,
    config: dict[str, Any] | None = None,
)

Bases: UtilitySource

Source that produces the same ForensicReport every time

Useful for duplicate report testing

Config

report: dict[str, Any]: static report to use instead of the default one.

New in 9.0.

PARAMETER DESCRIPTION
name

profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces

TYPE: str DEFAULT: 'default'

parser

parser to use when generating reports

TYPE: ReportParser | None DEFAULT: None

config

config for this instance

TYPE: dict[str, Any] | None DEFAULT: None

outstanding_jobs property 🔗

outstanding_jobs: MappingProxyType[str, Job]

Read only view of outstanding jobs

state property 🔗

state: AppState

Read only Source state

ack_job 🔗

ack_job(job: Job, status: JobStatus) -> None

Acknowledge a completed job

Child classes should override this method to implement their own logic.

Child classes MUST still call super().ack_job(job, status).

PARAMETER DESCRIPTION
job

the job to acknowledge

TYPE: Job

status

indicates how the job was processed

TYPE: JobStatus

cleanup 🔗

cleanup() -> None

Perform cleanup on this source.

This method is called as a part of self.shutdown.

Child classes can override this method to implement their own logic. It is still recomended to call super().cleanup().

register_job 🔗

register_job(job: Job) -> None

Register a job to this source so we can keep track of it

PARAMETER DESCRIPTION
job

the job to register

TYPE: Job

setup 🔗

setup() -> None

Perform setup actions to ensure this Source is ready to produce.

Child classes can override this method to implement their own logic.

Child classes should
  • check that self._state == AppState.SHUTDOWN
  • set self._state = AppState.SETTING_UP
  • do their setup actions
  • if an error occurs set self._state = AppState.SETUP_ERROR
  • otherwise set self._state = AppState.RUNNING

shutdown 🔗

shutdown(
    timeout: int | float = 120, force: bool = False
) -> None

Attempt to gracefully shutdown this source.

PARAMETER DESCRIPTION
timeout

Giveup after this many seonds (TODO)

TYPE: int | float DEFAULT: 120

force

If a timeout would occur, instead force shutdown.

TYPE: bool DEFAULT: False

sleep 🔗

sleep() -> None

Sleep for the configured time

validate_config 🔗

validate_config() -> None

Validate the config of this instance

Child classes can override this method to implement their own logic. It is still recomended to call super().validate_config().

UtilityConfig 🔗

Bases: BaseConfig

Utility Config

New in 9.0.

UtilitySource 🔗

UtilitySource(
    name: str = "default",
    parser: ReportParser | None = None,
    config: dict[str, Any] | None = None,
)

Bases: Source

Base class for utility sources.

This class should not be used directly.

Child classes MUST implement self.make_report.

New in 9.0.

PARAMETER DESCRIPTION
name

profile name for this instance, ideally should be unqiue to easily idenfity this instance and any log messages it produces

TYPE: str DEFAULT: 'default'

parser

parser to use when generating reports

TYPE: ReportParser | None DEFAULT: None

config

config for this instance

TYPE: dict[str, Any] | None DEFAULT: None

outstanding_jobs property 🔗

outstanding_jobs: MappingProxyType[str, Job]

Read only view of outstanding jobs

state property 🔗

state: AppState

Read only Source state

ack_job 🔗

ack_job(job: Job, status: JobStatus) -> None

Acknowledge a completed job

Child classes should override this method to implement their own logic.

Child classes MUST still call super().ack_job(job, status).

PARAMETER DESCRIPTION
job

the job to acknowledge

TYPE: Job

status

indicates how the job was processed

TYPE: JobStatus

cleanup 🔗

cleanup() -> None

Perform cleanup on this source.

This method is called as a part of self.shutdown.

Child classes can override this method to implement their own logic. It is still recomended to call super().cleanup().

register_job 🔗

register_job(job: Job) -> None

Register a job to this source so we can keep track of it

PARAMETER DESCRIPTION
job

the job to register

TYPE: Job

setup 🔗

setup() -> None

Perform setup actions to ensure this Source is ready to produce.

Child classes can override this method to implement their own logic.

Child classes should
  • check that self._state == AppState.SHUTDOWN
  • set self._state = AppState.SETTING_UP
  • do their setup actions
  • if an error occurs set self._state = AppState.SETUP_ERROR
  • otherwise set self._state = AppState.RUNNING

shutdown 🔗

shutdown(
    timeout: int | float = 120, force: bool = False
) -> None

Attempt to gracefully shutdown this source.

PARAMETER DESCRIPTION
timeout

Giveup after this many seonds (TODO)

TYPE: int | float DEFAULT: 120

force

If a timeout would occur, instead force shutdown.

TYPE: bool DEFAULT: False

sleep 🔗

sleep() -> None

Sleep for the configured time

validate_config 🔗

validate_config() -> None

Validate the config of this instance

Child classes can override this method to implement their own logic. It is still recomended to call super().validate_config().