django-spire 0.16.13__py3-none-any.whl → 0.17.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- django_spire/consts.py +1 -1
- django_spire/core/management/commands/spire_startapp.py +84 -46
- django_spire/core/management/commands/spire_startapp_pkg/__init__.py +60 -0
- django_spire/core/management/commands/spire_startapp_pkg/builder.py +91 -0
- django_spire/core/management/commands/spire_startapp_pkg/config.py +115 -0
- django_spire/core/management/commands/spire_startapp_pkg/filesystem.py +125 -0
- django_spire/core/management/commands/spire_startapp_pkg/generator.py +167 -0
- django_spire/core/management/commands/spire_startapp_pkg/maps.py +783 -25
- django_spire/core/management/commands/spire_startapp_pkg/permissions.py +147 -0
- django_spire/core/management/commands/spire_startapp_pkg/processor.py +144 -57
- django_spire/core/management/commands/spire_startapp_pkg/registry.py +89 -0
- django_spire/core/management/commands/spire_startapp_pkg/reporter.py +245 -108
- django_spire/core/management/commands/spire_startapp_pkg/resolver.py +86 -0
- django_spire/core/management/commands/spire_startapp_pkg/user_input.py +252 -0
- django_spire/core/management/commands/spire_startapp_pkg/validator.py +96 -0
- django_spire/core/middleware/__init__.py +1 -2
- django_spire/profiling/__init__.py +13 -0
- django_spire/profiling/middleware/__init__.py +6 -0
- django_spire/{core → profiling}/middleware/profiling.py +63 -58
- django_spire/profiling/panel.py +345 -0
- django_spire/profiling/templates/panel.html +166 -0
- {django_spire-0.16.13.dist-info → django_spire-0.17.0.dist-info}/METADATA +1 -1
- {django_spire-0.16.13.dist-info → django_spire-0.17.0.dist-info}/RECORD +26 -23
- django_spire/core/management/commands/spire_startapp_pkg/constants.py +0 -4
- django_spire/core/management/commands/spire_startapp_pkg/manager.py +0 -176
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/spirechildapp_detail_card.html +0 -24
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/spirechildapp_form_card.html +0 -9
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/card/spirechildapp_list_card.html +0 -18
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/form/spirechildapp_form.html +0 -22
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/item/spirechildapp_item.html +0 -24
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/spirechildapp_detail_page.html +0 -13
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/spirechildapp_form_page.html +0 -13
- django_spire/core/management/commands/spire_startapp_pkg/template/templates/page/spirechildapp_list_page.html +0 -9
- {django_spire-0.16.13.dist-info → django_spire-0.17.0.dist-info}/WHEEL +0 -0
- {django_spire-0.16.13.dist-info → django_spire-0.17.0.dist-info}/licenses/LICENSE.md +0 -0
- {django_spire-0.16.13.dist-info → django_spire-0.17.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from typing import TYPE_CHECKING
|
|
4
|
+
|
|
5
|
+
from django.core.management.base import CommandError
|
|
6
|
+
|
|
7
|
+
if TYPE_CHECKING:
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from django_spire.core.management.commands.spire_startapp_pkg.config import AppConfig, PathConfig
|
|
11
|
+
from django_spire.core.management.commands.spire_startapp_pkg.filesystem import FileSystemInterface
|
|
12
|
+
from django_spire.core.management.commands.spire_startapp_pkg.processor import TemplateProcessor
|
|
13
|
+
from django_spire.core.management.commands.spire_startapp_pkg.reporter import ReporterInterface
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class AppGenerator:
|
|
17
|
+
"""
|
|
18
|
+
Generates Django app structures from templates.
|
|
19
|
+
|
|
20
|
+
This class handles the creation of new Django apps by copying template
|
|
21
|
+
files and processing them with user-provided configuration.
|
|
22
|
+
"""
|
|
23
|
+
|
|
24
|
+
def __init__(
|
|
25
|
+
self,
|
|
26
|
+
filesystem: FileSystemInterface,
|
|
27
|
+
processor: TemplateProcessor,
|
|
28
|
+
reporter: ReporterInterface,
|
|
29
|
+
path_config: PathConfig
|
|
30
|
+
):
|
|
31
|
+
"""
|
|
32
|
+
Initializes the AppGenerator with required dependencies.
|
|
33
|
+
|
|
34
|
+
:param filesystem: File system interface for file operations.
|
|
35
|
+
:param processor: Template processor for replacing placeholders.
|
|
36
|
+
:param reporter: Reporter for user feedback and output.
|
|
37
|
+
:param path_config: Configuration containing template paths.
|
|
38
|
+
"""
|
|
39
|
+
|
|
40
|
+
self._filesystem = filesystem
|
|
41
|
+
self._path_config = path_config
|
|
42
|
+
self._processor = processor
|
|
43
|
+
self._reporter = reporter
|
|
44
|
+
|
|
45
|
+
def generate(self, config: AppConfig) -> None:
|
|
46
|
+
"""
|
|
47
|
+
Generates a new Django app from templates.
|
|
48
|
+
|
|
49
|
+
Creates the app directory, copies template files, and processes
|
|
50
|
+
them with user configuration. Skips generation if the app already exists.
|
|
51
|
+
|
|
52
|
+
:param config: Configuration for the app to generate.
|
|
53
|
+
"""
|
|
54
|
+
|
|
55
|
+
if self._filesystem.has_content(config.destination):
|
|
56
|
+
self._reporter.report_app_exists(config.app_path, config.destination)
|
|
57
|
+
return
|
|
58
|
+
|
|
59
|
+
self._validate_template_exists(self._path_config.app_template, 'app template')
|
|
60
|
+
self._reporter.report_creating_app(config.app_path, config.destination)
|
|
61
|
+
|
|
62
|
+
self._filesystem.create_directory(config.destination)
|
|
63
|
+
self._filesystem.copy_tree(self._path_config.app_template, config.destination)
|
|
64
|
+
|
|
65
|
+
self._processor.process_app_templates(
|
|
66
|
+
config.destination,
|
|
67
|
+
config.components,
|
|
68
|
+
config.user_inputs
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
self._reporter.report_app_creation_success(config.app_path)
|
|
72
|
+
|
|
73
|
+
def _validate_template_exists(self, path: Path, template_type: str) -> None:
|
|
74
|
+
"""
|
|
75
|
+
Validates that a template directory exists.
|
|
76
|
+
|
|
77
|
+
:param path: Path to the template directory.
|
|
78
|
+
:param template_type: Description of the template type for error messages.
|
|
79
|
+
:raises CommandError: If the template directory does not exist.
|
|
80
|
+
"""
|
|
81
|
+
|
|
82
|
+
if not self._filesystem.exists(path):
|
|
83
|
+
self._reporter.write('\n', self._reporter.style_notice)
|
|
84
|
+
|
|
85
|
+
message = (
|
|
86
|
+
f'Template directory "{path}" is missing. '
|
|
87
|
+
f'Ensure you have a valid {template_type}.'
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
raise CommandError(message)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
class TemplateGenerator:
|
|
94
|
+
"""
|
|
95
|
+
Generates HTML templates for Django apps.
|
|
96
|
+
|
|
97
|
+
This class handles the creation of HTML template files including
|
|
98
|
+
forms, cards, pages, and items for new Django apps.
|
|
99
|
+
"""
|
|
100
|
+
|
|
101
|
+
def __init__(
|
|
102
|
+
self,
|
|
103
|
+
filesystem: FileSystemInterface,
|
|
104
|
+
processor: TemplateProcessor,
|
|
105
|
+
reporter: ReporterInterface,
|
|
106
|
+
path_config: PathConfig
|
|
107
|
+
):
|
|
108
|
+
"""
|
|
109
|
+
Initializes the TemplateGenerator with required dependencies.
|
|
110
|
+
|
|
111
|
+
:param filesystem: File system interface for file operations.
|
|
112
|
+
:param processor: Template processor for replacing placeholders.
|
|
113
|
+
:param reporter: Reporter for user feedback and output.
|
|
114
|
+
:param path_config: Configuration containing template paths.
|
|
115
|
+
"""
|
|
116
|
+
|
|
117
|
+
self._filesystem = filesystem
|
|
118
|
+
self._path_config = path_config
|
|
119
|
+
self._processor = processor
|
|
120
|
+
self._reporter = reporter
|
|
121
|
+
|
|
122
|
+
def generate(self, config: AppConfig) -> None:
|
|
123
|
+
"""
|
|
124
|
+
Generates HTML templates for a new Django app.
|
|
125
|
+
|
|
126
|
+
Creates the template directory, copies template files, and processes
|
|
127
|
+
them with user configuration. Skips generation if templates already exist.
|
|
128
|
+
|
|
129
|
+
:param config: Configuration for the templates to generate.
|
|
130
|
+
"""
|
|
131
|
+
|
|
132
|
+
if self._filesystem.has_content(config.template_destination):
|
|
133
|
+
self._reporter.report_templates_exist(config.app_path, config.template_destination)
|
|
134
|
+
return
|
|
135
|
+
|
|
136
|
+
self._validate_template_exists(self._path_config.html_template, 'templates template')
|
|
137
|
+
self._reporter.report_creating_templates(config.app_path, config.template_destination)
|
|
138
|
+
|
|
139
|
+
self._filesystem.create_directory(config.template_destination)
|
|
140
|
+
self._filesystem.copy_tree(self._path_config.html_template, config.template_destination)
|
|
141
|
+
|
|
142
|
+
self._processor.process_html_templates(
|
|
143
|
+
config.template_destination,
|
|
144
|
+
config.components,
|
|
145
|
+
config.user_inputs
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
self._reporter.report_templates_creation_success(config.app_path)
|
|
149
|
+
|
|
150
|
+
def _validate_template_exists(self, path: Path, template_type: str) -> None:
|
|
151
|
+
"""
|
|
152
|
+
Validates that a template directory exists.
|
|
153
|
+
|
|
154
|
+
:param path: Path to the template directory.
|
|
155
|
+
:param template_type: Description of the template type for error messages.
|
|
156
|
+
:raises CommandError: If the template directory does not exist.
|
|
157
|
+
"""
|
|
158
|
+
|
|
159
|
+
if not self._filesystem.exists(path):
|
|
160
|
+
self._reporter.write('\n', self._reporter.style_notice)
|
|
161
|
+
|
|
162
|
+
message = (
|
|
163
|
+
f'Template directory "{path}" is missing. '
|
|
164
|
+
f'Ensure you have a valid {template_type}.'
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
raise CommandError(message)
|