diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-04 11:15:56 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-04 11:15:56 +0300 |
commit | 397251ba0cc1a1df2c558c28c416b64eef73a051 (patch) | |
tree | c5bd1c25eae4d890b7f5f79d938ca5e04802bafc /modules/postprocessing.py | |
parent | 149c9d223463c8fc34f53f26ca06e02be4c8835b (diff) | |
parent | df62ffbd2525792c115adefdbaeb7799699624b1 (diff) |
Merge pull request #14527 from akx/avoid-isfiles
Avoid unnecessary `isfile`/`exists` calls
Diffstat (limited to 'modules/postprocessing.py')
-rw-r--r-- | modules/postprocessing.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/modules/postprocessing.py b/modules/postprocessing.py index 7850328f..7449b0dc 100644 --- a/modules/postprocessing.py +++ b/modules/postprocessing.py @@ -97,11 +97,12 @@ def run_postprocessing(extras_mode, image, image_folder, input_dir, output_dir, if pp.caption:
caption_filename = os.path.splitext(fullfn)[0] + ".txt"
- if os.path.isfile(caption_filename):
+ existing_caption = ""
+ try:
with open(caption_filename, encoding="utf8") as file:
existing_caption = file.read().strip()
- else:
- existing_caption = ""
+ except FileNotFoundError:
+ pass
action = shared.opts.postprocessing_existing_caption_action
if action == 'Prepend' and existing_caption:
|