aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVenugopal Shivashankar <Venugopal.Shivashankar@qt.io>2022-10-03 11:10:04 +0200
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-11-16 09:12:13 +0000
commit586194db6e9e3c91ac41b4fdf707db1b9cafc4be (patch)
tree93970fee3d44698baada252339f6bb0bbed4f2c7
parentc0246aa2d62c342057c8985a7a8249a771d23507 (diff)
example_gallery: Check if a file exists
The files in the pyproject could be missing in some cases, so a check is required before appending to the files list. Change-Id: Ifc70eebacb35b72d8a9713a8bf75b321284906ff Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> (cherry picked from commit a96fa0c7702f51f2552d652ba0ca2aeff34ab71b) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--tools/example_gallery/main.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/example_gallery/main.py b/tools/example_gallery/main.py
index 9768fba4f..5e9029f27 100644
--- a/tools/example_gallery/main.py
+++ b/tools/example_gallery/main.py
@@ -248,8 +248,15 @@ if __name__ == "__main__":
try:
with pyproject_file.open("r", encoding="utf-8") as pyf:
pyproject = json.load(pyf)
- files = pyproject["files"]
- except (json.JSONDecodeError, KeyError) as e:
+ # iterate through the list of files in .pyproject and
+ # check if they exist, before appending to the list.
+ for f in pyproject["files"]:
+ if not Path(f).exists:
+ print(f"example_gallery: {f} listed in {pyproject_file} does not exist")
+ raise FileNotFoundError
+ else:
+ files.append(f)
+ except (json.JSONDecodeError, KeyError, FileNotFoundError) as e:
print(f"example_gallery: error reading {pyproject_file}: {e}")
raise