diff options
author | emkael <emkael@tlen.pl> | 2024-01-29 21:48:28 +0100 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2024-01-29 21:48:28 +0100 |
commit | 9fce8278fbcbe51f31ee9891a35b0da8008cfc73 (patch) | |
tree | 15c32369330a56b28b14852827080343701b36b9 /squaredeal | |
parent | 00dda83377c3efaa938e94e2d03ba6e1377205fa (diff) |
Checking if file exists on create
Diffstat (limited to 'squaredeal')
-rw-r--r-- | squaredeal/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/squaredeal/__init__.py b/squaredeal/__init__.py index dc1d2d4..5a9f80b 100644 --- a/squaredeal/__init__.py +++ b/squaredeal/__init__.py @@ -52,7 +52,11 @@ class SquareDeal(object): self.sqd.name = arguments.get('event_name') self.sqd.delayed_info = arguments.get('delayed_information') - self.sqd.tofile(arguments.get('sqd_file')) + sqd_file = arguments.get('sqd_file') + if os.path.exists(sqd_file) and not arguments.get('overwrite'): + raise FileExistsError(sqd_file) + + self.sqd.tofile(sqd_file) def set_name(self, **arguments): self.sqd.fromfile(arguments.get('sqd_file'), sqkpath=arguments.get('sqk_file')) |