Search is not available for this dataset
identifier stringlengths 1 155 | parameters stringlengths 2 6.09k | docstring stringlengths 11 63.4k | docstring_summary stringlengths 0 63.4k | function stringlengths 29 99.8k | function_tokens list | start_point list | end_point list | language stringclasses 1
value | docstring_language stringlengths 2 7 | docstring_language_predictions stringlengths 18 23 | is_langid_reliable stringclasses 2
values |
|---|---|---|---|---|---|---|---|---|---|---|---|
alpha_composite | (im1, im2) |
Alpha composite im2 over im1.
:param im1: The first image. Must have mode RGBA.
:param im2: The second image. Must have mode RGBA, and the same size as
the first image.
:returns: An :py:class:`~PIL.Image.Image` object.
|
Alpha composite im2 over im1. | def alpha_composite(im1, im2):
"""
Alpha composite im2 over im1.
:param im1: The first image. Must have mode RGBA.
:param im2: The second image. Must have mode RGBA, and the same size as
the first image.
:returns: An :py:class:`~PIL.Image.Image` object.
"""
im1.load()
im2.load(... | [
"def",
"alpha_composite",
"(",
"im1",
",",
"im2",
")",
":",
"im1",
".",
"load",
"(",
")",
"im2",
".",
"load",
"(",
")",
"return",
"im1",
".",
"_new",
"(",
"core",
".",
"alpha_composite",
"(",
"im1",
".",
"im",
",",
"im2",
".",
"im",
")",
")"
] | [
2938,
0
] | [
2950,
57
] | python | en | ['en', 'error', 'th'] | False |
Image.close | (self) |
Closes the file pointer, if possible.
This operation will destroy the image core and release its memory.
The image data will be unusable afterward.
This function is only required to close images that have not
had their file read and closed by the
:py:meth:`~PIL.Image.I... |
Closes the file pointer, if possible. | def close(self):
"""
Closes the file pointer, if possible.
This operation will destroy the image core and release its memory.
The image data will be unusable afterward.
This function is only required to close images that have not
had their file read and closed by the
... | [
"def",
"close",
"(",
"self",
")",
":",
"try",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_close__fp\"",
")",
":",
"self",
".",
"_close__fp",
"(",
")",
"self",
".",
"fp",
".",
"close",
"(",
")",
"self",
".",
"fp",
"=",
"None",
"except",
"Exception",... | [
581,
4
] | [
607,
73
] | python | en | ['en', 'error', 'th'] | False |
Image._repr_png_ | (self) | iPython display hook support
:returns: png version of the image as bytes
| iPython display hook support | def _repr_png_(self):
""" iPython display hook support
:returns: png version of the image as bytes
"""
b = io.BytesIO()
self.save(b, "PNG")
return b.getvalue() | [
"def",
"_repr_png_",
"(",
"self",
")",
":",
"b",
"=",
"io",
".",
"BytesIO",
"(",
")",
"self",
".",
"save",
"(",
"b",
",",
"\"PNG\"",
")",
"return",
"b",
".",
"getvalue",
"(",
")"
] | [
665,
4
] | [
672,
27
] | python | de | ['de', 'ky', 'en'] | False |
Image.tobytes | (self, encoder_name="raw", *args) |
Return image as a bytes object.
.. warning::
This method returns the raw image data from the internal
storage. For compressed image data (e.g. PNG, JPEG) use
:meth:`~.save`, with a BytesIO parameter for in-memory
data.
:param encoder_name: Wha... |
Return image as a bytes object. | def tobytes(self, encoder_name="raw", *args):
"""
Return image as a bytes object.
.. warning::
This method returns the raw image data from the internal
storage. For compressed image data (e.g. PNG, JPEG) use
:meth:`~.save`, with a BytesIO parameter for in-m... | [
"def",
"tobytes",
"(",
"self",
",",
"encoder_name",
"=",
"\"raw\"",
",",
"*",
"args",
")",
":",
"# may pass tuple instead of argument list",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"tuple",
")",
":"... | [
705,
4
] | [
746,
29
] | python | en | ['en', 'error', 'th'] | False |
Image.tobitmap | (self, name="image") |
Returns the image converted to an X11 bitmap.
.. note:: This method only works for mode "1" images.
:param name: The name prefix to use for the bitmap variables.
:returns: A string containing an X11 bitmap.
:raises ValueError: If the mode is not "1"
|
Returns the image converted to an X11 bitmap. | def tobitmap(self, name="image"):
"""
Returns the image converted to an X11 bitmap.
.. note:: This method only works for mode "1" images.
:param name: The name prefix to use for the bitmap variables.
:returns: A string containing an X11 bitmap.
:raises ValueError: If th... | [
"def",
"tobitmap",
"(",
"self",
",",
"name",
"=",
"\"image\"",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"self",
".",
"mode",
"!=",
"\"1\"",
":",
"raise",
"ValueError",
"(",
"\"not a bitmap\"",
")",
"data",
"=",
"self",
".",
"tobytes",
"(",
"\"x... | [
753,
4
] | [
776,
9
] | python | en | ['en', 'error', 'th'] | False |
Image.frombytes | (self, data, decoder_name="raw", *args) |
Loads this image with pixel data from a bytes object.
This method is similar to the :py:func:`~PIL.Image.frombytes` function,
but loads data into this image instead of creating a new image object.
|
Loads this image with pixel data from a bytes object. | def frombytes(self, data, decoder_name="raw", *args):
"""
Loads this image with pixel data from a bytes object.
This method is similar to the :py:func:`~PIL.Image.frombytes` function,
but loads data into this image instead of creating a new image object.
"""
# may pass ... | [
"def",
"frombytes",
"(",
"self",
",",
"data",
",",
"decoder_name",
"=",
"\"raw\"",
",",
"*",
"args",
")",
":",
"# may pass tuple instead of argument list",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"t... | [
778,
4
] | [
802,
56
] | python | en | ['en', 'error', 'th'] | False |
Image.load | (self) |
Allocates storage for the image and loads the pixel data. In
normal cases, you don't need to call this method, since the
Image class automatically loads an opened image when it is
accessed for the first time.
If the file associated with the image was opened by Pillow, then thi... |
Allocates storage for the image and loads the pixel data. In
normal cases, you don't need to call this method, since the
Image class automatically loads an opened image when it is
accessed for the first time. | def load(self):
"""
Allocates storage for the image and loads the pixel data. In
normal cases, you don't need to call this method, since the
Image class automatically loads an opened image when it is
accessed for the first time.
If the file associated with the image was... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"self",
".",
"im",
"and",
"self",
".",
"palette",
"and",
"self",
".",
"palette",
".",
"dirty",
":",
"# realize palette",
"self",
".",
"im",
".",
"putpalette",
"(",
"*",
"self",
".",
"palette",
".",
"getdata... | [
809,
4
] | [
846,
54
] | python | en | ['en', 'error', 'th'] | False |
Image.verify | (self) |
Verifies the contents of a file. For data read from a file, this
method attempts to determine if the file is broken, without
actually decoding the image data. If this method finds any
problems, it raises suitable exceptions. If you need to load
the image after using this metho... |
Verifies the contents of a file. For data read from a file, this
method attempts to determine if the file is broken, without
actually decoding the image data. If this method finds any
problems, it raises suitable exceptions. If you need to load
the image after using this metho... | def verify(self):
"""
Verifies the contents of a file. For data read from a file, this
method attempts to determine if the file is broken, without
actually decoding the image data. If this method finds any
problems, it raises suitable exceptions. If you need to load
the... | [
"def",
"verify",
"(",
"self",
")",
":",
"pass"
] | [
848,
4
] | [
857,
12
] | python | en | ['en', 'error', 'th'] | False |
Image.convert | (self, mode=None, matrix=None, dither=None, palette=WEB, colors=256) |
Returns a converted copy of this image. For the "P" mode, this
method translates pixels through the palette. If mode is
omitted, a mode is chosen so that all information in the image
and the palette can be represented without a palette.
The current version supports all possibl... |
Returns a converted copy of this image. For the "P" mode, this
method translates pixels through the palette. If mode is
omitted, a mode is chosen so that all information in the image
and the palette can be represented without a palette. | def convert(self, mode=None, matrix=None, dither=None, palette=WEB, colors=256):
"""
Returns a converted copy of this image. For the "P" mode, this
method translates pixels through the palette. If mode is
omitted, a mode is chosen so that all information in the image
and the pal... | [
"def",
"convert",
"(",
"self",
",",
"mode",
"=",
"None",
",",
"matrix",
"=",
"None",
",",
"dither",
"=",
"None",
",",
"palette",
"=",
"WEB",
",",
"colors",
"=",
"256",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"not",
"mode",
"and",
"self",
... | [
859,
4
] | [
1045,
21
] | python | en | ['en', 'error', 'th'] | False |
Image.quantize | (self, colors=256, method=None, kmeans=0, palette=None, dither=1) |
Convert the image to 'P' mode with the specified number
of colors.
:param colors: The desired number of colors, <= 256
:param method: :data:`MEDIANCUT` (median cut),
:data:`MAXCOVERAGE` (maximum coverage),
:data:`FASTOCTREE` (fast octree),
... |
Convert the image to 'P' mode with the specified number
of colors. | def quantize(self, colors=256, method=None, kmeans=0, palette=None, dither=1):
"""
Convert the image to 'P' mode with the specified number
of colors.
:param colors: The desired number of colors, <= 256
:param method: :data:`MEDIANCUT` (median cut),
:data:`... | [
"def",
"quantize",
"(",
"self",
",",
"colors",
"=",
"256",
",",
"method",
"=",
"None",
",",
"kmeans",
"=",
"0",
",",
"palette",
"=",
"None",
",",
"dither",
"=",
"1",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"method",
"is",
"None",
":",
"#... | [
1047,
4
] | [
1104,
17
] | python | en | ['en', 'error', 'th'] | False |
Image.copy | (self) |
Copies this image. Use this method if you wish to paste things
into an image, but still retain the original.
:rtype: :py:class:`~PIL.Image.Image`
:returns: An :py:class:`~PIL.Image.Image` object.
|
Copies this image. Use this method if you wish to paste things
into an image, but still retain the original. | def copy(self):
"""
Copies this image. Use this method if you wish to paste things
into an image, but still retain the original.
:rtype: :py:class:`~PIL.Image.Image`
:returns: An :py:class:`~PIL.Image.Image` object.
"""
self.load()
return self._new(self.i... | [
"def",
"copy",
"(",
"self",
")",
":",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"_new",
"(",
"self",
".",
"im",
".",
"copy",
"(",
")",
")"
] | [
1106,
4
] | [
1115,
40
] | python | en | ['en', 'error', 'th'] | False |
Image.crop | (self, box=None) |
Returns a rectangular region from this image. The box is a
4-tuple defining the left, upper, right, and lower pixel
coordinate. See :ref:`coordinate-system`.
Note: Prior to Pillow 3.4.0, this was a lazy operation.
:param box: The crop rectangle, as a (left, upper, right, lower... |
Returns a rectangular region from this image. The box is a
4-tuple defining the left, upper, right, and lower pixel
coordinate. See :ref:`coordinate-system`. | def crop(self, box=None):
"""
Returns a rectangular region from this image. The box is a
4-tuple defining the left, upper, right, and lower pixel
coordinate. See :ref:`coordinate-system`.
Note: Prior to Pillow 3.4.0, this was a lazy operation.
:param box: The crop recta... | [
"def",
"crop",
"(",
"self",
",",
"box",
"=",
"None",
")",
":",
"if",
"box",
"is",
"None",
":",
"return",
"self",
".",
"copy",
"(",
")",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"_new",
"(",
"self",
".",
"_crop",
"(",
"self",
".",
... | [
1119,
4
] | [
1136,
50
] | python | en | ['en', 'error', 'th'] | False |
Image._crop | (self, im, box) |
Returns a rectangular region from the core image object im.
This is equivalent to calling im.crop((x0, y0, x1, y1)), but
includes additional sanity checks.
:param im: a core image object
:param box: The crop rectangle, as a (left, upper, right, lower)-tuple.
:returns: ... |
Returns a rectangular region from the core image object im. | def _crop(self, im, box):
"""
Returns a rectangular region from the core image object im.
This is equivalent to calling im.crop((x0, y0, x1, y1)), but
includes additional sanity checks.
:param im: a core image object
:param box: The crop rectangle, as a (left, upper, ri... | [
"def",
"_crop",
"(",
"self",
",",
"im",
",",
"box",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"map",
"(",
"int",
",",
"map",
"(",
"round",
",",
"box",
")",
")",
"absolute_values",
"=",
"(",
"abs",
"(",
"x1",
"-",
"x0",
")",
",",... | [
1138,
4
] | [
1156,
40
] | python | en | ['en', 'error', 'th'] | False |
Image.draft | (self, mode, size) |
Configures the image file loader so it returns a version of the
image that as closely as possible matches the given mode and
size. For example, you can use this method to convert a color
JPEG to greyscale while loading it.
If any changes are made, returns a tuple with the chose... |
Configures the image file loader so it returns a version of the
image that as closely as possible matches the given mode and
size. For example, you can use this method to convert a color
JPEG to greyscale while loading it. | def draft(self, mode, size):
"""
Configures the image file loader so it returns a version of the
image that as closely as possible matches the given mode and
size. For example, you can use this method to convert a color
JPEG to greyscale while loading it.
If any changes ... | [
"def",
"draft",
"(",
"self",
",",
"mode",
",",
"size",
")",
":",
"pass"
] | [
1158,
4
] | [
1178,
12
] | python | en | ['en', 'error', 'th'] | False |
Image.filter | (self, filter) |
Filters this image using the given filter. For a list of
available filters, see the :py:mod:`~PIL.ImageFilter` module.
:param filter: Filter kernel.
:returns: An :py:class:`~PIL.Image.Image` object. |
Filters this image using the given filter. For a list of
available filters, see the :py:mod:`~PIL.ImageFilter` module. | def filter(self, filter):
"""
Filters this image using the given filter. For a list of
available filters, see the :py:mod:`~PIL.ImageFilter` module.
:param filter: Filter kernel.
:returns: An :py:class:`~PIL.Image.Image` object. """
from . import ImageFilter
... | [
"def",
"filter",
"(",
"self",
",",
"filter",
")",
":",
"from",
".",
"import",
"ImageFilter",
"self",
".",
"load",
"(",
")",
"if",
"isinstance",
"(",
"filter",
",",
"Callable",
")",
":",
"filter",
"=",
"filter",
"(",
")",
"if",
"not",
"hasattr",
"(",
... | [
1186,
4
] | [
1212,
36
] | python | en | ['en', 'error', 'th'] | False |
Image.getbands | (self) |
Returns a tuple containing the name of each band in this image.
For example, **getbands** on an RGB image returns ("R", "G", "B").
:returns: A tuple containing band names.
:rtype: tuple
|
Returns a tuple containing the name of each band in this image.
For example, **getbands** on an RGB image returns ("R", "G", "B"). | def getbands(self):
"""
Returns a tuple containing the name of each band in this image.
For example, **getbands** on an RGB image returns ("R", "G", "B").
:returns: A tuple containing band names.
:rtype: tuple
"""
return ImageMode.getmode(self.mode).bands | [
"def",
"getbands",
"(",
"self",
")",
":",
"return",
"ImageMode",
".",
"getmode",
"(",
"self",
".",
"mode",
")",
".",
"bands"
] | [
1214,
4
] | [
1222,
49
] | python | en | ['en', 'error', 'th'] | False |
Image.getbbox | (self) |
Calculates the bounding box of the non-zero regions in the
image.
:returns: The bounding box is returned as a 4-tuple defining the
left, upper, right, and lower pixel coordinate. See
:ref:`coordinate-system`. If the image is completely empty, this
method return... |
Calculates the bounding box of the non-zero regions in the
image. | def getbbox(self):
"""
Calculates the bounding box of the non-zero regions in the
image.
:returns: The bounding box is returned as a 4-tuple defining the
left, upper, right, and lower pixel coordinate. See
:ref:`coordinate-system`. If the image is completely empty,... | [
"def",
"getbbox",
"(",
"self",
")",
":",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"im",
".",
"getbbox",
"(",
")"
] | [
1224,
4
] | [
1237,
32
] | python | en | ['en', 'error', 'th'] | False |
Image.getcolors | (self, maxcolors=256) |
Returns a list of colors used in this image.
:param maxcolors: Maximum number of colors. If this number is
exceeded, this method returns None. The default limit is
256 colors.
:returns: An unsorted list of (count, pixel) values.
|
Returns a list of colors used in this image. | def getcolors(self, maxcolors=256):
"""
Returns a list of colors used in this image.
:param maxcolors: Maximum number of colors. If this number is
exceeded, this method returns None. The default limit is
256 colors.
:returns: An unsorted list of (count, pixel) va... | [
"def",
"getcolors",
"(",
"self",
",",
"maxcolors",
"=",
"256",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"self",
".",
"mode",
"in",
"(",
"\"1\"",
",",
"\"L\"",
",",
"\"P\"",
")",
":",
"h",
"=",
"self",
".",
"im",
".",
"histogram",
"(",
")"... | [
1239,
4
] | [
1259,
43
] | python | en | ['en', 'error', 'th'] | False |
Image.getdata | (self, band=None) |
Returns the contents of this image as a sequence object
containing pixel values. The sequence object is flattened, so
that values for line one follow directly after the values of
line zero, and so on.
Note that the sequence object returned by this method is an
internal... |
Returns the contents of this image as a sequence object
containing pixel values. The sequence object is flattened, so
that values for line one follow directly after the values of
line zero, and so on. | def getdata(self, band=None):
"""
Returns the contents of this image as a sequence object
containing pixel values. The sequence object is flattened, so
that values for line one follow directly after the values of
line zero, and so on.
Note that the sequence object retur... | [
"def",
"getdata",
"(",
"self",
",",
"band",
"=",
"None",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"band",
"is",
"not",
"None",
":",
"return",
"self",
".",
"im",
".",
"getband",
"(",
"band",
")",
"return",
"self",
".",
"im"
] | [
1261,
4
] | [
1282,
22
] | python | en | ['en', 'error', 'th'] | False |
Image.getextrema | (self) |
Gets the the minimum and maximum pixel values for each band in
the image.
:returns: For a single-band image, a 2-tuple containing the
minimum and maximum pixel value. For a multi-band image,
a tuple containing one 2-tuple for each band.
|
Gets the the minimum and maximum pixel values for each band in
the image. | def getextrema(self):
"""
Gets the the minimum and maximum pixel values for each band in
the image.
:returns: For a single-band image, a 2-tuple containing the
minimum and maximum pixel value. For a multi-band image,
a tuple containing one 2-tuple for each band.
... | [
"def",
"getextrema",
"(",
"self",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"self",
".",
"im",
".",
"bands",
">",
"1",
":",
"extrema",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"im",
".",
"bands",
")",
":",
"extrema",
"... | [
1284,
4
] | [
1300,
35
] | python | en | ['en', 'error', 'th'] | False |
Image.getim | (self) |
Returns a capsule that points to the internal image memory.
:returns: A capsule object.
|
Returns a capsule that points to the internal image memory. | def getim(self):
"""
Returns a capsule that points to the internal image memory.
:returns: A capsule object.
"""
self.load()
return self.im.ptr | [
"def",
"getim",
"(",
"self",
")",
":",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"im",
".",
"ptr"
] | [
1329,
4
] | [
1337,
26
] | python | en | ['en', 'error', 'th'] | False |
Image.getpalette | (self) |
Returns the image palette as a list.
:returns: A list of color values [r, g, b, ...], or None if the
image has no palette.
|
Returns the image palette as a list. | def getpalette(self):
"""
Returns the image palette as a list.
:returns: A list of color values [r, g, b, ...], or None if the
image has no palette.
"""
self.load()
try:
return list(self.im.getpalette())
except ValueError:
retu... | [
"def",
"getpalette",
"(",
"self",
")",
":",
"self",
".",
"load",
"(",
")",
"try",
":",
"return",
"list",
"(",
"self",
".",
"im",
".",
"getpalette",
"(",
")",
")",
"except",
"ValueError",
":",
"return",
"None"
] | [
1339,
4
] | [
1351,
23
] | python | en | ['en', 'error', 'th'] | False |
Image.getpixel | (self, xy) |
Returns the pixel value at a given position.
:param xy: The coordinate, given as (x, y). See
:ref:`coordinate-system`.
:returns: The pixel value. If the image is a multi-layer image,
this method returns a tuple.
|
Returns the pixel value at a given position. | def getpixel(self, xy):
"""
Returns the pixel value at a given position.
:param xy: The coordinate, given as (x, y). See
:ref:`coordinate-system`.
:returns: The pixel value. If the image is a multi-layer image,
this method returns a tuple.
"""
sel... | [
"def",
"getpixel",
"(",
"self",
",",
"xy",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"self",
".",
"pyaccess",
":",
"return",
"self",
".",
"pyaccess",
".",
"getpixel",
"(",
"xy",
")",
"return",
"self",
".",
"im",
".",
"getpixel",
"(",
"xy",
"... | [
1353,
4
] | [
1366,
35
] | python | en | ['en', 'error', 'th'] | False |
Image.getprojection | (self) |
Get projection to x and y axes
:returns: Two sequences, indicating where there are non-zero
pixels along the X-axis and the Y-axis, respectively.
|
Get projection to x and y axes | def getprojection(self):
"""
Get projection to x and y axes
:returns: Two sequences, indicating where there are non-zero
pixels along the X-axis and the Y-axis, respectively.
"""
self.load()
x, y = self.im.getprojection()
return [i8(c) for c in x], [... | [
"def",
"getprojection",
"(",
"self",
")",
":",
"self",
".",
"load",
"(",
")",
"x",
",",
"y",
"=",
"self",
".",
"im",
".",
"getprojection",
"(",
")",
"return",
"[",
"i8",
"(",
"c",
")",
"for",
"c",
"in",
"x",
"]",
",",
"[",
"i8",
"(",
"c",
"... | [
1368,
4
] | [
1378,
53
] | python | en | ['en', 'error', 'th'] | False |
Image.histogram | (self, mask=None, extrema=None) |
Returns a histogram for the image. The histogram is returned as
a list of pixel counts, one for each pixel value in the source
image. If the image has more than one band, the histograms for
all bands are concatenated (for example, the histogram for an
"RGB" image contains 768 va... |
Returns a histogram for the image. The histogram is returned as
a list of pixel counts, one for each pixel value in the source
image. If the image has more than one band, the histograms for
all bands are concatenated (for example, the histogram for an
"RGB" image contains 768 va... | def histogram(self, mask=None, extrema=None):
"""
Returns a histogram for the image. The histogram is returned as
a list of pixel counts, one for each pixel value in the source
image. If the image has more than one band, the histograms for
all bands are concatenated (for example,... | [
"def",
"histogram",
"(",
"self",
",",
"mask",
"=",
"None",
",",
"extrema",
"=",
"None",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"mask",
":",
"mask",
".",
"load",
"(",
")",
"return",
"self",
".",
"im",
".",
"histogram",
"(",
"(",
"0",
","... | [
1380,
4
] | [
1408,
34
] | python | en | ['en', 'error', 'th'] | False |
Image.entropy | (self, mask=None, extrema=None) |
Calculates and returns the entropy for the image.
A bilevel image (mode "1") is treated as a greyscale ("L")
image by this method.
If a mask is provided, the method employs the histogram for
those parts of the image where the mask image is non-zero.
The mask image must... |
Calculates and returns the entropy for the image. | def entropy(self, mask=None, extrema=None):
"""
Calculates and returns the entropy for the image.
A bilevel image (mode "1") is treated as a greyscale ("L")
image by this method.
If a mask is provided, the method employs the histogram for
those parts of the image where ... | [
"def",
"entropy",
"(",
"self",
",",
"mask",
"=",
"None",
",",
"extrema",
"=",
"None",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"mask",
":",
"mask",
".",
"load",
"(",
")",
"return",
"self",
".",
"im",
".",
"entropy",
"(",
"(",
"0",
",",
... | [
1410,
4
] | [
1434,
32
] | python | en | ['en', 'error', 'th'] | False |
Image.paste | (self, im, box=None, mask=None) |
Pastes another image into this image. The box argument is either
a 2-tuple giving the upper left corner, a 4-tuple defining the
left, upper, right, and lower pixel coordinate, or None (same as
(0, 0)). See :ref:`coordinate-system`. If a 4-tuple is given, the size
of the pasted i... |
Pastes another image into this image. The box argument is either
a 2-tuple giving the upper left corner, a 4-tuple defining the
left, upper, right, and lower pixel coordinate, or None (same as
(0, 0)). See :ref:`coordinate-system`. If a 4-tuple is given, the size
of the pasted i... | def paste(self, im, box=None, mask=None):
"""
Pastes another image into this image. The box argument is either
a 2-tuple giving the upper left corner, a 4-tuple defining the
left, upper, right, and lower pixel coordinate, or None (same as
(0, 0)). See :ref:`coordinate-system`. If... | [
"def",
"paste",
"(",
"self",
",",
"im",
",",
"box",
"=",
"None",
",",
"mask",
"=",
"None",
")",
":",
"if",
"isImageType",
"(",
"box",
")",
"and",
"mask",
"is",
"None",
":",
"# abbreviated paste(im, mask) syntax",
"mask",
"=",
"box",
"box",
"=",
"None",... | [
1441,
4
] | [
1519,
34
] | python | en | ['en', 'error', 'th'] | False |
Image.alpha_composite | (self, im, dest=(0, 0), source=(0, 0)) | 'In-place' analog of Image.alpha_composite. Composites an image
onto this image.
:param im: image to composite over this one
:param dest: Optional 2 tuple (left, top) specifying the upper
left corner in this (destination) image.
:param source: Optional 2 (left, top) tuple for... | 'In-place' analog of Image.alpha_composite. Composites an image
onto this image. | def alpha_composite(self, im, dest=(0, 0), source=(0, 0)):
""" 'In-place' analog of Image.alpha_composite. Composites an image
onto this image.
:param im: image to composite over this one
:param dest: Optional 2 tuple (left, top) specifying the upper
left corner in this (desti... | [
"def",
"alpha_composite",
"(",
"self",
",",
"im",
",",
"dest",
"=",
"(",
"0",
",",
"0",
")",
",",
"source",
"=",
"(",
"0",
",",
"0",
")",
")",
":",
"if",
"not",
"isinstance",
"(",
"source",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"rais... | [
1521,
4
] | [
1567,
31
] | python | en | ['en', 'en', 'en'] | True |
Image.point | (self, lut, mode=None) |
Maps this image through a lookup table or function.
:param lut: A lookup table, containing 256 (or 65536 if
self.mode=="I" and mode == "L") values per band in the
image. A function can be used instead, it should take a
single argument. The function is called once for ... |
Maps this image through a lookup table or function. | def point(self, lut, mode=None):
"""
Maps this image through a lookup table or function.
:param lut: A lookup table, containing 256 (or 65536 if
self.mode=="I" and mode == "L") values per band in the
image. A function can be used instead, it should take a
singl... | [
"def",
"point",
"(",
"self",
",",
"lut",
",",
"mode",
"=",
"None",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"isinstance",
"(",
"lut",
",",
"ImagePointHandler",
")",
":",
"return",
"lut",
".",
"point",
"(",
"self",
")",
"if",
"callable",
"(",
... | [
1569,
4
] | [
1606,
50
] | python | en | ['en', 'error', 'th'] | False |
Image.putalpha | (self, alpha) |
Adds or replaces the alpha layer in this image. If the image
does not have an alpha layer, it's converted to "LA" or "RGBA".
The new layer must be either "L" or "1".
:param alpha: The new alpha layer. This can either be an "L" or "1"
image having the same size as this imag... |
Adds or replaces the alpha layer in this image. If the image
does not have an alpha layer, it's converted to "LA" or "RGBA".
The new layer must be either "L" or "1". | def putalpha(self, alpha):
"""
Adds or replaces the alpha layer in this image. If the image
does not have an alpha layer, it's converted to "LA" or "RGBA".
The new layer must be either "L" or "1".
:param alpha: The new alpha layer. This can either be an "L" or "1"
i... | [
"def",
"putalpha",
"(",
"self",
",",
"alpha",
")",
":",
"self",
".",
"_ensure_mutable",
"(",
")",
"if",
"self",
".",
"mode",
"not",
"in",
"(",
"\"LA\"",
",",
"\"PA\"",
",",
"\"RGBA\"",
")",
":",
"# attempt to promote self to a matching alpha mode",
"try",
":... | [
1608,
4
] | [
1660,
39
] | python | en | ['en', 'error', 'th'] | False |
Image.putdata | (self, data, scale=1.0, offset=0.0) |
Copies pixel data to this image. This method copies data from a
sequence object into the image, starting at the upper left
corner (0, 0), and continuing until either the image or the
sequence ends. The scale and offset values are used to adjust
the sequence values: **pixel = v... |
Copies pixel data to this image. This method copies data from a
sequence object into the image, starting at the upper left
corner (0, 0), and continuing until either the image or the
sequence ends. The scale and offset values are used to adjust
the sequence values: **pixel = v... | def putdata(self, data, scale=1.0, offset=0.0):
"""
Copies pixel data to this image. This method copies data from a
sequence object into the image, starting at the upper left
corner (0, 0), and continuing until either the image or the
sequence ends. The scale and offset values ... | [
"def",
"putdata",
"(",
"self",
",",
"data",
",",
"scale",
"=",
"1.0",
",",
"offset",
"=",
"0.0",
")",
":",
"self",
".",
"_ensure_mutable",
"(",
")",
"self",
".",
"im",
".",
"putdata",
"(",
"data",
",",
"scale",
",",
"offset",
")"
] | [
1662,
4
] | [
1677,
44
] | python | en | ['en', 'error', 'th'] | False |
Image.putpalette | (self, data, rawmode="RGB") |
Attaches a palette to this image. The image must be a "P",
"PA", "L" or "LA" image, and the palette sequence must contain
768 integer values, where each group of three values represent
the red, green, and blue values for the corresponding pixel
index. Instead of an integer sequ... |
Attaches a palette to this image. The image must be a "P",
"PA", "L" or "LA" image, and the palette sequence must contain
768 integer values, where each group of three values represent
the red, green, and blue values for the corresponding pixel
index. Instead of an integer sequ... | def putpalette(self, data, rawmode="RGB"):
"""
Attaches a palette to this image. The image must be a "P",
"PA", "L" or "LA" image, and the palette sequence must contain
768 integer values, where each group of three values represent
the red, green, and blue values for the corresp... | [
"def",
"putpalette",
"(",
"self",
",",
"data",
",",
"rawmode",
"=",
"\"RGB\"",
")",
":",
"from",
".",
"import",
"ImagePalette",
"if",
"self",
".",
"mode",
"not",
"in",
"(",
"\"L\"",
",",
"\"LA\"",
",",
"\"P\"",
",",
"\"PA\"",
")",
":",
"raise",
"Valu... | [
1679,
4
] | [
1705,
19
] | python | en | ['en', 'error', 'th'] | False |
Image.putpixel | (self, xy, value) |
Modifies the pixel at the given position. The color is given as
a single numerical value for single-band images, and a tuple for
multi-band images. In addition to this, RGB and RGBA tuples are
accepted for P images.
Note that this method is relatively slow. For more extensive ... |
Modifies the pixel at the given position. The color is given as
a single numerical value for single-band images, and a tuple for
multi-band images. In addition to this, RGB and RGBA tuples are
accepted for P images. | def putpixel(self, xy, value):
"""
Modifies the pixel at the given position. The color is given as
a single numerical value for single-band images, and a tuple for
multi-band images. In addition to this, RGB and RGBA tuples are
accepted for P images.
Note that this metho... | [
"def",
"putpixel",
"(",
"self",
",",
"xy",
",",
"value",
")",
":",
"if",
"self",
".",
"readonly",
":",
"self",
".",
"_copy",
"(",
")",
"self",
".",
"load",
"(",
")",
"if",
"self",
".",
"pyaccess",
":",
"return",
"self",
".",
"pyaccess",
".",
"put... | [
1707,
4
] | [
1743,
42
] | python | en | ['en', 'error', 'th'] | False |
Image.remap_palette | (self, dest_map, source_palette=None) |
Rewrites the image to reorder the palette.
:param dest_map: A list of indexes into the original palette.
e.g. [1,0] would swap a two item palette, and list(range(256))
is the identity transform.
:param source_palette: Bytes or None.
:returns: An :py:class:`~PIL.I... |
Rewrites the image to reorder the palette. | def remap_palette(self, dest_map, source_palette=None):
"""
Rewrites the image to reorder the palette.
:param dest_map: A list of indexes into the original palette.
e.g. [1,0] would swap a two item palette, and list(range(256))
is the identity transform.
:param sou... | [
"def",
"remap_palette",
"(",
"self",
",",
"dest_map",
",",
"source_palette",
"=",
"None",
")",
":",
"from",
".",
"import",
"ImagePalette",
"if",
"self",
".",
"mode",
"not",
"in",
"(",
"\"L\"",
",",
"\"P\"",
")",
":",
"raise",
"ValueError",
"(",
"\"illega... | [
1745,
4
] | [
1818,
19
] | python | en | ['en', 'error', 'th'] | False |
Image._get_safe_box | (self, size, resample, box) | Expands the box so it includes adjacent pixels
that may be used by resampling with the given resampling filter.
| Expands the box so it includes adjacent pixels
that may be used by resampling with the given resampling filter.
| def _get_safe_box(self, size, resample, box):
"""Expands the box so it includes adjacent pixels
that may be used by resampling with the given resampling filter.
"""
filter_support = _filters_support[resample] - 0.5
scale_x = (box[2] - box[0]) / size[0]
scale_y = (box[3] -... | [
"def",
"_get_safe_box",
"(",
"self",
",",
"size",
",",
"resample",
",",
"box",
")",
":",
"filter_support",
"=",
"_filters_support",
"[",
"resample",
"]",
"-",
"0.5",
"scale_x",
"=",
"(",
"box",
"[",
"2",
"]",
"-",
"box",
"[",
"0",
"]",
")",
"/",
"s... | [
1820,
4
] | [
1835,
9
] | python | en | ['en', 'fr', 'en'] | True |
Image.resize | (self, size, resample=BICUBIC, box=None, reducing_gap=None) |
Returns a resized copy of this image.
:param size: The requested size in pixels, as a 2-tuple:
(width, height).
:param resample: An optional resampling filter. This can be
one of :py:data:`PIL.Image.NEAREST`, :py:data:`PIL.Image.BOX`,
:py:data:`PIL.Image.BILIN... |
Returns a resized copy of this image. | def resize(self, size, resample=BICUBIC, box=None, reducing_gap=None):
"""
Returns a resized copy of this image.
:param size: The requested size in pixels, as a 2-tuple:
(width, height).
:param resample: An optional resampling filter. This can be
one of :py:data:`... | [
"def",
"resize",
"(",
"self",
",",
"size",
",",
"resample",
"=",
"BICUBIC",
",",
"box",
"=",
"None",
",",
"reducing_gap",
"=",
"None",
")",
":",
"if",
"resample",
"not",
"in",
"(",
"NEAREST",
",",
"BILINEAR",
",",
"BICUBIC",
",",
"LANCZOS",
",",
"BOX... | [
1837,
4
] | [
1928,
61
] | python | en | ['en', 'error', 'th'] | False |
Image.reduce | (self, factor, box=None) |
Returns a copy of the image reduced by `factor` times.
If the size of the image is not dividable by the `factor`,
the resulting size will be rounded up.
:param factor: A greater than 0 integer or tuple of two integers
for width and height separately.
:param box: An o... |
Returns a copy of the image reduced by `factor` times.
If the size of the image is not dividable by the `factor`,
the resulting size will be rounded up. | def reduce(self, factor, box=None):
"""
Returns a copy of the image reduced by `factor` times.
If the size of the image is not dividable by the `factor`,
the resulting size will be rounded up.
:param factor: A greater than 0 integer or tuple of two integers
for width ... | [
"def",
"reduce",
"(",
"self",
",",
"factor",
",",
"box",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"factor",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"factor",
"=",
"(",
"factor",
",",
"factor",
")",
"if",
"box",
"is",
"None",
... | [
1930,
4
] | [
1961,
53
] | python | en | ['en', 'error', 'th'] | False |
Image.rotate | (
self,
angle,
resample=NEAREST,
expand=0,
center=None,
translate=None,
fillcolor=None,
) |
Returns a rotated copy of this image. This method returns a
copy of this image, rotated the given number of degrees counter
clockwise around its centre.
:param angle: In degrees counter clockwise.
:param resample: An optional resampling filter. This can be
one of :... |
Returns a rotated copy of this image. This method returns a
copy of this image, rotated the given number of degrees counter
clockwise around its centre. | def rotate(
self,
angle,
resample=NEAREST,
expand=0,
center=None,
translate=None,
fillcolor=None,
):
"""
Returns a rotated copy of this image. This method returns a
copy of this image, rotated the given number of degrees counter
... | [
"def",
"rotate",
"(",
"self",
",",
"angle",
",",
"resample",
"=",
"NEAREST",
",",
"expand",
"=",
"0",
",",
"center",
"=",
"None",
",",
"translate",
"=",
"None",
",",
"fillcolor",
"=",
"None",
",",
")",
":",
"angle",
"=",
"angle",
"%",
"360.0",
"# F... | [
1963,
4
] | [
2078,
84
] | python | en | ['en', 'error', 'th'] | False |
Image.save | (self, fp, format=None, **params) |
Saves this image under the given filename. If no format is
specified, the format to use is determined from the filename
extension, if possible.
Keyword options can be used to provide additional instructions
to the writer. If a writer doesn't recognise an option, it is
... |
Saves this image under the given filename. If no format is
specified, the format to use is determined from the filename
extension, if possible. | def save(self, fp, format=None, **params):
"""
Saves this image under the given filename. If no format is
specified, the format to use is determined from the filename
extension, if possible.
Keyword options can be used to provide additional instructions
to the writer. I... | [
"def",
"save",
"(",
"self",
",",
"fp",
",",
"format",
"=",
"None",
",",
"*",
"*",
"params",
")",
":",
"filename",
"=",
"\"\"",
"open_fp",
"=",
"False",
"if",
"isPath",
"(",
"fp",
")",
":",
"filename",
"=",
"fp",
"open_fp",
"=",
"True",
"elif",
"i... | [
2080,
4
] | [
2161,
26
] | python | en | ['en', 'error', 'th'] | False |
Image.seek | (self, frame) |
Seeks to the given frame in this sequence file. If you seek
beyond the end of the sequence, the method raises an
``EOFError`` exception. When a sequence file is opened, the
library automatically seeks to frame 0.
See :py:meth:`~PIL.Image.Image.tell`.
:param frame: Fram... |
Seeks to the given frame in this sequence file. If you seek
beyond the end of the sequence, the method raises an
``EOFError`` exception. When a sequence file is opened, the
library automatically seeks to frame 0. | def seek(self, frame):
"""
Seeks to the given frame in this sequence file. If you seek
beyond the end of the sequence, the method raises an
``EOFError`` exception. When a sequence file is opened, the
library automatically seeks to frame 0.
See :py:meth:`~PIL.Image.Image.... | [
"def",
"seek",
"(",
"self",
",",
"frame",
")",
":",
"# overridden by file handlers",
"if",
"frame",
"!=",
"0",
":",
"raise",
"EOFError"
] | [
2163,
4
] | [
2179,
26
] | python | en | ['en', 'error', 'th'] | False |
Image.show | (self, title=None, command=None) |
Displays this image. This method is mainly intended for debugging purposes.
This method calls :py:func:`PIL.ImageShow.show` internally. You can use
:py:func:`PIL.ImageShow.register` to override its default behaviour.
The image is first saved to a temporary file. By default, it will be... |
Displays this image. This method is mainly intended for debugging purposes. | def show(self, title=None, command=None):
"""
Displays this image. This method is mainly intended for debugging purposes.
This method calls :py:func:`PIL.ImageShow.show` internally. You can use
:py:func:`PIL.ImageShow.register` to override its default behaviour.
The image is fi... | [
"def",
"show",
"(",
"self",
",",
"title",
"=",
"None",
",",
"command",
"=",
"None",
")",
":",
"if",
"command",
"is",
"not",
"None",
":",
"warnings",
".",
"warn",
"(",
"\"The command parameter is deprecated and will be removed in a future \"",
"\"release. Use a subcl... | [
2181,
4
] | [
2208,
49
] | python | en | ['en', 'error', 'th'] | False |
Image.split | (self) |
Split this image into individual bands. This method returns a
tuple of individual image bands from an image. For example,
splitting an "RGB" image creates three new images each
containing a copy of one of the original bands (red, green,
blue).
If you need only one band,... |
Split this image into individual bands. This method returns a
tuple of individual image bands from an image. For example,
splitting an "RGB" image creates three new images each
containing a copy of one of the original bands (red, green,
blue). | def split(self):
"""
Split this image into individual bands. This method returns a
tuple of individual image bands from an image. For example,
splitting an "RGB" image creates three new images each
containing a copy of one of the original bands (red, green,
blue).
... | [
"def",
"split",
"(",
"self",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"self",
".",
"im",
".",
"bands",
"==",
"1",
":",
"ims",
"=",
"[",
"self",
".",
"copy",
"(",
")",
"]",
"else",
":",
"ims",
"=",
"map",
"(",
"self",
".",
"_new",
",",... | [
2210,
4
] | [
2229,
25
] | python | en | ['en', 'error', 'th'] | False |
Image.getchannel | (self, channel) |
Returns an image containing a single channel of the source image.
:param channel: What channel to return. Could be index
(0 for "R" channel of "RGB") or channel name
("A" for alpha channel of "RGBA").
:returns: An image in "L" mode.
.. versionadded:: 4.3.0
|
Returns an image containing a single channel of the source image. | def getchannel(self, channel):
"""
Returns an image containing a single channel of the source image.
:param channel: What channel to return. Could be index
(0 for "R" channel of "RGB") or channel name
("A" for alpha channel of "RGBA").
:returns: An image in "L" mode.... | [
"def",
"getchannel",
"(",
"self",
",",
"channel",
")",
":",
"self",
".",
"load",
"(",
")",
"if",
"isinstance",
"(",
"channel",
",",
"str",
")",
":",
"try",
":",
"channel",
"=",
"self",
".",
"getbands",
"(",
")",
".",
"index",
"(",
"channel",
")",
... | [
2231,
4
] | [
2250,
50
] | python | en | ['en', 'error', 'th'] | False |
Image.tell | (self) |
Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`.
:returns: Frame number, starting with 0.
|
Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`. | def tell(self):
"""
Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`.
:returns: Frame number, starting with 0.
"""
return 0 | [
"def",
"tell",
"(",
"self",
")",
":",
"return",
"0"
] | [
2252,
4
] | [
2258,
16
] | python | en | ['en', 'error', 'th'] | False |
Image.thumbnail | (self, size, resample=BICUBIC, reducing_gap=2.0) |
Make this image into a thumbnail. This method modifies the
image to contain a thumbnail version of itself, no larger than
the given size. This method calculates an appropriate thumbnail
size to preserve the aspect of the image, calls the
:py:meth:`~PIL.Image.Image.draft` metho... |
Make this image into a thumbnail. This method modifies the
image to contain a thumbnail version of itself, no larger than
the given size. This method calculates an appropriate thumbnail
size to preserve the aspect of the image, calls the
:py:meth:`~PIL.Image.Image.draft` metho... | def thumbnail(self, size, resample=BICUBIC, reducing_gap=2.0):
"""
Make this image into a thumbnail. This method modifies the
image to contain a thumbnail version of itself, no larger than
the given size. This method calculates an appropriate thumbnail
size to preserve the aspe... | [
"def",
"thumbnail",
"(",
"self",
",",
"size",
",",
"resample",
"=",
"BICUBIC",
",",
"reducing_gap",
"=",
"2.0",
")",
":",
"x",
",",
"y",
"=",
"map",
"(",
"math",
".",
"floor",
",",
"size",
")",
"if",
"x",
">=",
"self",
".",
"width",
"and",
"y",
... | [
2260,
4
] | [
2329,
28
] | python | en | ['en', 'error', 'th'] | False |
Image.transform | (
self, size, method, data=None, resample=NEAREST, fill=1, fillcolor=None
) |
Transforms this image. This method creates a new image with the
given size, and the same mode as the original, and copies data
to the new image using the given transform.
:param size: The output size.
:param method: The transformation method. This is one of
:py:data... |
Transforms this image. This method creates a new image with the
given size, and the same mode as the original, and copies data
to the new image using the given transform. | def transform(
self, size, method, data=None, resample=NEAREST, fill=1, fillcolor=None
):
"""
Transforms this image. This method creates a new image with the
given size, and the same mode as the original, and copies data
to the new image using the given transform.
:... | [
"def",
"transform",
"(",
"self",
",",
"size",
",",
"method",
",",
"data",
"=",
"None",
",",
"resample",
"=",
"NEAREST",
",",
"fill",
"=",
"1",
",",
"fillcolor",
"=",
"None",
")",
":",
"if",
"self",
".",
"mode",
"==",
"\"LA\"",
":",
"return",
"(",
... | [
2333,
4
] | [
2416,
17
] | python | en | ['en', 'error', 'th'] | False |
Image.transpose | (self, method) |
Transpose image (flip or rotate in 90 degree steps)
:param method: One of :py:data:`PIL.Image.FLIP_LEFT_RIGHT`,
:py:data:`PIL.Image.FLIP_TOP_BOTTOM`, :py:data:`PIL.Image.ROTATE_90`,
:py:data:`PIL.Image.ROTATE_180`, :py:data:`PIL.Image.ROTATE_270`,
:py:data:`PIL.Image.TRAN... |
Transpose image (flip or rotate in 90 degree steps) | def transpose(self, method):
"""
Transpose image (flip or rotate in 90 degree steps)
:param method: One of :py:data:`PIL.Image.FLIP_LEFT_RIGHT`,
:py:data:`PIL.Image.FLIP_TOP_BOTTOM`, :py:data:`PIL.Image.ROTATE_90`,
:py:data:`PIL.Image.ROTATE_180`, :py:data:`PIL.Image.ROTATE_... | [
"def",
"transpose",
"(",
"self",
",",
"method",
")",
":",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"_new",
"(",
"self",
".",
"im",
".",
"transpose",
"(",
"method",
")",
")"
] | [
2491,
4
] | [
2503,
51
] | python | en | ['en', 'error', 'th'] | False |
Image.effect_spread | (self, distance) |
Randomly spread pixels in an image.
:param distance: Distance to spread pixels.
|
Randomly spread pixels in an image. | def effect_spread(self, distance):
"""
Randomly spread pixels in an image.
:param distance: Distance to spread pixels.
"""
self.load()
return self._new(self.im.effect_spread(distance)) | [
"def",
"effect_spread",
"(",
"self",
",",
"distance",
")",
":",
"self",
".",
"load",
"(",
")",
"return",
"self",
".",
"_new",
"(",
"self",
".",
"im",
".",
"effect_spread",
"(",
"distance",
")",
")"
] | [
2505,
4
] | [
2512,
57
] | python | en | ['en', 'error', 'th'] | False |
Image.toqimage | (self) | Returns a QImage copy of this image | Returns a QImage copy of this image | def toqimage(self):
"""Returns a QImage copy of this image"""
from . import ImageQt
if not ImageQt.qt_is_installed:
raise ImportError("Qt bindings are not installed")
return ImageQt.toqimage(self) | [
"def",
"toqimage",
"(",
"self",
")",
":",
"from",
".",
"import",
"ImageQt",
"if",
"not",
"ImageQt",
".",
"qt_is_installed",
":",
"raise",
"ImportError",
"(",
"\"Qt bindings are not installed\"",
")",
"return",
"ImageQt",
".",
"toqimage",
"(",
"self",
")"
] | [
2514,
4
] | [
2520,
37
] | python | en | ['en', 'en', 'en'] | True |
Image.toqpixmap | (self) | Returns a QPixmap copy of this image | Returns a QPixmap copy of this image | def toqpixmap(self):
"""Returns a QPixmap copy of this image"""
from . import ImageQt
if not ImageQt.qt_is_installed:
raise ImportError("Qt bindings are not installed")
return ImageQt.toqpixmap(self) | [
"def",
"toqpixmap",
"(",
"self",
")",
":",
"from",
".",
"import",
"ImageQt",
"if",
"not",
"ImageQt",
".",
"qt_is_installed",
":",
"raise",
"ImportError",
"(",
"\"Qt bindings are not installed\"",
")",
"return",
"ImageQt",
".",
"toqpixmap",
"(",
"self",
")"
] | [
2522,
4
] | [
2528,
38
] | python | en | ['en', 'ca', 'en'] | True |
BaseModelAdminChecks._check_raw_id_fields | (self, cls, model) | Check that `raw_id_fields` only contains field names that are listed
on the model. | Check that `raw_id_fields` only contains field names that are listed
on the model. | def _check_raw_id_fields(self, cls, model):
""" Check that `raw_id_fields` only contains field names that are listed
on the model. """
if not isinstance(cls.raw_id_fields, (list, tuple)):
return must_be('a list or tuple', option='raw_id_fields', obj=cls, id='admin.E001')
els... | [
"def",
"_check_raw_id_fields",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"raw_id_fields",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",
"option",
"=",... | [
39,
4
] | [
49,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_raw_id_fields_item | (self, cls, model, field_name, label) | Check an item of `raw_id_fields`, i.e. check that field named
`field_name` exists in model `model` and is a ForeignKey or a
ManyToManyField. | Check an item of `raw_id_fields`, i.e. check that field named
`field_name` exists in model `model` and is a ForeignKey or a
ManyToManyField. | def _check_raw_id_fields_item(self, cls, model, field_name, label):
""" Check an item of `raw_id_fields`, i.e. check that field named
`field_name` exists in model `model` and is a ForeignKey or a
ManyToManyField. """
try:
field = model._meta.get_field(field_name)
exc... | [
"def",
"_check_raw_id_fields_item",
"(",
"self",
",",
"cls",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"models",
".",
"FieldDoesNotExist",
"... | [
51,
4
] | [
66,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_fields | (self, cls, model) | Check that `fields` only refer to existing fields, doesn't contain
duplicates. Check if at most one of `fields` and `fieldsets` is defined.
| Check that `fields` only refer to existing fields, doesn't contain
duplicates. Check if at most one of `fields` and `fieldsets` is defined.
| def _check_fields(self, cls, model):
""" Check that `fields` only refer to existing fields, doesn't contain
duplicates. Check if at most one of `fields` and `fieldsets` is defined.
"""
if cls.fields is None:
return []
elif not isinstance(cls.fields, (list, tuple)):
... | [
"def",
"_check_fields",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"cls",
".",
"fields",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"fields",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"re... | [
68,
4
] | [
100,
11
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_fieldsets | (self, cls, model) | Check that fieldsets is properly formatted and doesn't contain
duplicates. | Check that fieldsets is properly formatted and doesn't contain
duplicates. | def _check_fieldsets(self, cls, model):
""" Check that fieldsets is properly formatted and doesn't contain
duplicates. """
if cls.fieldsets is None:
return []
elif not isinstance(cls.fieldsets, (list, tuple)):
return must_be('a list or tuple', option='fieldsets',... | [
"def",
"_check_fieldsets",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"cls",
".",
"fieldsets",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"fieldsets",
",",
"(",
"list",
",",
"tuple",
")",
")",
"... | [
102,
4
] | [
114,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_fieldsets_item | (self, cls, model, fieldset, label) | Check an item of `fieldsets`, i.e. check that this is a pair of a
set name and a dictionary containing "fields" key. | Check an item of `fieldsets`, i.e. check that this is a pair of a
set name and a dictionary containing "fields" key. | def _check_fieldsets_item(self, cls, model, fieldset, label):
""" Check an item of `fieldsets`, i.e. check that this is a pair of a
set name and a dictionary containing "fields" key. """
if not isinstance(fieldset, (list, tuple)):
return must_be('a list or tuple', option=label, obj=... | [
"def",
"_check_fieldsets_item",
"(",
"self",
",",
"cls",
",",
"model",
",",
"fieldset",
",",
"label",
")",
":",
"if",
"not",
"isinstance",
"(",
"fieldset",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",... | [
116,
4
] | [
149,
11
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_field_spec | (self, cls, model, fields, label) | `fields` should be an item of `fields` or an item of
fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
field name or a tuple of field names. | `fields` should be an item of `fields` or an item of
fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
field name or a tuple of field names. | def _check_field_spec(self, cls, model, fields, label):
""" `fields` should be an item of `fields` or an item of
fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
field name or a tuple of field names. """
if isinstance(fields, tuple):
return list(chain(... | [
"def",
"_check_field_spec",
"(",
"self",
",",
"cls",
",",
"model",
",",
"fields",
",",
"label",
")",
":",
"if",
"isinstance",
"(",
"fields",
",",
"tuple",
")",
":",
"return",
"list",
"(",
"chain",
"(",
"*",
"[",
"self",
".",
"_check_field_spec_item",
"... | [
151,
4
] | [
162,
73
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_exclude | (self, cls, model) | Check that exclude is a sequence without duplicates. | Check that exclude is a sequence without duplicates. | def _check_exclude(self, cls, model):
""" Check that exclude is a sequence without duplicates. """
if cls.exclude is None: # default value is None
return []
elif not isinstance(cls.exclude, (list, tuple)):
return must_be('a list or tuple', option='exclude', obj=cls, id=... | [
"def",
"_check_exclude",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"cls",
".",
"exclude",
"is",
"None",
":",
"# default value is None",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"exclude",
",",
"(",
"list",
",",
"tu... | [
193,
4
] | [
210,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_form | (self, cls, model) | Check that form subclasses BaseModelForm. | Check that form subclasses BaseModelForm. | def _check_form(self, cls, model):
""" Check that form subclasses BaseModelForm. """
if hasattr(cls, 'form') and not issubclass(cls.form, BaseModelForm):
return must_inherit_from(parent='BaseModelForm', option='form',
obj=cls, id='admin.E016')
el... | [
"def",
"_check_form",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"hasattr",
"(",
"cls",
",",
"'form'",
")",
"and",
"not",
"issubclass",
"(",
"cls",
".",
"form",
",",
"BaseModelForm",
")",
":",
"return",
"must_inherit_from",
"(",
"parent",
"... | [
212,
4
] | [
219,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_filter_vertical | (self, cls, model) | Check that filter_vertical is a sequence of field names. | Check that filter_vertical is a sequence of field names. | def _check_filter_vertical(self, cls, model):
""" Check that filter_vertical is a sequence of field names. """
if not hasattr(cls, 'filter_vertical'):
return []
elif not isinstance(cls.filter_vertical, (list, tuple)):
return must_be('a list or tuple', option='filter_vert... | [
"def",
"_check_filter_vertical",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'filter_vertical'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"filter_vertical",
",",
"(",
"list... | [
221,
4
] | [
232,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_filter_horizontal | (self, cls, model) | Check that filter_horizontal is a sequence of field names. | Check that filter_horizontal is a sequence of field names. | def _check_filter_horizontal(self, cls, model):
""" Check that filter_horizontal is a sequence of field names. """
if not hasattr(cls, 'filter_horizontal'):
return []
elif not isinstance(cls.filter_horizontal, (list, tuple)):
return must_be('a list or tuple', option='fil... | [
"def",
"_check_filter_horizontal",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'filter_horizontal'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"filter_horizontal",
",",
"(",
... | [
234,
4
] | [
245,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_filter_item | (self, cls, model, field_name, label) | Check one item of `filter_vertical` or `filter_horizontal`, i.e.
check that given field exists and is a ManyToManyField. | Check one item of `filter_vertical` or `filter_horizontal`, i.e.
check that given field exists and is a ManyToManyField. | def _check_filter_item(self, cls, model, field_name, label):
""" Check one item of `filter_vertical` or `filter_horizontal`, i.e.
check that given field exists and is a ManyToManyField. """
try:
field = model._meta.get_field(field_name)
except models.FieldDoesNotExist:
... | [
"def",
"_check_filter_item",
"(",
"self",
",",
"cls",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"models",
".",
"FieldDoesNotExist",
":",
"... | [
247,
4
] | [
260,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_radio_fields | (self, cls, model) | Check that `radio_fields` is a dictionary. | Check that `radio_fields` is a dictionary. | def _check_radio_fields(self, cls, model):
""" Check that `radio_fields` is a dictionary. """
if not hasattr(cls, 'radio_fields'):
return []
elif not isinstance(cls.radio_fields, dict):
return must_be('a dictionary', option='radio_fields', obj=cls, id='admin.E021')
... | [
"def",
"_check_radio_fields",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'radio_fields'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"radio_fields",
",",
"dict",
")",
":",... | [
262,
4
] | [
274,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_radio_fields_key | (self, cls, model, field_name, label) | Check that a key of `radio_fields` dictionary is name of existing
field and that the field is a ForeignKey or has `choices` defined. | Check that a key of `radio_fields` dictionary is name of existing
field and that the field is a ForeignKey or has `choices` defined. | def _check_radio_fields_key(self, cls, model, field_name, label):
""" Check that a key of `radio_fields` dictionary is name of existing
field and that the field is a ForeignKey or has `choices` defined. """
try:
field = model._meta.get_field(field_name)
except models.FieldDo... | [
"def",
"_check_radio_fields_key",
"(",
"self",
",",
"cls",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"models",
".",
"FieldDoesNotExist",
":"... | [
276,
4
] | [
299,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_radio_fields_value | (self, cls, model, val, label) | Check type of a value of `radio_fields` dictionary. | Check type of a value of `radio_fields` dictionary. | def _check_radio_fields_value(self, cls, model, val, label):
""" Check type of a value of `radio_fields` dictionary. """
from django.contrib.admin.options import HORIZONTAL, VERTICAL
if val not in (HORIZONTAL, VERTICAL):
return [
checks.Error(
"T... | [
"def",
"_check_radio_fields_value",
"(",
"self",
",",
"cls",
",",
"model",
",",
"val",
",",
"label",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
".",
"options",
"import",
"HORIZONTAL",
",",
"VERTICAL",
"if",
"val",
"not",
"in",
"(",
"HORIZO... | [
301,
4
] | [
316,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields | (self, cls, model) | Check that `prepopulated_fields` is a dictionary containing allowed
field types. | Check that `prepopulated_fields` is a dictionary containing allowed
field types. | def _check_prepopulated_fields(self, cls, model):
""" Check that `prepopulated_fields` is a dictionary containing allowed
field types. """
if not hasattr(cls, 'prepopulated_fields'):
return []
elif not isinstance(cls.prepopulated_fields, dict):
return must_be('a ... | [
"def",
"_check_prepopulated_fields",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"hasattr",
"(",
"cls",
",",
"'prepopulated_fields'",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"prepopulated_fields",
",",
... | [
334,
4
] | [
347,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields_key | (self, cls, model, field_name, label) | Check a key of `prepopulated_fields` dictionary, i.e. check that it
is a name of existing field and the field is one of the allowed types.
| Check a key of `prepopulated_fields` dictionary, i.e. check that it
is a name of existing field and the field is one of the allowed types.
| def _check_prepopulated_fields_key(self, cls, model, field_name, label):
""" Check a key of `prepopulated_fields` dictionary, i.e. check that it
is a name of existing field and the field is one of the allowed types.
"""
forbidden_field_types = (
models.DateTimeField,
... | [
"def",
"_check_prepopulated_fields_key",
"(",
"self",
",",
"cls",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"forbidden_field_types",
"=",
"(",
"models",
".",
"DateTimeField",
",",
"models",
".",
"ForeignKey",
",",
"models",
".",
"ManyToManyField",... | [
349,
4
] | [
379,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields_value | (self, cls, model, val, label) | Check a value of `prepopulated_fields` dictionary, i.e. it's an
iterable of existing fields. | Check a value of `prepopulated_fields` dictionary, i.e. it's an
iterable of existing fields. | def _check_prepopulated_fields_value(self, cls, model, val, label):
""" Check a value of `prepopulated_fields` dictionary, i.e. it's an
iterable of existing fields. """
if not isinstance(val, (list, tuple)):
return must_be('a list or tuple', option=label, obj=cls, id='admin.E029')
... | [
"def",
"_check_prepopulated_fields_value",
"(",
"self",
",",
"cls",
",",
"model",
",",
"val",
",",
"label",
")",
":",
"if",
"not",
"isinstance",
"(",
"val",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
","... | [
381,
4
] | [
391,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_prepopulated_fields_value_item | (self, cls, model, field_name, label) | For `prepopulated_fields` equal to {"slug": ("title",)},
`field_name` is "title". | For `prepopulated_fields` equal to {"slug": ("title",)},
`field_name` is "title". | def _check_prepopulated_fields_value_item(self, cls, model, field_name, label):
""" For `prepopulated_fields` equal to {"slug": ("title",)},
`field_name` is "title". """
try:
model._meta.get_field(field_name)
except models.FieldDoesNotExist:
return refer_to_missi... | [
"def",
"_check_prepopulated_fields_value_item",
"(",
"self",
",",
"cls",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"try",
":",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"except",
"models",
".",
"FieldDoesNotExist",
":",
... | [
393,
4
] | [
403,
21
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_ordering | (self, cls, model) | Check that ordering refers to existing fields or is random. | Check that ordering refers to existing fields or is random. | def _check_ordering(self, cls, model):
""" Check that ordering refers to existing fields or is random. """
# ordering = None
if cls.ordering is None: # The default value is None
return []
elif not isinstance(cls.ordering, (list, tuple)):
return must_be('a list o... | [
"def",
"_check_ordering",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"# ordering = None",
"if",
"cls",
".",
"ordering",
"is",
"None",
":",
"# The default value is None",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"ordering",
",",... | [
405,
4
] | [
417,
15
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_ordering_item | (self, cls, model, field_name, label) | Check that `ordering` refers to existing fields. | Check that `ordering` refers to existing fields. | def _check_ordering_item(self, cls, model, field_name, label):
""" Check that `ordering` refers to existing fields. """
if field_name == '?' and len(cls.ordering) != 1:
return [
checks.Error(
("The value of 'ordering' has the random ordering marker '?', "... | [
"def",
"_check_ordering_item",
"(",
"self",
",",
"cls",
",",
"model",
",",
"field_name",
",",
"label",
")",
":",
"if",
"field_name",
"==",
"'?'",
"and",
"len",
"(",
"cls",
".",
"ordering",
")",
"!=",
"1",
":",
"return",
"[",
"checks",
".",
"Error",
"... | [
419,
4
] | [
448,
25
] | python | en | ['en', 'en', 'en'] | True |
BaseModelAdminChecks._check_readonly_fields | (self, cls, model) | Check that readonly_fields refers to proper attribute or field. | Check that readonly_fields refers to proper attribute or field. | def _check_readonly_fields(self, cls, model):
""" Check that readonly_fields refers to proper attribute or field. """
if cls.readonly_fields == ():
return []
elif not isinstance(cls.readonly_fields, (list, tuple)):
return must_be('a list or tuple', option='readonly_field... | [
"def",
"_check_readonly_fields",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"cls",
".",
"readonly_fields",
"==",
"(",
")",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"readonly_fields",
",",
"(",
"list",
",",
"tup... | [
450,
4
] | [
461,
15
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_save_as | (self, cls, model) | Check save_as is a boolean. | Check save_as is a boolean. | def _check_save_as(self, cls, model):
""" Check save_as is a boolean. """
if not isinstance(cls.save_as, bool):
return must_be('a boolean', option='save_as',
obj=cls, id='admin.E101')
else:
return [] | [
"def",
"_check_save_as",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"save_as",
",",
"bool",
")",
":",
"return",
"must_be",
"(",
"'a boolean'",
",",
"option",
"=",
"'save_as'",
",",
"obj",
"=",
"cls",
... | [
506,
4
] | [
513,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_save_on_top | (self, cls, model) | Check save_on_top is a boolean. | Check save_on_top is a boolean. | def _check_save_on_top(self, cls, model):
""" Check save_on_top is a boolean. """
if not isinstance(cls.save_on_top, bool):
return must_be('a boolean', option='save_on_top',
obj=cls, id='admin.E102')
else:
return [] | [
"def",
"_check_save_on_top",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"save_on_top",
",",
"bool",
")",
":",
"return",
"must_be",
"(",
"'a boolean'",
",",
"option",
"=",
"'save_on_top'",
",",
"obj",
"=",... | [
515,
4
] | [
522,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_inlines | (self, cls, model) | Check all inline model admin classes. | Check all inline model admin classes. | def _check_inlines(self, cls, model):
""" Check all inline model admin classes. """
if not isinstance(cls.inlines, (list, tuple)):
return must_be('a list or tuple', option='inlines', obj=cls, id='admin.E103')
else:
return list(chain(*[
self._check_inlines... | [
"def",
"_check_inlines",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"inlines",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",
"option",
"=",
"'inlines... | [
524,
4
] | [
533,
15
] | python | en | ['sv', 'it', 'en'] | False |
ModelAdminChecks._check_inlines_item | (self, cls, model, inline, label) | Check one inline model admin. | Check one inline model admin. | def _check_inlines_item(self, cls, model, inline, label):
""" Check one inline model admin. """
inline_label = '.'.join([inline.__module__, inline.__name__])
from django.contrib.admin.options import BaseModelAdmin
if not issubclass(inline, BaseModelAdmin):
return [
... | [
"def",
"_check_inlines_item",
"(",
"self",
",",
"cls",
",",
"model",
",",
"inline",
",",
"label",
")",
":",
"inline_label",
"=",
"'.'",
".",
"join",
"(",
"[",
"inline",
".",
"__module__",
",",
"inline",
".",
"__name__",
"]",
")",
"from",
"django",
".",... | [
535,
4
] | [
563,
38
] | python | en | ['es', 'en', 'en'] | True |
ModelAdminChecks._check_list_display | (self, cls, model) | Check that list_display only contains fields or usable attributes.
| Check that list_display only contains fields or usable attributes.
| def _check_list_display(self, cls, model):
""" Check that list_display only contains fields or usable attributes.
"""
if not isinstance(cls.list_display, (list, tuple)):
return must_be('a list or tuple', option='list_display', obj=cls, id='admin.E107')
else:
retu... | [
"def",
"_check_list_display",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"list_display",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",
"option",
"=",
... | [
565,
4
] | [
575,
15
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_list_display_links | (self, cls, model) | Check that list_display_links is a unique subset of list_display.
| Check that list_display_links is a unique subset of list_display.
| def _check_list_display_links(self, cls, model):
""" Check that list_display_links is a unique subset of list_display.
"""
if cls.list_display_links is None:
return []
elif not isinstance(cls.list_display_links, (list, tuple)):
return must_be('a list, a tuple, or... | [
"def",
"_check_list_display_links",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"cls",
".",
"list_display_links",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"list_display_links",
",",
"(",
"list",
",",
... | [
635,
4
] | [
647,
15
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_list_filter_item | (self, cls, model, item, label) |
Check one item of `list_filter`, i.e. check if it is one of three options:
1. 'field' -- a basic field filter, possibly w/ relationships (e.g.
'field__rel')
2. ('field', SomeFieldListFilter) - a field-based list filter class
3. SomeListFilter - a non-field list filter class
... |
Check one item of `list_filter`, i.e. check if it is one of three options:
1. 'field' -- a basic field filter, possibly w/ relationships (e.g.
'field__rel')
2. ('field', SomeFieldListFilter) - a field-based list filter class
3. SomeListFilter - a non-field list filter class
... | def _check_list_filter_item(self, cls, model, item, label):
"""
Check one item of `list_filter`, i.e. check if it is one of three options:
1. 'field' -- a basic field filter, possibly w/ relationships (e.g.
'field__rel')
2. ('field', SomeFieldListFilter) - a field-based list f... | [
"def",
"_check_list_filter_item",
"(",
"self",
",",
"cls",
",",
"model",
",",
"item",
",",
"label",
")",
":",
"from",
"django",
".",
"contrib",
".",
"admin",
"import",
"ListFilter",
",",
"FieldListFilter",
"if",
"callable",
"(",
"item",
")",
"and",
"not",
... | [
673,
4
] | [
726,
25
] | python | en | ['en', 'error', 'th'] | False |
ModelAdminChecks._check_list_select_related | (self, cls, model) | Check that list_select_related is a boolean, a list or a tuple. | Check that list_select_related is a boolean, a list or a tuple. | def _check_list_select_related(self, cls, model):
""" Check that list_select_related is a boolean, a list or a tuple. """
if not isinstance(cls.list_select_related, (bool, list, tuple)):
return must_be('a boolean, tuple or list', option='list_select_related',
obj=... | [
"def",
"_check_list_select_related",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"list_select_related",
",",
"(",
"bool",
",",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a boolean, tupl... | [
728,
4
] | [
735,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_list_per_page | (self, cls, model) | Check that list_per_page is an integer. | Check that list_per_page is an integer. | def _check_list_per_page(self, cls, model):
""" Check that list_per_page is an integer. """
if not isinstance(cls.list_per_page, int):
return must_be('an integer', option='list_per_page', obj=cls, id='admin.E118')
else:
return [] | [
"def",
"_check_list_per_page",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"list_per_page",
",",
"int",
")",
":",
"return",
"must_be",
"(",
"'an integer'",
",",
"option",
"=",
"'list_per_page'",
",",
"obj",
... | [
737,
4
] | [
743,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_list_max_show_all | (self, cls, model) | Check that list_max_show_all is an integer. | Check that list_max_show_all is an integer. | def _check_list_max_show_all(self, cls, model):
""" Check that list_max_show_all is an integer. """
if not isinstance(cls.list_max_show_all, int):
return must_be('an integer', option='list_max_show_all', obj=cls, id='admin.E119')
else:
return [] | [
"def",
"_check_list_max_show_all",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"list_max_show_all",
",",
"int",
")",
":",
"return",
"must_be",
"(",
"'an integer'",
",",
"option",
"=",
"'list_max_show_all'",
",... | [
745,
4
] | [
751,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_list_editable | (self, cls, model) | Check that list_editable is a sequence of editable fields from
list_display without first element. | Check that list_editable is a sequence of editable fields from
list_display without first element. | def _check_list_editable(self, cls, model):
""" Check that list_editable is a sequence of editable fields from
list_display without first element. """
if not isinstance(cls.list_editable, (list, tuple)):
return must_be('a list or tuple', option='list_editable', obj=cls, id='admin.E1... | [
"def",
"_check_list_editable",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"list_editable",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",
"option",
"=",... | [
753,
4
] | [
763,
15
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_search_fields | (self, cls, model) | Check search_fields is a sequence. | Check search_fields is a sequence. | def _check_search_fields(self, cls, model):
""" Check search_fields is a sequence. """
if not isinstance(cls.search_fields, (list, tuple)):
return must_be('a list or tuple', option='search_fields', obj=cls, id='admin.E126')
else:
return [] | [
"def",
"_check_search_fields",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"search_fields",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"must_be",
"(",
"'a list or tuple'",
",",
"option",
"=",... | [
822,
4
] | [
828,
21
] | python | en | ['en', 'en', 'en'] | True |
ModelAdminChecks._check_date_hierarchy | (self, cls, model) | Check that date_hierarchy refers to DateField or DateTimeField. | Check that date_hierarchy refers to DateField or DateTimeField. | def _check_date_hierarchy(self, cls, model):
""" Check that date_hierarchy refers to DateField or DateTimeField. """
if cls.date_hierarchy is None:
return []
else:
try:
field = model._meta.get_field(cls.date_hierarchy)
except models.FieldDoesN... | [
"def",
"_check_date_hierarchy",
"(",
"self",
",",
"cls",
",",
"model",
")",
":",
"if",
"cls",
".",
"date_hierarchy",
"is",
"None",
":",
"return",
"[",
"]",
"else",
":",
"try",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"cls",
".... | [
830,
4
] | [
847,
29
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdminChecks._check_extra | (self, cls) | Check that extra is an integer. | Check that extra is an integer. | def _check_extra(self, cls):
""" Check that extra is an integer. """
if not isinstance(cls.extra, int):
return must_be('an integer', option='extra', obj=cls, id='admin.E203')
else:
return [] | [
"def",
"_check_extra",
"(",
"self",
",",
"cls",
")",
":",
"if",
"not",
"isinstance",
"(",
"cls",
".",
"extra",
",",
"int",
")",
":",
"return",
"must_be",
"(",
"'an integer'",
",",
"option",
"=",
"'extra'",
",",
"obj",
"=",
"cls",
",",
"id",
"=",
"'... | [
900,
4
] | [
906,
21
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdminChecks._check_max_num | (self, cls) | Check that max_num is an integer. | Check that max_num is an integer. | def _check_max_num(self, cls):
""" Check that max_num is an integer. """
if cls.max_num is None:
return []
elif not isinstance(cls.max_num, int):
return must_be('an integer', option='max_num', obj=cls, id='admin.E204')
else:
return [] | [
"def",
"_check_max_num",
"(",
"self",
",",
"cls",
")",
":",
"if",
"cls",
".",
"max_num",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"max_num",
",",
"int",
")",
":",
"return",
"must_be",
"(",
"'an integer'",
"... | [
908,
4
] | [
916,
21
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdminChecks._check_min_num | (self, cls) | Check that min_num is an integer. | Check that min_num is an integer. | def _check_min_num(self, cls):
""" Check that min_num is an integer. """
if cls.min_num is None:
return []
elif not isinstance(cls.min_num, int):
return must_be('an integer', option='min_num', obj=cls, id='admin.E205')
else:
return [] | [
"def",
"_check_min_num",
"(",
"self",
",",
"cls",
")",
":",
"if",
"cls",
".",
"min_num",
"is",
"None",
":",
"return",
"[",
"]",
"elif",
"not",
"isinstance",
"(",
"cls",
".",
"min_num",
",",
"int",
")",
":",
"return",
"must_be",
"(",
"'an integer'",
"... | [
918,
4
] | [
926,
21
] | python | en | ['en', 'en', 'en'] | True |
InlineModelAdminChecks._check_formset | (self, cls) | Check formset is a subclass of BaseModelFormSet. | Check formset is a subclass of BaseModelFormSet. | def _check_formset(self, cls):
""" Check formset is a subclass of BaseModelFormSet. """
if not issubclass(cls.formset, BaseModelFormSet):
return must_inherit_from(parent='BaseModelFormSet', option='formset',
obj=cls, id='admin.E206')
else:
... | [
"def",
"_check_formset",
"(",
"self",
",",
"cls",
")",
":",
"if",
"not",
"issubclass",
"(",
"cls",
".",
"formset",
",",
"BaseModelFormSet",
")",
":",
"return",
"must_inherit_from",
"(",
"parent",
"=",
"'BaseModelFormSet'",
",",
"option",
"=",
"'formset'",
",... | [
928,
4
] | [
935,
21
] | python | en | ['en', 'en', 'en'] | True |
LazyObjectTestCase.lazy_wrap | (self, wrapped_object) |
Wrap the given object into a LazyObject
|
Wrap the given object into a LazyObject
| def lazy_wrap(self, wrapped_object):
"""
Wrap the given object into a LazyObject
"""
class AdHocLazyObject(LazyObject):
def _setup(self):
self._wrapped = wrapped_object
return AdHocLazyObject() | [
"def",
"lazy_wrap",
"(",
"self",
",",
"wrapped_object",
")",
":",
"class",
"AdHocLazyObject",
"(",
"LazyObject",
")",
":",
"def",
"_setup",
"(",
"self",
")",
":",
"self",
".",
"_wrapped",
"=",
"wrapped_object",
"return",
"AdHocLazyObject",
"(",
")"
] | [
22,
4
] | [
30,
32
] | python | en | ['en', 'error', 'th'] | False |
make_graph | (dists, scheme='default') | Makes a dependency graph from the given distributions.
:parameter dists: a list of distributions
:type dists: list of :class:`distutils2.database.InstalledDistribution` and
:class:`distutils2.database.EggInfoDistribution` instances
:rtype: a :class:`DependencyGraph` instance
| Makes a dependency graph from the given distributions. | def make_graph(dists, scheme='default'):
"""Makes a dependency graph from the given distributions.
:parameter dists: a list of distributions
:type dists: list of :class:`distutils2.database.InstalledDistribution` and
:class:`distutils2.database.EggInfoDistribution` instances
:rtype: a ... | [
"def",
"make_graph",
"(",
"dists",
",",
"scheme",
"=",
"'default'",
")",
":",
"scheme",
"=",
"get_scheme",
"(",
"scheme",
")",
"graph",
"=",
"DependencyGraph",
"(",
")",
"provided",
"=",
"{",
"}",
"# maps names to lists of (version, dist) tuples",
"# first, build ... | [
1224,
0
] | [
1275,
16
] | python | en | ['en', 'en', 'en'] | True |
get_dependent_dists | (dists, dist) | Recursively generate a list of distributions from *dists* that are
dependent on *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
| Recursively generate a list of distributions from *dists* that are
dependent on *dist*. | def get_dependent_dists(dists, dist):
"""Recursively generate a list of distributions from *dists* that are
dependent on *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
"""
if dist not in dists:
raise DistlibExcept... | [
"def",
"get_dependent_dists",
"(",
"dists",
",",
"dist",
")",
":",
"if",
"dist",
"not",
"in",
"dists",
":",
"raise",
"DistlibException",
"(",
"'given distribution %r is not a member '",
"'of the list'",
"%",
"dist",
".",
"name",
")",
"graph",
"=",
"make_graph",
... | [
1278,
0
] | [
1301,
14
] | python | en | ['en', 'en', 'en'] | True |
get_required_dists | (dists, dist) | Recursively generate a list of distributions from *dists* that are
required by *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
| Recursively generate a list of distributions from *dists* that are
required by *dist*. | def get_required_dists(dists, dist):
"""Recursively generate a list of distributions from *dists* that are
required by *dist*.
:param dists: a list of distributions
:param dist: a distribution, member of *dists* for which we are interested
"""
if dist not in dists:
raise DistlibExceptio... | [
"def",
"get_required_dists",
"(",
"dists",
",",
"dist",
")",
":",
"if",
"dist",
"not",
"in",
"dists",
":",
"raise",
"DistlibException",
"(",
"'given distribution %r is not a member '",
"'of the list'",
"%",
"dist",
".",
"name",
")",
"graph",
"=",
"make_graph",
"... | [
1304,
0
] | [
1326,
14
] | python | en | ['en', 'en', 'en'] | True |
make_dist | (name, version, **kwargs) |
A convenience method for making a dist given just a name and version.
|
A convenience method for making a dist given just a name and version.
| def make_dist(name, version, **kwargs):
"""
A convenience method for making a dist given just a name and version.
"""
summary = kwargs.pop('summary', 'Placeholder for summary')
md = Metadata(**kwargs)
md.name = name
md.version = version
md.summary = summary or 'Placeholder for summary'
... | [
"def",
"make_dist",
"(",
"name",
",",
"version",
",",
"*",
"*",
"kwargs",
")",
":",
"summary",
"=",
"kwargs",
".",
"pop",
"(",
"'summary'",
",",
"'Placeholder for summary'",
")",
"md",
"=",
"Metadata",
"(",
"*",
"*",
"kwargs",
")",
"md",
".",
"name",
... | [
1329,
0
] | [
1338,
27
] | python | en | ['en', 'error', 'th'] | False |
_Cache.__init__ | (self) |
Initialise an instance. There is normally one for each DistributionPath.
|
Initialise an instance. There is normally one for each DistributionPath.
| def __init__(self):
"""
Initialise an instance. There is normally one for each DistributionPath.
"""
self.name = {}
self.path = {}
self.generated = False | [
"def",
"__init__",
"(",
"self",
")",
":",
"self",
".",
"name",
"=",
"{",
"}",
"self",
".",
"path",
"=",
"{",
"}",
"self",
".",
"generated",
"=",
"False"
] | [
48,
4
] | [
54,
30
] | python | en | ['en', 'error', 'th'] | False |
_Cache.clear | (self) |
Clear the cache, setting it to its initial state.
|
Clear the cache, setting it to its initial state.
| def clear(self):
"""
Clear the cache, setting it to its initial state.
"""
self.name.clear()
self.path.clear()
self.generated = False | [
"def",
"clear",
"(",
"self",
")",
":",
"self",
".",
"name",
".",
"clear",
"(",
")",
"self",
".",
"path",
".",
"clear",
"(",
")",
"self",
".",
"generated",
"=",
"False"
] | [
56,
4
] | [
62,
30
] | python | en | ['en', 'error', 'th'] | False |
_Cache.add | (self, dist) |
Add a distribution to the cache.
:param dist: The distribution to add.
|
Add a distribution to the cache.
:param dist: The distribution to add.
| def add(self, dist):
"""
Add a distribution to the cache.
:param dist: The distribution to add.
"""
if dist.path not in self.path:
self.path[dist.path] = dist
self.name.setdefault(dist.key, []).append(dist) | [
"def",
"add",
"(",
"self",
",",
"dist",
")",
":",
"if",
"dist",
".",
"path",
"not",
"in",
"self",
".",
"path",
":",
"self",
".",
"path",
"[",
"dist",
".",
"path",
"]",
"=",
"dist",
"self",
".",
"name",
".",
"setdefault",
"(",
"dist",
".",
"key"... | [
64,
4
] | [
71,
59
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.__init__ | (self, path=None, include_egg=False) |
Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
sys.path is used.
:param include_egg: If True, this instance will look for and ret... |
Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
sys.path is used.
:param include_egg: If True, this instance will look for and ret... | def __init__(self, path=None, include_egg=False):
"""
Create an instance from a path, optionally including legacy (distutils/
setuptools/distribute) distributions.
:param path: The path to use, as a list of directories. If not specified,
sys.path is used.
:pa... | [
"def",
"__init__",
"(",
"self",
",",
"path",
"=",
"None",
",",
"include_egg",
"=",
"False",
")",
":",
"if",
"path",
"is",
"None",
":",
"path",
"=",
"sys",
".",
"path",
"self",
".",
"path",
"=",
"path",
"self",
".",
"_include_dist",
"=",
"True",
"se... | [
78,
4
] | [
96,
44
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath.clear_cache | (self) |
Clears the internal cache.
|
Clears the internal cache.
| def clear_cache(self):
"""
Clears the internal cache.
"""
self._cache.clear()
self._cache_egg.clear() | [
"def",
"clear_cache",
"(",
"self",
")",
":",
"self",
".",
"_cache",
".",
"clear",
"(",
")",
"self",
".",
"_cache_egg",
".",
"clear",
"(",
")"
] | [
106,
4
] | [
111,
31
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath._yield_distributions | (self) |
Yield .dist-info and/or .egg(-info) distributions.
|
Yield .dist-info and/or .egg(-info) distributions.
| def _yield_distributions(self):
"""
Yield .dist-info and/or .egg(-info) distributions.
"""
# We need to check if we've seen some resources already, because on
# some Linux systems (e.g. some Debian/Ubuntu variants) there are
# symlinks which alias other files in the envir... | [
"def",
"_yield_distributions",
"(",
"self",
")",
":",
"# We need to check if we've seen some resources already, because on",
"# some Linux systems (e.g. some Debian/Ubuntu variants) there are",
"# symlinks which alias other files in the environment.",
"seen",
"=",
"set",
"(",
")",
"for",... | [
114,
4
] | [
156,
54
] | python | en | ['en', 'error', 'th'] | False |
DistributionPath._generate_cache | (self) |
Scan the path for distributions and populate the cache with
those that are found.
|
Scan the path for distributions and populate the cache with
those that are found.
| def _generate_cache(self):
"""
Scan the path for distributions and populate the cache with
those that are found.
"""
gen_dist = not self._cache.generated
gen_egg = self._include_egg and not self._cache_egg.generated
if gen_dist or gen_egg:
for dist in ... | [
"def",
"_generate_cache",
"(",
"self",
")",
":",
"gen_dist",
"=",
"not",
"self",
".",
"_cache",
".",
"generated",
"gen_egg",
"=",
"self",
".",
"_include_egg",
"and",
"not",
"self",
".",
"_cache_egg",
".",
"generated",
"if",
"gen_dist",
"or",
"gen_egg",
":"... | [
158,
4
] | [
175,
48
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.