File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change 1
1
# /*##########################################################################
2
2
#
3
- # Copyright (c) 2016-2023 European Synchrotron Radiation Facility
3
+ # Copyright (c) 2016-2025 European Synchrotron Radiation Facility
4
4
#
5
5
# Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
# of this software and associated documentation files (the "Software"), to deal
@@ -397,9 +397,12 @@ def getQFile(name):
397
397
398
398
for format_ in _supported_formats :
399
399
format_ = str (format_ )
400
- filename = silx .resources ._resource_filename (
401
- f"{ name } .{ format_ } " , default_directory = "gui/icons"
402
- )
400
+ try :
401
+ filename = silx .resources ._resource_filename (
402
+ f"{ name } .{ format_ } " , default_directory = "gui/icons"
403
+ )
404
+ except ValueError :
405
+ continue
403
406
qfile = qt .QFile (filename )
404
407
if qfile .exists ():
405
408
return qfile
Original file line number Diff line number Diff line change 1
1
# /*##########################################################################
2
2
#
3
- # Copyright (c) 2016-2023 European Synchrotron Radiation Facility
3
+ # Copyright (c) 2016-2025 European Synchrotron Radiation Facility
4
4
#
5
5
# Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
# of this software and associated documentation files (the "Software"), to deal
@@ -237,9 +237,11 @@ def _get_resource_filename(package: str, resource: str) -> str:
237
237
:return: Abolute resource path in the file system
238
238
"""
239
239
# Caching prevents extracting the resource twice
240
- file_context = importlib_resources .as_file (
241
- importlib_resources .files (package ) / resource
242
- )
240
+ traversable = importlib_resources .files (package ).joinpath (resource )
241
+ if not traversable .is_file () and not traversable .is_dir ():
242
+ raise ValueError (f"Resource { resource } does not exists in { package } " )
243
+ file_context = importlib_resources .as_file (traversable )
244
+
243
245
path = _file_manager .enter_context (file_context )
244
246
return str (path .absolute ())
245
247
You can’t perform that action at this time.
0 commit comments