Reparatur der venv.
This commit is contained in:
@@ -4,6 +4,7 @@ import collections
|
||||
import os
|
||||
import sys
|
||||
import warnings
|
||||
from typing import IO
|
||||
|
||||
import PIL
|
||||
|
||||
@@ -18,7 +19,7 @@ modules = {
|
||||
}
|
||||
|
||||
|
||||
def check_module(feature):
|
||||
def check_module(feature: str) -> bool:
|
||||
"""
|
||||
Checks if a module is available.
|
||||
|
||||
@@ -42,7 +43,7 @@ def check_module(feature):
|
||||
return False
|
||||
|
||||
|
||||
def version_module(feature):
|
||||
def version_module(feature: str) -> str | None:
|
||||
"""
|
||||
:param feature: The module to check for.
|
||||
:returns:
|
||||
@@ -54,13 +55,10 @@ def version_module(feature):
|
||||
|
||||
module, ver = modules[feature]
|
||||
|
||||
if ver is None:
|
||||
return None
|
||||
|
||||
return getattr(__import__(module, fromlist=[ver]), ver)
|
||||
|
||||
|
||||
def get_supported_modules():
|
||||
def get_supported_modules() -> list[str]:
|
||||
"""
|
||||
:returns: A list of all supported modules.
|
||||
"""
|
||||
@@ -75,7 +73,7 @@ codecs = {
|
||||
}
|
||||
|
||||
|
||||
def check_codec(feature):
|
||||
def check_codec(feature: str) -> bool:
|
||||
"""
|
||||
Checks if a codec is available.
|
||||
|
||||
@@ -89,10 +87,10 @@ def check_codec(feature):
|
||||
|
||||
codec, lib = codecs[feature]
|
||||
|
||||
return codec + "_encoder" in dir(Image.core)
|
||||
return f"{codec}_encoder" in dir(Image.core)
|
||||
|
||||
|
||||
def version_codec(feature):
|
||||
def version_codec(feature: str) -> str | None:
|
||||
"""
|
||||
:param feature: The codec to check for.
|
||||
:returns:
|
||||
@@ -105,7 +103,7 @@ def version_codec(feature):
|
||||
|
||||
codec, lib = codecs[feature]
|
||||
|
||||
version = getattr(Image.core, lib + "_version")
|
||||
version = getattr(Image.core, f"{lib}_version")
|
||||
|
||||
if feature == "libtiff":
|
||||
return version.split("\n")[0].split("Version ")[1]
|
||||
@@ -113,7 +111,7 @@ def version_codec(feature):
|
||||
return version
|
||||
|
||||
|
||||
def get_supported_codecs():
|
||||
def get_supported_codecs() -> list[str]:
|
||||
"""
|
||||
:returns: A list of all supported codecs.
|
||||
"""
|
||||
@@ -133,7 +131,7 @@ features = {
|
||||
}
|
||||
|
||||
|
||||
def check_feature(feature):
|
||||
def check_feature(feature: str) -> bool | None:
|
||||
"""
|
||||
Checks if a feature is available.
|
||||
|
||||
@@ -157,7 +155,7 @@ def check_feature(feature):
|
||||
return None
|
||||
|
||||
|
||||
def version_feature(feature):
|
||||
def version_feature(feature: str) -> str | None:
|
||||
"""
|
||||
:param feature: The feature to check for.
|
||||
:returns: The version number as a string, or ``None`` if not available.
|
||||
@@ -174,14 +172,14 @@ def version_feature(feature):
|
||||
return getattr(__import__(module, fromlist=[ver]), ver)
|
||||
|
||||
|
||||
def get_supported_features():
|
||||
def get_supported_features() -> list[str]:
|
||||
"""
|
||||
:returns: A list of all supported features.
|
||||
"""
|
||||
return [f for f in features if check_feature(f)]
|
||||
|
||||
|
||||
def check(feature):
|
||||
def check(feature: str) -> bool | None:
|
||||
"""
|
||||
:param feature: A module, codec, or feature name.
|
||||
:returns:
|
||||
@@ -199,7 +197,7 @@ def check(feature):
|
||||
return False
|
||||
|
||||
|
||||
def version(feature):
|
||||
def version(feature: str) -> str | None:
|
||||
"""
|
||||
:param feature:
|
||||
The module, codec, or feature to check for.
|
||||
@@ -215,7 +213,7 @@ def version(feature):
|
||||
return None
|
||||
|
||||
|
||||
def get_supported():
|
||||
def get_supported() -> list[str]:
|
||||
"""
|
||||
:returns: A list of all supported modules, features, and codecs.
|
||||
"""
|
||||
@@ -226,7 +224,7 @@ def get_supported():
|
||||
return ret
|
||||
|
||||
|
||||
def pilinfo(out=None, supported_formats=True):
|
||||
def pilinfo(out: IO[str] | None = None, supported_formats: bool = True) -> None:
|
||||
"""
|
||||
Prints information about this installation of Pillow.
|
||||
This function can be called with ``python3 -m PIL``.
|
||||
@@ -247,9 +245,9 @@ def pilinfo(out=None, supported_formats=True):
|
||||
|
||||
print("-" * 68, file=out)
|
||||
print(f"Pillow {PIL.__version__}", file=out)
|
||||
py_version = sys.version.splitlines()
|
||||
print(f"Python {py_version[0].strip()}", file=out)
|
||||
for py_version in py_version[1:]:
|
||||
py_version_lines = sys.version.splitlines()
|
||||
print(f"Python {py_version_lines[0].strip()}", file=out)
|
||||
for py_version in py_version_lines[1:]:
|
||||
print(f" {py_version.strip()}", file=out)
|
||||
print("-" * 68, file=out)
|
||||
print(f"Python executable is {sys.executable or 'unknown'}", file=out)
|
||||
@@ -285,9 +283,12 @@ def pilinfo(out=None, supported_formats=True):
|
||||
("xcb", "XCB (X protocol)"),
|
||||
]:
|
||||
if check(name):
|
||||
if name == "jpg" and check_feature("libjpeg_turbo"):
|
||||
v = "libjpeg-turbo " + version_feature("libjpeg_turbo")
|
||||
else:
|
||||
v: str | None = None
|
||||
if name == "jpg":
|
||||
libjpeg_turbo_version = version_feature("libjpeg_turbo")
|
||||
if libjpeg_turbo_version is not None:
|
||||
v = "libjpeg-turbo " + libjpeg_turbo_version
|
||||
if v is None:
|
||||
v = version(name)
|
||||
if v is not None:
|
||||
version_static = name in ("pil", "jpg")
|
||||
|
||||
Reference in New Issue
Block a user