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
GeoQuerySet.num_geom
(self, **kwargs)
Returns the number of geometries if the field is a GeometryCollection or Multi* Field in a `num_geom` attribute on each element of this GeoQuerySet; otherwise the sets with None.
Returns the number of geometries if the field is a GeometryCollection or Multi* Field in a `num_geom` attribute on each element of this GeoQuerySet; otherwise the sets with None.
def num_geom(self, **kwargs): """ Returns the number of geometries if the field is a GeometryCollection or Multi* Field in a `num_geom` attribute on each element of this GeoQuerySet; otherwise the sets with None. """ return self._spatial_attribute('num_geom', {}, ...
[ "def", "num_geom", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_spatial_attribute", "(", "'num_geom'", ",", "{", "}", ",", "*", "*", "kwargs", ")" ]
[ 195, 4 ]
[ 202, 64 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.num_points
(self, **kwargs)
Returns the number of points in the first linestring in the Geometry field in a `num_points` attribute on each element of this GeoQuerySet; otherwise sets with None.
Returns the number of points in the first linestring in the Geometry field in a `num_points` attribute on each element of this GeoQuerySet; otherwise sets with None.
def num_points(self, **kwargs): """ Returns the number of points in the first linestring in the Geometry field in a `num_points` attribute on each element of this GeoQuerySet; otherwise sets with None. """ return self._spatial_attribute('num_points', {}, **kwargs)
[ "def", "num_points", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_spatial_attribute", "(", "'num_points'", ",", "{", "}", ",", "*", "*", "kwargs", ")" ]
[ 204, 4 ]
[ 210, 66 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.perimeter
(self, **kwargs)
Returns the perimeter of the geometry field as a `Distance` object stored in a `perimeter` attribute on each element of this GeoQuerySet.
Returns the perimeter of the geometry field as a `Distance` object stored in a `perimeter` attribute on each element of this GeoQuerySet.
def perimeter(self, **kwargs): """ Returns the perimeter of the geometry field as a `Distance` object stored in a `perimeter` attribute on each element of this GeoQuerySet. """ return self._distance_attribute('perimeter', None, **kwargs)
[ "def", "perimeter", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_distance_attribute", "(", "'perimeter'", ",", "None", ",", "*", "*", "kwargs", ")" ]
[ 212, 4 ]
[ 217, 68 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.point_on_surface
(self, **kwargs)
Returns a Point geometry guaranteed to lie on the surface of the Geometry field in a `point_on_surface` attribute on each element of this GeoQuerySet; otherwise sets with None.
Returns a Point geometry guaranteed to lie on the surface of the Geometry field in a `point_on_surface` attribute on each element of this GeoQuerySet; otherwise sets with None.
def point_on_surface(self, **kwargs): """ Returns a Point geometry guaranteed to lie on the surface of the Geometry field in a `point_on_surface` attribute on each element of this GeoQuerySet; otherwise sets with None. """ return self._geom_attribute('point_on_surface', *...
[ "def", "point_on_surface", "(", "self", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_geom_attribute", "(", "'point_on_surface'", ",", "*", "*", "kwargs", ")" ]
[ 219, 4 ]
[ 225, 65 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.reverse_geom
(self, **kwargs)
Reverses the coordinate order of the geometry, and attaches as a `reverse` attribute on each element of this GeoQuerySet.
Reverses the coordinate order of the geometry, and attaches as a `reverse` attribute on each element of this GeoQuerySet.
def reverse_geom(self, **kwargs): """ Reverses the coordinate order of the geometry, and attaches as a `reverse` attribute on each element of this GeoQuerySet. """ s = {'select_field': GeomField()} kwargs.setdefault('model_att', 'reverse_geom') if connections[self...
[ "def", "reverse_geom", "(", "self", ",", "*", "*", "kwargs", ")", ":", "s", "=", "{", "'select_field'", ":", "GeomField", "(", ")", "}", "kwargs", ".", "setdefault", "(", "'model_att'", ",", "'reverse_geom'", ")", "if", "connections", "[", "self", ".", ...
[ 227, 4 ]
[ 236, 62 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.scale
(self, x, y, z=0.0, **kwargs)
Scales the geometry to a new size by multiplying the ordinates with the given x,y,z scale factors.
Scales the geometry to a new size by multiplying the ordinates with the given x,y,z scale factors.
def scale(self, x, y, z=0.0, **kwargs): """ Scales the geometry to a new size by multiplying the ordinates with the given x,y,z scale factors. """ if connections[self.db].ops.spatialite: if z != 0.0: raise NotImplementedError('SpatiaLite does not suppo...
[ "def", "scale", "(", "self", ",", "x", ",", "y", ",", "z", "=", "0.0", ",", "*", "*", "kwargs", ")", ":", "if", "connections", "[", "self", ".", "db", "]", ".", "ops", ".", "spatialite", ":", "if", "z", "!=", "0.0", ":", "raise", "NotImplemente...
[ 238, 4 ]
[ 255, 60 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.snap_to_grid
(self, *args, **kwargs)
Snap all points of the input geometry to the grid. How the geometry is snapped to the grid depends on how many arguments were given: - 1 argument : A single size to snap both the X and Y grids to. - 2 arguments: X and Y sizes to snap the grid to. - 4 arguments: X,...
Snap all points of the input geometry to the grid. How the geometry is snapped to the grid depends on how many arguments were given: - 1 argument : A single size to snap both the X and Y grids to. - 2 arguments: X and Y sizes to snap the grid to. - 4 arguments: X,...
def snap_to_grid(self, *args, **kwargs): """ Snap all points of the input geometry to the grid. How the geometry is snapped to the grid depends on how many arguments were given: - 1 argument : A single size to snap both the X and Y grids to. - 2 arguments: X and Y si...
[ "def", "snap_to_grid", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "False", "in", "[", "isinstance", "(", "arg", ",", "(", "float", ",", ")", "+", "six", ".", "integer_types", ")", "for", "arg", "in", "args", "]", ":",...
[ 257, 4 ]
[ 291, 67 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.svg
(self, relative=False, precision=8, **kwargs)
Returns SVG representation of the geographic field in a `svg` attribute on each element of this GeoQuerySet. Keyword Arguments: `relative` => If set to True, this will evaluate the path in terms of relative moves (rather than absolute). `precision` =...
Returns SVG representation of the geographic field in a `svg` attribute on each element of this GeoQuerySet.
def svg(self, relative=False, precision=8, **kwargs): """ Returns SVG representation of the geographic field in a `svg` attribute on each element of this GeoQuerySet. Keyword Arguments: `relative` => If set to True, this will evaluate the path in terms ...
[ "def", "svg", "(", "self", ",", "relative", "=", "False", ",", "precision", "=", "8", ",", "*", "*", "kwargs", ")", ":", "relative", "=", "int", "(", "bool", "(", "relative", ")", ")", "if", "not", "isinstance", "(", "precision", ",", "six", ".", ...
[ 293, 4 ]
[ 316, 58 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.sym_difference
(self, geom, **kwargs)
Returns the symmetric difference of the geographic field in a `sym_difference` attribute on each element of this GeoQuerySet.
Returns the symmetric difference of the geographic field in a `sym_difference` attribute on each element of this GeoQuerySet.
def sym_difference(self, geom, **kwargs): """ Returns the symmetric difference of the geographic field in a `sym_difference` attribute on each element of this GeoQuerySet. """ return self._geomset_attribute('sym_difference', geom, **kwargs)
[ "def", "sym_difference", "(", "self", ",", "geom", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_geomset_attribute", "(", "'sym_difference'", ",", "geom", ",", "*", "*", "kwargs", ")" ]
[ 318, 4 ]
[ 323, 72 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.translate
(self, x, y, z=0.0, **kwargs)
Translates the geometry to a new location using the given numeric parameters as offsets.
Translates the geometry to a new location using the given numeric parameters as offsets.
def translate(self, x, y, z=0.0, **kwargs): """ Translates the geometry to a new location using the given numeric parameters as offsets. """ if connections[self.db].ops.spatialite: if z != 0.0: raise NotImplementedError('SpatiaLite does not support 3D ...
[ "def", "translate", "(", "self", ",", "x", ",", "y", ",", "z", "=", "0.0", ",", "*", "*", "kwargs", ")", ":", "if", "connections", "[", "self", ".", "db", "]", ".", "ops", ".", "spatialite", ":", "if", "z", "!=", "0.0", ":", "raise", "NotImplem...
[ 325, 4 ]
[ 342, 64 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.transform
(self, srid=4326, **kwargs)
Transforms the given geometry field to the given SRID. If no SRID is provided, the transformation will default to using 4326 (WGS84).
Transforms the given geometry field to the given SRID. If no SRID is provided, the transformation will default to using 4326 (WGS84).
def transform(self, srid=4326, **kwargs): """ Transforms the given geometry field to the given SRID. If no SRID is provided, the transformation will default to using 4326 (WGS84). """ if not isinstance(srid, six.integer_types): raise TypeError('An integer SRID must b...
[ "def", "transform", "(", "self", ",", "srid", "=", "4326", ",", "*", "*", "kwargs", ")", ":", "if", "not", "isinstance", "(", "srid", ",", "six", ".", "integer_types", ")", ":", "raise", "TypeError", "(", "'An integer SRID must be provided.'", ")", "field_...
[ 344, 4 ]
[ 354, 28 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet.union
(self, geom, **kwargs)
Returns the union of the geographic field with the given Geometry in a `union` attribute on each element of this GeoQuerySet.
Returns the union of the geographic field with the given Geometry in a `union` attribute on each element of this GeoQuerySet.
def union(self, geom, **kwargs): """ Returns the union of the geographic field with the given Geometry in a `union` attribute on each element of this GeoQuerySet. """ return self._geomset_attribute('union', geom, **kwargs)
[ "def", "union", "(", "self", ",", "geom", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_geomset_attribute", "(", "'union'", ",", "geom", ",", "*", "*", "kwargs", ")" ]
[ 356, 4 ]
[ 361, 63 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._spatial_setup
(self, att, desc=None, field_name=None, geo_field_type=None)
Performs set up for executing the spatial function.
Performs set up for executing the spatial function.
def _spatial_setup(self, att, desc=None, field_name=None, geo_field_type=None): """ Performs set up for executing the spatial function. """ # Does the spatial backend support this? connection = connections[self.db] func = getattr(connection.ops, att, False) if des...
[ "def", "_spatial_setup", "(", "self", ",", "att", ",", "desc", "=", "None", ",", "field_name", "=", "None", ",", "geo_field_type", "=", "None", ")", ":", "# Does the spatial backend support this?", "connection", "=", "connections", "[", "self", ".", "db", "]",...
[ 364, 4 ]
[ 395, 40 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._spatial_attribute
(self, att, settings, field_name=None, model_att=None)
DRY routine for calling a spatial stored procedure on a geometry column and attaching its output as an attribute of the model. Arguments: att: The name of the spatial attribute that holds the spatial SQL function to call. settings: Dictionary of...
DRY routine for calling a spatial stored procedure on a geometry column and attaching its output as an attribute of the model.
def _spatial_attribute(self, att, settings, field_name=None, model_att=None): """ DRY routine for calling a spatial stored procedure on a geometry column and attaching its output as an attribute of the model. Arguments: att: The name of the spatial attribute that hold...
[ "def", "_spatial_attribute", "(", "self", ",", "att", ",", "settings", ",", "field_name", "=", "None", ",", "model_att", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"The %s GeoQuerySet method is deprecated. See GeoDjango Functions \"", "\"documentation to fin...
[ 397, 4 ]
[ 482, 19 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._distance_attribute
(self, func, geom=None, tolerance=0.05, spheroid=False, **kwargs)
DRY routine for GeoQuerySet distance attribute routines.
DRY routine for GeoQuerySet distance attribute routines.
def _distance_attribute(self, func, geom=None, tolerance=0.05, spheroid=False, **kwargs): """ DRY routine for GeoQuerySet distance attribute routines. """ # Setting up the distance procedure arguments. procedure_args, geo_field = self._spatial_setup(func, field_name=kwargs.get('f...
[ "def", "_distance_attribute", "(", "self", ",", "func", ",", "geom", "=", "None", ",", "tolerance", "=", "0.05", ",", "spheroid", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# Setting up the distance procedure arguments.", "procedure_args", ",", "geo_field...
[ 484, 4 ]
[ 635, 57 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._geom_attribute
(self, func, tolerance=0.05, **kwargs)
DRY routine for setting up a GeoQuerySet method that attaches a Geometry attribute (e.g., `centroid`, `point_on_surface`).
DRY routine for setting up a GeoQuerySet method that attaches a Geometry attribute (e.g., `centroid`, `point_on_surface`).
def _geom_attribute(self, func, tolerance=0.05, **kwargs): """ DRY routine for setting up a GeoQuerySet method that attaches a Geometry attribute (e.g., `centroid`, `point_on_surface`). """ s = {'select_field': GeomField()} if connections[self.db].ops.oracle: ...
[ "def", "_geom_attribute", "(", "self", ",", "func", ",", "tolerance", "=", "0.05", ",", "*", "*", "kwargs", ")", ":", "s", "=", "{", "'select_field'", ":", "GeomField", "(", ")", "}", "if", "connections", "[", "self", ".", "db", "]", ".", "ops", "....
[ 637, 4 ]
[ 646, 57 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._geomset_attribute
(self, func, geom, tolerance=0.05, **kwargs)
DRY routine for setting up a GeoQuerySet method that attaches a Geometry attribute and takes a Geoemtry parameter. This is used for geometry set-like operations (e.g., intersection, difference, union, sym_difference).
DRY routine for setting up a GeoQuerySet method that attaches a Geometry attribute and takes a Geoemtry parameter. This is used for geometry set-like operations (e.g., intersection, difference, union, sym_difference).
def _geomset_attribute(self, func, geom, tolerance=0.05, **kwargs): """ DRY routine for setting up a GeoQuerySet method that attaches a Geometry attribute and takes a Geoemtry parameter. This is used for geometry set-like operations (e.g., intersection, difference, union, sym_di...
[ "def", "_geomset_attribute", "(", "self", ",", "func", ",", "geom", ",", "tolerance", "=", "0.05", ",", "*", "*", "kwargs", ")", ":", "s", "=", "{", "'geom_args'", ":", "(", "'geom'", ",", ")", ",", "'select_field'", ":", "GeomField", "(", ")", ",", ...
[ 648, 4 ]
[ 664, 57 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._geocol_select
(self, geo_field, field_name)
Helper routine for constructing the SQL to select the geographic column. Takes into account if the geographic field is in a ForeignKey relation to the current model.
Helper routine for constructing the SQL to select the geographic column. Takes into account if the geographic field is in a ForeignKey relation to the current model.
def _geocol_select(self, geo_field, field_name): """ Helper routine for constructing the SQL to select the geographic column. Takes into account if the geographic field is in a ForeignKey relation to the current model. """ compiler = self.query.get_compiler(self.db) ...
[ "def", "_geocol_select", "(", "self", ",", "geo_field", ",", "field_name", ")", ":", "compiler", "=", "self", ".", "query", ".", "get_compiler", "(", "self", ".", "db", ")", "opts", "=", "self", ".", "model", ".", "_meta", "if", "geo_field", "not", "in...
[ 666, 4 ]
[ 693, 58 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._geo_field
(self, field_name=None)
Returns the first Geometry field encountered or the one specified via the `field_name` keyword. The `field_name` may be a string specifying the geometry field on this GeoQuerySet's model, or a lookup string to a geometry field via a ForeignKey relation.
Returns the first Geometry field encountered or the one specified via the `field_name` keyword. The `field_name` may be a string specifying the geometry field on this GeoQuerySet's model, or a lookup string to a geometry field via a ForeignKey relation.
def _geo_field(self, field_name=None): """ Returns the first Geometry field encountered or the one specified via the `field_name` keyword. The `field_name` may be a string specifying the geometry field on this GeoQuerySet's model, or a lookup string to a geometry field via a Fore...
[ "def", "_geo_field", "(", "self", ",", "field_name", "=", "None", ")", ":", "if", "field_name", "is", "None", ":", "# Incrementing until the first geographic field is found.", "for", "field", "in", "self", ".", "model", ".", "_meta", ".", "fields", ":", "if", ...
[ 696, 4 ]
[ 712, 75 ]
python
en
['en', 'error', 'th']
False
GeoQuerySet._field_column
(self, compiler, field, table_alias=None, column=None)
Helper function that returns the database column for the given field. The table and column are returned (quoted) in the proper format, e.g., `"geoapp_city"."point"`. If `table_alias` is not specified, the database table associated with the model of this `GeoQuerySet` will be us...
Helper function that returns the database column for the given field. The table and column are returned (quoted) in the proper format, e.g., `"geoapp_city"."point"`. If `table_alias` is not specified, the database table associated with the model of this `GeoQuerySet` will be us...
def _field_column(self, compiler, field, table_alias=None, column=None): """ Helper function that returns the database column for the given field. The table and column are returned (quoted) in the proper format, e.g., `"geoapp_city"."point"`. If `table_alias` is not specified, the ...
[ "def", "_field_column", "(", "self", ",", "compiler", ",", "field", ",", "table_alias", "=", "None", ",", "column", "=", "None", ")", ":", "if", "table_alias", "is", "None", ":", "table_alias", "=", "compiler", ".", "query", ".", "get_meta", "(", ")", ...
[ 714, 4 ]
[ 726, 85 ]
python
en
['en', 'error', 'th']
False
ascii_lower
(string)
r"""Transform (only) ASCII letters to lower case: A-Z is mapped to a-z. :param string: An Unicode string. :returns: A new Unicode string. This is used for `ASCII case-insensitive <http://encoding.spec.whatwg.org/#ascii-case-insensitive>`_ matching of encoding labels. The same matching is also ...
r"""Transform (only) ASCII letters to lower case: A-Z is mapped to a-z.
def ascii_lower(string): r"""Transform (only) ASCII letters to lower case: A-Z is mapped to a-z. :param string: An Unicode string. :returns: A new Unicode string. This is used for `ASCII case-insensitive <http://encoding.spec.whatwg.org/#ascii-case-insensitive>`_ matching of encoding labels. ...
[ "def", "ascii_lower", "(", "string", ")", ":", "# This turns out to be faster than unicode.translate()", "return", "string", ".", "encode", "(", "'utf8'", ")", ".", "lower", "(", ")", ".", "decode", "(", "'utf8'", ")" ]
[ 34, 0 ]
[ 57, 55 ]
python
en
['en', 'en', 'en']
True
lookup
(label)
Look for an encoding by its label. This is the spec’s `get an encoding <http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm. Supported labels are listed there. :param label: A string. :returns: An :class:`Encoding` object, or :obj:`None` for an unknown label.
Look for an encoding by its label. This is the spec’s `get an encoding <http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm. Supported labels are listed there.
def lookup(label): """ Look for an encoding by its label. This is the spec’s `get an encoding <http://encoding.spec.whatwg.org/#concept-encoding-get>`_ algorithm. Supported labels are listed there. :param label: A string. :returns: An :class:`Encoding` object, or :obj:`None` for an ...
[ "def", "lookup", "(", "label", ")", ":", "# Only strip ASCII whitespace: U+0009, U+000A, U+000C, U+000D, and U+0020.", "label", "=", "ascii_lower", "(", "label", ".", "strip", "(", "'\\t\\n\\f\\r '", ")", ")", "name", "=", "LABELS", ".", "get", "(", "label", ")", ...
[ 60, 0 ]
[ 87, 19 ]
python
en
['en', 'error', 'th']
False
_get_encoding
(encoding_or_label)
Accept either an encoding object or label. :param encoding: An :class:`Encoding` object or a label string. :returns: An :class:`Encoding` object. :raises: :exc:`~exceptions.LookupError` for an unknown label.
Accept either an encoding object or label.
def _get_encoding(encoding_or_label): """ Accept either an encoding object or label. :param encoding: An :class:`Encoding` object or a label string. :returns: An :class:`Encoding` object. :raises: :exc:`~exceptions.LookupError` for an unknown label. """ if hasattr(encoding_or_label, 'codec...
[ "def", "_get_encoding", "(", "encoding_or_label", ")", ":", "if", "hasattr", "(", "encoding_or_label", ",", "'codec_info'", ")", ":", "return", "encoding_or_label", "encoding", "=", "lookup", "(", "encoding_or_label", ")", "if", "encoding", "is", "None", ":", "r...
[ 90, 0 ]
[ 105, 19 ]
python
en
['en', 'error', 'th']
False
decode
(input, fallback_encoding, errors='replace')
Decode a single string. :param input: A byte string :param fallback_encoding: An :class:`Encoding` object or a label string. The encoding to use if :obj:`input` does note have a BOM. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.Look...
Decode a single string.
def decode(input, fallback_encoding, errors='replace'): """ Decode a single string. :param input: A byte string :param fallback_encoding: An :class:`Encoding` object or a label string. The encoding to use if :obj:`input` does note have a BOM. :param errors: Type of error handling. S...
[ "def", "decode", "(", "input", ",", "fallback_encoding", ",", "errors", "=", "'replace'", ")", ":", "# Fail early if `encoding` is an invalid label.", "fallback_encoding", "=", "_get_encoding", "(", "fallback_encoding", ")", "bom_encoding", ",", "input", "=", "_detect_b...
[ 138, 0 ]
[ 157, 65 ]
python
en
['en', 'error', 'th']
False
_detect_bom
(input)
Return (bom_encoding, input), with any BOM removed from the input.
Return (bom_encoding, input), with any BOM removed from the input.
def _detect_bom(input): """Return (bom_encoding, input), with any BOM removed from the input.""" if input.startswith(b'\xFF\xFE'): return _UTF16LE, input[2:] if input.startswith(b'\xFE\xFF'): return _UTF16BE, input[2:] if input.startswith(b'\xEF\xBB\xBF'): return UTF8, input[3:] ...
[ "def", "_detect_bom", "(", "input", ")", ":", "if", "input", ".", "startswith", "(", "b'\\xFF\\xFE'", ")", ":", "return", "_UTF16LE", ",", "input", "[", "2", ":", "]", "if", "input", ".", "startswith", "(", "b'\\xFE\\xFF'", ")", ":", "return", "_UTF16BE"...
[ 160, 0 ]
[ 168, 22 ]
python
en
['en', 'en', 'en']
True
encode
(input, encoding=UTF8, errors='strict')
Encode a single string. :param input: An Unicode string. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. :return: A byte string.
Encode a single string.
def encode(input, encoding=UTF8, errors='strict'): """ Encode a single string. :param input: An Unicode string. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unkn...
[ "def", "encode", "(", "input", ",", "encoding", "=", "UTF8", ",", "errors", "=", "'strict'", ")", ":", "return", "_get_encoding", "(", "encoding", ")", ".", "codec_info", ".", "encode", "(", "input", ",", "errors", ")", "[", "0", "]" ]
[ 171, 0 ]
[ 182, 70 ]
python
en
['en', 'error', 'th']
False
iter_decode
(input, fallback_encoding, errors='replace')
"Pull"-based decoder. :param input: An iterable of byte strings. The input is first consumed just enough to determine the encoding based on the precense of a BOM, then consumed on demand when the return value is. :param fallback_encoding: An :class:`Encoding` objec...
"Pull"-based decoder.
def iter_decode(input, fallback_encoding, errors='replace'): """ "Pull"-based decoder. :param input: An iterable of byte strings. The input is first consumed just enough to determine the encoding based on the precense of a BOM, then consumed on demand when the return value ...
[ "def", "iter_decode", "(", "input", ",", "fallback_encoding", ",", "errors", "=", "'replace'", ")", ":", "decoder", "=", "IncrementalDecoder", "(", "fallback_encoding", ",", "errors", ")", "generator", "=", "_iter_decode_generator", "(", "input", ",", "decoder", ...
[ 185, 0 ]
[ 210, 30 ]
python
en
['en', 'error', 'th']
False
_iter_decode_generator
(input, decoder)
Return a generator that first yields the :obj:`Encoding`, then yields output chukns as Unicode strings.
Return a generator that first yields the :obj:`Encoding`, then yields output chukns as Unicode strings.
def _iter_decode_generator(input, decoder): """Return a generator that first yields the :obj:`Encoding`, then yields output chukns as Unicode strings. """ decode = decoder.decode input = iter(input) for chunck in input: output = decode(chunck) if output: assert decod...
[ "def", "_iter_decode_generator", "(", "input", ",", "decoder", ")", ":", "decode", "=", "decoder", ".", "decode", "input", "=", "iter", "(", "input", ")", "for", "chunck", "in", "input", ":", "output", "=", "decode", "(", "chunck", ")", "if", "output", ...
[ 213, 0 ]
[ 242, 20 ]
python
en
['en', 'en', 'en']
True
iter_encode
(input, encoding=UTF8, errors='strict')
“Pull”-based encoder. :param input: An iterable of Unicode strings. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupError` for an unknown encoding label. :returns: An iterable o...
“Pull”-based encoder.
def iter_encode(input, encoding=UTF8, errors='strict'): """ “Pull”-based encoder. :param input: An iterable of Unicode strings. :param encoding: An :class:`Encoding` object or a label string. :param errors: Type of error handling. See :func:`codecs.register`. :raises: :exc:`~exceptions.LookupEr...
[ "def", "iter_encode", "(", "input", ",", "encoding", "=", "UTF8", ",", "errors", "=", "'strict'", ")", ":", "# Fail early if `encoding` is an invalid label.", "encode", "=", "IncrementalEncoder", "(", "encoding", ",", "errors", ")", ".", "encode", "return", "_iter...
[ 245, 0 ]
[ 258, 48 ]
python
en
['en', 'error', 'th']
False
IncrementalDecoder.decode
(self, input, final=False)
Decode one chunk of the input. :param input: A byte string. :param final: Indicate that no more input is available. Must be :obj:`True` if this is the last call. :returns: An Unicode string.
Decode one chunk of the input.
def decode(self, input, final=False): """Decode one chunk of the input. :param input: A byte string. :param final: Indicate that no more input is available. Must be :obj:`True` if this is the last call. :returns: An Unicode string. """ decoder = ...
[ "def", "decode", "(", "self", ",", "input", ",", "final", "=", "False", ")", ":", "decoder", "=", "self", ".", "_decoder", "if", "decoder", "is", "not", "None", ":", "return", "decoder", "(", "input", ",", "final", ")", "input", "=", "self", ".", "...
[ 294, 4 ]
[ 319, 36 ]
python
en
['en', 'en', 'en']
True
reap
(instance=None, status='failed', excluded_uuids=[])
Reap all jobs in waiting|running for this instance.
Reap all jobs in waiting|running for this instance.
def reap(instance=None, status='failed', excluded_uuids=[]): """ Reap all jobs in waiting|running for this instance. """ me = instance if me is None: (changed, me) = Instance.objects.get_or_register() if changed: logger.info("Registered node '{}'".format(me.hostname)) ...
[ "def", "reap", "(", "instance", "=", "None", ",", "status", "=", "'failed'", ",", "excluded_uuids", "=", "[", "]", ")", ":", "me", "=", "instance", "if", "me", "is", "None", ":", "(", "changed", ",", "me", ")", "=", "Instance", ".", "objects", ".",...
[ 31, 0 ]
[ 48, 27 ]
python
en
['en', 'error', 'th']
False
Multimap.__init__
(self)
Make new multimap.
Make new multimap.
def __init__(self) -> None: """Make new multimap.""" # maybe defaultdict(set) is better self._map: OrderedDict[Optional[str], List[Any]] = OrderedDict()
[ "def", "__init__", "(", "self", ")", "->", "None", ":", "# maybe defaultdict(set) is better", "self", ".", "_map", ":", "OrderedDict", "[", "Optional", "[", "str", "]", ",", "List", "[", "Any", "]", "]", "=", "OrderedDict", "(", ")" ]
[ 12, 4 ]
[ 15, 72 ]
python
en
['en', 'sn', 'en']
True
Multimap.get
(self, key: Optional[str])
Get values.
Get values.
def get(self, key: Optional[str]) -> List[Any]: """Get values.""" return self._map.get(key, list())
[ "def", "get", "(", "self", ",", "key", ":", "Optional", "[", "str", "]", ")", "->", "List", "[", "Any", "]", ":", "return", "self", ".", "_map", ".", "get", "(", "key", ",", "list", "(", ")", ")" ]
[ 26, 4 ]
[ 28, 41 ]
python
ca
['nl', 'ca', 'en']
False
Multimap.has
(self, key: Optional[str])
Check key is in this map.
Check key is in this map.
def has(self, key: Optional[str]) -> bool: """Check key is in this map.""" return key in self._map
[ "def", "has", "(", "self", ",", "key", ":", "Optional", "[", "str", "]", ")", "->", "bool", ":", "return", "key", "in", "self", ".", "_map" ]
[ 30, 4 ]
[ 32, 31 ]
python
en
['en', 'en', 'en']
True
Multimap.hasValue
(self, key: Optional[str], value: Any)
Check value is in this map.
Check value is in this map.
def hasValue(self, key: Optional[str], value: Any) -> bool: """Check value is in this map.""" _set = self._map.get(key, list()) return value in _set
[ "def", "hasValue", "(", "self", ",", "key", ":", "Optional", "[", "str", "]", ",", "value", ":", "Any", ")", "->", "bool", ":", "_set", "=", "self", ".", "_map", ".", "get", "(", "key", ",", "list", "(", ")", ")", "return", "value", "in", "_set...
[ 34, 4 ]
[ 37, 28 ]
python
en
['en', 'en', 'en']
True
Multimap.size
(self)
Length of this map.
Length of this map.
def size(self) -> int: """Length of this map.""" return len(self._map)
[ "def", "size", "(", "self", ")", "->", "int", ":", "return", "len", "(", "self", ".", "_map", ")" ]
[ 39, 4 ]
[ 41, 29 ]
python
en
['en', 'en', 'en']
True
Multimap.delete
(self, key: Optional[str], value: Any)
Delete value from key.
Delete value from key.
def delete(self, key: Optional[str], value: Any) -> bool: """Delete value from key.""" values = self.get(key) result = value in values if result: values.remove(value) if len(values) == 0: self._map.pop(key) return result
[ "def", "delete", "(", "self", ",", "key", ":", "Optional", "[", "str", "]", ",", "value", ":", "Any", ")", "->", "bool", ":", "values", "=", "self", ".", "get", "(", "key", ")", "result", "=", "value", "in", "values", "if", "result", ":", "values...
[ 43, 4 ]
[ 51, 21 ]
python
en
['en', 'en', 'en']
True
Multimap.deleteAll
(self, key: Optional[str])
Delete all value of the key.
Delete all value of the key.
def deleteAll(self, key: Optional[str]) -> None: """Delete all value of the key.""" self._map.pop(key, None)
[ "def", "deleteAll", "(", "self", ",", "key", ":", "Optional", "[", "str", "]", ")", "->", "None", ":", "self", ".", "_map", ".", "pop", "(", "key", ",", "None", ")" ]
[ 53, 4 ]
[ 55, 32 ]
python
en
['en', 'en', 'en']
True
Multimap.firstValue
(self, key: Optional[str])
Get first value of the key.
Get first value of the key.
def firstValue(self, key: Optional[str]) -> Any: """Get first value of the key.""" _set = self._map.get(key) if not _set: return None return _set[0]
[ "def", "firstValue", "(", "self", ",", "key", ":", "Optional", "[", "str", "]", ")", "->", "Any", ":", "_set", "=", "self", ".", "_map", ".", "get", "(", "key", ")", "if", "not", "_set", ":", "return", "None", "return", "_set", "[", "0", "]" ]
[ 57, 4 ]
[ 62, 22 ]
python
en
['en', 'en', 'en']
True
Multimap.firstKey
(self)
Get first key.
Get first key.
def firstKey(self) -> Optional[str]: """Get first key.""" return next(iter(self._map.keys()))
[ "def", "firstKey", "(", "self", ")", "->", "Optional", "[", "str", "]", ":", "return", "next", "(", "iter", "(", "self", ".", "_map", ".", "keys", "(", ")", ")", ")" ]
[ 64, 4 ]
[ 66, 43 ]
python
da
['da', 'lb', 'en']
False
Multimap.valuesArray
(self)
Get all values as list.
Get all values as list.
def valuesArray(self) -> List[Any]: """Get all values as list.""" result: List[Any] = list() for values in self._map.values(): result.extend(values) return result
[ "def", "valuesArray", "(", "self", ")", "->", "List", "[", "Any", "]", ":", "result", ":", "List", "[", "Any", "]", "=", "list", "(", ")", "for", "values", "in", "self", ".", "_map", ".", "values", "(", ")", ":", "result", ".", "extend", "(", "...
[ 68, 4 ]
[ 73, 21 ]
python
en
['en', 'en', 'en']
True
Multimap.clear
(self)
Clear all entries of this map.
Clear all entries of this map.
def clear(self) -> None: """Clear all entries of this map.""" self._map.clear()
[ "def", "clear", "(", "self", ")", "->", "None", ":", "self", ".", "_map", ".", "clear", "(", ")" ]
[ 75, 4 ]
[ 77, 25 ]
python
en
['en', 'en', 'en']
True
CreateView.post
(self, request, *args, **kwargs)
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it's valid.
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it's valid.
def post(self, request, *args, **kwargs): """ Handle POST requests: instantiate a form instance with the passed POST variables and then check if it's valid. """ # Create an object now so that the permission panel forms have something to link them against self.object = Gro...
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "# Create an object now so that the permission panel forms have something to link them against", "self", ".", "object", "=", "Group", "(", ")", "form", "=", "self", "....
[ 74, 4 ]
[ 92, 42 ]
python
en
['en', 'error', 'th']
False
EditView.post
(self, request, *args, **kwargs)
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it's valid.
Handle POST requests: instantiate a form instance with the passed POST variables and then check if it's valid.
def post(self, request, *args, **kwargs): """ Handle POST requests: instantiate a form instance with the passed POST variables and then check if it's valid. """ self.object = self.get_object() form = self.get_form() permission_panels = self.get_permission_panel_f...
[ "def", "post", "(", "self", ",", "request", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "object", "=", "self", ".", "get_object", "(", ")", "form", "=", "self", ".", "get_form", "(", ")", "permission_panels", "=", "self", ".",...
[ 113, 4 ]
[ 130, 42 ]
python
en
['en', 'error', 'th']
False
suppressed_cache_errors
()
If we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled.
If we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled.
def suppressed_cache_errors(): # type: () -> Iterator[None] """If we can't access the cache then we can just skip caching and process requests as if caching wasn't enabled. """ try: yield except (OSError, IOError): pass
[ "def", "suppressed_cache_errors", "(", ")", ":", "# type: () -> Iterator[None]", "try", ":", "yield", "except", "(", "OSError", ",", "IOError", ")", ":", "pass" ]
[ 24, 0 ]
[ 32, 12 ]
python
en
['en', 'en', 'en']
True
get_model_root
(model)
This function finds the root model for any given model. The root model is the highest concrete model that it descends from. If the model doesn't descend from another concrete model then the model is it's own root model so it is returned. Examples: >>> get_model_root(wagtailcore.Page) wagta...
This function finds the root model for any given model. The root model is the highest concrete model that it descends from. If the model doesn't descend from another concrete model then the model is it's own root model so it is returned.
def get_model_root(model): """ This function finds the root model for any given model. The root model is the highest concrete model that it descends from. If the model doesn't descend from another concrete model then the model is it's own root model so it is returned. Examples: >>> get_mode...
[ "def", "get_model_root", "(", "model", ")", ":", "if", "model", ".", "_meta", ".", "parents", ":", "parent_model", "=", "list", "(", "model", ".", "_meta", ".", "parents", ".", "items", "(", ")", ")", "[", "0", "]", "[", "0", "]", "return", "get_mo...
[ 21, 0 ]
[ 42, 16 ]
python
en
['en', 'error', 'th']
False
Elasticsearch5Mapping.get_content_type
(self)
Returns the content type as a string for the model. For example: "wagtailcore.Page" "myapp.MyModel"
Returns the content type as a string for the model.
def get_content_type(self): """ Returns the content type as a string for the model. For example: "wagtailcore.Page" "myapp.MyModel" """ return self.model._meta.app_label + '.' + self.model.__name__
[ "def", "get_content_type", "(", "self", ")", ":", "return", "self", ".", "model", ".", "_meta", ".", "app_label", "+", "'.'", "+", "self", ".", "model", ".", "__name__" ]
[ 118, 4 ]
[ 125, 69 ]
python
en
['en', 'error', 'th']
False
Elasticsearch5Mapping.get_all_content_types
(self)
Returns all the content type strings that apply to this model. This includes the models' content type and all concrete ancestor models that inherit from Indexed. For example: ["myapp.MyPageModel", "wagtailcore.Page"] ["myapp.MyModel"]
Returns all the content type strings that apply to this model. This includes the models' content type and all concrete ancestor models that inherit from Indexed.
def get_all_content_types(self): """ Returns all the content type strings that apply to this model. This includes the models' content type and all concrete ancestor models that inherit from Indexed. For example: ["myapp.MyPageModel", "wagtailcore.Page"] ["my...
[ "def", "get_all_content_types", "(", "self", ")", ":", "# Add our content type", "content_types", "=", "[", "self", ".", "get_content_type", "(", ")", "]", "# Add all ancestor classes content types as well", "ancestor", "=", "self", ".", "get_parent", "(", ")", "while...
[ 127, 4 ]
[ 145, 28 ]
python
en
['en', 'error', 'th']
False
Elasticsearch5SearchResults._get_results_from_hits
(self, hits)
Yields Django model instances from a page of hits returned by Elasticsearch
Yields Django model instances from a page of hits returned by Elasticsearch
def _get_results_from_hits(self, hits): """ Yields Django model instances from a page of hits returned by Elasticsearch """ # Get pks from results pks = [hit['fields']['pk'][0] for hit in hits] scores = {str(hit['fields']['pk'][0]): hit['_score'] for hit in hits} ...
[ "def", "_get_results_from_hits", "(", "self", ",", "hits", ")", ":", "# Get pks from results", "pks", "=", "[", "hit", "[", "'fields'", "]", "[", "'pk'", "]", "[", "0", "]", "for", "hit", "in", "hits", "]", "scores", "=", "{", "str", "(", "hit", "[",...
[ 704, 4 ]
[ 726, 28 ]
python
en
['en', 'error', 'th']
False
Elasticsearch5Index.aliased_indices
(self)
If this index object represents an alias (which appear the same in the Elasticsearch API), this method can be used to fetch the list of indices the alias points to. Use the is_alias method if you need to find out if this an alias. This returns an empty list if called on an inde...
If this index object represents an alias (which appear the same in the Elasticsearch API), this method can be used to fetch the list of indices the alias points to.
def aliased_indices(self): """ If this index object represents an alias (which appear the same in the Elasticsearch API), this method can be used to fetch the list of indices the alias points to. Use the is_alias method if you need to find out if this an alias. This retu...
[ "def", "aliased_indices", "(", "self", ")", ":", "return", "[", "self", ".", "backend", ".", "index_class", "(", "self", ".", "backend", ",", "index_name", ")", "for", "index_name", "in", "self", ".", "es", ".", "indices", ".", "get_alias", "(", "name", ...
[ 842, 4 ]
[ 854, 9 ]
python
en
['en', 'error', 'th']
False
Elasticsearch5Index.put_alias
(self, name)
Creates a new alias to this index. If the alias already exists it will be repointed to this index.
Creates a new alias to this index. If the alias already exists it will be repointed to this index.
def put_alias(self, name): """ Creates a new alias to this index. If the alias already exists it will be repointed to this index. """ self.es.indices.put_alias(name=name, index=self.name)
[ "def", "put_alias", "(", "self", ",", "name", ")", ":", "self", ".", "es", ".", "indices", ".", "put_alias", "(", "name", "=", "name", ",", "index", "=", "self", ".", "name", ")" ]
[ 856, 4 ]
[ 861, 61 ]
python
en
['en', 'error', 'th']
False
TestDraftAccess.test_draft_access_admin
(self)
Test that admin can view draft.
Test that admin can view draft.
def test_draft_access_admin(self): """Test that admin can view draft.""" # Login as admin self.user = self.login() # Try getting page draft response = self.client.get(reverse('wagtailadmin_pages:view_draft', args=(self.child_page.id, ))) # User can view self.ass...
[ "def", "test_draft_access_admin", "(", "self", ")", ":", "# Login as admin", "self", ".", "user", "=", "self", ".", "login", "(", ")", "# Try getting page draft", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:view_...
[ 35, 4 ]
[ 44, 51 ]
python
en
['en', 'en', 'en']
True
TestDraftAccess.test_draft_access_unauthorized
(self)
Test that user without edit/publish permission can't view draft.
Test that user without edit/publish permission can't view draft.
def test_draft_access_unauthorized(self): """Test that user without edit/publish permission can't view draft.""" self.login(username='bob', password='password') # Try getting page draft response = self.client.get(reverse('wagtailadmin_pages:view_draft', args=(self.child_page.id, ))) ...
[ "def", "test_draft_access_unauthorized", "(", "self", ")", ":", "self", ".", "login", "(", "username", "=", "'bob'", ",", "password", "=", "'password'", ")", "# Try getting page draft", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", ...
[ 56, 4 ]
[ 64, 51 ]
python
en
['en', 'en', 'en']
True
TestDraftAccess.test_draft_access_authorized
(self)
Test that user with edit permission can view draft.
Test that user with edit permission can view draft.
def test_draft_access_authorized(self): """Test that user with edit permission can view draft.""" # give user the permission to edit page user = get_user_model().objects.get(email='bob@example.com') user.groups.add(Group.objects.get(name='Moderators')) user.save() self.l...
[ "def", "test_draft_access_authorized", "(", "self", ")", ":", "# give user the permission to edit page", "user", "=", "get_user_model", "(", ")", ".", "objects", ".", "get", "(", "email", "=", "'bob@example.com'", ")", "user", ".", "groups", ".", "add", "(", "Gr...
[ 66, 4 ]
[ 79, 51 ]
python
en
['en', 'en', 'en']
True
TestDraftAccess.test_middleware_response_is_returned
(self)
If middleware returns a response while serving a page preview, that response should be returned back to the user
If middleware returns a response while serving a page preview, that response should be returned back to the user
def test_middleware_response_is_returned(self): """ If middleware returns a response while serving a page preview, that response should be returned back to the user """ self.login() response = self.client.get( reverse('wagtailadmin_pages:view_draft', args=(sel...
[ "def", "test_middleware_response_is_returned", "(", "self", ")", ":", "self", ".", "login", "(", ")", "response", "=", "self", ".", "client", ".", "get", "(", "reverse", "(", "'wagtailadmin_pages:view_draft'", ",", "args", "=", "(", "self", ".", "child_page", ...
[ 81, 4 ]
[ 91, 51 ]
python
en
['en', 'error', 'th']
False
BZAObject.__init__
(self, proto=None, data=None)
:type proto: BZAObject :type data: dict
:type proto: BZAObject :type data: dict
def __init__(self, proto=None, data=None): """ :type proto: BZAObject :type data: dict """ super(BZAObject, self).__init__() self.update(data if data is not None else {}) self.address = "https://a.blazemeter.com" self.data_address = "https://data.blazemet...
[ "def", "__init__", "(", "self", ",", "proto", "=", "None", ",", "data", "=", "None", ")", ":", "super", "(", "BZAObject", ",", "self", ")", ".", "__init__", "(", ")", "self", ".", "update", "(", "data", "if", "data", "is", "not", "None", "else", ...
[ 69, 4 ]
[ 95, 68 ]
python
en
['en', 'error', 'th']
False
BZAObject._request
(self, url, data=None, headers=None, method=None, raw_result=False, retry=True)
:param url: str :type data: Union[dict,str] :param headers: dict :param method: str :return: dict
:param url: str :type data: Union[dict,str] :param headers: dict :param method: str :return: dict
def _request(self, url, data=None, headers=None, method=None, raw_result=False, retry=True): """ :param url: str :type data: Union[dict,str] :param headers: dict :param method: str :return: dict """ if not headers: headers = {} headers...
[ "def", "_request", "(", "self", ",", "url", ",", "data", "=", "None", ",", "headers", "=", "None", ",", "method", "=", "None", ",", "raw_result", "=", "False", ",", "retry", "=", "True", ")", ":", "if", "not", "headers", ":", "headers", "=", "{", ...
[ 97, 4 ]
[ 180, 21 ]
python
en
['en', 'error', 'th']
False
BZAObjectsList.first
(self)
Returns first item of non-empty list or None
Returns first item of non-empty list or None
def first(self): """ Returns first item of non-empty list or None """ if len(self): return self[0] return None
[ "def", "first", "(", "self", ")", ":", "if", "len", "(", "self", ")", ":", "return", "self", "[", "0", "]", "return", "None" ]
[ 184, 4 ]
[ 189, 19 ]
python
en
['en', 'en', 'en']
True
User.ping
(self)
Quick check if we can access the service
Quick check if we can access the service
def ping(self): """ Quick check if we can access the service """ self._request(self.address + '/api/v4/web/version')
[ "def", "ping", "(", "self", ")", ":", "self", ".", "_request", "(", "self", ".", "address", "+", "'/api/v4/web/version'", ")" ]
[ 211, 4 ]
[ 213, 59 ]
python
en
['en', 'en', 'en']
True
User.accounts
(self, ident=None, name=None)
:rtype: BZAObjectsList[Account]
:rtype: BZAObjectsList[Account]
def accounts(self, ident=None, name=None): """ :rtype: BZAObjectsList[Account] """ res = self._request(self.address + '/api/v4/accounts') accounts = [] for acc in res['result']: if ident is not None and acc['id'] != ident: continue ...
[ "def", "accounts", "(", "self", ",", "ident", "=", "None", ",", "name", "=", "None", ")", ":", "res", "=", "self", ".", "_request", "(", "self", ".", "address", "+", "'/api/v4/accounts'", ")", "accounts", "=", "[", "]", "for", "acc", "in", "res", "...
[ 215, 4 ]
[ 227, 39 ]
python
en
['en', 'error', 'th']
False
Account.workspaces
(self, ident=None, name=None)
:rtype: BZAObjectsList[Workspace]
:rtype: BZAObjectsList[Workspace]
def workspaces(self, ident=None, name=None): """ :rtype: BZAObjectsList[Workspace] """ params = {"accountId": self['id'], 'enabled': 'true', 'limit': 100} params = OrderedDict(sorted(params.items(), key=lambda t: t[0])) res = self._request(self.address + '/api/v4/workspac...
[ "def", "workspaces", "(", "self", ",", "ident", "=", "None", ",", "name", "=", "None", ")", ":", "params", "=", "{", "\"accountId\"", ":", "self", "[", "'id'", "]", ",", "'enabled'", ":", "'true'", ",", "'limit'", ":", "100", "}", "params", "=", "O...
[ 271, 4 ]
[ 291, 41 ]
python
en
['en', 'error', 'th']
False
Workspace.projects
(self, name=None, ident=None)
:rtype: BZAObjectsList[Project]
:rtype: BZAObjectsList[Project]
def projects(self, name=None, ident=None): """ :rtype: BZAObjectsList[Project] """ params = OrderedDict() params.update({"workspaceId": self['id']}) if name: params.update({"name": name}) if ident: params.update({"limit": 1000}) ...
[ "def", "projects", "(", "self", ",", "name", "=", "None", ",", "ident", "=", "None", ")", ":", "params", "=", "OrderedDict", "(", ")", "params", ".", "update", "(", "{", "\"workspaceId\"", ":", "self", "[", "'id'", "]", "}", ")", "if", "name", ":",...
[ 295, 4 ]
[ 319, 39 ]
python
en
['en', 'error', 'th']
False
Workspace.private_locations
(self)
:rtype: BZAObjectsList[BZAObject]
:rtype: BZAObjectsList[BZAObject]
def private_locations(self): """ :rtype: BZAObjectsList[BZAObject] """ params = {"workspaceId": self['id']} res = self._request(self.address + '/api/v4/private-locations?' + urlencode(params)) return BZAObjectsList([BZAObject(self, x) for x in res['result']])
[ "def", "private_locations", "(", "self", ")", ":", "params", "=", "{", "\"workspaceId\"", ":", "self", "[", "'id'", "]", "}", "res", "=", "self", ".", "_request", "(", "self", ".", "address", "+", "'/api/v4/private-locations?'", "+", "urlencode", "(", "par...
[ 331, 4 ]
[ 337, 74 ]
python
en
['en', 'error', 'th']
False
Workspace.tests
(self, name=None, ident=None, test_type=None)
:rtype: BZAObjectsList[Test]
:rtype: BZAObjectsList[Test]
def tests(self, name=None, ident=None, test_type=None): """ :rtype: BZAObjectsList[Test] """ params = OrderedDict({"workspaceId": self['id']}) if name is not None: params["name"] = name if ident is not None: params["id"] = ident res = self...
[ "def", "tests", "(", "self", ",", "name", "=", "None", ",", "ident", "=", "None", ",", "test_type", "=", "None", ")", ":", "params", "=", "OrderedDict", "(", "{", "\"workspaceId\"", ":", "self", "[", "'id'", "]", "}", ")", "if", "name", "is", "not"...
[ 339, 4 ]
[ 362, 20 ]
python
en
['en', 'error', 'th']
False
Project.tests
(self, name=None, ident=None, test_type=None)
:rtype: BZAObjectsList[Test]
:rtype: BZAObjectsList[Test]
def tests(self, name=None, ident=None, test_type=None): """ :rtype: BZAObjectsList[Test] """ params = OrderedDict({"projectId": self['id']}) if name is not None: params["name"] = name if ident is not None: params["id"] = ident res = self._...
[ "def", "tests", "(", "self", ",", "name", "=", "None", ",", "ident", "=", "None", ",", "test_type", "=", "None", ")", ":", "params", "=", "OrderedDict", "(", "{", "\"projectId\"", ":", "self", "[", "'id'", "]", "}", ")", "if", "name", "is", "not", ...
[ 380, 4 ]
[ 403, 20 ]
python
en
['en', 'error', 'th']
False
Project.create_test
(self, name, configuration)
:param name: :param configuration: :rtype: Test
:param name: :param configuration: :rtype: Test
def create_test(self, name, configuration): """ :param name: :param configuration: :rtype: Test """ self.log.debug("Creating new test") url = self.address + '/api/v4/tests' data = {"name": name, "projectId": self['id'], "configuration": configuration} ...
[ "def", "create_test", "(", "self", ",", "name", ",", "configuration", ")", ":", "self", ".", "log", ".", "debug", "(", "\"Creating new test\"", ")", "url", "=", "self", ".", "address", "+", "'/api/v4/tests'", "data", "=", "{", "\"name\"", ":", "name", ",...
[ 405, 4 ]
[ 415, 41 ]
python
en
['en', 'error', 'th']
False
Test.start_anonymous_external_test
(self)
:rtype: (Session,Master,str)
:rtype: (Session,Master,str)
def start_anonymous_external_test(self): """ :rtype: (Session,Master,str) """ url = self.address + "/api/v4/sessions" res = self._request(url, method='POST') result = res['result'] session = Session(self, result['session']) session.data_signature = result[...
[ "def", "start_anonymous_external_test", "(", "self", ")", ":", "url", "=", "self", ".", "address", "+", "\"/api/v4/sessions\"", "res", "=", "self", ".", "_request", "(", "url", ",", "method", "=", "'POST'", ")", "result", "=", "res", "[", "'result'", "]", ...
[ 427, 4 ]
[ 436, 80 ]
python
en
['en', 'error', 'th']
False
Session.send_kpi_data
(self, data, is_check_response=True, submit_target=None)
Sends online data :type submit_target: str :param is_check_response: :type data: str
Sends online data
def send_kpi_data(self, data, is_check_response=True, submit_target=None): """ Sends online data :type submit_target: str :param is_check_response: :type data: str """ submit_target = self.kpi_target if submit_target is None else submit_target url = self....
[ "def", "send_kpi_data", "(", "self", ",", "data", ",", "is_check_response", "=", "True", ",", "submit_target", "=", "None", ")", ":", "submit_target", "=", "self", ".", "kpi_target", "if", "submit_target", "is", "None", "else", "submit_target", "url", "=", "...
[ 643, 4 ]
[ 667, 79 ]
python
en
['en', 'error', 'th']
False
Session.upload_file
(self, filename, contents=None)
Upload single artifact :type filename: str :type contents: str :raise TaurusNetworkError:
Upload single artifact
def upload_file(self, filename, contents=None): """ Upload single artifact :type filename: str :type contents: str :raise TaurusNetworkError: """ body = MultiPartForm() # TODO: can we migrate off it, and use something native to requests lib? # maybe http...
[ "def", "upload_file", "(", "self", ",", "filename", ",", "contents", "=", "None", ")", ":", "body", "=", "MultiPartForm", "(", ")", "# TODO: can we migrate off it, and use something native to requests lib?", "# maybe http://stackoverflow.com/questions/12385179/how-to-send-a-multi...
[ 678, 4 ]
[ 702, 68 ]
python
en
['en', 'error', 'th']
False
FullNodeRpcApi.get_blockchain_state
(self, _request: Dict)
Returns a summary of the node's view of the blockchain.
Returns a summary of the node's view of the blockchain.
async def get_blockchain_state(self, _request: Dict): """ Returns a summary of the node's view of the blockchain. """ if self.service.initialized is False: res: Dict = { "blockchain_state": { "peak": None, "genesis_chall...
[ "async", "def", "get_blockchain_state", "(", "self", ",", "_request", ":", "Dict", ")", ":", "if", "self", ".", "service", ".", "initialized", "is", "False", ":", "res", ":", "Dict", "=", "{", "\"blockchain_state\"", ":", "{", "\"peak\"", ":", "None", ",...
[ 67, 4 ]
[ 152, 23 ]
python
en
['en', 'error', 'th']
False
FullNodeRpcApi.get_network_space
(self, request: Dict)
Retrieves an estimate of total space validating the chain between two block header hashes.
Retrieves an estimate of total space validating the chain between two block header hashes.
async def get_network_space(self, request: Dict) -> Optional[Dict]: """ Retrieves an estimate of total space validating the chain between two block header hashes. """ if "newer_block_header_hash" not in request or "older_block_header_hash" not in request: raise ValueE...
[ "async", "def", "get_network_space", "(", "self", ",", "request", ":", "Dict", ")", "->", "Optional", "[", "Dict", "]", ":", "if", "\"newer_block_header_hash\"", "not", "in", "request", "or", "\"older_block_header_hash\"", "not", "in", "request", ":", "raise", ...
[ 275, 4 ]
[ 309, 68 ]
python
en
['en', 'error', 'th']
False
FullNodeRpcApi.get_coin_records_by_puzzle_hash
(self, request: Dict)
Retrieves the coins for a given puzzlehash, by default returns unspent coins.
Retrieves the coins for a given puzzlehash, by default returns unspent coins.
async def get_coin_records_by_puzzle_hash(self, request: Dict) -> Optional[Dict]: """ Retrieves the coins for a given puzzlehash, by default returns unspent coins. """ if "puzzle_hash" not in request: raise ValueError("Puzzle hash not in request") kwargs: Dict[str, An...
[ "async", "def", "get_coin_records_by_puzzle_hash", "(", "self", ",", "request", ":", "Dict", ")", "->", "Optional", "[", "Dict", "]", ":", "if", "\"puzzle_hash\"", "not", "in", "request", ":", "raise", "ValueError", "(", "\"Puzzle hash not in request\"", ")", "k...
[ 311, 4 ]
[ 328, 45 ]
python
en
['en', 'error', 'th']
False
FullNodeRpcApi.get_coin_records_by_puzzle_hashes
(self, request: Dict)
Retrieves the coins for a given puzzlehash, by default returns unspent coins.
Retrieves the coins for a given puzzlehash, by default returns unspent coins.
async def get_coin_records_by_puzzle_hashes(self, request: Dict) -> Optional[Dict]: """ Retrieves the coins for a given puzzlehash, by default returns unspent coins. """ if "puzzle_hashes" not in request: raise ValueError("Puzzle hashes not in request") kwargs: Dict[s...
[ "async", "def", "get_coin_records_by_puzzle_hashes", "(", "self", ",", "request", ":", "Dict", ")", "->", "Optional", "[", "Dict", "]", ":", "if", "\"puzzle_hashes\"", "not", "in", "request", ":", "raise", "ValueError", "(", "\"Puzzle hashes not in request\"", ")"...
[ 330, 4 ]
[ 350, 45 ]
python
en
['en', 'error', 'th']
False
FullNodeRpcApi.get_coin_record_by_name
(self, request: Dict)
Retrieves a coin record by it's name.
Retrieves a coin record by it's name.
async def get_coin_record_by_name(self, request: Dict) -> Optional[Dict]: """ Retrieves a coin record by it's name. """ if "name" not in request: raise ValueError("Name not in request") name = hexstr_to_bytes(request["name"]) coin_record: Optional[CoinRecord]...
[ "async", "def", "get_coin_record_by_name", "(", "self", ",", "request", ":", "Dict", ")", "->", "Optional", "[", "Dict", "]", ":", "if", "\"name\"", "not", "in", "request", ":", "raise", "ValueError", "(", "\"Name not in request\"", ")", "name", "=", "hexstr...
[ 352, 4 ]
[ 364, 43 ]
python
en
['en', 'error', 'th']
False
fix_duplicate_attachments
(apps: StateApps, schema_editor: DatabaseSchemaEditor)
Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object for all of them, we would incorrectly create one for each message. This results in exceptions looking up the Attachment object corresponding to a file that was used in mul...
Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object for all of them, we would incorrectly create one for each message. This results in exceptions looking up the Attachment object corresponding to a file that was used in mul...
def fix_duplicate_attachments(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: """Migration 0041 had a bug, where if multiple messages referenced the same attachment, rather than creating a single attachment object for all of them, we would incorrectly create one for each message. This res...
[ "def", "fix_duplicate_attachments", "(", "apps", ":", "StateApps", ",", "schema_editor", ":", "DatabaseSchemaEditor", ")", "->", "None", ":", "Attachment", "=", "apps", ".", "get_model", "(", "\"zerver\"", ",", "\"Attachment\"", ")", "# Loop through all groups of Atta...
[ 7, 0 ]
[ 41, 22 ]
python
en
['en', 'en', 'en']
True
DatabaseFeatures.introspected_boolean_field_type
(self, field=None, created_separately=False)
Some versions of Oracle -- we've seen this on 11.2.0.1 and suspect it goes back -- have a weird bug where, when an integer column is added to an existing table with a default, its precision is later reported on introspection as 0, regardless of the real precision. For Django int...
Some versions of Oracle -- we've seen this on 11.2.0.1 and suspect it goes back -- have a weird bug where, when an integer column is added to an existing table with a default, its precision is later reported on introspection as 0, regardless of the real precision. For Django int...
def introspected_boolean_field_type(self, field=None, created_separately=False): """ Some versions of Oracle -- we've seen this on 11.2.0.1 and suspect it goes back -- have a weird bug where, when an integer column is added to an existing table with a default, its precision is later ...
[ "def", "introspected_boolean_field_type", "(", "self", ",", "field", "=", "None", ",", "created_separately", "=", "False", ")", ":", "if", "self", ".", "connection", ".", "oracle_full_version", "<", "'11.2.0.2'", "and", "field", "and", "field", ".", "has_default...
[ 38, 4 ]
[ 51, 103 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation._maindb_connection
(self)
This is analogous to other backends' `_nodb_connection` property, which allows access to an "administrative" connection which can be used to manage the test databases. For Oracle, the only connection that can be used for that purpose is the main (non-test) connection.
This is analogous to other backends' `_nodb_connection` property, which allows access to an "administrative" connection which can be used to manage the test databases. For Oracle, the only connection that can be used for that purpose is the main (non-test) connection.
def _maindb_connection(self): """ This is analogous to other backends' `_nodb_connection` property, which allows access to an "administrative" connection which can be used to manage the test databases. For Oracle, the only connection that can be used for that purpose is t...
[ "def", "_maindb_connection", "(", "self", ")", ":", "settings_dict", "=", "settings", ".", "DATABASES", "[", "self", ".", "connection", ".", "alias", "]", "user", "=", "settings_dict", ".", "get", "(", "'SAVED_USER'", ")", "or", "settings_dict", "[", "'USER'...
[ 15, 4 ]
[ 29, 74 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation._switch_to_test_user
(self, parameters)
Oracle doesn't have the concept of separate databases under the same user. Thus, we use a separate user (see _create_test_db). This method is used to switch to that user. We will need the main user again for clean-up when we end testing, so we keep its credentials in SAVED_USER/SAVED_PA...
Oracle doesn't have the concept of separate databases under the same user. Thus, we use a separate user (see _create_test_db). This method is used to switch to that user. We will need the main user again for clean-up when we end testing, so we keep its credentials in SAVED_USER/SAVED_PA...
def _switch_to_test_user(self, parameters): """ Oracle doesn't have the concept of separate databases under the same user. Thus, we use a separate user (see _create_test_db). This method is used to switch to that user. We will need the main user again for clean-up when we end tes...
[ "def", "_switch_to_test_user", "(", "self", ",", "parameters", ")", ":", "real_settings", "=", "settings", ".", "DATABASES", "[", "self", ".", "connection", ".", "alias", "]", "real_settings", "[", "'SAVED_USER'", "]", "=", "self", ".", "connection", ".", "s...
[ 102, 4 ]
[ 119, 102 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation.set_as_test_mirror
(self, primary_settings_dict)
Set this database up to be used in testing as a mirror of a primary database whose settings are given
Set this database up to be used in testing as a mirror of a primary database whose settings are given
def set_as_test_mirror(self, primary_settings_dict): """ Set this database up to be used in testing as a mirror of a primary database whose settings are given """ self.connection.settings_dict['USER'] = primary_settings_dict['USER'] self.connection.settings_dict['PASSWORD...
[ "def", "set_as_test_mirror", "(", "self", ",", "primary_settings_dict", ")", ":", "self", ".", "connection", ".", "settings_dict", "[", "'USER'", "]", "=", "primary_settings_dict", "[", "'USER'", "]", "self", ".", "connection", ".", "settings_dict", "[", "'PASSW...
[ 121, 4 ]
[ 127, 85 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation._destroy_test_db
(self, test_database_name, verbosity=1)
Destroy a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created.
Destroy a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created.
def _destroy_test_db(self, test_database_name, verbosity=1): """ Destroy a test database, prompting the user for confirmation if the database already exists. Returns the name of the test database created. """ self.connection.settings_dict['USER'] = self.connection.settings_dict['...
[ "def", "_destroy_test_db", "(", "self", ",", "test_database_name", ",", "verbosity", "=", "1", ")", ":", "self", ".", "connection", ".", "settings_dict", "[", "'USER'", "]", "=", "self", ".", "connection", ".", "settings_dict", "[", "'SAVED_USER'", "]", "sel...
[ 164, 4 ]
[ 182, 39 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation._execute_allow_fail_statements
(self, cursor, statements, parameters, verbosity, acceptable_ora_err)
Execute statements which are allowed to fail silently if the Oracle error code given by `acceptable_ora_err` is raised. Return True if the statements execute without an exception, or False otherwise.
Execute statements which are allowed to fail silently if the Oracle error code given by `acceptable_ora_err` is raised. Return True if the statements execute without an exception, or False otherwise.
def _execute_allow_fail_statements(self, cursor, statements, parameters, verbosity, acceptable_ora_err): """ Execute statements which are allowed to fail silently if the Oracle error code given by `acceptable_ora_err` is raised. Return True if the statements execute without an exception,...
[ "def", "_execute_allow_fail_statements", "(", "self", ",", "cursor", ",", "statements", ",", "parameters", ",", "verbosity", ",", "acceptable_ora_err", ")", ":", "try", ":", "# Statement can fail when acceptable_ora_err is not None", "allow_quiet_fail", "=", "acceptable_ora...
[ 261, 4 ]
[ 276, 24 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation._test_settings_get
(self, key, default=None, prefixed=None)
Return a value from the test settings dict, or a given default, or a prefixed entry from the main settings dict
Return a value from the test settings dict, or a given default, or a prefixed entry from the main settings dict
def _test_settings_get(self, key, default=None, prefixed=None): """ Return a value from the test settings dict, or a given default, or a prefixed entry from the main settings dict """ settings_dict = self.connection.settings_dict val = settings_dict['TEST'].get(ke...
[ "def", "_test_settings_get", "(", "self", ",", "key", ",", "default", "=", "None", ",", "prefixed", "=", "None", ")", ":", "settings_dict", "=", "self", ".", "connection", ".", "settings_dict", "val", "=", "settings_dict", "[", "'TEST'", "]", ".", "get", ...
[ 291, 4 ]
[ 301, 18 ]
python
en
['en', 'error', 'th']
False
DatabaseCreation._get_test_db_name
(self)
We need to return the 'production' DB name to get the test DB creation machinery to work. This isn't a great deal in this case because DB names as handled by Django haven't real counterparts in Oracle.
We need to return the 'production' DB name to get the test DB creation machinery to work. This isn't a great deal in this case because DB names as handled by Django haven't real counterparts in Oracle.
def _get_test_db_name(self): """ We need to return the 'production' DB name to get the test DB creation machinery to work. This isn't a great deal in this case because DB names as handled by Django haven't real counterparts in Oracle. """ return self.connection.settings_d...
[ "def", "_get_test_db_name", "(", "self", ")", ":", "return", "self", ".", "connection", ".", "settings_dict", "[", "'NAME'", "]" ]
[ 344, 4 ]
[ 350, 52 ]
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", "...
[ 532, 0 ]
[ 545, 57 ]
python
en
['en', 'error', 'th']
False
comment
(parser, token)
Ignores everything between ``{% comment %}`` and ``{% endcomment %}``.
Ignores everything between ``{% comment %}`` and ``{% endcomment %}``.
def comment(parser, token): """ Ignores everything between ``{% comment %}`` and ``{% endcomment %}``. """ parser.skip_past('endcomment') return CommentNode()
[ "def", "comment", "(", "parser", ",", "token", ")", ":", "parser", ".", "skip_past", "(", "'endcomment'", ")", "return", "CommentNode", "(", ")" ]
[ 549, 0 ]
[ 554, 24 ]
python
en
['en', 'error', 'th']
False
cycle
(parser, token)
Cycles 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 loo...
Cycles among the given strings each time this tag is encountered.
def cycle(parser, token): """ Cycles 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...
[ 558, 0 ]
[ 642, 15 ]
python
en
['en', 'error', 'th']
False
debug
(parser, token)
Outputs a whole load of debugging information, including the current context and imported modules. Sample usage:: <pre> {% debug %} </pre>
Outputs a whole load of debugging information, including the current context and imported modules.
def debug(parser, token): """ Outputs 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", "(", ")" ]
[ 651, 0 ]
[ 662, 22 ]
python
en
['en', 'error', 'th']
False
do_filter
(parser, token)
Filters 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. ...
Filters the contents of the block through variable filters.
def do_filter(parser, token): """ Filters 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-escape...
[ "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", "="...
[ 666, 0 ]
[ 692, 44 ]
python
en
['en', 'error', 'th']
False
firstof
(parser, token)
Outputs the first variable passed that is not False. Outputs 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 }} {% el...
Outputs the first variable passed that is not False.
def firstof(parser, token): """ Outputs the first variable passed that is not False. Outputs 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", "len", "(", "bits", ")", "<", "1", ":", "raise", "TemplateSyntaxError", "(", "\"'firstof' ...
[ 696, 0 ]
[ 741, 75 ]
python
en
['en', 'error', 'th']
False
do_for
(parser, token)
Loops 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 re...
Loops over each item in an array.
def do_for(parser, token): """ Loops 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\"", ...
[ 745, 0 ]
[ 833, 82 ]
python
en
['en', 'error', 'th']
False
ifequal
(parser, token)
Outputs 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 %}
Outputs the contents of the block if the two arguments equal each other.
def ifequal(parser, token): """ Outputs 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", ")", ":", "return", "do_ifequal", "(", "parser", ",", "token", ",", "False", ")" ]
[ 854, 0 ]
[ 870, 43 ]
python
en
['en', 'error', 'th']
False
ifnotequal
(parser, token)
Outputs the contents of the block if the two arguments are not equal. See ifequal.
Outputs the contents of the block if the two arguments are not equal. See ifequal.
def ifnotequal(parser, token): """ Outputs the contents of the block if the two arguments are not equal. See ifequal. """ return do_ifequal(parser, token, True)
[ "def", "ifnotequal", "(", "parser", ",", "token", ")", ":", "return", "do_ifequal", "(", "parser", ",", "token", ",", "True", ")" ]
[ 874, 0 ]
[ 879, 42 ]
python
en
['en', 'error', 'th']
False
do_if
(parser, token)
The ``{% if %}`` tag evaluates a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), the contents of the block are output: :: {% if athlete_list %} Number of athletes: {{ athlete_list|count }} {% elif athlete_in_locker_r...
The ``{% if %}`` tag evaluates a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), the contents of the block are output:
def do_if(parser, token): """ The ``{% if %}`` tag evaluates a variable, and if that variable is "true" (i.e., exists, is not empty, and is not a false boolean value), the contents of the block are output: :: {% if athlete_list %} Number of athletes: {{ athlete_list|count }} ...
[ "def", "do_if", "(", "parser", ",", "token", ")", ":", "# {% if ... %}", "bits", "=", "token", ".", "split_contents", "(", ")", "[", "1", ":", "]", "condition", "=", "TemplateIfParser", "(", "parser", ",", "bits", ")", ".", "parse", "(", ")", "nodelist...
[ 906, 0 ]
[ 990, 39 ]
python
en
['en', 'error', 'th']
False
ifchanged
(parser, token)
Checks 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. Checks its own rendered contents against its previous state and only displays the content if it has changed. For example, this displays a ...
Checks if a value has changed from the last iteration of a loop.
def ifchanged(parser, token): """ Checks 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. Checks its own rendered contents against its previous state and only displays the content if it has change...
[ "def", "ifchanged", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "nodelist_true", "=", "parser", ".", "parse", "(", "(", "'else'", ",", "'endifchanged'", ")", ")", "token", "=", "parser", ".", "next_token"...
[ 994, 0 ]
[ 1032, 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...
[ 1046, 0 ]
[ 1065, 17 ]
python
en
['en', 'error', 'th']
False
load
(parser, token)
Loads 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 %}
Loads a custom template tag library into the parser.
def load(parser, token): """ Loads 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 n...
[ "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", ...
[ 1069, 0 ]
[ 1096, 21 ]
python
en
['en', 'error', 'th']
False
lorem
(parser, token)
Creates 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 p...
Creates random Latin text useful for providing test data in templates.
def lorem(parser, token): """ Creates 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"...
[ 1100, 0 ]
[ 1143, 43 ]
python
en
['en', 'error', 'th']
False
now
(parser, token)
Displays the date, formatted according to the given string. Uses the same format as PHP's ``date()`` function; see http://php.net/date for all the possible values. Sample usage:: It is {% now "jS F Y H:i" %}
Displays the date, formatted according to the given string.
def now(parser, token): """ Displays the date, formatted according to the given string. Uses the same format as PHP's ``date()`` function; see http://php.net/date for all the possible values. Sample usage:: It is {% now "jS F Y H:i" %} """ bits = token.split_contents() asvar =...
[ "def", "now", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "asvar", "=", "None", "if", "len", "(", "bits", ")", "==", "4", "and", "bits", "[", "-", "2", "]", "==", "'as'", ":", "asvar", "=", "bit...
[ 1147, 0 ]
[ 1166, 40 ]
python
en
['en', 'error', 'th']
False
regroup
(parser, token)
Regroups a list of alike objects by a common attribute. This complex tag is best illustrated by use of an example: say that ``musicians`` is a list of ``Musician`` objects that have ``name`` and ``instrument`` attributes, and you'd like to display a list that looks like: * Guitar: ...
Regroups a list of alike objects by a common attribute.
def regroup(parser, token): """ Regroups a list of alike objects by a common attribute. This complex tag is best illustrated by use of an example: say that ``musicians`` is a list of ``Musician`` objects that have ``name`` and ``instrument`` attributes, and you'd like to display a list that loo...
[ "def", "regroup", "(", "parser", ",", "token", ")", ":", "bits", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "bits", ")", "!=", "6", ":", "raise", "TemplateSyntaxError", "(", "\"'regroup' tag takes five arguments\"", ")", "target", "=", ...
[ 1170, 0 ]
[ 1235, 52 ]
python
en
['en', 'error', 'th']
False
resetcycle
(parser, token)
Resets a cycle tag. If an argument is given, resets the last rendered cycle tag whose name matches the argument, else resets the last rendered cycle tag (named or unnamed).
Resets a cycle tag.
def resetcycle(parser, token): """ Resets a cycle tag. If an argument is given, resets the last rendered cycle tag whose name matches the argument, else resets the last rendered cycle tag (named or unnamed). """ args = token.split_contents() if len(args) > 2: raise TemplateSynt...
[ "def", "resetcycle", "(", "parser", ",", "token", ")", ":", "args", "=", "token", ".", "split_contents", "(", ")", "if", "len", "(", "args", ")", ">", "2", ":", "raise", "TemplateSyntaxError", "(", "\"%r tag accepts at most one argument.\"", "%", "args", "["...
[ 1239, 0 ]
[ 1261, 59 ]
python
en
['en', 'error', 'th']
False