Skip to content

Commit b6cb4da

Browse files
committed
more fixy
1 parent fc1821b commit b6cb4da

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

seqerakit/cli.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,12 @@ def handle_block(self, block, args, destroy=False, dryrun=False):
174174
}
175175

176176
# Get the on_exists option from args for backward compatibility
177-
on_exists = args.get("on_exists", OnExists.FAIL)
177+
on_exists = args.get("on_exists", "fail")
178+
if isinstance(on_exists, str):
179+
try:
180+
on_exists = OnExists[on_exists.upper()]
181+
except KeyError:
182+
on_exists = OnExists.FAIL
178183

179184
# Global settings take precedence over block-level settings
180185
# First check the global --on-exists parameter
@@ -188,9 +193,11 @@ def handle_block(self, block, args, destroy=False, dryrun=False):
188193
on_exists = OnExists.OVERWRITE
189194

190195
if not dryrun:
191-
logging.debug(
192-
f" on_exists is set to '{on_exists.name.lower()}' for {block}\n"
196+
# Use on_exists.name.lower() only if it's an enum, otherwise use the string
197+
on_exists_str = (
198+
on_exists.name.lower() if hasattr(on_exists, "name") else on_exists
193199
)
200+
logging.debug(f" on_exists is set to '{on_exists_str}' for {block}\n")
194201
should_continue = self.overwrite_method.handle_overwrite(
195202
block, args["cmd_args"], on_exists=on_exists
196203
)

seqerakit/overwrite.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,10 @@ def handle_overwrite(
178178
self.delete_resource(block, operation, sp_args)
179179
else: # fail
180180
raise ResourceExistsError(
181-
f" The {block} resource already exists and"
182-
" will not be created. Please set 'on_exists: overwrite' "
183-
" to replace the resource or set 'on_exists: ignore' to "
184-
" ignore this error.\n"
181+
f"The {block} resource already exists and "
182+
"will not be created. Please set 'on_exists: overwrite' "
183+
"to replace the resource or set 'on_exists: ignore' to "
184+
"ignore this error.\n"
185185
)
186186
return True
187187
return True

0 commit comments

Comments
 (0)