componentsDjangoType 0.0.1__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- componentsDjangoType-0.0.1.dist-info/LICENSE +21 -0
- componentsDjangoType-0.0.1.dist-info/METADATA +24 -0
- componentsDjangoType-0.0.1.dist-info/RECORD +9 -0
- componentsDjangoType-0.0.1.dist-info/WHEEL +5 -0
- componentsDjangoType-0.0.1.dist-info/top_level.txt +1 -0
- settings/__init__.py +0 -0
- settings/management/__init__.py +0 -0
- settings/management/commands/__init__.py +0 -0
- settings/management/commands/createcomponent.py +57 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 Alejandro Rivas
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: componentsDjangoType
|
3
|
+
Version: 0.0.1
|
4
|
+
Summary: A Django app for creating HTML components
|
5
|
+
Home-page: https://github.com/jose-CR/componentsDjangoType
|
6
|
+
Author: Alejandro
|
7
|
+
Author-email: your-email@example.com
|
8
|
+
License: MIT
|
9
|
+
Platform: UNKNOWN
|
10
|
+
Classifier: Environment :: Web Environment
|
11
|
+
Classifier: Framework :: Django
|
12
|
+
Classifier: Intended Audience :: Developers
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
14
|
+
Classifier: Operating System :: OS Independent
|
15
|
+
Classifier: Programming Language :: Python
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
17
|
+
Classifier: Programming Language :: Python :: 3.7
|
18
|
+
Classifier: Framework :: Django :: 3.2
|
19
|
+
Description-Content-Type: text/markdown
|
20
|
+
License-File: LICENSE
|
21
|
+
Requires-Dist: Django (>=3.2)
|
22
|
+
|
23
|
+
# componentsDjangotype
|
24
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
settings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
|
+
settings/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
3
|
+
settings/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
settings/management/commands/createcomponent.py,sha256=vJ5FxNkF0fKbd2zlqFgXHBmdXHlrn0RucyCA9U_bSzw,2304
|
5
|
+
componentsDjangoType-0.0.1.dist-info/LICENSE,sha256=9aNimqkKochIjlUq7EEvsikSVUdEwCwwF85TJO7jFBQ,1072
|
6
|
+
componentsDjangoType-0.0.1.dist-info/METADATA,sha256=HwiAWUNiPeRynkABKueyZYrJKY1kUaEit7UQ2r6LKgQ,774
|
7
|
+
componentsDjangoType-0.0.1.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
8
|
+
componentsDjangoType-0.0.1.dist-info/top_level.txt,sha256=wZK3kjBHOHXxWdRCPXTQD32cxOY0Yas7CgQwuGdtn3A,9
|
9
|
+
componentsDjangoType-0.0.1.dist-info/RECORD,,
|
@@ -0,0 +1 @@
|
|
1
|
+
settings
|
settings/__init__.py
ADDED
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,57 @@
|
|
1
|
+
from django.core.management.base import BaseCommand, CommandError
|
2
|
+
from django.apps import apps
|
3
|
+
import os
|
4
|
+
|
5
|
+
class Command(BaseCommand):
|
6
|
+
help = 'Crear un archivo HTML dentro de la carpeta templates o static de una app'
|
7
|
+
|
8
|
+
def add_arguments(self, parser):
|
9
|
+
parser.add_argument('app_name', type=str, help='Nombre de la app')
|
10
|
+
parser.add_argument('file_path', type=str, help='Ruta del componente HTML')
|
11
|
+
parser.add_argument(
|
12
|
+
'--type',
|
13
|
+
type=str,
|
14
|
+
choices=['template', 'static'],
|
15
|
+
default='template',
|
16
|
+
help='Tipo de archivo a crear: "template" para archivos en la carpeta templates, "static" para archivos en la carpeta static'
|
17
|
+
)
|
18
|
+
|
19
|
+
def handle(self, *args, **kwargs):
|
20
|
+
app_name = kwargs['app_name']
|
21
|
+
file_path = kwargs['file_path']
|
22
|
+
file_type = kwargs['type']
|
23
|
+
|
24
|
+
try:
|
25
|
+
app_config = apps.get_app_config(app_name)
|
26
|
+
except LookupError:
|
27
|
+
raise CommandError(f'App "{app_name}" no encontrada.')
|
28
|
+
|
29
|
+
base_dir = os.path.join(app_config.path, 'templates' if file_type == 'template' else 'static')
|
30
|
+
|
31
|
+
if not os.path.exists(base_dir):
|
32
|
+
os.makedirs(base_dir)
|
33
|
+
|
34
|
+
file_full_path = os.path.join(base_dir, file_path)
|
35
|
+
file_full_path = os.path.normpath(file_full_path)
|
36
|
+
|
37
|
+
file_folder = os.path.dirname(file_full_path)
|
38
|
+
if not os.path.exists(file_folder):
|
39
|
+
os.makedirs(file_folder)
|
40
|
+
|
41
|
+
if os.path.exists(file_full_path):
|
42
|
+
self.stdout.write(self.style.WARNING(f'El archivo {file_path} ya existe en {app_name}/{file_type}/.'))
|
43
|
+
else:
|
44
|
+
file_extension = os.path.splitext(file_path)[1]
|
45
|
+
if file_extension == '.html':
|
46
|
+
content = '<div>Este es el contenido del componente.</div>'
|
47
|
+
elif file_extension == '.js':
|
48
|
+
content = 'console.log("Este es el contenido del componente.");'
|
49
|
+
elif file_extension == '.css':
|
50
|
+
content = '/* Este es el contenido del componente */'
|
51
|
+
else:
|
52
|
+
content = ''
|
53
|
+
|
54
|
+
with open(file_full_path, 'w') as f:
|
55
|
+
f.write(content)
|
56
|
+
|
57
|
+
self.stdout.write(self.style.SUCCESS(f'Se creó correctamente {file_path} en {app_name}/{file_type}/.'))
|