Skip to content

reporter

django_spire.core.management.commands.spire_startapp_pkg.reporter

Reporter

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def __init__(self, command: BaseCommand):
    self.command = command

command = command instance-attribute

report_app_tree_structure

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_app_tree_structure(
    self,
    base: Path,
    components: list[str],
    registry: list[str],
    template: Path
) -> None:
    self._report_tree_structure(
        title='\nThe following app(s) will be created:\n\n',
        base=base,
        components=components,
        registry=registry,
        template=template,
        formatter=self._app_formatter,
        transformation=self._app_transformation,
    )

report_html_tree_structure

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_html_tree_structure(
    self,
    base: Path,
    components: list[str],
    registry: list[str],
    template: Path
) -> None:
    replacement = generate_replacement_map(components)

    def html_formatter_with_replacement(item: Path) -> str:
        return self._html_formatter(item, replacement)

    self._report_tree_structure(
        title='\nThe following template(s) will be created:\n\n',
        base=base,
        components=components,
        registry=registry,
        template=template,
        formatter=html_formatter_with_replacement,
        transformation=self._html_transformation,
    )

prompt_for_confirmation

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def prompt_for_confirmation(self, message: str) -> bool:
    return input(message).strip().lower() == 'y'

report_missing_components

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_missing_components(self, missing_components: list[str]) -> None:
    self.command.stdout.write(self.command.style.WARNING('The following are not registered apps:'))
    self.command.stdout.write('\n'.join(f' - {app}' for app in missing_components))

report_installed_apps_suggestion

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_installed_apps_suggestion(self, missing_components: list[str]) -> None:
    self.command.stdout.write(self.command.style.NOTICE('\nPlease add the following to INSTALLED_APPS in settings.py:'))
    self.command.stdout.write(f'\n {missing_components[-1]}')

report_app_creation_success

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_app_creation_success(self, app: str) -> None:
    message = f'Successfully created app: {app}'
    self.write(message, self.command.style.SUCCESS)

report_app_exists

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_app_exists(self, app: str, destination: Path) -> None:
    message = f'The app "{app}" already exists at {destination}'
    self.write(message, self.command.style.WARNING)

report_creating_app

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_creating_app(self, app: str, destination: Path) -> None:
    message = f'Creating app "{app}" at {destination}'
    self.write(message, self.command.style.NOTICE)

report_templates_exist

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_templates_exist(self, app: str, destination: Path) -> None:
    message = f'The templates for app "{app}" already exist at {destination}'
    self.write(message, self.command.style.WARNING)

report_creating_templates

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_creating_templates(self, app: str, destination: Path) -> None:
    message = f'Creating templates for app "{app}" at {destination}'
    self.write(message, self.command.style.NOTICE)

report_templates_creation_success

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def report_templates_creation_success(self, app: str) -> None:
    message = f'Successfully created templates for app: {app}'
    self.write(message, self.command.style.SUCCESS)

write

Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
def write(self, message: str, func: Callable[[str], str]) -> None:
    self.command.stdout.write(func(message))