mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-07-11 00:32:27 +03:00
function 2 added flags
This commit is contained in:
parent
0a88a142c0
commit
4d9e87c31a
|
@ -29,6 +29,17 @@ from . import Image, __version__
|
||||||
from ._deprecate import deprecate
|
from ._deprecate import deprecate
|
||||||
from ._typing import SupportsRead
|
from ._typing import SupportsRead
|
||||||
|
|
||||||
|
branches = {
|
||||||
|
"1": False,
|
||||||
|
"2": False,
|
||||||
|
"3": False,
|
||||||
|
"4": False,
|
||||||
|
"5": False,
|
||||||
|
"6": False,
|
||||||
|
"7": False,
|
||||||
|
"8": False,
|
||||||
|
}
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from . import _imagingcms as core
|
from . import _imagingcms as core
|
||||||
except ImportError as ex:
|
except ImportError as ex:
|
||||||
|
@ -246,20 +257,28 @@ class ImageCmsProfile:
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if isinstance(profile, str):
|
if isinstance(profile, str):
|
||||||
|
branches["1"] = True
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
|
branches["2"] = True
|
||||||
profile_bytes_path = profile.encode()
|
profile_bytes_path = profile.encode()
|
||||||
try:
|
try:
|
||||||
|
branches["3"] = True
|
||||||
profile_bytes_path.decode("ascii")
|
profile_bytes_path.decode("ascii")
|
||||||
except UnicodeDecodeError:
|
except UnicodeDecodeError:
|
||||||
|
branches["4"] = True
|
||||||
with open(profile, "rb") as f:
|
with open(profile, "rb") as f:
|
||||||
|
branches["5"] = True
|
||||||
self._set(core.profile_frombytes(f.read()))
|
self._set(core.profile_frombytes(f.read()))
|
||||||
return
|
return
|
||||||
self._set(core.profile_open(profile), profile)
|
self._set(core.profile_open(profile), profile)
|
||||||
elif hasattr(profile, "read"):
|
elif hasattr(profile, "read"):
|
||||||
|
branches["6"] = True
|
||||||
self._set(core.profile_frombytes(profile.read()))
|
self._set(core.profile_frombytes(profile.read()))
|
||||||
elif isinstance(profile, core.CmsProfile):
|
elif isinstance(profile, core.CmsProfile):
|
||||||
|
branches["7"] = True
|
||||||
self._set(profile)
|
self._set(profile)
|
||||||
else:
|
else:
|
||||||
|
branches["8"] = True
|
||||||
msg = "Invalid type for Profile" # type: ignore[unreachable]
|
msg = "Invalid type for Profile" # type: ignore[unreachable]
|
||||||
raise TypeError(msg)
|
raise TypeError(msg)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user