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,19 @@ 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, False or None otherwise.
115+ """
116+
81117 if feature in modules :
82118 return check_module (feature )
83119 if feature in codecs :
@@ -89,13 +125,27 @@ def check(feature):
89125
90126
91127def get_supported ():
128+ """
129+ :returns: A list of all supported modules, features, and codecs.
130+ """
131+
92132 ret = get_supported_modules ()
93133 ret .extend (get_supported_features ())
94134 ret .extend (get_supported_codecs ())
95135 return ret
96136
97137
98138def pilinfo (out = None , supported_formats = True ):
139+ """
140+ Prints information about this installation of Pillow.
141+ This function can be called with ``python -m PIL``.
142+
143+ :param out:
144+ The output stream to print to. Defaults to ``sys.stdout`` if None.
145+ :param supported_formats:
146+ If True, a list of all supported image file formats will be printed.
147+ """
148+
99149 if out is None :
100150 out = sys .stdout
101151
0 commit comments