id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
174,150 | import io
from . import Image, ImageFile, ImagePalette
from ._binary import i8
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import si16be as si16
def _maketile(file, mode, bbox, channels):
tile = None
read = file.read
compression = i16(read(2))
xsize = bbox[2] - bbox... | null |
174,151 | import base64
import math
import os
import sys
import warnings
from enum import IntEnum
from io import BytesIO
from . import Image
from ._deprecate import deprecate
from ._util import is_directory, is_path
class Layout(IntEnum):
BASIC = 0
RAQM = 1
def deprecate(
deprecated: str,
when: int | None,
r... | null |
174,152 | import base64
import math
import os
import sys
import warnings
from enum import IntEnum
from io import BytesIO
from . import Image
from ._deprecate import deprecate
from ._util import is_directory, is_path
class FreeTypeFont:
"""FreeType font wrapper (requires _imagingft service)"""
def __init__(self, font=None... | Load a TrueType or OpenType font from a file or file-like object, and create a font object. This function loads a font object from the given file or file-like object, and creates a font object for a font of the given size. Pillow uses FreeType to open font files. On Windows, be aware that FreeType will keep the file op... |
174,153 | import base64
import math
import os
import sys
import warnings
from enum import IntEnum
from io import BytesIO
from . import Image
from ._deprecate import deprecate
from ._util import is_directory, is_path
def load(filename):
"""
Load a font file. This function loads a font object from the given
bitmap fon... | Load font file. Same as :py:func:`~PIL.ImageFont.load`, but searches for a bitmap font along the Python path. :param filename: Name of font file. :return: A font object. :exception OSError: If the file could not be read. |
174,154 | import base64
import math
import os
import sys
import warnings
from enum import IntEnum
from io import BytesIO
from . import Image
from ._deprecate import deprecate
from ._util import is_directory, is_path
class ImageFont:
"""PIL font wrapper"""
def _load_pilfont(self, filename):
with open(filename, "rb... | Load a "better than nothing" default font. .. versionadded:: 1.1.4 :return: A font object. |
174,155 | from . import ImageFile, ImagePalette, UnidentifiedImageError
from ._binary import i16be as i16
from ._binary import i32be as i32
class GdImageFile(ImageFile.ImageFile):
"""
Image plugin for the GD uncompressed format. Note that this format
is not supported by the standard :py:func:`PIL.Image.open()` funct... | Load texture from a GD image file. :param fp: GD file name, or an opened file handle. :param mode: Optional mode. In this version, if the mode argument is given, it must be "r". :returns: An image instance. :raises OSError: If the image could not be read. |
174,156 | import itertools
import logging
import re
import struct
import warnings
import zlib
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._binary... | null |
174,157 | import itertools
import logging
import re
import struct
import warnings
import zlib
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._binary... | null |
174,158 | import itertools
import logging
import re
import struct
import warnings
import zlib
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._binary... | null |
174,159 | import itertools
import logging
import re
import struct
import warnings
import zlib
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._binary... | null |
174,160 | import itertools
import logging
import re
import struct
import warnings
import zlib
from enum import IntEnum
from . import Image, ImageChops, ImageFile, ImagePalette, ImageSequence
from ._binary import i16be as i16
from ._binary import i32be as i32
from ._binary import o8
from ._binary import o16be as o16
from ._binary... | Return a list of PNG chunks representing this image. |
174,162 | import os
import struct
from . import Image, ImageFile
from ._binary import i16be as i16
from ._binary import o8
def o8(i):
return bytes((i & 255,))
def _save(im, fp, filename):
if im.mode != "RGB" and im.mode != "RGBA" and im.mode != "L":
msg = "Unsupported SGI image mode"
raise ValueError(ms... | null |
174,165 | from . import Image, ImageFile
_handler = None
def _save(im, fp, filename):
if _handler is None or not hasattr(_handler, "save"):
msg = "BUFR save handler not installed"
raise OSError(msg)
_handler.save(im, fp, filename) | null |
174,167 | import os
import struct
from enum import IntEnum
from io import BytesIO
from . import Image, ImageFile
from ._deprecate import deprecate
class Format(IntEnum):
JPEG = 0
class Encoding(IntEnum):
UNCOMPRESSED = 1
DXT = 2
UNCOMPRESSED_RAW_BGRA = 3
class AlphaEncoding(IntEnum):
DXT1 = 0
DXT3 = 1
... | null |
174,168 | import os
import struct
from enum import IntEnum
from io import BytesIO
from . import Image, ImageFile
from ._deprecate import deprecate
def unpack_565(i):
return ((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3
The provided code snippet includes necessary dependencies for implementing the `decode_... | input: one "row" of data (i.e. will produce 4*width pixels) |
174,169 | import os
import struct
from enum import IntEnum
from io import BytesIO
from . import Image, ImageFile
from ._deprecate import deprecate
def unpack_565(i):
return ((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3
The provided code snippet includes necessary dependencies for implementing the `decode_... | input: one "row" of data (i.e. will produce 4*width pixels) |
174,170 | import os
import struct
from enum import IntEnum
from io import BytesIO
from . import Image, ImageFile
from ._deprecate import deprecate
def unpack_565(i):
return ((i >> 11) & 0x1F) << 3, ((i >> 5) & 0x3F) << 2, (i & 0x1F) << 3
The provided code snippet includes necessary dependencies for implementing the `decode_... | input: one "row" of data (i.e. will produce 4 * width pixels) |
174,171 | import os
import struct
from enum import IntEnum
from io import BytesIO
from . import Image, ImageFile
from ._deprecate import deprecate
def _accept(prefix):
return prefix[:4] in (b"BLP1", b"BLP2") | null |
174,172 | import os
import struct
from enum import IntEnum
from io import BytesIO
from . import Image, ImageFile
from ._deprecate import deprecate
class Encoding(IntEnum):
UNCOMPRESSED = 1
DXT = 2
UNCOMPRESSED_RAW_BGRA = 3
class ImageFile(Image.Image):
"""Base class for image file format handlers."""
def __... | null |
174,173 | from . import Image
class Image:
"""
This class represents an image object. To create
:py:class:`~PIL.Image.Image` objects, use the appropriate factory
functions. There's hardly ever any reason to call the Image constructor
directly.
* :py:func:`~PIL.Image.open`
* :py:func:`~PIL.Image.ne... | Fill a channel with a given grey level. :rtype: :py:class:`~PIL.Image.Image` |
174,175 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `invert` function. Write a Python function `def invert(image)` to solve the following problem:
Invert an image (channel). :: out = MAX - image :rtype: :py:class:`~PIL.Image.Image`
Here is the function:
def invert(image... | Invert an image (channel). :: out = MAX - image :rtype: :py:class:`~PIL.Image.Image` |
174,176 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `lighter` function. Write a Python function `def lighter(image1, image2)` to solve the following problem:
Compares the two images, pixel by pixel, and returns a new image containing the lighter values. :: out = max(image... | Compares the two images, pixel by pixel, and returns a new image containing the lighter values. :: out = max(image1, image2) :rtype: :py:class:`~PIL.Image.Image` |
174,177 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `darker` function. Write a Python function `def darker(image1, image2)` to solve the following problem:
Compares the two images, pixel by pixel, and returns a new image containing the darker values. :: out = min(image1, ... | Compares the two images, pixel by pixel, and returns a new image containing the darker values. :: out = min(image1, image2) :rtype: :py:class:`~PIL.Image.Image` |
174,178 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `difference` function. Write a Python function `def difference(image1, image2)` to solve the following problem:
Returns the absolute value of the pixel-by-pixel difference between the two images. :: out = abs(image1 - im... | Returns the absolute value of the pixel-by-pixel difference between the two images. :: out = abs(image1 - image2) :rtype: :py:class:`~PIL.Image.Image` |
174,179 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `multiply` function. Write a Python function `def multiply(image1, image2)` to solve the following problem:
Superimposes two images on top of each other. If you multiply an image with a solid black image, the result is b... | Superimposes two images on top of each other. If you multiply an image with a solid black image, the result is black. If you multiply with a solid white image, the image is unaffected. :: out = image1 * image2 / MAX :rtype: :py:class:`~PIL.Image.Image` |
174,180 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `screen` function. Write a Python function `def screen(image1, image2)` to solve the following problem:
Superimposes two inverted images on top of each other. :: out = MAX - ((MAX - image1) * (MAX - image2) / MAX) :rtype... | Superimposes two inverted images on top of each other. :: out = MAX - ((MAX - image1) * (MAX - image2) / MAX) :rtype: :py:class:`~PIL.Image.Image` |
174,184 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `subtract` function. Write a Python function `def subtract(image1, image2, scale=1.0, offset=0)` to solve the following problem:
Subtracts two images, dividing the result by scale and adding the offset. If omitted, scale... | Subtracts two images, dividing the result by scale and adding the offset. If omitted, scale defaults to 1.0, and offset to 0.0. :: out = ((image1 - image2) / scale + offset) :rtype: :py:class:`~PIL.Image.Image` |
174,185 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `add_modulo` function. Write a Python function `def add_modulo(image1, image2)` to solve the following problem:
Add two images, without clipping the result. :: out = ((image1 + image2) % MAX) :rtype: :py:class:`~PIL.Imag... | Add two images, without clipping the result. :: out = ((image1 + image2) % MAX) :rtype: :py:class:`~PIL.Image.Image` |
174,186 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `logical_and` function. Write a Python function `def logical_and(image1, image2)` to solve the following problem:
Logical AND between two images. Both of the images must have mode "1". If you would like to perform a logi... | Logical AND between two images. Both of the images must have mode "1". If you would like to perform a logical AND on an image with a mode other than "1", try :py:meth:`~PIL.ImageChops.multiply` instead, using a black-and-white mask as the second image. :: out = ((image1 and image2) % MAX) :rtype: :py:class:`~PIL.Image.... |
174,187 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `logical_or` function. Write a Python function `def logical_or(image1, image2)` to solve the following problem:
Logical OR between two images. Both of the images must have mode "1". :: out = ((image1 or image2) % MAX) :r... | Logical OR between two images. Both of the images must have mode "1". :: out = ((image1 or image2) % MAX) :rtype: :py:class:`~PIL.Image.Image` |
174,188 | from . import Image
The provided code snippet includes necessary dependencies for implementing the `logical_xor` function. Write a Python function `def logical_xor(image1, image2)` to solve the following problem:
Logical XOR between two images. Both of the images must have mode "1". :: out = ((bool(image1) != bool(ima... | Logical XOR between two images. Both of the images must have mode "1". :: out = ((bool(image1) != bool(image2)) % MAX) :rtype: :py:class:`~PIL.Image.Image` |
174,189 | from . import Image
class Image:
"""
This class represents an image object. To create
:py:class:`~PIL.Image.Image` objects, use the appropriate factory
functions. There's hardly ever any reason to call the Image constructor
directly.
* :py:func:`~PIL.Image.open`
* :py:func:`~PIL.Image.ne... | Create composite using transparency mask. Alias for :py:func:`PIL.Image.composite`. :rtype: :py:class:`~PIL.Image.Image` |
174,192 | from . import Image, ImageFile
_handler = None
def _save(im, fp, filename):
if _handler is None or not hasattr(_handler, "save"):
msg = "HDF5 save handler not installed"
raise OSError(msg)
_handler.save(im, fp, filename) | null |
174,193 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | null |
174,194 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | 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 |
174,195 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | null |
174,196 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | 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 of the tuple gives the numb... |
174,197 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | null |
174,198 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | null |
174,199 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | null |
174,200 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Create greyscale wedge (for debugging only) |
174,201 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Creates an image instance from a QPixmap image |
174,202 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | 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. |
174,203 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Create composite image by blending images using a transparency mask. :param image1: The first image. :param image2: The second image. Must have the same mode and size as the first image. :param mask: A mask image. This image can have mode "1", "L", or "RGBA", and must have the same size as the other two images. |
174,204 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Applies the function (which should take one argument) to each pixel in the given image. If the image has more than one band, the same function is applied to each band. Note that the function is evaluated once for each possible pixel value, so you cannot use random components or other generators. :param image: The input... |
174,205 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Registers an image MIME type. This function should not be used in application code. :param id: An image format identifier. :param mimetype: The image MIME type for this format. |
174,206 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Registers an image save function. This function should not be used in application code. :param id: An image format identifier. :param driver: A function to save images in this format. |
174,207 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Registers an image function to save all the frames of a multiframe format. This function should not be used in application code. :param id: An image format identifier. :param driver: A function to save images in this format. |
174,208 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Registers image extensions. This function should not be used in application code. :param id: An image format identifier. :param extensions: A list of extensions used for this format. |
174,209 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Returns a dictionary containing all file extensions belonging to registered plugins |
174,210 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Registers an image decoder. This function should not be used in application code. :param name: The name of the decoder :param decoder: A callable(mode, args) that returns an ImageFile.PyDecoder object .. versionadded:: 4.1.0 |
174,211 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Registers an image encoder. This function should not be used in application code. :param name: The name of the encoder :param encoder: A callable(mode, args) that returns an ImageFile.PyEncoder object .. versionadded:: 4.1.0 |
174,212 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | null |
174,213 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Generate a Mandelbrot set covering the given extent. :param size: The requested size in pixels, as a 2-tuple: (width, height). :param extent: The extent to cover, as a 4-tuple: (x0, y0, x1, y1). :param quality: Quality. |
174,214 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Generate Gaussian noise centered around 128. :param size: The requested size in pixels, as a 2-tuple: (width, height). :param sigma: Standard deviation of noise. |
174,215 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Generate 256x256 linear gradient from black to white, top to bottom. :param mode: Input mode. |
174,216 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | Generate 256x256 radial gradient from black to white, centre to edge. :param mode: Input mode. |
174,217 | import atexit
import builtins
import io
import logging
import math
import os
import re
import struct
import sys
import tempfile
import warnings
from collections.abc import Callable, MutableMapping
from enum import IntEnum
from pathlib import Path
from . import (
ExifTags,
ImageMode,
TiffTags,
Unidentifi... | null |
174,220 | import collections
import os
import sys
import warnings
import PIL
from . import Image
features = {
"webp_anim": ("PIL._webp", "HAVE_WEBPANIM", None),
"webp_mux": ("PIL._webp", "HAVE_WEBPMUX", None),
"transp_webp": ("PIL._webp", "HAVE_TRANSPARENCY", None),
"raqm": ("PIL._imagingft", "HAVE_RAQM", "raqm_v... | Prints information about this installation of Pillow. This function can be called with ``python3 -m PIL``. :param out: The output stream to print to. Defaults to ``sys.stdout`` if ``None``. :param supported_formats: If ``True``, a list of all supported image file formats will be printed. |
174,221 | from typing import Any, Dict, Optional, Union
from warnings import warn
from .api import from_bytes
from .constant import CHARDET_CORRESPONDENCE
Any = object()
Union: _SpecialForm = ...
Optional: _SpecialForm = ...
Dict = _Alias()
def from_bytes(
sequences: bytes,
steps: int = 5,
chunk... | chardet legacy method Detect the encoding of the given byte string. It should be mostly backward-compatible. Encoding name will match Chardet own writing whenever possible. (Not on encoding name unsupported by it) This function is deprecated and should be used to migrate your project easily, consult the documentation f... |
174,222 | import logging
from os import PathLike
from typing import Any, BinaryIO, List, Optional, Set
from .cd import (
coherence_ratio,
encoding_languages,
mb_encoding_languages,
merge_coherence_ratios,
)
from .constant import IANA_SUPPORTED, TOO_BIG_SEQUENCE, TOO_SMALL_SEQUENCE, TRACE
from .md import mess_rati... | Same thing than the function from_bytes but with one extra step. Opening and reading given file path in binary mode. Can raise IOError. |
174,223 | import importlib
import logging
import unicodedata
from codecs import IncrementalDecoder
from encodings.aliases import aliases
from functools import lru_cache
from re import findall
from typing import Generator, List, Optional, Set, Tuple, Union
from _multibytecodec import MultibyteIncrementalDecoder
from .constant imp... | null |
174,225 | import importlib
import logging
import unicodedata
from codecs import IncrementalDecoder
from encodings.aliases import aliases
from functools import lru_cache
from re import findall
from typing import Generator, List, Optional, Set, Tuple, Union
from _multibytecodec import MultibyteIncrementalDecoder
from .constant imp... | null |
174,226 | import importlib
import logging
import unicodedata
from codecs import IncrementalDecoder
from encodings.aliases import aliases
from functools import lru_cache
from re import findall
from typing import Generator, List, Optional, Set, Tuple, Union
from _multibytecodec import MultibyteIncrementalDecoder
from .constant imp... | null |
174,227 | import importlib
import logging
import unicodedata
from codecs import IncrementalDecoder
from encodings.aliases import aliases
from functools import lru_cache
from re import findall
from typing import Generator, List, Optional, Set, Tuple, Union
from _multibytecodec import MultibyteIncrementalDecoder
from .constant imp... | null |
174,237 | import importlib
import logging
import unicodedata
from codecs import IncrementalDecoder
from encodings.aliases import aliases
from functools import lru_cache
from re import findall
from typing import Generator, List, Optional, Set, Tuple, Union
from _multibytecodec import MultibyteIncrementalDecoder
from .constant imp... | null |
174,238 | import importlib
import logging
import unicodedata
from codecs import IncrementalDecoder
from encodings.aliases import aliases
from functools import lru_cache
from re import findall
from typing import Generator, List, Optional, Set, Tuple, Union
from _multibytecodec import MultibyteIncrementalDecoder
from .constant imp... | null |
174,240 | import argparse
import sys
from json import dumps
from os.path import abspath, basename, dirname, join, realpath
from platform import python_version
from typing import List, Optional
from unicodedata import unidata_version
import charset_normalizer.md as md_module
from charset_normalizer import from_fp
from charset_nor... | CLI assistant using ARGV and ArgumentParser :param argv: :return: 0 if everything is fine, anything else equal trouble |
174,244 | import os
import re
import sys
from functools import wraps
from unicodedata import east_asian_width
from warnings import warn
from weakref import proxy
def _supports_unicode(fp):
try:
return _is_utf(fp.encoding)
except AttributeError:
return False
def _is_ascii(s):
if isinstance(s, str):
... | null |
174,245 | import os
import re
import sys
from functools import wraps
from unicodedata import east_asian_width
from warnings import warn
from weakref import proxy
def _screen_shape_wrapper(): # pragma: no cover
"""
Return a function which returns console dimensions (width, height).
Supported: linux, osx, windows, cyg... | Return a function which returns console width. Supported: linux, osx, windows, cygwin. |
174,259 | import sys
from collections import OrderedDict, defaultdict
from contextlib import contextmanager
from datetime import datetime, timedelta
from numbers import Number
from time import time
from warnings import warn
from weakref import WeakSet
from ._monitor import TMonitor
from .utils import (
CallbackIOWrapper, Com... | threading RLock |
174,263 | import os
from . import PYSIDE6, PYSIDE2, PYQT5, PYQT6
from .QtWidgets import QComboBox
if PYQT6:
from PyQt6.uic import *
elif PYQT5:
from PyQt5.uic import *
else:
__all__ = ['loadUi', 'loadUiType']
# In PySide, loadUi does not exist, so we define it using QUiLoader, and
# then make sure we expose t... | null |
174,264 | import os
from . import PYSIDE6, PYSIDE2, PYQT5, PYQT6
from .QtWidgets import QComboBox
if PYQT6:
from PyQt6.uic import *
elif PYQT5:
from PyQt5.uic import *
else:
__all__ = ['loadUi', 'loadUiType']
# In PySide, loadUi does not exist, so we define it using QUiLoader, and
# then make sure we expose t... | Dynamically load a user interface from the given ``uifile``. ``uifile`` is a string containing a file name of the UI file to load. If ``baseinstance`` is ``None``, the a new instance of the top-level widget will be created. Otherwise, the user interface is created within the given ``baseinstance``. In this case ``basei... |
174,265 | import os
from . import PYSIDE6, PYSIDE2, PYQT5, PYQT6
from .QtWidgets import QComboBox
class StringIO(TextIOWrapper):
def __init__(self, initial_value: Optional[str] = ..., newline: Optional[str] = ...) -> None: ...
# StringIO does not contain a "name" field. This workaround is necessary
# to allow String... | Load a .ui file and return the generated form class and the Qt base class. The "loadUiType" command convert the ui file to py code in-memory first and then execute it in a special frame to retrieve the form_class. Credit: https://stackoverflow.com/a/14195313/15954282 |
174,266 | import argparse
import textwrap
def print_version():
"""Print the current version of the package."""
import qtpy
print('QtPy version', qtpy.__version__)
def print_mypy_args():
"""Print the generated mypy args to stdout."""
print(generate_mypy_args())
The provided code snippet includes necessary dep... | Generate the argument parser for the dev CLI for QtPy. |
174,267 | from . import PYQT6, PYQT5, PYSIDE2, PYSIDE6
def movePositionPatched(
self,
operation: QTextCursor.MoveOperation,
mode: QTextCursor.MoveMode = QTextCursor.MoveAnchor,
n: int = 1,
) -> bool:
return movePosition(self, operation, mode, n) | null |
174,268 | from . import PYQT6
The provided code snippet includes necessary dependencies for implementing the `promote_enums` function. Write a Python function `def promote_enums(module)` to solve the following problem:
Search enums in the given module and allow unscoped access. Taken from: https://github.com/pyqtgraph/pyqtgraph... | Search enums in the given module and allow unscoped access. Taken from: https://github.com/pyqtgraph/pyqtgraph/blob/pyqtgraph-0.12.1/pyqtgraph/Qt.py#L331-L377 and adapted to also copy enum values aliased under different names. |
174,269 | import sys
from . import (
PYQT5,
PYQT6,
PYSIDE2,
PYSIDE6,
)
from .QtWidgets import QFileDialog
The provided code snippet includes necessary dependencies for implementing the `to_qvariant` function. Write a Python function `def to_qvariant(obj=None)` to solve the following problem:
Convert Python objec... | Convert Python object to QVariant This is a transitional function from PyQt API#1 (QVariant exist) to PyQt API#2 and Pyside (QVariant does not exist) |
174,270 | import sys
from . import (
PYQT5,
PYQT6,
PYSIDE2,
PYSIDE6,
)
from .QtWidgets import QFileDialog
The provided code snippet includes necessary dependencies for implementing the `from_qvariant` function. Write a Python function `def from_qvariant(qobj=None, pytype=None)` to solve the following problem:
Co... | Convert QVariant object to Python object This is a transitional function from PyQt API #1 (QVariant exist) to PyQt API #2 and Pyside (QVariant does not exist) |
174,271 | import sys
from . import (
PYQT5,
PYQT6,
PYSIDE2,
PYSIDE6,
)
from .QtWidgets import QFileDialog
def is_text_string(obj):
"""Return True if `obj` is a text string, False if it is anything else,
like binary data."""
return isinstance(obj, str)
def to_text_string(obj, encoding=None):
"""Con... | Wrapper around QtGui.QFileDialog.getExistingDirectory static method Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0 |
174,272 | import sys
from . import (
PYQT5,
PYQT6,
PYSIDE2,
PYSIDE6,
)
from .QtWidgets import QFileDialog
def _qfiledialog_wrapper(attr, parent=None, caption='', basedir='',
filters='', selectedfilter='', options=None):
if options is None:
options = QFileDialog.Option(0)
f... | Wrapper around QtGui.QFileDialog.getOpenFileName static method Returns a tuple (filename, selectedfilter) -- when dialog box is canceled, returns a tuple of empty strings Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0 |
174,273 | import sys
from . import (
PYQT5,
PYQT6,
PYSIDE2,
PYSIDE6,
)
from .QtWidgets import QFileDialog
def _qfiledialog_wrapper(attr, parent=None, caption='', basedir='',
filters='', selectedfilter='', options=None):
if options is None:
options = QFileDialog.Option(0)
f... | Wrapper around QtGui.QFileDialog.getOpenFileNames static method Returns a tuple (filenames, selectedfilter) -- when dialog box is canceled, returns a tuple (empty list, empty string) Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0 |
174,274 | import sys
from . import (
PYQT5,
PYQT6,
PYSIDE2,
PYSIDE6,
)
from .QtWidgets import QFileDialog
def _qfiledialog_wrapper(attr, parent=None, caption='', basedir='',
filters='', selectedfilter='', options=None):
if options is None:
options = QFileDialog.Option(0)
f... | Wrapper around QtGui.QFileDialog.getSaveFileName static method Returns a tuple (filename, selectedfilter) -- when dialog box is canceled, returns a tuple of empty strings Compatible with PyQt >=v4.4 (API #1 and #2) and PySide >=v1.0 |
174,275 | import sys
from . import (
PYQT5,
PYQT6,
PYSIDE2,
PYSIDE6,
)
from .QtWidgets import QFileDialog
The provided code snippet includes necessary dependencies for implementing the `isalive` function. Write a Python function `def isalive(object)` to solve the following problem:
Wrapper around sip.isdeleted a... | Wrapper around sip.isdeleted and shiboken.isValid which tests whether an object is currently alive. |
174,276 | import calendar
import datetime
import heapq
import itertools
import re
import sys
from functools import wraps
from warnings import warn
from six import advance_iterator, integer_types
from six.moves import _thread, range
from ._common import weekday as weekdaybase
def wraps(wrapped: _AnyCallable, assigned: Sequence[s... | Decorator for rruleset methods which may invalidate the cached length. |
174,277 | import logging
import os
import tempfile
import shutil
import json
from subprocess import check_call, check_output
from tarfile import TarFile
from dateutil.zoneinfo import METADATA_FN, ZONEFILENAME
def _run_zic(zonedir, filepaths):
"""Calls the ``zic`` compiler in a compatible way to get a "fat" binary.
Recent... | Rebuild the internal timezone info in dateutil/zoneinfo/zoneinfo*tar* filename is the timezone tarball from ``ftp.iana.org/tz``. |
174,278 | from __future__ import unicode_literals
from datetime import datetime, time
from time import struct_time
class time:
min: ClassVar[time]
max: ClassVar[time]
resolution: ClassVar[timedelta]
if sys.version_info >= (3, 6):
def __init__(
self,
hour: int = ...,
... | Returns a :py:class:`datetime` representing the current day at midnight :param tzinfo: The time zone to attach (also used to determine the current day). :return: A :py:class:`datetime.datetime` object representing the current day at midnight. |
174,281 | import datetime
import calendar
import operator
from math import copysign
from six import integer_types
from warnings import warn
from ._common import weekday
def copysign(__x: SupportsFloat, __y: SupportsFloat) -> float: ...
def _sign(x):
return int(copysign(1, x)) | null |
174,282 | from six import PY2
from functools import wraps
from datetime import datetime, timedelta, tzinfo
PY2 = sys.version_info[0] == 2
def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ...
The provided code snippet includes necessary dependencies for implem... | Change unicode output into bytestrings in Python 2 tzname() API changed in Python 3. It used to return bytes, but was changed to unicode strings |
174,283 | from six import PY2
from functools import wraps
from datetime import datetime, timedelta, tzinfo
def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]: ...
class tzinfo:
def tzname(self, dt: Optional[datetime]) -> Optional[str]: ...
def utcoffset(s... | The CPython version of ``fromutc`` checks that the input is a ``datetime`` object and that ``self`` is attached as its ``tzinfo``. |
174,284 | import datetime
import struct
import time
import sys
import os
import bisect
import weakref
from collections import OrderedDict
import six
from six import string_types
from six.moves import _thread
from ._common import tzname_in_python2, _tzinfo
from ._common import tzrangebase, enfold
from ._common import _validate_fr... | null |
174,293 | from datetime import datetime, timedelta, time, date
import calendar
from dateutil import tz
from functools import wraps
import re
import six
def wraps(wrapped: _AnyCallable, assigned: Sequence[str] = ..., updated: Sequence[str] = ...) -> Callable[[_T], _T]:
def _takes_ascii(f):
@wraps(f)
def func(self, str_i... | null |
174,296 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
class Callable(BaseTypingInstance):
def py__call__(s... | null |
174,297 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
Any = object()
The provided code snippet includes necess... | Imports an object by name. ``import_object('x')`` is equivalent to ``import x``. ``import_object('x.y.z')`` is equivalent to ``from x.y import z``. >>> import tornado.escape >>> import_object('tornado.escape') is tornado.escape True >>> import_object('tornado.escape.utf8') is tornado.escape.utf8 True >>> import_object(... |
174,298 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
Any = object()
Optional: _SpecialForm = ...
... | null |
174,299 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
if typing.TYPE_CHECKING:
# Additional imports only use... | null |
174,300 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
def _re_unescape_replacement(match: Match[str]) -> str:
... | r"""Unescape a string escaped by `re.escape`. May raise ``ValueError`` for regular expressions which could not have been produced by `re.escape` (for example, strings containing ``\d`` cannot be unescaped). .. versionadded:: 4.4 |
174,301 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
The provided code snippet includes necessary dependencies... | Equivalent to ``td.total_seconds()`` (introduced in Python 2.7). |
174,302 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
The provided code snippet includes necessary dependencies... | Websocket masking function. `mask` is a `bytes` object of length 4; `data` is a `bytes` object of any length. Returns a `bytes` object of the same length as `data` with the mask applied as specified in section 5.3 of RFC 6455. This pure-python implementation may be replaced by an optimized version when available. |
174,303 | import array
import asyncio
import atexit
from inspect import getfullargspec
import os
import re
import typing
import zlib
from typing import (
Any,
Optional,
Dict,
Mapping,
List,
Tuple,
Match,
Callable,
Type,
Sequence,
)
def doctests():
# type: () -> unittest.TestSuite
... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.