from textwrap import dedent
from datetime import datetime


def generate_header(model_name: str, use_async: bool) -> str:
    """Generates the header for a Python module.

    Args:
        model_name (str): The name of the system model the header is generated for.
        use_async (bool): True if asynchronous code should be generated, false otherwise.

    Returns:
        str: The Python code for the header.


    """
    return dedent("""\
        # Generated from '{model}' on {date}

        from typing import Tuple

        from toptica.lasersdk.{_async}client import UserLevel
        from toptica.lasersdk.{_async}client import Client

        from toptica.lasersdk.{_async}client import DecopBoolean
        from toptica.lasersdk.{_async}client import DecopInteger
        from toptica.lasersdk.{_async}client import DecopReal
        from toptica.lasersdk.{_async}client import DecopString
        from toptica.lasersdk.{_async}client import DecopBinary

        from toptica.lasersdk.{_async}client import MutableDecopBoolean
        from toptica.lasersdk.{_async}client import MutableDecopInteger
        from toptica.lasersdk.{_async}client import MutableDecopReal
        from toptica.lasersdk.{_async}client import MutableDecopString
        from toptica.lasersdk.{_async}client import MutableDecopBinary

        from toptica.lasersdk.{_async}client import Connection
        from toptica.lasersdk.{_async}client import NetworkConnection
        from toptica.lasersdk.{_async}client import SerialConnection

        from toptica.lasersdk.{_async}client import DecopError
        from toptica.lasersdk.{_async}client import DeviceNotFoundError


        """.format(model=model_name, date=str(datetime.now()), _async='asyncio.' if use_async else ''))