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
LazySettings._setup
(self, name=None)
Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not previously configured the settings manually.
Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not previously configured the settings manually.
def _setup(self, name=None): """ Load the settings module pointed to by the environment variable. This is used the first time we need any settings at all, if the user has not previously configured the settings manually. """ settings_module = os.environ.get(ENVIRONMENT_VAR...
[ "def", "_setup", "(", "self", ",", "name", "=", "None", ")", ":", "settings_module", "=", "os", ".", "environ", ".", "get", "(", "ENVIRONMENT_VARIABLE", ")", "if", "not", "settings_module", ":", "desc", "=", "(", "\"setting %s\"", "%", "name", ")", "if",...
[ 25, 4 ]
[ 40, 49 ]
python
en
['en', 'error', 'th']
False
LazySettings.__getattr__
(self, name)
Return the value of a setting and cache it in self.__dict__.
Return the value of a setting and cache it in self.__dict__.
def __getattr__(self, name): """ Return the value of a setting and cache it in self.__dict__. """ if self._wrapped is empty: self._setup(name) val = getattr(self._wrapped, name) self.__dict__[name] = val return val
[ "def", "__getattr__", "(", "self", ",", "name", ")", ":", "if", "self", ".", "_wrapped", "is", "empty", ":", "self", ".", "_setup", "(", "name", ")", "val", "=", "getattr", "(", "self", ".", "_wrapped", ",", "name", ")", "self", ".", "__dict__", "[...
[ 50, 4 ]
[ 58, 18 ]
python
en
['en', 'error', 'th']
False
LazySettings.__setattr__
(self, name, value)
Set the value of setting. Clear all cached values if _wrapped changes (@override_settings does this) or clear single values when set.
Set the value of setting. Clear all cached values if _wrapped changes (
def __setattr__(self, name, value): """ Set the value of setting. Clear all cached values if _wrapped changes (@override_settings does this) or clear single values when set. """ if name == '_wrapped': self.__dict__.clear() else: self.__dict__.pop(n...
[ "def", "__setattr__", "(", "self", ",", "name", ",", "value", ")", ":", "if", "name", "==", "'_wrapped'", ":", "self", ".", "__dict__", ".", "clear", "(", ")", "else", ":", "self", ".", "__dict__", ".", "pop", "(", "name", ",", "None", ")", "super"...
[ 60, 4 ]
[ 69, 58 ]
python
en
['en', 'error', 'th']
False
LazySettings.__delattr__
(self, name)
Delete a setting and clear it from cache if needed.
Delete a setting and clear it from cache if needed.
def __delattr__(self, name): """ Delete a setting and clear it from cache if needed. """ super(LazySettings, self).__delattr__(name) self.__dict__.pop(name, None)
[ "def", "__delattr__", "(", "self", ",", "name", ")", ":", "super", "(", "LazySettings", ",", "self", ")", ".", "__delattr__", "(", "name", ")", "self", ".", "__dict__", ".", "pop", "(", "name", ",", "None", ")" ]
[ 71, 4 ]
[ 76, 37 ]
python
en
['en', 'error', 'th']
False
LazySettings.configure
(self, default_settings=global_settings, **options)
Called to manually configure the settings. The 'default_settings' parameter sets where to retrieve any unspecified values from (its argument must support attribute access (__getattr__)).
Called to manually configure the settings. The 'default_settings' parameter sets where to retrieve any unspecified values from (its argument must support attribute access (__getattr__)).
def configure(self, default_settings=global_settings, **options): """ Called to manually configure the settings. The 'default_settings' parameter sets where to retrieve any unspecified values from (its argument must support attribute access (__getattr__)). """ if self._wr...
[ "def", "configure", "(", "self", ",", "default_settings", "=", "global_settings", ",", "*", "*", "options", ")", ":", "if", "self", ".", "_wrapped", "is", "not", "empty", ":", "raise", "RuntimeError", "(", "'Settings already configured.'", ")", "holder", "=", ...
[ 78, 4 ]
[ 89, 30 ]
python
en
['en', 'error', 'th']
False
LazySettings.configured
(self)
Returns True if the settings have already been configured.
Returns True if the settings have already been configured.
def configured(self): """ Returns True if the settings have already been configured. """ return self._wrapped is not empty
[ "def", "configured", "(", "self", ")", ":", "return", "self", ".", "_wrapped", "is", "not", "empty" ]
[ 92, 4 ]
[ 96, 41 ]
python
en
['en', 'error', 'th']
False
UserSettingsHolder.__init__
(self, default_settings)
Requests for configuration variables not in this class are satisfied from the module specified in default_settings (if possible).
Requests for configuration variables not in this class are satisfied from the module specified in default_settings (if possible).
def __init__(self, default_settings): """ Requests for configuration variables not in this class are satisfied from the module specified in default_settings (if possible). """ self.__dict__['_deleted'] = set() self.default_settings = default_settings
[ "def", "__init__", "(", "self", ",", "default_settings", ")", ":", "self", ".", "__dict__", "[", "'_deleted'", "]", "=", "set", "(", ")", "self", ".", "default_settings", "=", "default_settings" ]
[ 160, 4 ]
[ 166, 48 ]
python
en
['en', 'error', 'th']
False
isImageType
(t)
Checks if an object is an image object. .. warning:: This function is for internal use only. :param t: object to check if it's an image :returns: True if the object is an image
Checks if an object is an image object.
def isImageType(t): """ Checks if an object is an image object. .. warning:: This function is for internal use only. :param t: object to check if it's an image :returns: True if the object is an image """ return hasattr(t, "im")
[ "def", "isImageType", "(", "t", ")", ":", "return", "hasattr", "(", "t", ",", "\"im\"", ")" ]
[ 128, 0 ]
[ 139, 27 ]
python
en
['en', 'error', 'th']
False
getmodebase
(mode)
Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data. :param mode: Input mode. :returns: "L" or "RGB". :exception KeyError: If the input mode was not a standard mode.
Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data.
def getmodebase(mode): """ Gets the "base" mode for given mode. This function returns "L" for images that contain grayscale data, and "RGB" for images that contain color data. :param mode: Input mode. :returns: "L" or "RGB". :exception KeyError: If the input mode was not a standard mode. ...
[ "def", "getmodebase", "(", "mode", ")", ":", "return", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "basemode" ]
[ 289, 0 ]
[ 299, 43 ]
python
en
['en', 'error', 'th']
False
getmodetype
(mode)
Gets the storage type mode. Given a mode, this function returns a single-layer mode suitable for storing individual bands. :param mode: Input mode. :returns: "L", "I", or "F". :exception KeyError: If the input mode was not a standard mode.
Gets the storage type mode. Given a mode, this function returns a single-layer mode suitable for storing individual bands.
def getmodetype(mode): """ Gets the storage type mode. Given a mode, this function returns a single-layer mode suitable for storing individual bands. :param mode: Input mode. :returns: "L", "I", or "F". :exception KeyError: If the input mode was not a standard mode. """ return ImageMod...
[ "def", "getmodetype", "(", "mode", ")", ":", "return", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "basetype" ]
[ 302, 0 ]
[ 311, 43 ]
python
en
['en', 'error', 'th']
False
getmodebandnames
(mode)
Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band. :param mode: Input mode. :returns: A tuple containing band names. The length...
Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band.
def getmodebandnames(mode): """ Gets a list of individual band names. Given a mode, this function returns a tuple containing the names of individual bands (use :py:method:`~PIL.Image.getmodetype` to get the mode used to store each individual band. :param mode: Input mode. :returns: A tuple...
[ "def", "getmodebandnames", "(", "mode", ")", ":", "return", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "bands" ]
[ 314, 0 ]
[ 326, 40 ]
python
en
['en', 'error', 'th']
False
getmodebands
(mode)
Gets the number of individual bands for this mode. :param mode: Input mode. :returns: The number of bands in this mode. :exception KeyError: If the input mode was not a standard mode.
Gets the number of individual bands for this mode.
def getmodebands(mode): """ Gets the number of individual bands for this mode. :param mode: Input mode. :returns: The number of bands in this mode. :exception KeyError: If the input mode was not a standard mode. """ return len(ImageMode.getmode(mode).bands)
[ "def", "getmodebands", "(", "mode", ")", ":", "return", "len", "(", "ImageMode", ".", "getmode", "(", "mode", ")", ".", "bands", ")" ]
[ 329, 0 ]
[ 337, 45 ]
python
en
['en', 'error', 'th']
False
preinit
()
Explicitly load standard file format drivers.
Explicitly load standard file format drivers.
def preinit(): """Explicitly load standard file format drivers.""" global _initialized if _initialized >= 1: return try: from . import BmpImagePlugin assert BmpImagePlugin except ImportError: pass try: from . import GifImagePlugin assert GifIma...
[ "def", "preinit", "(", ")", ":", "global", "_initialized", "if", "_initialized", ">=", "1", ":", "return", "try", ":", "from", ".", "import", "BmpImagePlugin", "assert", "BmpImagePlugin", "except", "ImportError", ":", "pass", "try", ":", "from", ".", "import...
[ 346, 0 ]
[ 389, 20 ]
python
en
['en', 'en', 'en']
True
init
()
Explicitly initializes the Python Imaging Library. This function loads all available file format drivers.
Explicitly initializes the Python Imaging Library. This function loads all available file format drivers.
def init(): """ Explicitly initializes the Python Imaging Library. This function loads all available file format drivers. """ global _initialized if _initialized >= 2: return 0 for plugin in _plugins: try: logger.debug("Importing %s", plugin) __impor...
[ "def", "init", "(", ")", ":", "global", "_initialized", "if", "_initialized", ">=", "2", ":", "return", "0", "for", "plugin", "in", "_plugins", ":", "try", ":", "logger", ".", "debug", "(", "\"Importing %s\"", ",", "plugin", ")", "__import__", "(", "f\"P...
[ 392, 0 ]
[ 411, 16 ]
python
en
['en', 'error', 'th']
False
_wedge
()
Create greyscale wedge (for debugging only)
Create greyscale wedge (for debugging only)
def _wedge(): """Create greyscale wedge (for debugging only)""" return Image()._new(core.wedge("L"))
[ "def", "_wedge", "(", ")", ":", "return", "Image", "(", ")", ".", "_new", "(", "core", ".", "wedge", "(", "\"L\"", ")", ")" ]
[ 2560, 0 ]
[ 2563, 40 ]
python
en
['en', 'en', 'en']
True
_check_size
(size)
Common check to enforce type and sanity check on size tuples :param size: Should be a 2 tuple of (width, height) :returns: True, or raises a ValueError
Common check to enforce type and sanity check on size tuples
def _check_size(size): """ Common check to enforce type and sanity check on size tuples :param size: Should be a 2 tuple of (width, height) :returns: True, or raises a ValueError """ if not isinstance(size, (list, tuple)): raise ValueError("Size must be a tuple") if len(size) != 2:...
[ "def", "_check_size", "(", "size", ")", ":", "if", "not", "isinstance", "(", "size", ",", "(", "list", ",", "tuple", ")", ")", ":", "raise", "ValueError", "(", "\"Size must be a tuple\"", ")", "if", "len", "(", "size", ")", "!=", "2", ":", "raise", "...
[ 2566, 0 ]
[ 2581, 15 ]
python
en
['en', 'error', 'th']
False
new
(mode, size, color=0)
Creates a new image with the given mode and size. :param mode: The mode to use for the new image. See: :ref:`concept-modes`. :param size: A 2-tuple, containing (width, height) in pixels. :param color: What color to use for the image. Default is black. If given, this should be a single i...
Creates a new image with the given mode and size.
def new(mode, size, color=0): """ Creates a new image with the given mode and size. :param mode: The mode to use for the new image. See: :ref:`concept-modes`. :param size: A 2-tuple, containing (width, height) in pixels. :param color: What color to use for the image. Default is black. ...
[ "def", "new", "(", "mode", ",", "size", ",", "color", "=", "0", ")", ":", "_check_size", "(", "size", ")", "if", "color", "is", "None", ":", "# don't initialize", "return", "Image", "(", ")", ".", "_new", "(", "core", ".", "new", "(", "mode", ",", ...
[ 2584, 0 ]
[ 2620, 48 ]
python
en
['en', 'error', 'th']
False
frombytes
(mode, size, data, decoder_name="raw", *args)
Creates a copy of an image memory from pixel data in a buffer. In its simplest form, this function takes three arguments (mode, size, and unpacked pixel data). You can also use any pixel decoder supported by PIL. For more information on available decoders, see the section :ref:`Writing Your ...
Creates a copy of an image memory from pixel data in a buffer.
def frombytes(mode, size, data, decoder_name="raw", *args): """ Creates a copy of an image memory from pixel data in a buffer. In its simplest form, this function takes three arguments (mode, size, and unpacked pixel data). You can also use any pixel decoder supported by PIL. For more informa...
[ "def", "frombytes", "(", "mode", ",", "size", ",", "data", ",", "decoder_name", "=", "\"raw\"", ",", "*", "args", ")", ":", "_check_size", "(", "size", ")", "# may pass tuple instead of argument list", "if", "len", "(", "args", ")", "==", "1", "and", "isin...
[ 2623, 0 ]
[ 2658, 13 ]
python
en
['en', 'error', 'th']
False
frombuffer
(mode, size, data, decoder_name="raw", *args)
Creates an image memory referencing pixel data in a byte buffer. This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data in the byte buffer, where possible. This means that changes to the original buffer object are reflected in this image). Not all modes can share memory; supp...
Creates an image memory referencing pixel data in a byte buffer.
def frombuffer(mode, size, data, decoder_name="raw", *args): """ Creates an image memory referencing pixel data in a byte buffer. This function is similar to :py:func:`~PIL.Image.frombytes`, but uses data in the byte buffer, where possible. This means that changes to the original buffer object are...
[ "def", "frombuffer", "(", "mode", ",", "size", ",", "data", ",", "decoder_name", "=", "\"raw\"", ",", "*", "args", ")", ":", "_check_size", "(", "size", ")", "# may pass tuple instead of argument list", "if", "len", "(", "args", ")", "==", "1", "and", "isi...
[ 2661, 0 ]
[ 2711, 58 ]
python
en
['en', 'error', 'th']
False
fromarray
(obj, mode=None)
Creates an image memory from an object exporting the array interface (using the buffer protocol). If ``obj`` is not contiguous, then the ``tobytes`` method is called and :py:func:`~PIL.Image.frombuffer` is used. If you have an image in NumPy:: from PIL import Image import numpy as np...
Creates an image memory from an object exporting the array interface (using the buffer protocol).
def fromarray(obj, mode=None): """ Creates an image memory from an object exporting the array interface (using the buffer protocol). If ``obj`` is not contiguous, then the ``tobytes`` method is called and :py:func:`~PIL.Image.frombuffer` is used. If you have an image in NumPy:: from PIL...
[ "def", "fromarray", "(", "obj", ",", "mode", "=", "None", ")", ":", "arr", "=", "obj", ".", "__array_interface__", "shape", "=", "arr", "[", "\"shape\"", "]", "ndim", "=", "len", "(", "shape", ")", "strides", "=", "arr", ".", "get", "(", "\"strides\"...
[ 2714, 0 ]
[ 2771, 60 ]
python
en
['en', 'error', 'th']
False
fromqimage
(im)
Creates an image instance from a QImage image
Creates an image instance from a QImage image
def fromqimage(im): """Creates an image instance from a QImage image""" from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.fromqimage(im)
[ "def", "fromqimage", "(", "im", ")", ":", "from", ".", "import", "ImageQt", "if", "not", "ImageQt", ".", "qt_is_installed", ":", "raise", "ImportError", "(", "\"Qt bindings are not installed\"", ")", "return", "ImageQt", ".", "fromqimage", "(", "im", ")" ]
[ 2774, 0 ]
[ 2780, 33 ]
python
en
['en', 'en', 'en']
True
fromqpixmap
(im)
Creates an image instance from a QPixmap image
Creates an image instance from a QPixmap image
def fromqpixmap(im): """Creates an image instance from a QPixmap image""" from . import ImageQt if not ImageQt.qt_is_installed: raise ImportError("Qt bindings are not installed") return ImageQt.fromqpixmap(im)
[ "def", "fromqpixmap", "(", "im", ")", ":", "from", ".", "import", "ImageQt", "if", "not", "ImageQt", ".", "qt_is_installed", ":", "raise", "ImportError", "(", "\"Qt bindings are not installed\"", ")", "return", "ImageQt", ".", "fromqpixmap", "(", "im", ")" ]
[ 2783, 0 ]
[ 2789, 34 ]
python
en
['en', 'en', 'en']
True
open
(fp, mode="r", formats=None)
Opens and identifies the given image file. This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the :py:meth:`~PIL.Image.Image.load` method). See :py:func:`~PIL.Ima...
Opens and identifies the given image file.
def open(fp, mode="r", formats=None): """ Opens and identifies the given image file. This is a lazy operation; this function identifies the file, but the file remains open and the actual image data is not read from the file until you try to process the data (or call the :py:meth:`~PIL.Image.Ima...
[ "def", "open", "(", "fp", ",", "mode", "=", "\"r\"", ",", "formats", "=", "None", ")", ":", "if", "mode", "!=", "\"r\"", ":", "raise", "ValueError", "(", "f\"bad mode {repr(mode)}\"", ")", "elif", "isinstance", "(", "fp", ",", "io", ".", "StringIO", ")...
[ 2840, 0 ]
[ 2944, 5 ]
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", "(", ")", "if", "self", ".", "fp", ":", "self", ".", "fp", ".", "close", "(", ")", "self", ".", "fp", "...
[ 581, 4 ]
[ 608, 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", "(", ")" ]
[ 666, 4 ]
[ 673, 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", ")", ":"...
[ 706, 4 ]
[ 747, 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...
[ 749, 4 ]
[ 772, 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...
[ 774, 4 ]
[ 798, 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...
[ 800, 4 ]
[ 837, 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" ]
[ 839, 4 ]
[ 848, 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", ...
[ 850, 4 ]
[ 1036, 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", ":", "#...
[ 1038, 4 ]
[ 1095, 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", "(", ")", ")" ]
[ 1097, 4 ]
[ 1106, 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", ".", ...
[ 1110, 4 ]
[ 1127, 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", ")", ",",...
[ 1129, 4 ]
[ 1147, 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" ]
[ 1149, 4 ]
[ 1169, 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 se...
[ "def", "filter", "(", "self", ",", "filter", ")", ":", "from", ".", "import", "ImageFilter", "self", ".", "load", "(", ")", "if", "isinstance", "(", "filter", ",", "Callable", ")", ":", "filter", "=", "filter", "(", ")", "if", "not", "hasattr", "(", ...
[ 1177, 4 ]
[ 1203, 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" ]
[ 1205, 4 ]
[ 1213, 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", "(", ")" ]
[ 1215, 4 ]
[ 1228, 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", "(", ")"...
[ 1230, 4 ]
[ 1250, 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" ]
[ 1252, 4 ]
[ 1273, 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", "...
[ 1275, 4 ]
[ 1291, 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" ]
[ 1320, 4 ]
[ 1328, 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" ]
[ 1330, 4 ]
[ 1342, 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", "...
[ 1344, 4 ]
[ 1357, 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", "...
[ 1359, 4 ]
[ 1369, 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", ","...
[ 1371, 4 ]
[ 1399, 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", ",", ...
[ 1401, 4 ]
[ 1425, 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",...
[ 1427, 4 ]
[ 1505, 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 t...
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 (destin...
[ "def", "alpha_composite", "(", "self", ",", "im", ",", "dest", "=", "(", "0", ",", "0", ")", ",", "source", "=", "(", "0", ",", "0", ")", ")", ":", "if", "not", "isinstance", "(", "source", ",", "(", "list", ",", "tuple", ")", ")", ":", "rais...
[ 1507, 4 ]
[ 1553, 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", "(", ...
[ 1555, 4 ]
[ 1599, 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", ":...
[ 1601, 4 ]
[ 1653, 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", ")" ]
[ 1655, 4 ]
[ 1670, 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...
[ 1672, 4 ]
[ 1698, 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...
[ 1700, 4 ]
[ 1736, 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...
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. :p...
[ "def", "remap_palette", "(", "self", ",", "dest_map", ",", "source_palette", "=", "None", ")", ":", "from", ".", "import", "ImagePalette", "if", "self", ".", "mode", "not", "in", "(", "\"L\"", ",", "\"P\"", ")", ":", "raise", "ValueError", "(", "\"illega...
[ 1738, 4 ]
[ 1811, 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...
[ 1813, 4 ]
[ 1828, 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...
[ 1830, 4 ]
[ 1921, 61 ]
python
en
['en', 'error', 'th']
False
Image.reduce
(self, factor, box=None)
Returns a copy of the image reduced ``factor`` times. If the size of the image is not dividable by ``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 opti...
Returns a copy of the image reduced ``factor`` times. If the size of the image is not dividable by ``factor``, the resulting size will be rounded up.
def reduce(self, factor, box=None): """ Returns a copy of the image reduced ``factor`` times. If the size of the image is not dividable by ``factor``, the resulting size will be rounded up. :param factor: A greater than 0 integer or tuple of two integers for width and...
[ "def", "reduce", "(", "self", ",", "factor", ",", "box", "=", "None", ")", ":", "if", "not", "isinstance", "(", "factor", ",", "(", "list", ",", "tuple", ")", ")", ":", "factor", "=", "(", "factor", ",", "factor", ")", "if", "box", "is", "None", ...
[ 1923, 4 ]
[ 1954, 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...
[ 1956, 4 ]
[ 2071, 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...
[ 2073, 4 ]
[ 2154, 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`. If defined, :attr:...
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" ]
[ 2156, 4 ]
[ 2175, 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...
[ 2177, 4 ]
[ 2204, 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", ",",...
[ 2206, 4 ]
[ 2225, 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", ")", ...
[ 2227, 4 ]
[ 2246, 50 ]
python
en
['en', 'error', 'th']
False
Image.tell
(self)
Returns the current frame number. See :py:meth:`~PIL.Image.Image.seek`. If defined, :attr:`~PIL.Image.Image.n_frames` refers to the number of available frames. :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`. If defined, :attr:`~PIL.Image.Image.n_frames` refers to the number of available frames. :returns: Frame number, starting with 0. """ return 0
[ "def", "tell", "(", "self", ")", ":", "return", "0" ]
[ 2248, 4 ]
[ 2257, 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", ...
[ 2259, 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
dameraulevenshtein
(seq1, seq2)
Calculate the Damerau-Levenshtein distance between sequences. This distance is the number of additions, deletions, substitutions, and transpositions needed to transform the first sequence into the second. Although generally used with strings, any sequences of comparable objects will work. Transpos...
Calculate the Damerau-Levenshtein distance between sequences.
def dameraulevenshtein(seq1, seq2): """Calculate the Damerau-Levenshtein distance between sequences. This distance is the number of additions, deletions, substitutions, and transpositions needed to transform the first sequence into the second. Although generally used with strings, any sequences of ...
[ "def", "dameraulevenshtein", "(", "seq1", ",", "seq2", ")", ":", "oneago", "=", "None", "thisrow", "=", "list", "(", "range", "(", "1", ",", "len", "(", "seq2", ")", "+", "1", ")", ")", "+", "[", "0", "]", "seq1_size", "=", "len", "(", "seq1", ...
[ 5, 0 ]
[ 35, 33 ]
python
en
['en', 'en', 'en']
True
ConfigurationLinter.__init__
(self, config, ignored_warnings, parent_log)
:type config: dict :type ignored_warnings: list[str]
def __init__(self, config, ignored_warnings, parent_log): """ :type config: dict :type ignored_warnings: list[str] """ self.log = parent_log.getChild(self.__class__.__name__) self._subscriptions = {} self._warnings = [] self._config = config self....
[ "def", "__init__", "(", "self", ",", "config", ",", "ignored_warnings", ",", "parent_log", ")", ":", "self", ".", "log", "=", "parent_log", ".", "getChild", "(", "self", ".", "__class__", ".", "__name__", ")", "self", ".", "_subscriptions", "=", "{", "}"...
[ 107, 4 ]
[ 118, 49 ]
python
en
['en', 'error', 'th']
False
Checker.__init__
(self, linter)
:type linter: ConfigurationLinter
def __init__(self, linter): """ :type linter: ConfigurationLinter """ self.linter = linter self.log = linter.log.getChild(self.__class__.__name__)
[ "def", "__init__", "(", "self", ",", "linter", ")", ":", "self", ".", "linter", "=", "linter", "self", ".", "log", "=", "linter", ".", "log", ".", "getChild", "(", "self", ".", "__class__", ".", "__name__", ")" ]
[ 191, 4 ]
[ 197, 63 ]
python
en
['en', 'error', 'th']
False
make_raw
(query: Any, exclude: Optional[List[Field]] = None)
Takes a Django query and returns a JSONable list of dictionaries corresponding to the database rows.
Takes a Django query and returns a JSONable list of dictionaries corresponding to the database rows.
def make_raw(query: Any, exclude: Optional[List[Field]] = None) -> List[Record]: """ Takes a Django query and returns a JSONable list of dictionaries corresponding to the database rows. """ rows = [] for instance in query: data = model_to_dict(instance, exclude=exclude) """ ...
[ "def", "make_raw", "(", "query", ":", "Any", ",", "exclude", ":", "Optional", "[", "List", "[", "Field", "]", "]", "=", "None", ")", "->", "List", "[", "Record", "]", ":", "rows", "=", "[", "]", "for", "instance", "in", "query", ":", "data", "=",...
[ 347, 0 ]
[ 367, 15 ]
python
en
['en', 'error', 'th']
False
fetch_attachment_data
(response: TableData, realm_id: int, message_ids: Set[int])
We usually export most messages for the realm, but not quite ALL messages for the realm. So, we need to clean up our attachment data to have correct values for response['zerver_attachment'][<n>]['messages'].
We usually export most messages for the realm, but not quite ALL messages for the realm. So, we need to clean up our attachment data to have correct values for response['zerver_attachment'][<n>]['messages'].
def fetch_attachment_data(response: TableData, realm_id: int, message_ids: Set[int]) -> None: filter_args = {"realm_id": realm_id} query = Attachment.objects.filter(**filter_args) response["zerver_attachment"] = make_raw(list(query)) floatify_datetime_fields(response, "zerver_attachment") """ W...
[ "def", "fetch_attachment_data", "(", "response", ":", "TableData", ",", "realm_id", ":", "int", ",", "message_ids", ":", "Set", "[", "int", "]", ")", "->", "None", ":", "filter_args", "=", "{", "\"realm_id\"", ":", "realm_id", "}", "query", "=", "Attachmen...
[ 909, 0 ]
[ 934, 5 ]
python
en
['en', 'error', 'th']
False
export_usermessages_batch
( input_path: Path, output_path: Path, consent_message_id: Optional[int] = None )
As part of the system for doing parallel exports, this runs on one batch of Message objects and adds the corresponding UserMessage objects. (This is called by the export_usermessage_batch management command).
As part of the system for doing parallel exports, this runs on one batch of Message objects and adds the corresponding UserMessage objects. (This is called by the export_usermessage_batch management command).
def export_usermessages_batch( input_path: Path, output_path: Path, consent_message_id: Optional[int] = None ) -> None: """As part of the system for doing parallel exports, this runs on one batch of Message objects and adds the corresponding UserMessage objects. (This is called by the export_usermessage...
[ "def", "export_usermessages_batch", "(", "input_path", ":", "Path", ",", "output_path", ":", "Path", ",", "consent_message_id", ":", "Optional", "[", "int", "]", "=", "None", ")", "->", "None", ":", "with", "open", "(", "input_path", ",", "\"rb\"", ")", "a...
[ 1011, 0 ]
[ 1029, 25 ]
python
en
['en', 'en', 'en']
True
add_srs_entry
(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, database=None)
This function takes a GDAL SpatialReference system and adds its information to the `spatial_ref_sys` table of the spatial backend. Doing this enables database-level spatial transformations for the backend. Thus, this utility is useful for adding spatial reference systems not included by default with ...
This function takes a GDAL SpatialReference system and adds its information to the `spatial_ref_sys` table of the spatial backend. Doing this enables database-level spatial transformations for the backend. Thus, this utility is useful for adding spatial reference systems not included by default with ...
def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, database=None): """ This function takes a GDAL SpatialReference system and adds its information to the `spatial_ref_sys` table of the spatial backend. Doing this enables database-level spatial transformations ...
[ "def", "add_srs_entry", "(", "srs", ",", "auth_name", "=", "'EPSG'", ",", "auth_srid", "=", "None", ",", "ref_sys_name", "=", "None", ",", "database", "=", "None", ")", ":", "if", "not", "database", ":", "database", "=", "DEFAULT_DB_ALIAS", "connection", "...
[ 4, 0 ]
[ 76, 62 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_get_public
(self)
This tests that a blank form is returned when a user opens the set_privacy view on a public page
This tests that a blank form is returned when a user opens the set_privacy view on a public page
def test_get_public(self): """ This tests that a blank form is returned when a user opens the set_privacy view on a public page """ response = self.client.get(reverse('wagtailadmin_pages:set_privacy', args=(self.public_page.id, ))) # Check response self.assertEqual(respo...
[ "def", "test_get_public", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:set_privacy'", ",", "args", "=", "(", "self", ".", "public_page", ".", "id", ",", ")", ")", ")", "# Check respons...
[ 54, 4 ]
[ 66, 86 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_get_private
(self)
This tests that the restriction type and password fields as set correctly when a user opens the set_privacy view on a public page
This tests that the restriction type and password fields as set correctly when a user opens the set_privacy view on a public page
def test_get_private(self): """ This tests that the restriction type and password fields as set correctly when a user opens the set_privacy view on a public page """ response = self.client.get(reverse('wagtailadmin_pages:set_privacy', args=(self.private_page.id, ))) # Ch...
[ "def", "test_get_private", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:set_privacy'", ",", "args", "=", "(", "self", ".", "private_page", ".", "id", ",", ")", ")", ")", "# Check respo...
[ 68, 4 ]
[ 83, 72 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_get_private_child
(self)
This tests that the set_privacy view tells the user that the password restriction has been applied to an ancestor
This tests that the set_privacy view tells the user that the password restriction has been applied to an ancestor
def test_get_private_child(self): """ This tests that the set_privacy view tells the user that the password restriction has been applied to an ancestor """ response = self.client.get(reverse('wagtailadmin_pages:set_privacy', args=(self.private_child_page.id, ))) # Check ...
[ "def", "test_get_private_child", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:set_privacy'", ",", "args", "=", "(", "self", ".", "private_child_page", ".", "id", ",", ")", ")", ")", "#...
[ 85, 4 ]
[ 95, 95 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_set_password_restriction
(self)
This tests that setting a password restriction using the set_privacy view works
This tests that setting a password restriction using the set_privacy view works
def test_set_password_restriction(self): """ This tests that setting a password restriction using the set_privacy view works """ post_data = { 'restriction_type': 'password', 'password': 'helloworld', 'groups': [], } response = self.cli...
[ "def", "test_set_password_restriction", "(", "self", ")", ":", "post_data", "=", "{", "'restriction_type'", ":", "'password'", ",", "'password'", ":", "'helloworld'", ",", "'groups'", ":", "[", "]", ",", "}", "response", "=", "self", ".", "client", ".", "pos...
[ 97, 4 ]
[ 123, 55 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_set_password_restriction_password_unset
(self)
This tests that the password field on the form is validated correctly
This tests that the password field on the form is validated correctly
def test_set_password_restriction_password_unset(self): """ This tests that the password field on the form is validated correctly """ post_data = { 'restriction_type': 'password', 'password': '', 'groups': [], } response = self.client.p...
[ "def", "test_set_password_restriction_password_unset", "(", "self", ")", ":", "post_data", "=", "{", "'restriction_type'", ":", "'password'", ",", "'password'", ":", "''", ",", "'groups'", ":", "[", "]", ",", "}", "response", "=", "self", ".", "client", ".", ...
[ 125, 4 ]
[ 140, 85 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_unset_password_restriction
(self)
This tests that removing a password restriction using the set_privacy view works
This tests that removing a password restriction using the set_privacy view works
def test_unset_password_restriction(self): """ This tests that removing a password restriction using the set_privacy view works """ post_data = { 'restriction_type': 'none', 'password': '', 'groups': [], } response = self.client.post( ...
[ "def", "test_unset_password_restriction", "(", "self", ")", ":", "post_data", "=", "{", "'restriction_type'", ":", "'none'", ",", "'password'", ":", "''", ",", "'groups'", ":", "[", "]", ",", "}", "response", "=", "self", ".", "client", ".", "post", "(", ...
[ 142, 4 ]
[ 159, 93 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_get_private_groups
(self)
This tests that the restriction type and group fields as set correctly when a user opens the set_privacy view on a public page
This tests that the restriction type and group fields as set correctly when a user opens the set_privacy view on a public page
def test_get_private_groups(self): """ This tests that the restriction type and group fields as set correctly when a user opens the set_privacy view on a public page """ response = self.client.get(reverse('wagtailadmin_pages:set_privacy', args=(self.private_groups_page.id, ))) #...
[ "def", "test_get_private_groups", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:set_privacy'", ",", "args", "=", "(", "self", ".", "private_groups_page", ".", "id", ",", ")", ")", ")", ...
[ 161, 4 ]
[ 175, 101 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_set_group_restriction
(self)
This tests that setting a group restriction using the set_privacy view works
This tests that setting a group restriction using the set_privacy view works
def test_set_group_restriction(self): """ This tests that setting a group restriction using the set_privacy view works """ post_data = { 'restriction_type': 'groups', 'password': '', 'groups': [self.group.id, self.group2.id], } response...
[ "def", "test_set_group_restriction", "(", "self", ")", ":", "post_data", "=", "{", "'restriction_type'", ":", "'groups'", ",", "'password'", ":", "''", ",", "'groups'", ":", "[", "self", ".", "group", ".", "id", ",", "self", ".", "group2", ".", "id", "]"...
[ 177, 4 ]
[ 207, 9 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_set_group_restriction_password_unset
(self)
This tests that the group fields on the form are validated correctly
This tests that the group fields on the form are validated correctly
def test_set_group_restriction_password_unset(self): """ This tests that the group fields on the form are validated correctly """ post_data = { 'restriction_type': 'groups', 'password': '', 'groups': [], } response = self.client.post(re...
[ "def", "test_set_group_restriction_password_unset", "(", "self", ")", ":", "post_data", "=", "{", "'restriction_type'", ":", "'groups'", ",", "'password'", ":", "''", ",", "'groups'", ":", "[", "]", ",", "}", "response", "=", "self", ".", "client", ".", "pos...
[ 209, 4 ]
[ 224, 93 ]
python
en
['en', 'error', 'th']
False
TestSetPrivacyView.test_unset_group_restriction
(self)
This tests that removing a groups restriction using the set_privacy view works
This tests that removing a groups restriction using the set_privacy view works
def test_unset_group_restriction(self): """ This tests that removing a groups restriction using the set_privacy view works """ post_data = { 'restriction_type': 'none', 'password': '', 'groups': [], } response = self.client.post(reverse...
[ "def", "test_unset_group_restriction", "(", "self", ")", ":", "post_data", "=", "{", "'restriction_type'", ":", "'none'", ",", "'password'", ":", "''", ",", "'groups'", ":", "[", "]", ",", "}", "response", "=", "self", ".", "client", ".", "post", "(", "r...
[ 226, 4 ]
[ 242, 93 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_explorer_public
(self)
This tests that the privacy indicator on the public pages explore view is set to "PUBLIC"
This tests that the privacy indicator on the public pages explore view is set to "PUBLIC"
def test_explorer_public(self): """ This tests that the privacy indicator on the public pages explore view is set to "PUBLIC" """ response = self.client.get(reverse('wagtailadmin_explore', args=(self.public_page.id, ))) # Check the response self.assertEqual(response.stat...
[ "def", "test_explorer_public", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_explore'", ",", "args", "=", "(", "self", ".", "public_page", ".", "id", ",", ")", ")", ")", "# Check the response...
[ 273, 4 ]
[ 285, 83 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_explorer_private
(self)
This tests that the privacy indicator on the private pages explore view is set to "PRIVATE"
This tests that the privacy indicator on the private pages explore view is set to "PRIVATE"
def test_explorer_private(self): """ This tests that the privacy indicator on the private pages explore view is set to "PRIVATE" """ response = self.client.get(reverse('wagtailadmin_explore', args=(self.private_page.id, ))) # Check the response self.assertEqual(response....
[ "def", "test_explorer_private", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_explore'", ",", "args", "=", "(", "self", ".", "private_page", ".", "id", ",", ")", ")", ")", "# Check the respon...
[ 287, 4 ]
[ 299, 82 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_explorer_private_child
(self)
This tests that the privacy indicator on the private child pages explore view is set to "PRIVATE"
This tests that the privacy indicator on the private child pages explore view is set to "PRIVATE"
def test_explorer_private_child(self): """ This tests that the privacy indicator on the private child pages explore view is set to "PRIVATE" """ response = self.client.get(reverse('wagtailadmin_explore', args=(self.private_child_page.id, ))) # Check the response self.ass...
[ "def", "test_explorer_private_child", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_explore'", ",", "args", "=", "(", "self", ".", "private_child_page", ".", "id", ",", ")", ")", ")", "# Chec...
[ 301, 4 ]
[ 313, 82 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_explorer_list_homepage
(self)
This tests that there is a padlock displayed next to the private page in the homepages explorer listing
This tests that there is a padlock displayed next to the private page in the homepages explorer listing
def test_explorer_list_homepage(self): """ This tests that there is a padlock displayed next to the private page in the homepages explorer listing """ response = self.client.get(reverse('wagtailadmin_explore', args=(self.homepage.id, ))) # Check the response self.assertE...
[ "def", "test_explorer_list_homepage", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_explore'", ",", "args", "=", "(", "self", ".", "homepage", ".", "id", ",", ")", ")", ")", "# Check the resp...
[ 315, 4 ]
[ 325, 111 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_explorer_list_private
(self)
This tests that there is a padlock displayed next to the private child page in the private pages explorer listing
This tests that there is a padlock displayed next to the private child page in the private pages explorer listing
def test_explorer_list_private(self): """ This tests that there is a padlock displayed next to the private child page in the private pages explorer listing """ response = self.client.get(reverse('wagtailadmin_explore', args=(self.private_page.id, ))) # Check the response...
[ "def", "test_explorer_list_private", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_explore'", ",", "args", "=", "(", "self", ".", "private_page", ".", "id", ",", ")", ")", ")", "# Check the r...
[ 327, 4 ]
[ 338, 111 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_edit_public
(self)
This tests that the privacy indicator on the public pages edit view is set to "PUBLIC"
This tests that the privacy indicator on the public pages edit view is set to "PUBLIC"
def test_edit_public(self): """ This tests that the privacy indicator on the public pages edit view is set to "PUBLIC" """ response = self.client.get(reverse('wagtailadmin_pages:edit', args=(self.public_page.id, ))) # Check the response self.assertEqual(response.status_c...
[ "def", "test_edit_public", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:edit'", ",", "args", "=", "(", "self", ".", "public_page", ".", "id", ",", ")", ")", ")", "# Check the response"...
[ 340, 4 ]
[ 352, 83 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_edit_private
(self)
This tests that the privacy indicator on the private pages edit view is set to "PRIVATE"
This tests that the privacy indicator on the private pages edit view is set to "PRIVATE"
def test_edit_private(self): """ This tests that the privacy indicator on the private pages edit view is set to "PRIVATE" """ response = self.client.get(reverse('wagtailadmin_pages:edit', args=(self.private_page.id, ))) # Check the response self.assertEqual(response.stat...
[ "def", "test_edit_private", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:edit'", ",", "args", "=", "(", "self", ".", "private_page", ".", "id", ",", ")", ")", ")", "# Check the respons...
[ 354, 4 ]
[ 366, 82 ]
python
en
['en', 'error', 'th']
False
TestPrivacyIndicators.test_edit_private_child
(self)
This tests that the privacy indicator on the private child pages edit view is set to "PRIVATE"
This tests that the privacy indicator on the private child pages edit view is set to "PRIVATE"
def test_edit_private_child(self): """ This tests that the privacy indicator on the private child pages edit view is set to "PRIVATE" """ response = self.client.get(reverse('wagtailadmin_pages:edit', args=(self.private_child_page.id, ))) # Check the response self.assertE...
[ "def", "test_edit_private_child", "(", "self", ")", ":", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:edit'", ",", "args", "=", "(", "self", ".", "private_child_page", ".", "id", ",", ")", ")", ")", "# Check...
[ 368, 4 ]
[ 380, 82 ]
python
en
['en', 'error', 'th']
False
FlockTool.Dispatch
(self, args)
Dispatches a string command to a method.
Dispatches a string command to a method.
def Dispatch(self, args): """Dispatches a string command to a method.""" if len(args) < 1: raise Exception("Not enough arguments") method = "Exec%s" % self._CommandifyName(args[0]) getattr(self, method)(*args[1:])
[ "def", "Dispatch", "(", "self", ",", "args", ")", ":", "if", "len", "(", "args", ")", "<", "1", ":", "raise", "Exception", "(", "\"Not enough arguments\"", ")", "method", "=", "\"Exec%s\"", "%", "self", ".", "_CommandifyName", "(", "args", "[", "0", "]...
[ 23, 4 ]
[ 29, 40 ]
python
en
['en', 'en', 'en']
True
FlockTool._CommandifyName
(self, name_string)
Transforms a tool name like copy-info-plist to CopyInfoPlist
Transforms a tool name like copy-info-plist to CopyInfoPlist
def _CommandifyName(self, name_string): """Transforms a tool name like copy-info-plist to CopyInfoPlist""" return name_string.title().replace("-", "")
[ "def", "_CommandifyName", "(", "self", ",", "name_string", ")", ":", "return", "name_string", ".", "title", "(", ")", ".", "replace", "(", "\"-\"", ",", "\"\"", ")" ]
[ 31, 4 ]
[ 33, 51 ]
python
en
['en', 'pl', 'en']
True
FlockTool.ExecFlock
(self, lockfile, *cmd_list)
Emulates the most basic behavior of Linux's flock(1).
Emulates the most basic behavior of Linux's flock(1).
def ExecFlock(self, lockfile, *cmd_list): """Emulates the most basic behavior of Linux's flock(1).""" # Rely on exception handling to report errors. # Note that the stock python on SunOS has a bug # where fcntl.flock(fd, LOCK_EX) always fails # with EBADF, that's why we use this ...
[ "def", "ExecFlock", "(", "self", ",", "lockfile", ",", "*", "cmd_list", ")", ":", "# Rely on exception handling to report errors.", "# Note that the stock python on SunOS has a bug", "# where fcntl.flock(fd, LOCK_EX) always fails", "# with EBADF, that's why we use this F_SETLK", "# hac...
[ 35, 4 ]
[ 50, 40 ]
python
en
['en', 'da', 'en']
True