mirror of
				https://github.com/python-pillow/Pillow.git
				synced 2025-11-04 01:47:47 +03:00 
			
		
		
		
	deprecate ImageCms members: DESCRIPTION, VERSION, FLAGS, versions()
This commit is contained in:
		
							parent
							
								
									a786a0551b
								
							
						
					
					
						commit
						08f11c57a1
					
				| 
						 | 
				
			
			@ -49,7 +49,7 @@ def skip_missing():
 | 
			
		|||
def test_sanity():
 | 
			
		||||
    # basic smoke test.
 | 
			
		||||
    # this mostly follows the cms_test outline.
 | 
			
		||||
 | 
			
		||||
    with pytest.warns(DeprecationWarning):
 | 
			
		||||
        v = ImageCms.versions()  # should return four strings
 | 
			
		||||
    assert v[0] == "1.0.0 pil"
 | 
			
		||||
    assert list(map(type, v)) == [str, str, str, str]
 | 
			
		||||
| 
						 | 
				
			
			@ -637,3 +637,12 @@ def test_rgb_lab(mode):
 | 
			
		|||
    im = Image.new("LAB", (1, 1), (255, 0, 0))
 | 
			
		||||
    converted_im = im.convert(mode)
 | 
			
		||||
    assert converted_im.getpixel((0, 0))[:3] == (0, 255, 255)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def test_deprecation():
 | 
			
		||||
    with pytest.warns(DeprecationWarning):
 | 
			
		||||
        assert ImageCms.DESCRIPTION.strip().startswith("pyCMS")
 | 
			
		||||
    with pytest.warns(DeprecationWarning):
 | 
			
		||||
        assert ImageCms.VERSION == "1.0.0 pil"
 | 
			
		||||
    with pytest.warns(DeprecationWarning):
 | 
			
		||||
        assert isinstance(ImageCms.FLAGS, dict)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,8 +20,10 @@ import operator
 | 
			
		|||
import sys
 | 
			
		||||
from enum import IntEnum, IntFlag
 | 
			
		||||
from functools import reduce
 | 
			
		||||
from typing import Any
 | 
			
		||||
 | 
			
		||||
from . import Image
 | 
			
		||||
from ._deprecate import deprecate
 | 
			
		||||
 | 
			
		||||
try:
 | 
			
		||||
    from . import _imagingcms
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +34,7 @@ except ImportError as ex:
 | 
			
		|||
 | 
			
		||||
    _imagingcms = DeferredError.new(ex)
 | 
			
		||||
 | 
			
		||||
DESCRIPTION = """
 | 
			
		||||
_DESCRIPTION = """
 | 
			
		||||
pyCMS
 | 
			
		||||
 | 
			
		||||
    a Python / PIL interface to the littleCMS ICC Color Management System
 | 
			
		||||
| 
						 | 
				
			
			@ -95,7 +97,22 @@ pyCMS
 | 
			
		|||
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
VERSION = "1.0.0 pil"
 | 
			
		||||
_VERSION = "1.0.0 pil"
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def __getattr__(name: str) -> Any:
 | 
			
		||||
    if name == "DESCRIPTION":
 | 
			
		||||
        deprecate("PIL.ImageCms.DESCRIPTION", 12)
 | 
			
		||||
        return _DESCRIPTION
 | 
			
		||||
    elif name == "VERSION":
 | 
			
		||||
        deprecate("PIL.ImageCms.VERSION", 12)
 | 
			
		||||
        return _VERSION
 | 
			
		||||
    elif name == "FLAGS":
 | 
			
		||||
        deprecate("PIL.ImageCms.FLAGS", 12, "PIL.ImageCms.Flags")
 | 
			
		||||
        return _FLAGS
 | 
			
		||||
    msg = f"module '{__name__}' has no attribute '{name}'"
 | 
			
		||||
    raise AttributeError(msg)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
# --------------------------------------------------------------------.
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -184,7 +201,7 @@ class Flags(IntFlag):
 | 
			
		|||
_MAX_FLAG = reduce(operator.or_, Flags)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
FLAGS = {
 | 
			
		||||
_FLAGS = {
 | 
			
		||||
    "MATRIXINPUT": 1,
 | 
			
		||||
    "MATRIXOUTPUT": 2,
 | 
			
		||||
    "MATRIXONLY": (1 | 2),
 | 
			
		||||
| 
						 | 
				
			
			@ -1064,4 +1081,9 @@ def versions():
 | 
			
		|||
    (pyCMS) Fetches versions.
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    return VERSION, core.littlecms_version, sys.version.split()[0], Image.__version__
 | 
			
		||||
    deprecate(
 | 
			
		||||
        "PIL.ImageCms.versions()",
 | 
			
		||||
        12,
 | 
			
		||||
        '(PIL.features.version("littlecms2"), sys.version, PIL.__version__)',
 | 
			
		||||
    )
 | 
			
		||||
    return _VERSION, core.littlecms_version, sys.version.split()[0], Image.__version__
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue
	
	Block a user