Skip to content

Commit

Permalink
chore: auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Oct 18, 2024
1 parent 0a70b58 commit aa37aeb
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/ansible_creator/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class Config:
output: Output
subcommand: str
type: str = ""
resource_type :str = ""
path :str = ""
resource_type: str = ""
path: str = ""
collection: str = ""
force: bool = False
overwrite: bool = False
Expand Down
26 changes: 13 additions & 13 deletions src/ansible_creator/subcommands/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,24 @@
from ansible_creator.exceptions import CreatorError
from ansible_creator.templar import Templar
from ansible_creator.types import TemplateData
from ansible_creator.utils import Walker, Copier, ask_yes_no
from ansible_creator.utils import Copier, Walker, ask_yes_no

Check warning on line 11 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L8-L11

Added lines #L8 - L11 were not covered by tests


if TYPE_CHECKING:
from ansible_creator.config import Config
from ansible_creator.output import Output


class Add:

Check warning on line 19 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L19

Added line #L19 was not covered by tests
"""Class to handle the add subcommand."""

common_resources = ("common.devfile",)

Check warning on line 22 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L22

Added line #L22 was not covered by tests



def __init__(

Check warning on line 24 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L24

Added line #L24 was not covered by tests
self: Add,
config: Config,
) -> None:

self._resource_type: str = config.resource_type
self._add_path: Path = Path(config.path)
self._force = config.force
Expand All @@ -35,7 +35,7 @@ def __init__(
self._project = config.project
self.output: Output = config.output
self.templar = Templar()

Check warning on line 37 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L29-L37

Added lines #L29 - L37 were not covered by tests

def run(self) -> None:

Check warning on line 39 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L39

Added line #L39 was not covered by tests
"""Start scaffolding the resource file."""
self._check_add_path()
Expand All @@ -46,7 +46,9 @@ def run(self) -> None:
def _check_add_path(self) -> None:

Check warning on line 46 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L46

Added line #L46 was not covered by tests
"""Validate the provided add path."""
if not self._add_path.exists():
raise CreatorError(f"The path {self._add_path} does not exist. Please provide an existing directory.")
raise CreatorError(

Check warning on line 49 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L48-L49

Added lines #L48 - L49 were not covered by tests
f"The path {self._add_path} does not exist. Please provide an existing directory.",
)

def _scaffold(self) -> None:

Check warning on line 53 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L53

Added line #L53 was not covered by tests
"""Scaffold the specified resource file."""
Expand All @@ -59,8 +61,7 @@ def _scaffold(self) -> None:
)

# Initialize Walker and Copier for file operations



walker = Walker(

Check warning on line 65 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L65

Added line #L65 was not covered by tests
resources=self.common_resources,
resource_id="common.devfile",
Expand All @@ -71,28 +72,27 @@ def _scaffold(self) -> None:
)
paths = walker.collect_paths()
copier = Copier(output=self.output)

Check warning on line 74 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L73-L74

Added lines #L73 - L74 were not covered by tests

if self._no_overwrite:
if paths.has_conflicts():
raise CreatorError(

Check warning on line 78 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L76-L78

Added lines #L76 - L78 were not covered by tests
"The destination directory contains files that may be overwritten. "
"Please re-run ansible-creator with --overwrite to proceed."
"Please re-run ansible-creator with --overwrite to proceed.",
)

if not paths.has_conflicts() or self._force or self._overwrite:
copier.copy_containers(paths)
self.output.note(f"Resource added to {self._add_path}")
return

Check warning on line 86 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L83-L86

Added lines #L83 - L86 were not covered by tests


if not self._overwrite:
question = "Some files in the destination directory may be overwritten. Do you want to proceed?"
if ask_yes_no(question):
copier.copy_containers(paths)

Check warning on line 91 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L88-L91

Added lines #L88 - L91 were not covered by tests
else:
raise CreatorError(

Check warning on line 93 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L93

Added line #L93 was not covered by tests
"The destination contains files that could be overwritten. "
"Please re-run ansible-creator with --overwrite to continue."
"Please re-run ansible-creator with --overwrite to continue.",
)

self.output.note(f"Resource added to {self._add_path}")
self.output.note(f"Resource added to {self._add_path}")

Check warning on line 98 in src/ansible_creator/subcommands/add.py

View check run for this annotation

Codecov / codecov/patch

src/ansible_creator/subcommands/add.py#L98

Added line #L98 was not covered by tests

0 comments on commit aa37aeb

Please sign in to comment.