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
Storage.path
(self, name)
Return a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method.
Return a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method.
def path(self, name): """ Return a local filesystem path where the file can be retrieved using Python's built-in open() function. Storage systems that can't be accessed using open() should *not* implement this method. """ raise NotImplementedError("This backend doesn't su...
[ "def", "path", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "\"This backend doesn't support absolute paths.\"", ")" ]
[ 116, 4 ]
[ 122, 81 ]
python
en
['en', 'error', 'th']
False
Storage.delete
(self, name)
Delete the specified file from the storage system.
Delete the specified file from the storage system.
def delete(self, name): """ Delete the specified file from the storage system. """ raise NotImplementedError('subclasses of Storage must provide a delete() method')
[ "def", "delete", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a delete() method'", ")" ]
[ 127, 4 ]
[ 131, 89 ]
python
en
['en', 'error', 'th']
False
Storage.exists
(self, name)
Return True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.
Return True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file.
def exists(self, name): """ Return True if a file referenced by the given name already exists in the storage system, or False if the name is available for a new file. """ raise NotImplementedError('subclasses of Storage must provide an exists() method')
[ "def", "exists", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide an exists() method'", ")" ]
[ 133, 4 ]
[ 138, 90 ]
python
en
['en', 'error', 'th']
False
Storage.listdir
(self, path)
List the contents of the specified path. Return a 2-tuple of lists: the first item being directories, the second item being files.
List the contents of the specified path. Return a 2-tuple of lists: the first item being directories, the second item being files.
def listdir(self, path): """ List the contents of the specified path. Return a 2-tuple of lists: the first item being directories, the second item being files. """ raise NotImplementedError('subclasses of Storage must provide a listdir() method')
[ "def", "listdir", "(", "self", ",", "path", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a listdir() method'", ")" ]
[ 140, 4 ]
[ 145, 90 ]
python
en
['en', 'error', 'th']
False
Storage.size
(self, name)
Return the total size, in bytes, of the file specified by name.
Return the total size, in bytes, of the file specified by name.
def size(self, name): """ Return the total size, in bytes, of the file specified by name. """ raise NotImplementedError('subclasses of Storage must provide a size() method')
[ "def", "size", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a size() method'", ")" ]
[ 147, 4 ]
[ 151, 87 ]
python
en
['en', 'error', 'th']
False
Storage.url
(self, name)
Return an absolute URL where the file's contents can be accessed directly by a Web browser.
Return an absolute URL where the file's contents can be accessed directly by a Web browser.
def url(self, name): """ Return an absolute URL where the file's contents can be accessed directly by a Web browser. """ raise NotImplementedError('subclasses of Storage must provide a url() method')
[ "def", "url", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a url() method'", ")" ]
[ 153, 4 ]
[ 158, 86 ]
python
en
['en', 'error', 'th']
False
Storage.get_accessed_time
(self, name)
Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_accessed_time(self, name): """ Return the last accessed time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ raise NotImplementedError('subclasses of Storage must provide a get_accessed_time() method')
[ "def", "get_accessed_time", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a get_accessed_time() method'", ")" ]
[ 160, 4 ]
[ 165, 100 ]
python
en
['en', 'error', 'th']
False
Storage.get_created_time
(self, name)
Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_created_time(self, name): """ Return the creation time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ raise NotImplementedError('subclasses of Storage must provide a get_created_time() method')
[ "def", "get_created_time", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a get_created_time() method'", ")" ]
[ 167, 4 ]
[ 172, 99 ]
python
en
['en', 'error', 'th']
False
Storage.get_modified_time
(self, name)
Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True.
def get_modified_time(self, name): """ Return the last modified time (as a datetime) of the file specified by name. The datetime will be timezone-aware if USE_TZ=True. """ raise NotImplementedError('subclasses of Storage must provide a get_modified_time() method')
[ "def", "get_modified_time", "(", "self", ",", "name", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Storage must provide a get_modified_time() method'", ")" ]
[ 174, 4 ]
[ 179, 100 ]
python
en
['en', 'error', 'th']
False
shell
(name: Optional[str] = None, **attrs: Any)
Creates a new :class:`Shell` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Shell`.
Creates a new :class:`Shell` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Shell`.
def shell(name: Optional[str] = None, **attrs: Any) -> Callable[[F], Shell]: """Creates a new :class:`Shell` with a function as callback. This works otherwise the same as :func:`command` just that the `cls` parameter is set to :class:`Shell`. """ attrs.setdefault('cls', Shell) return cast(Shell...
[ "def", "shell", "(", "name", ":", "Optional", "[", "str", "]", "=", "None", ",", "*", "*", "attrs", ":", "Any", ")", "->", "Callable", "[", "[", "F", "]", ",", "Shell", "]", ":", "attrs", ".", "setdefault", "(", "'cls'", ",", "Shell", ")", "ret...
[ 15, 0 ]
[ 21, 52 ]
python
en
['en', 'en', 'en']
True
Command.get_input_data
(self, field, message, default=None)
Override this method if you want to customize data inputs or validation exceptions.
Override this method if you want to customize data inputs or validation exceptions.
def get_input_data(self, field, message, default=None): """ Override this method if you want to customize data inputs or validation exceptions. """ raw_value = input(message) if default and raw_value == '': raw_value = default try: val = fi...
[ "def", "get_input_data", "(", "self", ",", "field", ",", "message", ",", "default", "=", "None", ")", ":", "raw_value", "=", "input", "(", "message", ")", "if", "default", "and", "raw_value", "==", "''", ":", "raw_value", "=", "default", "try", ":", "v...
[ 203, 4 ]
[ 217, 18 ]
python
en
['en', 'error', 'th']
False
Command._validate_username
(self, username, verbose_field_name, database)
Validate username. If invalid, return a string error message.
Validate username. If invalid, return a string error message.
def _validate_username(self, username, verbose_field_name, database): """Validate username. If invalid, return a string error message.""" if self.username_field.unique: try: self.UserModel._default_manager.db_manager(database).get_by_natural_key(username) except s...
[ "def", "_validate_username", "(", "self", ",", "username", ",", "verbose_field_name", ",", "database", ")", ":", "if", "self", ".", "username_field", ".", "unique", ":", "try", ":", "self", ".", "UserModel", ".", "_default_manager", ".", "db_manager", "(", "...
[ 229, 4 ]
[ 243, 40 ]
python
en
['en', 'en', 'en']
True
IFDRational.__init__
(self, value, denominator=1)
:param value: either an integer numerator, a float/rational/other number, or an IFDRational :param denominator: Optional integer denominator
:param value: either an integer numerator, a float/rational/other number, or an IFDRational :param denominator: Optional integer denominator
def __init__(self, value, denominator=1): """ :param value: either an integer numerator, a float/rational/other number, or an IFDRational :param denominator: Optional integer denominator """ if isinstance(value, IFDRational): self._numerator = value.numerator ...
[ "def", "__init__", "(", "self", ",", "value", ",", "denominator", "=", "1", ")", ":", "if", "isinstance", "(", "value", ",", "IFDRational", ")", ":", "self", ".", "_numerator", "=", "value", ".", "numerator", "self", ".", "_denominator", "=", "value", ...
[ 302, 4 ]
[ 326, 52 ]
python
en
['en', 'error', 'th']
False
IFDRational.limit_rational
(self, max_denominator)
:param max_denominator: Integer, the maximum denominator value :returns: Tuple of (numerator, denominator)
def limit_rational(self, max_denominator): """ :param max_denominator: Integer, the maximum denominator value :returns: Tuple of (numerator, denominator) """ if self.denominator == 0: return (self.numerator, self.denominator) f = self._val.limit_denominator...
[ "def", "limit_rational", "(", "self", ",", "max_denominator", ")", ":", "if", "self", ".", "denominator", "==", "0", ":", "return", "(", "self", ".", "numerator", ",", "self", ".", "denominator", ")", "f", "=", "self", ".", "_val", ".", "limit_denominato...
[ 336, 4 ]
[ 347, 43 ]
python
en
['en', 'error', 'th']
False
ImageFileDirectory_v2.__init__
(self, ifh=b"II\052\0\0\0\0\0", prefix=None, group=None)
Initialize an ImageFileDirectory. To construct an ImageFileDirectory from a real file, pass the 8-byte magic header to the constructor. To only set the endianness, pass it as the 'prefix' keyword argument. :param ifh: One of the accepted magic headers (cf. PREFIXES); also sets ...
Initialize an ImageFileDirectory.
def __init__(self, ifh=b"II\052\0\0\0\0\0", prefix=None, group=None): """Initialize an ImageFileDirectory. To construct an ImageFileDirectory from a real file, pass the 8-byte magic header to the constructor. To only set the endianness, pass it as the 'prefix' keyword argument. ...
[ "def", "__init__", "(", "self", ",", "ifh", "=", "b\"II\\052\\0\\0\\0\\0\\0\"", ",", "prefix", "=", "None", ",", "group", "=", "None", ")", ":", "if", "ifh", "[", ":", "4", "]", "not", "in", "PREFIXES", ":", "raise", "SyntaxError", "(", "f\"not a TIFF fi...
[ 470, 4 ]
[ 495, 32 ]
python
en
['en', 'en', 'en']
True
ImageFileDirectory_v2.named
(self)
:returns: dict of name|key: value Returns the complete tag dictionary, with named tags where possible.
:returns: dict of name|key: value
def named(self): """ :returns: dict of name|key: value Returns the complete tag dictionary, with named tags where possible. """ return { TiffTags.lookup(code, self.group).name: value for code, value in self.items() }
[ "def", "named", "(", "self", ")", ":", "return", "{", "TiffTags", ".", "lookup", "(", "code", ",", "self", ".", "group", ")", ".", "name", ":", "value", "for", "code", ",", "value", "in", "self", ".", "items", "(", ")", "}" ]
[ 516, 4 ]
[ 525, 9 ]
python
en
['en', 'error', 'th']
False
ImageFileDirectory_v1.from_v2
(cls, original)
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1`
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance.
def from_v2(cls, original): """Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFi...
[ "def", "from_v2", "(", "cls", ",", "original", ")", ":", "ifd", "=", "cls", "(", "prefix", "=", "original", ".", "prefix", ")", "ifd", ".", "_tagdata", "=", "original", ".", "_tagdata", "ifd", ".", "tagtype", "=", "original", ".", "tagtype", "ifd", "...
[ 942, 4 ]
[ 957, 18 ]
python
en
['en', 'lb', 'en']
False
ImageFileDirectory_v1.to_v2
(self)
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2`
Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance.
def to_v2(self): """Returns an :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v2` instance with the same data as is contained in the original :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory_v1` instance. :returns: :py:class:`~PIL.TiffImagePlugin.ImageFileDirectory...
[ "def", "to_v2", "(", "self", ")", ":", "ifd", "=", "ImageFileDirectory_v2", "(", "prefix", "=", "self", ".", "prefix", ")", "ifd", ".", "_tagdata", "=", "dict", "(", "self", ".", "_tagdata", ")", "ifd", ".", "tagtype", "=", "dict", "(", "self", ".", ...
[ 959, 4 ]
[ 974, 18 ]
python
en
['en', 'lb', 'en']
False
TiffImageFile.__init__
(self, fp=None, filename=None)
Image file directory (tag dictionary)
Image file directory (tag dictionary)
def __init__(self, fp=None, filename=None): self.tag_v2 = None """ Image file directory (tag dictionary) """ self.tag = None """ Legacy tag entries """ super().__init__(fp, filename)
[ "def", "__init__", "(", "self", ",", "fp", "=", "None", ",", "filename", "=", "None", ")", ":", "self", ".", "tag_v2", "=", "None", "self", ".", "tag", "=", "None", "\"\"\" Legacy tag entries \"\"\"", "super", "(", ")", ".", "__init__", "(", "fp", ",",...
[ 1016, 4 ]
[ 1023, 38 ]
python
it
['it', 'en', 'it']
True
TiffImageFile._open
(self)
Open the first image in a TIFF file
Open the first image in a TIFF file
def _open(self): """Open the first image in a TIFF file""" # Header ifh = self.fp.read(8) self.tag_v2 = ImageFileDirectory_v2(ifh) # legacy IFD entries will be filled in later self.ifd = None # setup frame pointers self.__first = self.__next = self.tag...
[ "def", "_open", "(", "self", ")", ":", "# Header", "ifh", "=", "self", ".", "fp", ".", "read", "(", "8", ")", "self", ".", "tag_v2", "=", "ImageFileDirectory_v2", "(", "ifh", ")", "# legacy IFD entries will be filled in later", "self", ".", "ifd", "=", "No...
[ 1025, 4 ]
[ 1048, 21 ]
python
en
['en', 'en', 'en']
True
TiffImageFile.seek
(self, frame)
Select a given frame as current image
Select a given frame as current image
def seek(self, frame): """Select a given frame as current image""" if not self._seek_check(frame): return self._seek(frame) # Create a new core image object on second and # subsequent frames in the image. Image may be # different size/mode. Image._deco...
[ "def", "seek", "(", "self", ",", "frame", ")", ":", "if", "not", "self", ".", "_seek_check", "(", "frame", ")", ":", "return", "self", ".", "_seek", "(", "frame", ")", "# Create a new core image object on second and", "# subsequent frames in the image. Image may be"...
[ 1060, 4 ]
[ 1069, 54 ]
python
en
['en', 'en', 'en']
True
TiffImageFile.tell
(self)
Return the current frame number
Return the current frame number
def tell(self): """Return the current frame number""" return self.__frame
[ "def", "tell", "(", "self", ")", ":", "return", "self", ".", "__frame" ]
[ 1107, 4 ]
[ 1109, 27 ]
python
en
['en', 'da', 'en']
True
TiffImageFile.getxmp
(self)
Returns a dictionary containing the XMP tags. Requires defusedxml to be installed. :returns: XMP tags in a dictionary.
Returns a dictionary containing the XMP tags. Requires defusedxml to be installed. :returns: XMP tags in a dictionary.
def getxmp(self): """ Returns a dictionary containing the XMP tags. Requires defusedxml to be installed. :returns: XMP tags in a dictionary. """ return self._getxmp(self.tag_v2[700]) if 700 in self.tag_v2 else {}
[ "def", "getxmp", "(", "self", ")", ":", "return", "self", ".", "_getxmp", "(", "self", ".", "tag_v2", "[", "700", "]", ")", "if", "700", "in", "self", ".", "tag_v2", "else", "{", "}" ]
[ 1111, 4 ]
[ 1117, 75 ]
python
en
['en', 'error', 'th']
False
TiffImageFile._load_libtiff
(self)
Overload method triggered when we detect a compressed tiff Calls out to libtiff
Overload method triggered when we detect a compressed tiff Calls out to libtiff
def _load_libtiff(self): """Overload method triggered when we detect a compressed tiff Calls out to libtiff""" Image.Image.load(self) self.load_prepare() if not len(self.tile) == 1: raise OSError("Not exactly one tile") # (self._compression, (extents tuple...
[ "def", "_load_libtiff", "(", "self", ")", ":", "Image", ".", "Image", ".", "load", "(", "self", ")", "self", ".", "load_prepare", "(", ")", "if", "not", "len", "(", "self", ".", "tile", ")", "==", "1", ":", "raise", "OSError", "(", "\"Not exactly one...
[ 1144, 4 ]
[ 1227, 37 ]
python
en
['en', 'en', 'en']
True
TiffImageFile._setup
(self)
Setup this image object based on current tags
Setup this image object based on current tags
def _setup(self): """Setup this image object based on current tags""" if 0xBC01 in self.tag_v2: raise OSError("Windows Media Photo files not yet supported") # extract relevant tags self._compression = COMPRESSION_INFO[self.tag_v2.get(COMPRESSION, 1)] self._planar_co...
[ "def", "_setup", "(", "self", ")", ":", "if", "0xBC01", "in", "self", ".", "tag_v2", ":", "raise", "OSError", "(", "\"Windows Media Photo files not yet supported\"", ")", "# extract relevant tags", "self", ".", "_compression", "=", "COMPRESSION_INFO", "[", "self", ...
[ 1229, 4 ]
[ 1435, 56 ]
python
en
['en', 'en', 'en']
True
get_path_uid
(path: str)
Return path's uid. Does not follow symlinks: https://github.com/pypa/pip/pull/935#discussion_r5307003 Placed this function in compat due to differences on AIX and Jython, that should eventually go away. :raises OSError: When path is a symlink or can't be read.
Return path's uid.
def get_path_uid(path: str) -> int: """ Return path's uid. Does not follow symlinks: https://github.com/pypa/pip/pull/935#discussion_r5307003 Placed this function in compat due to differences on AIX and Jython, that should eventually go away. :raises OSError: When path is a symlink or...
[ "def", "get_path_uid", "(", "path", ":", "str", ")", "->", "int", ":", "if", "hasattr", "(", "os", ",", "\"O_NOFOLLOW\"", ")", ":", "fd", "=", "os", ".", "open", "(", "path", ",", "os", ".", "O_RDONLY", "|", "os", ".", "O_NOFOLLOW", ")", "file_uid"...
[ 26, 0 ]
[ 50, 19 ]
python
en
['en', 'error', 'th']
False
_proxy_stream
()
Finds the most appropriate error stream for the application. If a WSGI request is in flight we log to wsgi.errors, otherwise this resolves to sys.stderr.
Finds the most appropriate error stream for the application. If a WSGI request is in flight we log to wsgi.errors, otherwise this resolves to sys.stderr.
def _proxy_stream(): """Finds the most appropriate error stream for the application. If a WSGI request is in flight we log to wsgi.errors, otherwise this resolves to sys.stderr. """ ctx = _request_ctx_stack.top if ctx is not None: return ctx.request.environ['wsgi.errors'] return sys...
[ "def", "_proxy_stream", "(", ")", ":", "ctx", "=", "_request_ctx_stack", ".", "top", "if", "ctx", "is", "not", "None", ":", "return", "ctx", ".", "request", ".", "environ", "[", "'wsgi.errors'", "]", "return", "sys", ".", "stderr" ]
[ 31, 0 ]
[ 39, 21 ]
python
en
['en', 'en', 'en']
True
create_logger
(app)
Creates a logger for the given application. This logger works similar to a regular Python logger but changes the effective logging level based on the application's debug flag. Furthermore this function also removes all attached handlers in case there was a logger with the log name before.
Creates a logger for the given application. This logger works similar to a regular Python logger but changes the effective logging level based on the application's debug flag. Furthermore this function also removes all attached handlers in case there was a logger with the log name before.
def create_logger(app): """Creates a logger for the given application. This logger works similar to a regular Python logger but changes the effective logging level based on the application's debug flag. Furthermore this function also removes all attached handlers in case there was a logger with th...
[ "def", "create_logger", "(", "app", ")", ":", "Logger", "=", "getLoggerClass", "(", ")", "class", "DebugLogger", "(", "Logger", ")", ":", "def", "getEffectiveLevel", "(", "self", ")", ":", "if", "self", ".", "level", "==", "0", "and", "app", ".", "debu...
[ 49, 0 ]
[ 93, 17 ]
python
en
['en', 'en', 'en']
True
OracleSpatialAdapter.__init__
(self, geom)
Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise
Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise
def __init__(self, geom): """ Oracle requires that polygon rings are in proper orientation. This affects spatial operations and an invalid orientation may cause failures. Correct orientations are: * Outer ring - counter clockwise * Inner ring(s) - clockwise """ ...
[ "def", "__init__", "(", "self", ",", "geom", ")", ":", "if", "isinstance", "(", "geom", ",", "Polygon", ")", ":", "if", "self", ".", "_polygon_must_be_fixed", "(", "geom", ")", ":", "geom", "=", "self", ".", "_fix_polygon", "(", "geom", ")", "elif", ...
[ 9, 4 ]
[ 25, 29 ]
python
en
['en', 'error', 'th']
False
OracleSpatialAdapter._fix_polygon
(cls, poly, clone=True)
Fix single polygon orientation as described in __init__().
Fix single polygon orientation as described in __init__().
def _fix_polygon(cls, poly, clone=True): """Fix single polygon orientation as described in __init__().""" if clone: poly = poly.clone() if not poly.exterior_ring.is_counterclockwise: poly.exterior_ring = list(reversed(poly.exterior_ring)) for i in range(1, len(p...
[ "def", "_fix_polygon", "(", "cls", ",", "poly", ",", "clone", "=", "True", ")", ":", "if", "clone", ":", "poly", "=", "poly", ".", "clone", "(", ")", "if", "not", "poly", ".", "exterior_ring", ".", "is_counterclockwise", ":", "poly", ".", "exterior_rin...
[ 38, 4 ]
[ 50, 19 ]
python
en
['en', 'es', 'en']
True
OracleSpatialAdapter._fix_geometry_collection
(cls, coll)
Fix polygon orientations in geometry collections as described in __init__().
Fix polygon orientations in geometry collections as described in __init__().
def _fix_geometry_collection(cls, coll): """ Fix polygon orientations in geometry collections as described in __init__(). """ coll = coll.clone() for i, geom in enumerate(coll): if isinstance(geom, Polygon): coll[i] = cls._fix_polygon(geom, clo...
[ "def", "_fix_geometry_collection", "(", "cls", ",", "coll", ")", ":", "coll", "=", "coll", ".", "clone", "(", ")", "for", "i", ",", "geom", "in", "enumerate", "(", "coll", ")", ":", "if", "isinstance", "(", "geom", ",", "Polygon", ")", ":", "coll", ...
[ 53, 4 ]
[ 62, 19 ]
python
en
['en', 'error', 'th']
False
_get
( d: Dict[str, Any], expected_type: Type[T], key: str, default: Optional[T] = None )
Get value from dictionary and verify expected type.
Get value from dictionary and verify expected type.
def _get( d: Dict[str, Any], expected_type: Type[T], key: str, default: Optional[T] = None ) -> Optional[T]: """Get value from dictionary and verify expected type.""" if key not in d: return default value = d[key] if not isinstance(value, expected_type): raise DirectUrlValidationErro...
[ "def", "_get", "(", "d", ":", "Dict", "[", "str", ",", "Any", "]", ",", "expected_type", ":", "Type", "[", "T", "]", ",", "key", ":", "str", ",", "default", ":", "Optional", "[", "T", "]", "=", "None", ")", "->", "Optional", "[", "T", "]", ":...
[ 24, 0 ]
[ 37, 16 ]
python
en
['en', 'en', 'en']
True
_filter_none
(**kwargs: Any)
Make dict excluding None values.
Make dict excluding None values.
def _filter_none(**kwargs: Any) -> Dict[str, Any]: """Make dict excluding None values.""" return {k: v for k, v in kwargs.items() if v is not None}
[ "def", "_filter_none", "(", "*", "*", "kwargs", ":", "Any", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "k", ":", "v", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", "if", "v", "is", "not", "None", "}" ]
[ 63, 0 ]
[ 65, 61 ]
python
en
['en', 'en', 'en']
True
DirectUrl.redacted_url
(self)
url with user:password part removed unless it is formed with environment variables as specified in PEP 610, or it is ``git`` in the case of a git URL.
url with user:password part removed unless it is formed with environment variables as specified in PEP 610, or it is ``git`` in the case of a git URL.
def redacted_url(self) -> str: """url with user:password part removed unless it is formed with environment variables as specified in PEP 610, or it is ``git`` in the case of a git URL. """ purl = urllib.parse.urlsplit(self.url) netloc = self._remove_auth_from_netloc(purl....
[ "def", "redacted_url", "(", "self", ")", "->", "str", ":", "purl", "=", "urllib", ".", "parse", ".", "urlsplit", "(", "self", ".", "url", ")", "netloc", "=", "self", ".", "_remove_auth_from_netloc", "(", "purl", ".", "netloc", ")", "surl", "=", "urllib...
[ 177, 4 ]
[ 187, 19 ]
python
en
['en', 'en', 'en']
True
check_requires_python
(requires_python, version_info)
Check if the given Python version matches a "Requires-Python" specifier. :param version_info: A 3-tuple of ints representing a Python major-minor-micro version to check (e.g. `sys.version_info[:3]`). :return: `True` if the given Python version satisfies the requirement. Otherwise, return ...
Check if the given Python version matches a "Requires-Python" specifier.
def check_requires_python(requires_python, version_info): # type: (Optional[str], Tuple[int, ...]) -> bool """ Check if the given Python version matches a "Requires-Python" specifier. :param version_info: A 3-tuple of ints representing a Python major-minor-micro version to check (e.g. `sys.vers...
[ "def", "check_requires_python", "(", "requires_python", ",", "version_info", ")", ":", "# type: (Optional[str], Tuple[int, ...]) -> bool", "if", "requires_python", "is", "None", ":", "# The package provides no information", "return", "True", "requires_python_specifier", "=", "s...
[ 15, 0 ]
[ 34, 54 ]
python
en
['en', 'error', 'th']
False
get_metadata
(dist)
:raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None.
:raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None.
def get_metadata(dist): # type: (Distribution) -> Message """ :raises NoneMetadataError: if the distribution reports `has_metadata()` True but `get_metadata()` returns None. """ metadata_name = "METADATA" if isinstance(dist, pkg_resources.DistInfoDistribution) and dist.has_metadata( ...
[ "def", "get_metadata", "(", "dist", ")", ":", "# type: (Distribution) -> Message", "metadata_name", "=", "\"METADATA\"", "if", "isinstance", "(", "dist", ",", "pkg_resources", ".", "DistInfoDistribution", ")", "and", "dist", ".", "has_metadata", "(", "metadata_name", ...
[ 37, 0 ]
[ 62, 30 ]
python
en
['en', 'error', 'th']
False
get_requires_python
(dist)
Return the "Requires-Python" metadata for a distribution, or None if not present.
Return the "Requires-Python" metadata for a distribution, or None if not present.
def get_requires_python(dist): # type: (pkg_resources.Distribution) -> Optional[str] """ Return the "Requires-Python" metadata for a distribution, or None if not present. """ pkg_info_dict = get_metadata(dist) requires_python = pkg_info_dict.get("Requires-Python") if requires_python is ...
[ "def", "get_requires_python", "(", "dist", ")", ":", "# type: (pkg_resources.Distribution) -> Optional[str]", "pkg_info_dict", "=", "get_metadata", "(", "dist", ")", "requires_python", "=", "pkg_info_dict", ".", "get", "(", "\"Requires-Python\"", ")", "if", "requires_pyth...
[ 65, 0 ]
[ 79, 26 ]
python
en
['en', 'error', 'th']
False
build_instance
(Model, data, db)
Build a model instance. If the model instance doesn't have a primary key and the model supports natural keys, try to retrieve it from the database.
Build a model instance.
def build_instance(Model, data, db): """ Build a model instance. If the model instance doesn't have a primary key and the model supports natural keys, try to retrieve it from the database. """ default_manager = Model._meta.default_manager pk = data.get(Model._meta.pk.attname) if (pk is ...
[ "def", "build_instance", "(", "Model", ",", "data", ",", "db", ")", ":", "default_manager", "=", "Model", ".", "_meta", ".", "default_manager", "pk", "=", "data", ".", "get", "(", "Model", ".", "_meta", ".", "pk", ".", "attname", ")", "if", "(", "pk"...
[ 251, 0 ]
[ 269, 24 ]
python
en
['en', 'error', 'th']
False
DeserializationError.WithData
(cls, original_exc, model, fk, field_value)
Factory method for creating a deserialization error which has a more explanatory message.
Factory method for creating a deserialization error which has a more explanatory message.
def WithData(cls, original_exc, model, fk, field_value): """ Factory method for creating a deserialization error which has a more explanatory message. """ return cls("%s: (%s:pk=%s) field_value was '%s'" % (original_exc, model, fk, field_value))
[ "def", "WithData", "(", "cls", ",", "original_exc", ",", "model", ",", "fk", ",", "field_value", ")", ":", "return", "cls", "(", "\"%s: (%s:pk=%s) field_value was '%s'\"", "%", "(", "original_exc", ",", "model", ",", "fk", ",", "field_value", ")", ")" ]
[ 25, 4 ]
[ 30, 98 ]
python
en
['en', 'error', 'th']
False
Serializer.serialize
(self, queryset, *, stream=None, fields=None, use_natural_foreign_keys=False, use_natural_primary_keys=False, progress_output=None, object_count=0, **options)
Serialize a queryset.
Serialize a queryset.
def serialize(self, queryset, *, stream=None, fields=None, use_natural_foreign_keys=False, use_natural_primary_keys=False, progress_output=None, object_count=0, **options): """ Serialize a queryset. """ self.options = options self.stream = stream if stream is n...
[ "def", "serialize", "(", "self", ",", "queryset", ",", "*", ",", "stream", "=", "None", ",", "fields", "=", "None", ",", "use_natural_foreign_keys", "=", "False", ",", "use_natural_primary_keys", "=", "False", ",", "progress_output", "=", "None", ",", "objec...
[ 74, 4 ]
[ 118, 30 ]
python
en
['en', 'error', 'th']
False
Serializer.start_serialization
(self)
Called when serializing of the queryset starts.
Called when serializing of the queryset starts.
def start_serialization(self): """ Called when serializing of the queryset starts. """ raise NotImplementedError('subclasses of Serializer must provide a start_serialization() method')
[ "def", "start_serialization", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide a start_serialization() method'", ")" ]
[ 120, 4 ]
[ 124, 105 ]
python
en
['en', 'error', 'th']
False
Serializer.end_serialization
(self)
Called when serializing of the queryset ends.
Called when serializing of the queryset ends.
def end_serialization(self): """ Called when serializing of the queryset ends. """ pass
[ "def", "end_serialization", "(", "self", ")", ":", "pass" ]
[ 126, 4 ]
[ 130, 12 ]
python
en
['en', 'error', 'th']
False
Serializer.start_object
(self, obj)
Called when serializing of an object starts.
Called when serializing of an object starts.
def start_object(self, obj): """ Called when serializing of an object starts. """ raise NotImplementedError('subclasses of Serializer must provide a start_object() method')
[ "def", "start_object", "(", "self", ",", "obj", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide a start_object() method'", ")" ]
[ 132, 4 ]
[ 136, 98 ]
python
en
['en', 'error', 'th']
False
Serializer.end_object
(self, obj)
Called when serializing of an object ends.
Called when serializing of an object ends.
def end_object(self, obj): """ Called when serializing of an object ends. """ pass
[ "def", "end_object", "(", "self", ",", "obj", ")", ":", "pass" ]
[ 138, 4 ]
[ 142, 12 ]
python
en
['en', 'error', 'th']
False
Serializer.handle_field
(self, obj, field)
Called to handle each individual (non-relational) field on an object.
Called to handle each individual (non-relational) field on an object.
def handle_field(self, obj, field): """ Called to handle each individual (non-relational) field on an object. """ raise NotImplementedError('subclasses of Serializer must provide a handle_field() method')
[ "def", "handle_field", "(", "self", ",", "obj", ",", "field", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide a handle_field() method'", ")" ]
[ 144, 4 ]
[ 148, 98 ]
python
en
['en', 'error', 'th']
False
Serializer.handle_fk_field
(self, obj, field)
Called to handle a ForeignKey field.
Called to handle a ForeignKey field.
def handle_fk_field(self, obj, field): """ Called to handle a ForeignKey field. """ raise NotImplementedError('subclasses of Serializer must provide a handle_fk_field() method')
[ "def", "handle_fk_field", "(", "self", ",", "obj", ",", "field", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide a handle_fk_field() method'", ")" ]
[ 150, 4 ]
[ 154, 101 ]
python
en
['en', 'error', 'th']
False
Serializer.handle_m2m_field
(self, obj, field)
Called to handle a ManyToManyField.
Called to handle a ManyToManyField.
def handle_m2m_field(self, obj, field): """ Called to handle a ManyToManyField. """ raise NotImplementedError('subclasses of Serializer must provide a handle_m2m_field() method')
[ "def", "handle_m2m_field", "(", "self", ",", "obj", ",", "field", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide a handle_m2m_field() method'", ")" ]
[ 156, 4 ]
[ 160, 102 ]
python
en
['en', 'error', 'th']
False
Serializer.getvalue
(self)
Return the fully serialized queryset (or None if the output stream is not seekable).
Return the fully serialized queryset (or None if the output stream is not seekable).
def getvalue(self): """ Return the fully serialized queryset (or None if the output stream is not seekable). """ if callable(getattr(self.stream, 'getvalue', None)): return self.stream.getvalue()
[ "def", "getvalue", "(", "self", ")", ":", "if", "callable", "(", "getattr", "(", "self", ".", "stream", ",", "'getvalue'", ",", "None", ")", ")", ":", "return", "self", ".", "stream", ".", "getvalue", "(", ")" ]
[ 162, 4 ]
[ 168, 41 ]
python
en
['en', 'error', 'th']
False
Deserializer.__init__
(self, stream_or_string, **options)
Init this serializer given a stream or a string
Init this serializer given a stream or a string
def __init__(self, stream_or_string, **options): """ Init this serializer given a stream or a string """ self.options = options if isinstance(stream_or_string, str): self.stream = StringIO(stream_or_string) else: self.stream = stream_or_string
[ "def", "__init__", "(", "self", ",", "stream_or_string", ",", "*", "*", "options", ")", ":", "self", ".", "options", "=", "options", "if", "isinstance", "(", "stream_or_string", ",", "str", ")", ":", "self", ".", "stream", "=", "StringIO", "(", "stream_o...
[ 176, 4 ]
[ 184, 42 ]
python
en
['en', 'error', 'th']
False
Deserializer.__next__
(self)
Iteration interface -- return the next item in the stream
Iteration interface -- return the next item in the stream
def __next__(self): """Iteration interface -- return the next item in the stream""" raise NotImplementedError('subclasses of Deserializer must provide a __next__() method')
[ "def", "__next__", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Deserializer must provide a __next__() method'", ")" ]
[ 189, 4 ]
[ 191, 96 ]
python
en
['en', 'en', 'en']
True
normalize_together
(option_together)
option_together can be either a tuple of tuples, or a single tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that.
option_together can be either a tuple of tuples, or a single tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that.
def normalize_together(option_together): """ option_together can be either a tuple of tuples, or a single tuple of two strings. Normalize it to a tuple of tuples, so that calling code can uniformly expect that. """ try: if not option_together: return () if not isinsta...
[ "def", "normalize_together", "(", "option_together", ")", ":", "try", ":", "if", "not", "option_together", ":", "return", "(", ")", "if", "not", "isinstance", "(", "option_together", ",", "(", "tuple", ",", "list", ")", ")", ":", "raise", "TypeError", "fir...
[ 37, 0 ]
[ 56, 30 ]
python
en
['en', 'error', 'th']
False
Options._format_names_with_class
(self, cls, objs)
App label/class name interpolation for object names.
App label/class name interpolation for object names.
def _format_names_with_class(self, cls, objs): """App label/class name interpolation for object names.""" new_objs = [] for obj in objs: obj = obj.clone() obj.name = obj.name % { 'app_label': cls._meta.app_label.lower(), 'class': cls.__name...
[ "def", "_format_names_with_class", "(", "self", ",", "cls", ",", "objs", ")", ":", "new_objs", "=", "[", "]", "for", "obj", "in", "objs", ":", "obj", "=", "obj", ".", "clone", "(", ")", "obj", ".", "name", "=", "obj", ".", "name", "%", "{", "'app...
[ 208, 4 ]
[ 218, 23 ]
python
en
['nb', 'en', 'en']
True
Options.setup_proxy
(self, target)
Do the internal setup so that the current model is a proxy for "target".
Do the internal setup so that the current model is a proxy for "target".
def setup_proxy(self, target): """ Do the internal setup so that the current model is a proxy for "target". """ self.pk = target._meta.pk self.proxy_for_model = target self.db_table = target._meta.db_table
[ "def", "setup_proxy", "(", "self", ",", "target", ")", ":", "self", ".", "pk", "=", "target", ".", "_meta", ".", "pk", "self", ".", "proxy_for_model", "=", "target", "self", ".", "db_table", "=", "target", ".", "_meta", ".", "db_table" ]
[ 327, 4 ]
[ 334, 45 ]
python
en
['en', 'error', 'th']
False
Options.can_migrate
(self, connection)
Return True if the model can/should be migrated on the `connection`. `connection` can be either a real connection or a connection alias.
Return True if the model can/should be migrated on the `connection`. `connection` can be either a real connection or a connection alias.
def can_migrate(self, connection): """ Return True if the model can/should be migrated on the `connection`. `connection` can be either a real connection or a connection alias. """ if self.proxy or self.swapped or not self.managed: return False if isinstance(co...
[ "def", "can_migrate", "(", "self", ",", "connection", ")", ":", "if", "self", ".", "proxy", "or", "self", ".", "swapped", "or", "not", "self", ".", "managed", ":", "return", "False", "if", "isinstance", "(", "connection", ",", "str", ")", ":", "connect...
[ 342, 4 ]
[ 356, 19 ]
python
en
['en', 'error', 'th']
False
Options.verbose_name_raw
(self)
Return the untranslated verbose name.
Return the untranslated verbose name.
def verbose_name_raw(self): """Return the untranslated verbose name.""" with override(None): return str(self.verbose_name)
[ "def", "verbose_name_raw", "(", "self", ")", ":", "with", "override", "(", "None", ")", ":", "return", "str", "(", "self", ".", "verbose_name", ")" ]
[ 359, 4 ]
[ 362, 41 ]
python
en
['en', 'da', 'en']
True
Options.swapped
(self)
Has this model been swapped out for another? If so, return the model name of the replacement; otherwise, return None. For historical reasons, model name lookups using get_model() are case insensitive, so we make sure we are case insensitive here.
Has this model been swapped out for another? If so, return the model name of the replacement; otherwise, return None.
def swapped(self): """ Has this model been swapped out for another? If so, return the model name of the replacement; otherwise, return None. For historical reasons, model name lookups using get_model() are case insensitive, so we make sure we are case insensitive here. "...
[ "def", "swapped", "(", "self", ")", ":", "if", "self", ".", "swappable", ":", "swapped_for", "=", "getattr", "(", "settings", ",", "self", ".", "swappable", ",", "None", ")", "if", "swapped_for", ":", "try", ":", "swapped_label", ",", "swapped_object", "...
[ 365, 4 ]
[ 387, 19 ]
python
en
['en', 'error', 'th']
False
Options.fields
(self)
Return a list of all forward fields on the model and its parents, excluding ManyToManyFields. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this field list.
Return a list of all forward fields on the model and its parents, excluding ManyToManyFields.
def fields(self): """ Return a list of all forward fields on the model and its parents, excluding ManyToManyFields. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this field ...
[ "def", "fields", "(", "self", ")", ":", "# For legacy reasons, the fields property should only contain forward", "# fields that are not private or with a m2m cardinality. Therefore we", "# pass these three filters as filters to the generator.", "# The third lambda is a longwinded way of checking f...
[ 466, 4 ]
[ 497, 9 ]
python
en
['en', 'error', 'th']
False
Options.concrete_fields
(self)
Return a list of all concrete fields on the model and its parents. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this field list.
Return a list of all concrete fields on the model and its parents.
def concrete_fields(self): """ Return a list of all concrete fields on the model and its parents. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this field list. """ ...
[ "def", "concrete_fields", "(", "self", ")", ":", "return", "make_immutable_fields_list", "(", "\"concrete_fields\"", ",", "(", "f", "for", "f", "in", "self", ".", "fields", "if", "f", ".", "concrete", ")", ")" ]
[ 500, 4 ]
[ 510, 9 ]
python
en
['en', 'error', 'th']
False
Options.local_concrete_fields
(self)
Return a list of all concrete fields on the model. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this field list.
Return a list of all concrete fields on the model.
def local_concrete_fields(self): """ Return a list of all concrete fields on the model. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this field list. """ return mak...
[ "def", "local_concrete_fields", "(", "self", ")", ":", "return", "make_immutable_fields_list", "(", "\"local_concrete_fields\"", ",", "(", "f", "for", "f", "in", "self", ".", "local_fields", "if", "f", ".", "concrete", ")", ")" ]
[ 513, 4 ]
[ 523, 9 ]
python
en
['en', 'error', 'th']
False
Options.many_to_many
(self)
Return a list of all many to many fields on the model and its parents. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this list.
Return a list of all many to many fields on the model and its parents.
def many_to_many(self): """ Return a list of all many to many fields on the model and its parents. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the public API for obtaining this list. """ retur...
[ "def", "many_to_many", "(", "self", ")", ":", "return", "make_immutable_fields_list", "(", "\"many_to_many\"", ",", "(", "f", "for", "f", "in", "self", ".", "_get_fields", "(", "reverse", "=", "False", ")", "if", "f", ".", "is_relation", "and", "f", ".", ...
[ 526, 4 ]
[ 537, 9 ]
python
en
['en', 'error', 'th']
False
Options.related_objects
(self)
Return all related objects pointing to the current model. The related objects can come from a one-to-one, one-to-many, or many-to-many field relation type. Private API intended only to be used by Django itself; get_fields() combined with filtering of field properties is the pub...
Return all related objects pointing to the current model. The related objects can come from a one-to-one, one-to-many, or many-to-many field relation type.
def related_objects(self): """ Return all related objects pointing to the current model. The related objects can come from a one-to-one, one-to-many, or many-to-many field relation type. Private API intended only to be used by Django itself; get_fields() combined with fi...
[ "def", "related_objects", "(", "self", ")", ":", "all_related_fields", "=", "self", ".", "_get_fields", "(", "forward", "=", "False", ",", "reverse", "=", "True", ",", "include_hidden", "=", "True", ")", "return", "make_immutable_fields_list", "(", "\"related_ob...
[ 540, 4 ]
[ 554, 9 ]
python
en
['en', 'error', 'th']
False
Options.get_field
(self, field_name)
Return a field instance given the name of a forward or reverse field.
Return a field instance given the name of a forward or reverse field.
def get_field(self, field_name): """ Return a field instance given the name of a forward or reverse field. """ try: # In order to avoid premature loading of the relation tree # (expensive) we prefer checking if the field is a forward field. return self...
[ "def", "get_field", "(", "self", ",", "field_name", ")", ":", "try", ":", "# In order to avoid premature loading of the relation tree", "# (expensive) we prefer checking if the field is a forward field.", "return", "self", ".", "_forward_fields_map", "[", "field_name", "]", "ex...
[ 586, 4 ]
[ 609, 98 ]
python
en
['en', 'error', 'th']
False
Options.get_base_chain
(self, model)
Return a list of parent classes leading to `model` (ordered from closest to most distant ancestor). This has to handle the case where `model` is a grandparent or even more distant relation.
Return a list of parent classes leading to `model` (ordered from closest to most distant ancestor). This has to handle the case where `model` is a grandparent or even more distant relation.
def get_base_chain(self, model): """ Return a list of parent classes leading to `model` (ordered from closest to most distant ancestor). This has to handle the case where `model` is a grandparent or even more distant relation. """ if not self.parents: return [...
[ "def", "get_base_chain", "(", "self", ",", "model", ")", ":", "if", "not", "self", ".", "parents", ":", "return", "[", "]", "if", "model", "in", "self", ".", "parents", ":", "return", "[", "model", "]", "for", "parent", "in", "self", ".", "parents", ...
[ 611, 4 ]
[ 626, 17 ]
python
en
['en', 'error', 'th']
False
Options.get_parent_list
(self)
Return all the ancestors of this model as a list ordered by MRO. Useful for determining if something is an ancestor, regardless of lineage.
Return all the ancestors of this model as a list ordered by MRO. Useful for determining if something is an ancestor, regardless of lineage.
def get_parent_list(self): """ Return all the ancestors of this model as a list ordered by MRO. Useful for determining if something is an ancestor, regardless of lineage. """ result = OrderedSet(self.parents) for parent in self.parents: for ancestor in parent....
[ "def", "get_parent_list", "(", "self", ")", ":", "result", "=", "OrderedSet", "(", "self", ".", "parents", ")", "for", "parent", "in", "self", ".", "parents", ":", "for", "ancestor", "in", "parent", ".", "_meta", ".", "get_parent_list", "(", ")", ":", ...
[ 628, 4 ]
[ 637, 27 ]
python
en
['en', 'error', 'th']
False
Options.get_ancestor_link
(self, ancestor)
Return the field on the current model which points to the given "ancestor". This is possible an indirect link (a pointer to a parent model, which points, eventually, to the ancestor). Used when constructing table joins for model inheritance. Return None if the model isn't an an...
Return the field on the current model which points to the given "ancestor". This is possible an indirect link (a pointer to a parent model, which points, eventually, to the ancestor). Used when constructing table joins for model inheritance.
def get_ancestor_link(self, ancestor): """ Return the field on the current model which points to the given "ancestor". This is possible an indirect link (a pointer to a parent model, which points, eventually, to the ancestor). Used when constructing table joins for model inherita...
[ "def", "get_ancestor_link", "(", "self", ",", "ancestor", ")", ":", "if", "ancestor", "in", "self", ".", "parents", ":", "return", "self", ".", "parents", "[", "ancestor", "]", "for", "parent", "in", "self", ".", "parents", ":", "# Tries to get a link field ...
[ 639, 4 ]
[ 657, 58 ]
python
en
['en', 'error', 'th']
False
Options.get_path_to_parent
(self, parent)
Return a list of PathInfos containing the path from the current model to the parent model, or an empty list if parent is not a parent of the current model.
Return a list of PathInfos containing the path from the current model to the parent model, or an empty list if parent is not a parent of the current model.
def get_path_to_parent(self, parent): """ Return a list of PathInfos containing the path from the current model to the parent model, or an empty list if parent is not a parent of the current model. """ if self.model is parent: return [] # Skip the chai...
[ "def", "get_path_to_parent", "(", "self", ",", "parent", ")", ":", "if", "self", ".", "model", "is", "parent", ":", "return", "[", "]", "# Skip the chain of proxy to the concrete proxied model.", "proxied_model", "=", "self", ".", "concrete_model", "path", "=", "[...
[ 659, 4 ]
[ 687, 19 ]
python
en
['en', 'error', 'th']
False
Options.get_path_from_parent
(self, parent)
Return a list of PathInfos containing the path from the parent model to the current model, or an empty list if parent is not a parent of the current model.
Return a list of PathInfos containing the path from the parent model to the current model, or an empty list if parent is not a parent of the current model.
def get_path_from_parent(self, parent): """ Return a list of PathInfos containing the path from the parent model to the current model, or an empty list if parent is not a parent of the current model. """ if self.model is parent: return [] model = self....
[ "def", "get_path_from_parent", "(", "self", ",", "parent", ")", ":", "if", "self", ".", "model", "is", "parent", ":", "return", "[", "]", "model", "=", "self", ".", "concrete_model", "# Get a reversed base chain including both the current and parent", "# models.", "...
[ 689, 4 ]
[ 709, 19 ]
python
en
['en', 'error', 'th']
False
Options._populate_directed_relation_graph
(self)
This method is used by each model to find its reverse objects. As this method is very expensive and is accessed frequently (it looks up every field in a model, in every app), it is computed on first access and then is set as a property on every model.
This method is used by each model to find its reverse objects. As this method is very expensive and is accessed frequently (it looks up every field in a model, in every app), it is computed on first access and then is set as a property on every model.
def _populate_directed_relation_graph(self): """ This method is used by each model to find its reverse objects. As this method is very expensive and is accessed frequently (it looks up every field in a model, in every app), it is computed on first access and then is set as a prop...
[ "def", "_populate_directed_relation_graph", "(", "self", ")", ":", "related_objects_graph", "=", "defaultdict", "(", "list", ")", "all_models", "=", "self", ".", "apps", ".", "get_models", "(", "include_auto_created", "=", "True", ")", "for", "model", "in", "all...
[ 711, 4 ]
[ 746, 71 ]
python
en
['en', 'error', 'th']
False
Options.get_fields
(self, include_parents=True, include_hidden=False)
Return a list of fields associated to the model. By default, include forward and reverse fields, fields derived from inheritance, but not hidden fields. The returned fields can be changed using the parameters: - include_parents: include fields derived from inheritance - include...
Return a list of fields associated to the model. By default, include forward and reverse fields, fields derived from inheritance, but not hidden fields. The returned fields can be changed using the parameters:
def get_fields(self, include_parents=True, include_hidden=False): """ Return a list of fields associated to the model. By default, include forward and reverse fields, fields derived from inheritance, but not hidden fields. The returned fields can be changed using the parameters: ...
[ "def", "get_fields", "(", "self", ",", "include_parents", "=", "True", ",", "include_hidden", "=", "False", ")", ":", "if", "include_parents", "is", "False", ":", "include_parents", "=", "PROXY_PARENTS", "return", "self", ".", "_get_fields", "(", "include_parent...
[ 765, 4 ]
[ 777, 95 ]
python
en
['en', 'error', 'th']
False
Options._get_fields
(self, forward=True, reverse=True, include_parents=True, include_hidden=False, seen_models=None)
Internal helper function to return fields of the model. * If forward=True, then fields defined on this model are returned. * If reverse=True, then relations pointing to this model are returned. * If include_hidden=True, then fields with is_hidden=True are returned. * The include...
Internal helper function to return fields of the model. * If forward=True, then fields defined on this model are returned. * If reverse=True, then relations pointing to this model are returned. * If include_hidden=True, then fields with is_hidden=True are returned. * The include...
def _get_fields(self, forward=True, reverse=True, include_parents=True, include_hidden=False, seen_models=None): """ Internal helper function to return fields of the model. * If forward=True, then fields defined on this model are returned. * If reverse=True, then rela...
[ "def", "_get_fields", "(", "self", ",", "forward", "=", "True", ",", "reverse", "=", "True", ",", "include_parents", "=", "True", ",", "include_hidden", "=", "False", ",", "seen_models", "=", "None", ")", ":", "if", "include_parents", "not", "in", "(", "...
[ 779, 4 ]
[ 861, 21 ]
python
en
['en', 'error', 'th']
False
Options.total_unique_constraints
(self)
Return a list of total unique constraints. Useful for determining set of fields guaranteed to be unique for all rows.
Return a list of total unique constraints. Useful for determining set of fields guaranteed to be unique for all rows.
def total_unique_constraints(self): """ Return a list of total unique constraints. Useful for determining set of fields guaranteed to be unique for all rows. """ return [ constraint for constraint in self.constraints if isinstance(constraint, U...
[ "def", "total_unique_constraints", "(", "self", ")", ":", "return", "[", "constraint", "for", "constraint", "in", "self", ".", "constraints", "if", "isinstance", "(", "constraint", ",", "UniqueConstraint", ")", "and", "constraint", ".", "condition", "is", "None"...
[ 864, 4 ]
[ 873, 9 ]
python
en
['en', 'error', 'th']
False
Options._property_names
(self)
Return a set of the names of the properties defined on the model.
Return a set of the names of the properties defined on the model.
def _property_names(self): """Return a set of the names of the properties defined on the model.""" names = [] for name in dir(self.model): attr = inspect.getattr_static(self.model, name) if isinstance(attr, property): names.append(name) return froz...
[ "def", "_property_names", "(", "self", ")", ":", "names", "=", "[", "]", "for", "name", "in", "dir", "(", "self", ".", "model", ")", ":", "attr", "=", "inspect", ".", "getattr_static", "(", "self", ".", "model", ",", "name", ")", "if", "isinstance", ...
[ 876, 4 ]
[ 883, 31 ]
python
en
['en', 'en', 'en']
True
Options.db_returning_fields
(self)
Private API intended only to be used by Django itself. Fields to be returned after a database insert.
Private API intended only to be used by Django itself. Fields to be returned after a database insert.
def db_returning_fields(self): """ Private API intended only to be used by Django itself. Fields to be returned after a database insert. """ return [ field for field in self._get_fields(forward=True, reverse=False, include_parents=PROXY_PARENTS) if getattr...
[ "def", "db_returning_fields", "(", "self", ")", ":", "return", "[", "field", "for", "field", "in", "self", ".", "_get_fields", "(", "forward", "=", "True", ",", "reverse", "=", "False", ",", "include_parents", "=", "PROXY_PARENTS", ")", "if", "getattr", "(...
[ 886, 4 ]
[ 894, 9 ]
python
en
['en', 'error', 'th']
False
_get_project_id
()
Get project ID from default GCP connection.
Get project ID from default GCP connection.
def _get_project_id(): """Get project ID from default GCP connection.""" extras = BaseHook.get_connection("google_cloud_default").extra_dejson key = "extra__google_cloud_platform__project" if key in extras: project_id = extras[key] else: raise ("Must configure project_id in google_cloud_default " ...
[ "def", "_get_project_id", "(", ")", ":", "extras", "=", "BaseHook", ".", "get_connection", "(", "\"google_cloud_default\"", ")", ".", "extra_dejson", "key", "=", "\"extra__google_cloud_platform__project\"", "if", "key", "in", "extras", ":", "project_id", "=", "extra...
[ 32, 0 ]
[ 42, 19 ]
python
en
['en', 'en', 'en']
True
run
(argv=None)
Build and run the pipeline.
Build and run the pipeline.
def run(argv=None): """Build and run the pipeline.""" parser = argparse.ArgumentParser() parser.add_argument( '--project', help=('Google Cloud Project ID'), required=True) parser.add_argument( '--input_topic', help=('Google Cloud PubSub topic name '), required=True) k...
[ "def", "run", "(", "argv", "=", "None", ")", ":", "parser", "=", "argparse", ".", "ArgumentParser", "(", ")", "parser", ".", "add_argument", "(", "'--project'", ",", "help", "=", "(", "'Google Cloud Project ID'", ")", ",", "required", "=", "True", ")", "...
[ 32, 0 ]
[ 71, 18 ]
python
en
['en', 'en', 'en']
True
arg_byref
(args, offset=-1)
Return the pointer argument's by-reference value.
Return the pointer argument's by-reference value.
def arg_byref(args, offset=-1): "Return the pointer argument's by-reference value." return args[offset]._obj.value
[ "def", "arg_byref", "(", "args", ",", "offset", "=", "-", "1", ")", ":", "return", "args", "[", "offset", "]", ".", "_obj", ".", "value" ]
[ 14, 0 ]
[ 16, 34 ]
python
en
['en', 'en', 'en']
True
ptr_byref
(args, offset=-1)
Return the pointer argument passed in by-reference.
Return the pointer argument passed in by-reference.
def ptr_byref(args, offset=-1): "Return the pointer argument passed in by-reference." return args[offset]._obj
[ "def", "ptr_byref", "(", "args", ",", "offset", "=", "-", "1", ")", ":", "return", "args", "[", "offset", "]", ".", "_obj" ]
[ 19, 0 ]
[ 21, 28 ]
python
en
['en', 'en', 'en']
True
check_const_string
(result, func, cargs, offset=None, cpl=False)
Similar functionality to `check_string`, but does not free the pointer.
Similar functionality to `check_string`, but does not free the pointer.
def check_const_string(result, func, cargs, offset=None, cpl=False): """ Similar functionality to `check_string`, but does not free the pointer. """ if offset: check_err(result, cpl=cpl) ptr = ptr_byref(cargs, offset) return ptr.value else: return result
[ "def", "check_const_string", "(", "result", ",", "func", ",", "cargs", ",", "offset", "=", "None", ",", "cpl", "=", "False", ")", ":", "if", "offset", ":", "check_err", "(", "result", ",", "cpl", "=", "cpl", ")", "ptr", "=", "ptr_byref", "(", "cargs"...
[ 25, 0 ]
[ 34, 21 ]
python
en
['en', 'error', 'th']
False
check_string
(result, func, cargs, offset=-1, str_result=False)
Check the string output returned from the given function, and free the string pointer allocated by OGR. The `str_result` keyword may be used when the result is the string pointer, otherwise the OGR error code is assumed. The `offset` keyword may be used to extract the string pointer passed in by-...
Check the string output returned from the given function, and free the string pointer allocated by OGR. The `str_result` keyword may be used when the result is the string pointer, otherwise the OGR error code is assumed. The `offset` keyword may be used to extract the string pointer passed in by-...
def check_string(result, func, cargs, offset=-1, str_result=False): """ Check the string output returned from the given function, and free the string pointer allocated by OGR. The `str_result` keyword may be used when the result is the string pointer, otherwise the OGR error code is assumed. The `...
[ "def", "check_string", "(", "result", ",", "func", ",", "cargs", ",", "offset", "=", "-", "1", ",", "str_result", "=", "False", ")", ":", "if", "str_result", ":", "# For routines that return a string.", "ptr", "=", "result", "if", "not", "ptr", ":", "s", ...
[ 37, 0 ]
[ 63, 12 ]
python
en
['en', 'error', 'th']
False
check_envelope
(result, func, cargs, offset=-1)
Check a function that returns an OGR Envelope by reference.
Check a function that returns an OGR Envelope by reference.
def check_envelope(result, func, cargs, offset=-1): "Check a function that returns an OGR Envelope by reference." return ptr_byref(cargs, offset)
[ "def", "check_envelope", "(", "result", ",", "func", ",", "cargs", ",", "offset", "=", "-", "1", ")", ":", "return", "ptr_byref", "(", "cargs", ",", "offset", ")" ]
[ 69, 0 ]
[ 71, 35 ]
python
en
['en', 'en', 'en']
True
check_geom
(result, func, cargs)
Check a function that returns a geometry.
Check a function that returns a geometry.
def check_geom(result, func, cargs): "Check a function that returns a geometry." # OGR_G_Clone may return an integer, even though the # restype is set to c_void_p if isinstance(result, int): result = c_void_p(result) if not result: raise GDALException('Invalid geometry pointer return...
[ "def", "check_geom", "(", "result", ",", "func", ",", "cargs", ")", ":", "# OGR_G_Clone may return an integer, even though the", "# restype is set to c_void_p", "if", "isinstance", "(", "result", ",", "int", ")", ":", "result", "=", "c_void_p", "(", "result", ")", ...
[ 75, 0 ]
[ 83, 17 ]
python
en
['en', 'en', 'en']
True
check_geom_offset
(result, func, cargs, offset=-1)
Check the geometry at the given offset in the C parameter list.
Check the geometry at the given offset in the C parameter list.
def check_geom_offset(result, func, cargs, offset=-1): "Check the geometry at the given offset in the C parameter list." check_err(result) geom = ptr_byref(cargs, offset=offset) return check_geom(geom, func, cargs)
[ "def", "check_geom_offset", "(", "result", ",", "func", ",", "cargs", ",", "offset", "=", "-", "1", ")", ":", "check_err", "(", "result", ")", "geom", "=", "ptr_byref", "(", "cargs", ",", "offset", "=", "offset", ")", "return", "check_geom", "(", "geom...
[ 86, 0 ]
[ 90, 40 ]
python
en
['en', 'en', 'en']
True
check_arg_errcode
(result, func, cargs, cpl=False)
The error code is returned in the last argument, by reference. Check its value with `check_err` before returning the result.
The error code is returned in the last argument, by reference. Check its value with `check_err` before returning the result.
def check_arg_errcode(result, func, cargs, cpl=False): """ The error code is returned in the last argument, by reference. Check its value with `check_err` before returning the result. """ check_err(arg_byref(cargs), cpl=cpl) return result
[ "def", "check_arg_errcode", "(", "result", ",", "func", ",", "cargs", ",", "cpl", "=", "False", ")", ":", "check_err", "(", "arg_byref", "(", "cargs", ")", ",", "cpl", "=", "cpl", ")", "return", "result" ]
[ 103, 0 ]
[ 109, 17 ]
python
en
['en', 'error', 'th']
False
check_errcode
(result, func, cargs, cpl=False)
Check the error code returned (c_int).
Check the error code returned (c_int).
def check_errcode(result, func, cargs, cpl=False): """ Check the error code returned (c_int). """ check_err(result, cpl=cpl)
[ "def", "check_errcode", "(", "result", ",", "func", ",", "cargs", ",", "cpl", "=", "False", ")", ":", "check_err", "(", "result", ",", "cpl", "=", "cpl", ")" ]
[ 112, 0 ]
[ 116, 30 ]
python
en
['en', 'error', 'th']
False
check_pointer
(result, func, cargs)
Make sure the result pointer is valid.
Make sure the result pointer is valid.
def check_pointer(result, func, cargs): "Make sure the result pointer is valid." if isinstance(result, int): result = c_void_p(result) if result: return result else: raise GDALException('Invalid pointer returned from "%s"' % func.__name__)
[ "def", "check_pointer", "(", "result", ",", "func", ",", "cargs", ")", ":", "if", "isinstance", "(", "result", ",", "int", ")", ":", "result", "=", "c_void_p", "(", "result", ")", "if", "result", ":", "return", "result", "else", ":", "raise", "GDALExce...
[ 119, 0 ]
[ 126, 81 ]
python
en
['en', 'en', 'en']
True
check_str_arg
(result, func, cargs)
This is for the OSRGet[Angular|Linear]Units functions, which require that the returned string pointer not be freed. This returns both the double and string values.
This is for the OSRGet[Angular|Linear]Units functions, which require that the returned string pointer not be freed. This returns both the double and string values.
def check_str_arg(result, func, cargs): """ This is for the OSRGet[Angular|Linear]Units functions, which require that the returned string pointer not be freed. This returns both the double and string values. """ dbl = result ptr = cargs[-1]._obj return dbl, ptr.value.decode()
[ "def", "check_str_arg", "(", "result", ",", "func", ",", "cargs", ")", ":", "dbl", "=", "result", "ptr", "=", "cargs", "[", "-", "1", "]", ".", "_obj", "return", "dbl", ",", "ptr", ".", "value", ".", "decode", "(", ")" ]
[ 129, 0 ]
[ 137, 34 ]
python
en
['en', 'error', 'th']
False
autoescape
(parser, token)
Force autoescape behavior for this block.
Force autoescape behavior for this block.
def autoescape(parser, token): """ Force autoescape behavior for this block. """ # token.split_contents() isn't useful here because this tag doesn't accept variable as arguments args = token.contents.split() if len(args) != 2: raise TemplateSyntaxError("'autoescape' tag requires exactly ...
[ "def", "autoescape", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "args", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "args", ")", "!=", "2", "...
[ 519, 0 ]
[ 532, 57 ]
python
en
['en', 'error', 'th']
False
comment
(parser, token)
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``.
Ignore everything between ``{% comment %}`` and ``{% endcomment %}``.
def comment(parser, token): """ Ignore everything between ``{% comment %}`` and ``{% endcomment %}``. """ parser.skip_past('endcomment') return CommentNode()
[ "def", "comment", "(", "parser", ",", "token", ")", ":", "parser", ".", "skip_past", "(", "'endcomment'", ")", "return", "CommentNode", "(", ")" ]
[ 536, 0 ]
[ 541, 24 ]
python
en
['en', 'error', 'th']
False
cycle
(parser, token)
Cycle among the given strings each time this tag is encountered. Within a loop, cycles among the given strings each time through the loop:: {% for o in some_list %} <tr class="{% cycle 'row1' 'row2' %}"> ... </tr> {% endfor %} Outside of a loop...
Cycle among the given strings each time this tag is encountered.
def cycle(parser, token): """ Cycle among the given strings each time this tag is encountered. Within a loop, cycles among the given strings each time through the loop:: {% for o in some_list %} <tr class="{% cycle 'row1' 'row2' %}"> ... </tr> {%...
[ "def", "cycle", "(", "parser", ",", "token", ")", ":", "# Note: This returns the exact same node on each {% cycle name %} call;", "# that is, the node object returned from {% cycle a b c as name %} and the", "# one returned from {% cycle name %} are the exact same object. This", "# shouldn't c...
[ 545, 0 ]
[ 629, 15 ]
python
en
['en', 'error', 'th']
False
debug
(parser, token)
Output a whole load of debugging information, including the current context and imported modules. Sample usage:: <pre> {% debug %} </pre>
Output a whole load of debugging information, including the current context and imported modules.
def debug(parser, token): """ Output a whole load of debugging information, including the current context and imported modules. Sample usage:: <pre> {% debug %} </pre> """ return DebugNode()
[ "def", "debug", "(", "parser", ",", "token", ")", ":", "return", "DebugNode", "(", ")" ]
[ 638, 0 ]
[ 649, 22 ]
python
en
['en', 'error', 'th']
False
do_filter
(parser, token)
Filter the contents of the block through variable filters. Filters can also be piped through each other, and they can have arguments -- just like in variable syntax. Sample usage:: {% filter force_escape|lower %} This text will be HTML-escaped, and will appear in lowercase. ...
Filter the contents of the block through variable filters.
def do_filter(parser, token): """ Filter the contents of the block through variable filters. Filters can also be piped through each other, and they can have arguments -- just like in variable syntax. Sample usage:: {% filter force_escape|lower %} This text will be HTML-escaped...
[ "def", "do_filter", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "_", ",", "rest", "=", "token", ".", "contents", ".", "split", "(", "None", ",", "1", ")", "filter_expr", "="...
[ 653, 0 ]
[ 679, 44 ]
python
en
['en', 'error', 'th']
False
firstof
(parser, token)
Output the first variable passed that is not False. Output nothing if all the passed variables are False. Sample usage:: {% firstof var1 var2 var3 as myvar %} This is equivalent to:: {% if var1 %} {{ var1 }} {% elif var2 %} {{ var2 }} {% elif...
Output the first variable passed that is not False.
def firstof(parser, token): """ Output the first variable passed that is not False. Output nothing if all the passed variables are False. Sample usage:: {% firstof var1 var2 var3 as myvar %} This is equivalent to:: {% if var1 %} {{ var1 }} {% elif var2 %} ...
[ "def", "firstof", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "[", "1", ":", "]", "asvar", "=", "None", "if", "not", "bits", ":", "raise", "TemplateSyntaxError", "(", "\"'firstof' statement requires at least ...
[ 683, 0 ]
[ 728, 75 ]
python
en
['en', 'error', 'th']
False
do_for
(parser, token)
Loop over each item in an array. For example, to display a list of athletes given ``athlete_list``:: <ul> {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} </ul> You can loop over a list in reverse by using ``{% for obj in list rev...
Loop over each item in an array.
def do_for(parser, token): """ Loop over each item in an array. For example, to display a list of athletes given ``athlete_list``:: <ul> {% for athlete in athlete_list %} <li>{{ athlete.name }}</li> {% endfor %} </ul> You can loop over a list in reverse by ...
[ "def", "do_for", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "<", "4", ":", "raise", "TemplateSyntaxError", "(", "\"'for' statements should have at least four\"", "\" words: %s\"", ...
[ 732, 0 ]
[ 820, 82 ]
python
en
['en', 'error', 'th']
False
ifequal
(parser, token)
Output the contents of the block if the two arguments equal each other. Examples:: {% ifequal user.id comment.user_id %} ... {% endifequal %} {% ifnotequal user.id comment.user_id %} ... {% else %} ... {% endifnotequal %}
Output the contents of the block if the two arguments equal each other.
def ifequal(parser, token): """ Output the contents of the block if the two arguments equal each other. Examples:: {% ifequal user.id comment.user_id %} ... {% endifequal %} {% ifnotequal user.id comment.user_id %} ... {% else %} ... ...
[ "def", "ifequal", "(", "parser", ",", "token", ")", ":", "warnings", ".", "warn", "(", "'The {% ifequal %} template tag is deprecated in favor of {% if %}.'", ",", "RemovedInDjango40Warning", ",", ")", "return", "do_ifequal", "(", "parser", ",", "token", ",", "False",...
[ 842, 0 ]
[ 862, 43 ]
python
en
['en', 'error', 'th']
False
ifnotequal
(parser, token)
Output the contents of the block if the two arguments are not equal. See ifequal.
Output the contents of the block if the two arguments are not equal. See ifequal.
def ifnotequal(parser, token): """ Output the contents of the block if the two arguments are not equal. See ifequal. """ warnings.warn( 'The {% ifnotequal %} template tag is deprecated in favor of ' '{% if %}.', RemovedInDjango40Warning, ) return do_ifequal(parser, to...
[ "def", "ifnotequal", "(", "parser", ",", "token", ")", ":", "warnings", ".", "warn", "(", "'The {% ifnotequal %} template tag is deprecated in favor of '", "'{% if %}.'", ",", "RemovedInDjango40Warning", ",", ")", "return", "do_ifequal", "(", "parser", ",", "token", "...
[ 866, 0 ]
[ 876, 42 ]
python
en
['en', 'error', 'th']
False
do_if
(parser, token)
Evaluate a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), output the contents of the block: :: {% if athlete_list %} Number of athletes: {{ athlete_list|count }} {% elif athlete_in_locker_room_list %} Athlet...
Evaluate a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), output the contents of the block:
def do_if(parser, token): """ Evaluate a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), output the contents of the block: :: {% if athlete_list %} Number of athletes: {{ athlete_list|count }} {% elif athlete_in_locke...
[ "def", "do_if", "(", "parser", ",", "token", ")", ":", "# {% if ... %}", "bits", "=", "token", ".", "split_contents", "(", ")", "[", "1", ":", "]", "condition", "=", "TemplateIfParser", "(", "parser", ",", "bits", ")", ".", "parse", "(", ")", "nodelist...
[ 903, 0 ]
[ 986, 39 ]
python
en
['en', 'error', 'th']
False
ifchanged
(parser, token)
Check if a value has changed from the last iteration of a loop. The ``{% ifchanged %}`` block tag is used within a loop. It has two possible uses. 1. Check its own rendered contents against its previous state and only displays the content if it has changed. For example, this displays a ...
Check if a value has changed from the last iteration of a loop.
def ifchanged(parser, token): """ Check if a value has changed from the last iteration of a loop. The ``{% ifchanged %}`` block tag is used within a loop. It has two possible uses. 1. Check its own rendered contents against its previous state and only displays the content if it has changed....
[ "def", "ifchanged", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "nodelist_true", "=", "parser", ".", "parse", "(", "(", "'else'", ",", "'endifchanged'", ")", ")", "token", "=", "parser", ".", "next_token"...
[ 990, 0 ]
[ 1028, 64 ]
python
en
['en', 'error', 'th']
False
load_from_library
(library, label, names)
Return a subset of tags and filters from a library.
Return a subset of tags and filters from a library.
def load_from_library(library, label, names): """ Return a subset of tags and filters from a library. """ subset = Library() for name in names: found = False if name in library.tags: found = True subset.tags[name] = library.tags[name] if name in librar...
[ "def", "load_from_library", "(", "library", ",", "label", ",", "names", ")", ":", "subset", "=", "Library", "(", ")", "for", "name", "in", "names", ":", "found", "=", "False", "if", "name", "in", "library", ".", "tags", ":", "found", "=", "True", "su...
[ 1042, 0 ]
[ 1061, 17 ]
python
en
['en', 'error', 'th']
False
load
(parser, token)
Load a custom template tag library into the parser. For example, to load the template tags in ``django/templatetags/news/photos.py``:: {% load news.photos %} Can also be used to load an individual tag/filter from a library:: {% load byline from news %}
Load a custom template tag library into the parser.
def load(parser, token): """ Load a custom template tag library into the parser. For example, to load the template tags in ``django/templatetags/news/photos.py``:: {% load news.photos %} Can also be used to load an individual tag/filter from a library:: {% load byline from ne...
[ "def", "load", "(", "parser", ",", "token", ")", ":", "# token.split_contents() isn't useful here because this tag doesn't accept variable as arguments", "bits", "=", "token", ".", "contents", ".", "split", "(", ")", "if", "len", "(", "bits", ")", ">=", "4", "and", ...
[ 1065, 0 ]
[ 1092, 21 ]
python
en
['en', 'error', 'th']
False
lorem
(parser, token)
Create random Latin text useful for providing test data in templates. Usage format:: {% lorem [count] [method] [random] %} ``count`` is a number (or variable) containing the number of paragraphs or words to generate (default is 1). ``method`` is either ``w`` for words, ``p`` for HTML pa...
Create random Latin text useful for providing test data in templates.
def lorem(parser, token): """ Create random Latin text useful for providing test data in templates. Usage format:: {% lorem [count] [method] [random] %} ``count`` is a number (or variable) containing the number of paragraphs or words to generate (default is 1). ``method`` is either `...
[ "def", "lorem", "(", "parser", ",", "token", ")", ":", "bits", "=", "list", "(", "token", ".", "split_contents", "(", ")", ")", "tagname", "=", "bits", "[", "0", "]", "# Random bit", "common", "=", "bits", "[", "-", "1", "]", "!=", "'random'", "if"...
[ 1096, 0 ]
[ 1139, 43 ]
python
en
['en', 'error', 'th']
False