Skip to content

Commit 46abfe8

Browse files
Update formatting
1 parent 51c0f05 commit 46abfe8

File tree

3 files changed

+25
-12
lines changed

3 files changed

+25
-12
lines changed

src/ansible_creator/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ class Config:
3131
collection_name: The name of the collection.
3232
namespace: The namespace for the collection.
3333
resource_type: The type of resource to be scaffolded.
34-
path: The file path where the resource should be added.
3534
type: The type of the project for which the resource is being scaffolded.
35+
path: The file path where the resource should be added.
3636
"""
3737

3838
creator_version: str
3939
output: Output
4040
subcommand: str
41-
type: str = ""
42-
resource_type: str = ""
43-
path: str = ""
4441
collection: str = ""
4542
force: bool = False
4643
overwrite: bool = False
@@ -49,6 +46,9 @@ class Config:
4946
project: str = ""
5047
collection_name: str | None = None
5148
namespace: str = ""
49+
resource_type: str = ""
50+
type: str = ""
51+
path: str = ""
5252

5353
def __post_init__(self: Config) -> None:
5454
"""Post process config values."""

src/ansible_creator/subcommands/add.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@
1717

1818

1919
class Add:
20-
"""Class to handle the add subcommand."""
20+
"""Class to handle the add subcommand.
21+
22+
Attributes:
23+
common_resources: List of common resources to copy.
24+
"""
2125

2226
common_resources = ("common.devfile",)
2327

@@ -30,7 +34,6 @@ def __init__(
3034
Args:
3135
config: App configuration object.
3236
"""
33-
3437
self._resource_type: str = config.resource_type
3538
self._add_path: Path = Path(config.path)
3639
self._force = config.force
@@ -49,14 +52,21 @@ def run(self) -> None:
4952
self._scaffold()
5053

5154
def _check_add_path(self) -> None:
52-
"""Validate the provided add path."""
55+
"""Validate the provided add path.
56+
57+
Raises:
58+
CreatorError: If the add path does not exist.
59+
"""
5360
if not self._add_path.exists():
54-
raise CreatorError(
55-
f"The path {self._add_path} does not exist. Please provide an existing directory.",
56-
)
61+
msg = f"The path {self._add_path} does not exist. Please provide an existing directory."
62+
raise CreatorError(msg)
5763

5864
def _scaffold(self) -> None:
59-
"""Scaffold the specified resource file."""
65+
"""Scaffold the specified resource file.
66+
67+
Raises:
68+
CreatorError: If there are conflicts and overwriting is not allowed.
69+
"""
6070
self.output.debug(f"Started copying {self._project} resource to destination")
6171

6272
# Set up template data
@@ -93,7 +103,9 @@ def _scaffold(self) -> None:
93103
return
94104

95105
if not self._overwrite:
96-
question = "Some files in the destination directory may be overwritten. Do you want to proceed?"
106+
question = (
107+
"Files in the destination directory will be overwritten. Do you want to proceed?"
108+
)
97109
if ask_yes_no(question):
98110
copier.copy_containers(paths)
99111
else:

src/ansible_creator/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class TemplateData:
1717
"""Dataclass representing the template data.
1818
1919
Attributes:
20+
resource_type: The type of resource to be scaffolded.
2021
additions: A dictionary containing additional data to add to the gitignore.
2122
collection_name: The name of the collection.
2223
creator_version: The version of the creator.

0 commit comments

Comments
 (0)