in pathology/dicom_proxy/color_conversion_util.py [0:0]
def read_icc_profile_plugin_file(name: str) -> bytes:
"""Returns ICC Profile bytes read from plugin directory."""
icc_profile_plugin_dir = (
dicom_proxy_flags.THIRD_PARTY_ICC_PROFILE_DICRECTORY_FLG.value
)
if not icc_profile_plugin_dir:
return _EMPTY_BYTES
name = name.lower()
try:
file_list = os.scandir(icc_profile_plugin_dir)
except FileNotFoundError:
return _EMPTY_BYTES
profile = _EMPTY_BYTES
for entry in file_list:
if entry.is_file() and _does_icc_profile_file_name_match(entry.name, name):
profile = _read_icc_profile_file(icc_profile_plugin_dir, entry.name)
elif entry.is_dir() and entry.name.lower() == name:
profile = _read_dir_icc_profile(
os.path.join(icc_profile_plugin_dir, entry.name)
)
if profile:
return profile
return _EMPTY_BYTES