Skip to content

Settings

Settings for SUISA Sendemeldung.

ACR

ACRCloud configuration

Source code in suisa_sendemeldung/settings.py
@ts.settings
class ACR:
    """ACRCloud configuration"""  # noqa: D400, D415

    bearer_token: str = ts.secret(
        help="Bearer token for ACRCloud API access",
        validator=validators.min_len(32),
    )
    project_id: int = ts.option(
        help="Id of the project in ACRCloud",
        validator=validators.ge(0),
    )
    stream_id: str = ts.option(
        help="Id of the stream in ACRCloud",
        validator=validators.min_len(9),
    )

EmailSettings

Email configuration

Source code in suisa_sendemeldung/settings.py
@ts.settings
class EmailSettings:
    """Email configuration"""  # noqa: D400, D415

    sender: str = ts.option(help="the sender of the email", default="")
    to: str = ts.option(help="the recipients of the email", default="")
    server: str = ts.option(help="the smtp server to send the mail with", default="")
    port: int = ts.option(help="the port of the smtp server", default=587)
    username: str = ts.option(
        help="the username to logon to the smtp server (default: email_from)",
        default="",
    )
    password: str = ts.secret(help="the password for the smtp server", default="")
    responsible_email: str = ts.option(
        help="Used to hint whom to contact in the emails text.", default=""
    )
    cc: str = ts.option(help="the cc recipients of the email", default="")
    bcc: str = ts.option(help="the bcc recipients of the email", default="")
    subject: str = ts.option(
        help="""
        Template for subject of the email.

        Placeholders are $station_name, $year and $month.
        """,
        default="SUISA Sendemeldung von $station_name für $year-$month",
        click={"show_default": False},
    )
    text: str = ts.option(
        help="""
        Template for email text.

        Placeholders are $station_name, $month, $year, $previous_year,
        $responsible_email, and $email_footer.
        """,
        default=_EMAIL_TEMPLATE,
        click={"show_default": False},
    )
    footer: str = ts.option(
        help="Footer for the Email",
        default="Email generated by <https://github.com/radiorabe/suisa_sendemeldung>",
        click={"show_default": False},
    )

FileFormat

Bases: StrEnum

File formats for the report.

Source code in suisa_sendemeldung/settings.py
class FileFormat(StrEnum):
    """File formats for the report."""

    xlsx = "xlsx"
    csv = "csv"

FileSettings

File configuration

Source code in suisa_sendemeldung/settings.py
@ts.settings
class FileSettings:
    """File configuration"""  # noqa: D400, D415

    format: FileFormat = ts.option(default=FileFormat.xlsx)
    path: str = ts.option(default="")

IdentifierMode

Bases: StrEnum

Modes for generating the identifier in the report.

Source code in suisa_sendemeldung/settings.py
class IdentifierMode(StrEnum):
    """Modes for generating the identifier in the report."""

    local = "local"
    cridlib = "cridlib"

LocalizationSettings

Localization configuration

Source code in suisa_sendemeldung/settings.py
@ts.settings
class LocalizationSettings:
    """Localization configuration"""  # noqa: D400, D415

    timezone: str = "Europe/Zurich"
    locale: str = "de_CH"

OutputMode

Bases: StrEnum

Output modes for the report.

Source code in suisa_sendemeldung/settings.py
class OutputMode(StrEnum):
    """Output modes for the report."""

    file = "file"
    email = "email"
    stdout = "stdout"

RangeSettings

Configure the range of the report

Source code in suisa_sendemeldung/settings.py
@ts.settings
class RangeSettings:
    """Configure the range of the report"""  # noqa: D400, D415

    last_month: bool = ts.option(
        help="""
        The default is to generate ia report for the full last month,
        use --by-date with --date-start and --date-end for a range
        """,
        default=True,
        click={"param_decls": ("--last-month/--by-date",)},
    )
    start: str = ts.option(
        help="The start date of the interval in format YYYY-MM-DD [env var: SENDEMELDUNG_DATE_START; default: now - 30d]",  # noqa: E501
        default="",
        click={"show_default": False, "show_envvar": False},
    )
    end: str = ts.option(
        help="The end date of the interval in format YYYY-MM-DD [env var: SENDEMELDUNG_DATE_END; default: now]",  # noqa: E501
        default="",
        click={"show_default": False, "show_envvar": False},
    )

Settings

Settings

Source code in suisa_sendemeldung/settings.py
@ts.settings
class Settings:
    """Settings"""  # noqa: D400, D415

    output: OutputMode = ts.option(
        help="How to output the report", default=OutputMode.file
    )
    crid_mode: IdentifierMode = ts.option(
        help="How to generate the identifier in the report",
        default=IdentifierMode.local,
    )

    acr: ACR = ts.option(default=None)
    date: RangeSettings = ts.option(default=RangeSettings())
    station: StationSettings = ts.option(default=StationSettings())
    l10n: LocalizationSettings = ts.option(default=LocalizationSettings())
    file: FileSettings = ts.option(default=FileSettings())
    email: EmailSettings = ts.option(default=EmailSettings())

StationSettings

Basic station information

Source code in suisa_sendemeldung/settings.py
@ts.settings
class StationSettings:
    """Basic station information"""  # noqa: D400, D415

    name: str = ts.option(
        help="Station name, used in output and emails", default="Radio Bern RaBe"
    )
    name_short: str = ts.option(
        help="Shortname for station as used in filenames (locally and in attachment)",
        default="rabe",
    )