1717
1818
1919def check_module (feature ):
20+ """
21+ Checks if a module is available.
22+
23+ :param feature: The module to check for.
24+ :returns: ``True`` if available, ``False`` otherwise.
25+ :raises ValueError: If the module is not defined in this version of Pillow.
26+ """
2027 if not (feature in modules ):
2128 raise ValueError ("Unknown module %s" % feature )
2229
@@ -30,13 +37,23 @@ def check_module(feature):
3037
3138
3239def get_supported_modules ():
40+ """
41+ :returns: A list of all supported modules.
42+ """
3343 return [f for f in modules if check_module (f )]
3444
3545
3646codecs = {"jpg" : "jpeg" , "jpg_2000" : "jpeg2k" , "zlib" : "zip" , "libtiff" : "libtiff" }
3747
3848
3949def check_codec (feature ):
50+ """
51+ Checks if a codec is available.
52+
53+ :param feature: The codec to check for.
54+ :returns: ``True`` if available, ``False`` otherwise.
55+ :raises ValueError: If the codec is not defined in this version of Pillow.
56+ """
4057 if feature not in codecs :
4158 raise ValueError ("Unknown codec %s" % feature )
4259
@@ -46,6 +63,9 @@ def check_codec(feature):
4663
4764
4865def get_supported_codecs ():
66+ """
67+ :returns: A list of all supported codecs.
68+ """
4969 return [f for f in codecs if check_codec (f )]
5070
5171
@@ -61,6 +81,13 @@ def get_supported_codecs():
6181
6282
6383def check_feature (feature ):
84+ """
85+ Checks if a feature is available.
86+
87+ :param feature: The feature to check for.
88+ :returns: ``True`` if available, ``False`` if unavailable, ``None`` if unknown.
89+ :raises ValueError: If the feature is not defined in this version of Pillow.
90+ """
6491 if feature not in features :
6592 raise ValueError ("Unknown feature %s" % feature )
6693
@@ -74,10 +101,20 @@ def check_feature(feature):
74101
75102
76103def get_supported_features ():
104+ """
105+ :returns: A list of all supported features.
106+ """
77107 return [f for f in features if check_feature (f )]
78108
79109
80110def check (feature ):
111+ """
112+ :param feature: A module, feature, or codec name.
113+ :returns:
114+ ``True`` if the module, feature, or codec is available,
115+ ``False`` or ``None`` otherwise.
116+ """
117+
81118 if feature in modules :
82119 return check_module (feature )
83120 if feature in codecs :
@@ -89,13 +126,27 @@ def check(feature):
89126
90127
91128def get_supported ():
129+ """
130+ :returns: A list of all supported modules, features, and codecs.
131+ """
132+
92133 ret = get_supported_modules ()
93134 ret .extend (get_supported_features ())
94135 ret .extend (get_supported_codecs ())
95136 return ret
96137
97138
98139def pilinfo (out = None , supported_formats = True ):
140+ """
141+ Prints information about this installation of Pillow.
142+ This function can be called with ``python -m PIL``.
143+
144+ :param out:
145+ The output stream to print to. Defaults to ``sys.stdout`` if ``None``.
146+ :param supported_formats:
147+ If ``True``, a list of all supported image file formats will be printed.
148+ """
149+
99150 if out is None :
100151 out = sys .stdout
101152
0 commit comments