Skip to content

Formatters

mongorunway.presentation.formatters ¤

__all__: typing.Sequence[str] = ('format_auditlog_entry', 'format_app_date') module-attribute ¤

format_app_date(application, date_parts) ¤

Source code in mongorunway\presentation\formatters.py
def format_app_date(
    application: applications.MigrationApp,
    date_parts: typing.Optional[typing.Sequence[str]],
) -> typing.Optional[datetime.datetime]:
    if date_parts is None:
        return None

    return datetime.datetime.strptime(
        " ".join(date_parts),
        application.session.session_date_format,
    )

format_auditlog_entry(entry) ¤

Source code in mongorunway\presentation\formatters.py
def format_auditlog_entry(
    entry: domain_auditlog_entry.MigrationAuditlogEntry, /
) -> typing.Sequence[str]:
    migration = entry.migration_read_model

    failed_msg = "False"
    if entry.is_failed():
        failed_msg = f"Error: {entry.exc_name}\nMessage: {entry.exc_message}"

    return [
        entry.format_date(),
        failed_msg,
        entry.transaction_name,
        f"Name: {migration.name}\n"
        f"Version: {migration.version}\n"
        f"Is applied: {migration.is_applied}\n",
    ]