mirror of
https://github.com/django-components/django-components.git
synced 2025-09-26 15:39:08 +00:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
58c7d55256
commit
4f4b81b7a0
1 changed files with 14 additions and 8 deletions
|
@ -10,9 +10,7 @@ class Command(BaseCommand):
|
||||||
|
|
||||||
def add_arguments(self, parser):
|
def add_arguments(self, parser):
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"name",
|
"name", type=str, help="The name of the component to create"
|
||||||
type=str,
|
|
||||||
help="The name of the component to create"
|
|
||||||
)
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--path",
|
"--path",
|
||||||
|
@ -68,7 +66,9 @@ class Command(BaseCommand):
|
||||||
verbose = kwargs["verbose"]
|
verbose = kwargs["verbose"]
|
||||||
dry_run = kwargs["dry_run"]
|
dry_run = kwargs["dry_run"]
|
||||||
|
|
||||||
component_path = os.path.join(path or f"{base_dir}/components", name)
|
component_path = os.path.join(
|
||||||
|
path or f"{base_dir}/components", name
|
||||||
|
)
|
||||||
|
|
||||||
if os.path.exists(component_path):
|
if os.path.exists(component_path):
|
||||||
if force:
|
if force:
|
||||||
|
@ -102,7 +102,9 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
f.write(script_content.strip())
|
f.write(script_content.strip())
|
||||||
|
|
||||||
with open(os.path.join(component_path, css_filename), "w") as f:
|
with open(
|
||||||
|
os.path.join(component_path, css_filename), "w"
|
||||||
|
) as f:
|
||||||
style_content = dedent(
|
style_content = dedent(
|
||||||
f"""
|
f"""
|
||||||
.component-{name} {{
|
.component-{name} {{
|
||||||
|
@ -112,7 +114,9 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
f.write(style_content.strip())
|
f.write(style_content.strip())
|
||||||
|
|
||||||
with open(os.path.join(component_path, template_filename), "w") as f:
|
with open(
|
||||||
|
os.path.join(component_path, template_filename), "w"
|
||||||
|
) as f:
|
||||||
template_content = dedent(
|
template_content = dedent(
|
||||||
f"""
|
f"""
|
||||||
<div class="component-{name}">
|
<div class="component-{name}">
|
||||||
|
@ -122,7 +126,9 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
f.write(template_content.strip())
|
f.write(template_content.strip())
|
||||||
|
|
||||||
with open(os.path.join(component_path, f"{name}.py"), "w") as f:
|
with open(
|
||||||
|
os.path.join(component_path, f"{name}.py"), "w"
|
||||||
|
) as f:
|
||||||
py_content = dedent(
|
py_content = dedent(
|
||||||
f"""
|
f"""
|
||||||
from django_components import component
|
from django_components import component
|
||||||
|
@ -156,4 +162,4 @@ class Command(BaseCommand):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
raise CommandError("You must specify a component name")
|
raise CommandError("You must specify a component name")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue