reporter
django_spire.core.management.commands.spire_startapp_pkg.reporter
Reporter
Handles user interaction and console output for the app creation command.
This class manages all console output including status messages, tree structures, confirmations, and styled text for the app creation process.
Initializes the reporter with a Django management command.
Parameters:
-
command(BaseCommand) –Django BaseCommand instance for accessing stdout and styling.
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
ICON_FILE = '📄'
class-attribute
instance-attribute
ICON_FOLDER_CLOSED = '📁'
class-attribute
instance-attribute
ICON_FOLDER_OPEN = '📂'
class-attribute
instance-attribute
INDENTATION = ' '
class-attribute
instance-attribute
command = command
instance-attribute
style_error = command.style.ERROR
instance-attribute
style_notice = command.style.NOTICE
instance-attribute
style_success = command.style.SUCCESS
instance-attribute
style_warning = command.style.WARNING
instance-attribute
format_app_item
format_html_item
Formats an HTML template file or directory name for display.
Applies variable replacements and removes .template extensions.
Parameters:
-
item(Path) –Path to the item to format.
-
replacement(dict[str, str]) –Dictionary of placeholder replacements.
Returns:
-
str–Formatted item name with placeholders replaced.
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
prompt_confirmation
report_app_creation_success
Reports successful creation of an app.
Parameters:
-
app(str) –Name of the app that was created.
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_app_exists
Reports that an app already exists at the destination.
Parameters:
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_creating_app
Reports that an app is being created.
Parameters:
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_creating_templates
Reports that templates are being created for an app.
Parameters:
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_installed_apps_suggestion
Suggests which app to add to INSTALLED_APPS in settings.py.
Parameters:
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_missing_components
Reports which app components are not yet registered.
Parameters:
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_templates_creation_success
Reports successful creation of templates for an app.
Parameters:
-
app(str) –Name of the app whose templates were created.
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_templates_exist
Reports that templates already exist for an app.
Parameters:
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
report_tree_structure
Displays a tree structure of files and directories that will be created.
Shows a hierarchical view of the app structure with appropriate icons and formatting for files and directories.
Parameters:
-
title(str) –Title to display above the tree structure.
-
base(Path) –Base directory path.
-
components(list[str]) –List of app path components.
-
registry(list[str]) –List of registered apps.
-
template(Path) –Path to template directory.
-
formatter(Callable[[Path], str]) –Function to format item names for display.
-
transformation(Callable[[int, str], str] | None, default:None) –Optional function to transform component names.
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
transform_app_component
Transforms an app component name (default: no transformation).
Parameters:
Returns:
-
str–Transformed component name.
Source code in django_spire/core/management/commands/spire_startapp_pkg/reporter.py
transform_html_component
Transforms an HTML component name (replaces first component with 'templates').
Parameters:
Returns:
-
str–Transformed component name.