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._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... | [
559,
4
] | [
708,
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",
".... | [
710,
4
] | [
719,
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",
"(",
")",
",",
... | [
721,
4
] | [
737,
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.
"""
opts = self.model._meta
if geo_field not... | [
"def",
"_geocol_select",
"(",
"self",
",",
"geo_field",
",",
"field_name",
")",
":",
"opts",
"=",
"self",
".",
"model",
".",
"_meta",
"if",
"geo_field",
"not",
"in",
"opts",
".",
"fields",
":",
"# Is this operation going to be on a related geographic field?",
"# I... | [
739,
4
] | [
763,
76
] | python | en | ['en', 'error', 'th'] | False |
set_language | (request) |
Redirect to a given URL while setting the chosen language in the session
(if enabled) and in a cookie. The URL and the language code need to be
specified in the request parameters.
Since this view changes how the user will see the rest of the site, it must
only be accessed as a POST request. If ca... |
Redirect to a given URL while setting the chosen language in the session
(if enabled) and in a cookie. The URL and the language code need to be
specified in the request parameters. | def set_language(request):
"""
Redirect to a given URL while setting the chosen language in the session
(if enabled) and in a cookie. The URL and the language code need to be
specified in the request parameters.
Since this view changes how the user will see the rest of the site, it must
only be... | [
"def",
"set_language",
"(",
"request",
")",
":",
"next",
"=",
"request",
".",
"POST",
".",
"get",
"(",
"'next'",
",",
"request",
".",
"GET",
".",
"get",
"(",
"'next'",
")",
")",
"if",
"(",
"(",
"next",
"or",
"not",
"request",
".",
"is_ajax",
"(",
... | [
22,
0
] | [
67,
19
] | python | en | ['en', 'error', 'th'] | False |
get_formats | () | Return all formats strings required for i18n to work. | Return all formats strings required for i18n to work. | def get_formats():
"""Return all formats strings required for i18n to work."""
FORMAT_SETTINGS = (
'DATE_FORMAT', 'DATETIME_FORMAT', 'TIME_FORMAT',
'YEAR_MONTH_FORMAT', 'MONTH_DAY_FORMAT', 'SHORT_DATE_FORMAT',
'SHORT_DATETIME_FORMAT', 'FIRST_DAY_OF_WEEK', 'DECIMAL_SEPARATOR',
'TH... | [
"def",
"get_formats",
"(",
")",
":",
"FORMAT_SETTINGS",
"=",
"(",
"'DATE_FORMAT'",
",",
"'DATETIME_FORMAT'",
",",
"'TIME_FORMAT'",
",",
"'YEAR_MONTH_FORMAT'",
",",
"'MONTH_DAY_FORMAT'",
",",
"'SHORT_DATE_FORMAT'",
",",
"'SHORT_DATETIME_FORMAT'",
",",
"'FIRST_DAY_OF_WEEK'"... | [
70,
0
] | [
79,
63
] | python | en | ['en', 'en', 'en'] | True |
JavaScriptCatalog._num_plurals | (self) |
Return the number of plurals for this catalog language, or 2 if no
plural string is available.
|
Return the number of plurals for this catalog language, or 2 if no
plural string is available.
| def _num_plurals(self):
"""
Return the number of plurals for this catalog language, or 2 if no
plural string is available.
"""
match = re.search(r'nplurals=\s*(\d+)', self._plural_string or '')
if match:
return int(match.groups()[0])
return 2 | [
"def",
"_num_plurals",
"(",
"self",
")",
":",
"match",
"=",
"re",
".",
"search",
"(",
"r'nplurals=\\s*(\\d+)'",
",",
"self",
".",
"_plural_string",
"or",
"''",
")",
"if",
"match",
":",
"return",
"int",
"(",
"match",
".",
"groups",
"(",
")",
"[",
"0",
... | [
227,
4
] | [
235,
16
] | python | en | ['en', 'error', 'th'] | False |
JavaScriptCatalog._plural_string | (self) |
Return the plural string (including nplurals) for this catalog language,
or None if no plural string is available.
|
Return the plural string (including nplurals) for this catalog language,
or None if no plural string is available.
| def _plural_string(self):
"""
Return the plural string (including nplurals) for this catalog language,
or None if no plural string is available.
"""
if '' in self.translation._catalog:
for line in self.translation._catalog[''].split('\n'):
if line.star... | [
"def",
"_plural_string",
"(",
"self",
")",
":",
"if",
"''",
"in",
"self",
".",
"translation",
".",
"_catalog",
":",
"for",
"line",
"in",
"self",
".",
"translation",
".",
"_catalog",
"[",
"''",
"]",
".",
"split",
"(",
"'\\n'",
")",
":",
"if",
"line",
... | [
238,
4
] | [
247,
19
] | python | en | ['en', 'error', 'th'] | False |
Draw | (im, mode=None) |
A simple 2D drawing interface for PIL images.
:param im: The image to draw in.
:param mode: Optional mode to use for color values. For RGB
images, this argument can be RGB or RGBA (to blend the
drawing into the image). For all other modes, this argument
must be the same as the image... |
A simple 2D drawing interface for PIL images. | def Draw(im, mode=None):
"""
A simple 2D drawing interface for PIL images.
:param im: The image to draw in.
:param mode: Optional mode to use for color values. For RGB
images, this argument can be RGB or RGBA (to blend the
drawing into the image). For all other modes, this argument
... | [
"def",
"Draw",
"(",
"im",
",",
"mode",
"=",
"None",
")",
":",
"try",
":",
"return",
"im",
".",
"getdraw",
"(",
"mode",
")",
"except",
"AttributeError",
":",
"return",
"ImageDraw",
"(",
"im",
",",
"mode",
")"
] | [
454,
0
] | [
468,
34
] | python | en | ['en', 'error', 'th'] | False |
getdraw | (im=None, hints=None) |
(Experimental) A more advanced 2D drawing interface for PIL images,
based on the WCK interface.
:param im: The image to draw in.
:param hints: An optional list of hints.
:returns: A (drawing context, drawing resource factory) tuple.
|
(Experimental) A more advanced 2D drawing interface for PIL images,
based on the WCK interface. | def getdraw(im=None, hints=None):
"""
(Experimental) A more advanced 2D drawing interface for PIL images,
based on the WCK interface.
:param im: The image to draw in.
:param hints: An optional list of hints.
:returns: A (drawing context, drawing resource factory) tuple.
"""
# FIXME: thi... | [
"def",
"getdraw",
"(",
"im",
"=",
"None",
",",
"hints",
"=",
"None",
")",
":",
"# FIXME: this needs more work!",
"# FIXME: come up with a better 'hints' scheme.",
"handler",
"=",
"None",
"if",
"not",
"hints",
"or",
"\"nicest\"",
"in",
"hints",
":",
"try",
":",
"... | [
478,
0
] | [
499,
22
] | python | en | ['en', 'error', 'th'] | False |
floodfill | (image, xy, value, border=None, thresh=0) |
(experimental) Fills a bounded region with a given color.
:param image: Target image.
:param xy: Seed position (a 2-item coordinate tuple). See
:ref:`coordinate-system`.
:param value: Fill color.
:param border: Optional border value. If given, the region consists of
pixels with a ... |
(experimental) Fills a bounded region with a given color. | def floodfill(image, xy, value, border=None, thresh=0):
"""
(experimental) Fills a bounded region with a given color.
:param image: Target image.
:param xy: Seed position (a 2-item coordinate tuple). See
:ref:`coordinate-system`.
:param value: Fill color.
:param border: Optional border ... | [
"def",
"floodfill",
"(",
"image",
",",
"xy",
",",
"value",
",",
"border",
"=",
"None",
",",
"thresh",
"=",
"0",
")",
":",
"# based on an implementation by Eric S. Raymond",
"# amended by yo1995 @20180806",
"pixel",
"=",
"image",
".",
"load",
"(",
")",
"x",
","... | [
502,
0
] | [
555,
23
] | python | en | ['en', 'error', 'th'] | False |
_color_diff | (color1, color2) |
Uses 1-norm distance to calculate difference between two values.
|
Uses 1-norm distance to calculate difference between two values.
| def _color_diff(color1, color2):
"""
Uses 1-norm distance to calculate difference between two values.
"""
if isinstance(color2, tuple):
return sum([abs(color1[i] - color2[i]) for i in range(0, len(color2))])
else:
return abs(color1 - color2) | [
"def",
"_color_diff",
"(",
"color1",
",",
"color2",
")",
":",
"if",
"isinstance",
"(",
"color2",
",",
"tuple",
")",
":",
"return",
"sum",
"(",
"[",
"abs",
"(",
"color1",
"[",
"i",
"]",
"-",
"color2",
"[",
"i",
"]",
")",
"for",
"i",
"in",
"range",... | [
558,
0
] | [
565,
35
] | python | en | ['en', 'error', 'th'] | False |
ImageDraw.__init__ | (self, im, mode=None) |
Create a drawing instance.
:param im: The image to draw in.
:param mode: Optional mode to use for color values. For RGB
images, this argument can be RGB or RGBA (to blend the
drawing into the image). For all other modes, this argument
must be the same as the ... |
Create a drawing instance. | def __init__(self, im, mode=None):
"""
Create a drawing instance.
:param im: The image to draw in.
:param mode: Optional mode to use for color values. For RGB
images, this argument can be RGB or RGBA (to blend the
drawing into the image). For all other modes, thi... | [
"def",
"__init__",
"(",
"self",
",",
"im",
",",
"mode",
"=",
"None",
")",
":",
"im",
".",
"load",
"(",
")",
"if",
"im",
".",
"readonly",
":",
"im",
".",
"_copy",
"(",
")",
"# make it writeable",
"blend",
"=",
"0",
"if",
"mode",
"is",
"None",
":",... | [
47,
4
] | [
86,
24
] | python | en | ['en', 'error', 'th'] | False |
ImageDraw.getfont | (self) |
Get the current default font.
:returns: An image font. |
Get the current default font. | def getfont(self):
"""
Get the current default font.
:returns: An image font."""
if not self.font:
# FIXME: should add a font repository
from . import ImageFont
self.font = ImageFont.load_default()
return self.font | [
"def",
"getfont",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"font",
":",
"# FIXME: should add a font repository",
"from",
".",
"import",
"ImageFont",
"self",
".",
"font",
"=",
"ImageFont",
".",
"load_default",
"(",
")",
"return",
"self",
".",
"font"
] | [
88,
4
] | [
98,
24
] | python | en | ['en', 'error', 'th'] | False |
ImageDraw.arc | (self, xy, start, end, fill=None, width=0) | Draw an arc. | Draw an arc. | def arc(self, xy, start, end, fill=None, width=0):
"""Draw an arc."""
ink, fill = self._getink(fill)
if ink is not None:
self.draw.draw_arc(xy, start, end, ink, width) | [
"def",
"arc",
"(",
"self",
",",
"xy",
",",
"start",
",",
"end",
",",
"fill",
"=",
"None",
",",
"width",
"=",
"0",
")",
":",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"fill",
")",
"if",
"ink",
"is",
"not",
"None",
":",
"self",
".",... | [
121,
4
] | [
125,
58
] | python | en | ['en', 'pl', 'en'] | True |
ImageDraw.bitmap | (self, xy, bitmap, fill=None) | Draw a bitmap. | Draw a bitmap. | def bitmap(self, xy, bitmap, fill=None):
"""Draw a bitmap."""
bitmap.load()
ink, fill = self._getink(fill)
if ink is None:
ink = fill
if ink is not None:
self.draw.draw_bitmap(xy, bitmap.im, ink) | [
"def",
"bitmap",
"(",
"self",
",",
"xy",
",",
"bitmap",
",",
"fill",
"=",
"None",
")",
":",
"bitmap",
".",
"load",
"(",
")",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"fill",
")",
"if",
"ink",
"is",
"None",
":",
"ink",
"=",
"fill",
... | [
127,
4
] | [
134,
53
] | python | en | ['en', 'mt', 'en'] | True |
ImageDraw.chord | (self, xy, start, end, fill=None, outline=None, width=1) | Draw a chord. | Draw a chord. | def chord(self, xy, start, end, fill=None, outline=None, width=1):
"""Draw a chord."""
ink, fill = self._getink(outline, fill)
if fill is not None:
self.draw.draw_chord(xy, start, end, fill, 1)
if ink is not None and ink != fill and width != 0:
self.draw.draw_chor... | [
"def",
"chord",
"(",
"self",
",",
"xy",
",",
"start",
",",
"end",
",",
"fill",
"=",
"None",
",",
"outline",
"=",
"None",
",",
"width",
"=",
"1",
")",
":",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"outline",
",",
"fill",
")",
"if",
... | [
136,
4
] | [
142,
63
] | python | cy | ['en', 'cy', 'hi'] | False |
ImageDraw.ellipse | (self, xy, fill=None, outline=None, width=1) | Draw an ellipse. | Draw an ellipse. | def ellipse(self, xy, fill=None, outline=None, width=1):
"""Draw an ellipse."""
ink, fill = self._getink(outline, fill)
if fill is not None:
self.draw.draw_ellipse(xy, fill, 1)
if ink is not None and ink != fill and width != 0:
self.draw.draw_ellipse(xy, ink, 0, w... | [
"def",
"ellipse",
"(",
"self",
",",
"xy",
",",
"fill",
"=",
"None",
",",
"outline",
"=",
"None",
",",
"width",
"=",
"1",
")",
":",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"outline",
",",
"fill",
")",
"if",
"fill",
"is",
"not",
"No... | [
144,
4
] | [
150,
53
] | python | en | ['en', 'fy', 'es'] | False |
ImageDraw.line | (self, xy, fill=None, width=0, joint=None) | Draw a line, or a connected sequence of line segments. | Draw a line, or a connected sequence of line segments. | def line(self, xy, fill=None, width=0, joint=None):
"""Draw a line, or a connected sequence of line segments."""
ink = self._getink(fill)[0]
if ink is not None:
self.draw.draw_lines(xy, ink, width)
if joint == "curve" and width > 4:
if not isinstance(xy[0]... | [
"def",
"line",
"(",
"self",
",",
"xy",
",",
"fill",
"=",
"None",
",",
"width",
"=",
"0",
",",
"joint",
"=",
"None",
")",
":",
"ink",
"=",
"self",
".",
"_getink",
"(",
"fill",
")",
"[",
"0",
"]",
"if",
"ink",
"is",
"not",
"None",
":",
"self",
... | [
152,
4
] | [
212,
59
] | python | en | ['en', 'en', 'en'] | True |
ImageDraw.shape | (self, shape, fill=None, outline=None) | (Experimental) Draw a shape. | (Experimental) Draw a shape. | def shape(self, shape, fill=None, outline=None):
"""(Experimental) Draw a shape."""
shape.close()
ink, fill = self._getink(outline, fill)
if fill is not None:
self.draw.draw_outline(shape, fill, 1)
if ink is not None and ink != fill:
self.draw.draw_outline... | [
"def",
"shape",
"(",
"self",
",",
"shape",
",",
"fill",
"=",
"None",
",",
"outline",
"=",
"None",
")",
":",
"shape",
".",
"close",
"(",
")",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"outline",
",",
"fill",
")",
"if",
"fill",
"is",
... | [
214,
4
] | [
221,
49
] | python | en | ['en', 'haw', 'en'] | True |
ImageDraw.pieslice | (self, xy, start, end, fill=None, outline=None, width=1) | Draw a pieslice. | Draw a pieslice. | def pieslice(self, xy, start, end, fill=None, outline=None, width=1):
"""Draw a pieslice."""
ink, fill = self._getink(outline, fill)
if fill is not None:
self.draw.draw_pieslice(xy, start, end, fill, 1)
if ink is not None and ink != fill and width != 0:
self.draw.... | [
"def",
"pieslice",
"(",
"self",
",",
"xy",
",",
"start",
",",
"end",
",",
"fill",
"=",
"None",
",",
"outline",
"=",
"None",
",",
"width",
"=",
"1",
")",
":",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"outline",
",",
"fill",
")",
"if... | [
223,
4
] | [
229,
66
] | python | pl | ['en', 'pl', 'pl'] | True |
ImageDraw.point | (self, xy, fill=None) | Draw one or more individual pixels. | Draw one or more individual pixels. | def point(self, xy, fill=None):
"""Draw one or more individual pixels."""
ink, fill = self._getink(fill)
if ink is not None:
self.draw.draw_points(xy, ink) | [
"def",
"point",
"(",
"self",
",",
"xy",
",",
"fill",
"=",
"None",
")",
":",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"fill",
")",
"if",
"ink",
"is",
"not",
"None",
":",
"self",
".",
"draw",
".",
"draw_points",
"(",
"xy",
",",
"ink"... | [
231,
4
] | [
235,
42
] | python | en | ['en', 'en', 'en'] | True |
ImageDraw.polygon | (self, xy, fill=None, outline=None) | Draw a polygon. | Draw a polygon. | def polygon(self, xy, fill=None, outline=None):
"""Draw a polygon."""
ink, fill = self._getink(outline, fill)
if fill is not None:
self.draw.draw_polygon(xy, fill, 1)
if ink is not None and ink != fill:
self.draw.draw_polygon(xy, ink, 0) | [
"def",
"polygon",
"(",
"self",
",",
"xy",
",",
"fill",
"=",
"None",
",",
"outline",
"=",
"None",
")",
":",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"outline",
",",
"fill",
")",
"if",
"fill",
"is",
"not",
"None",
":",
"self",
".",
"... | [
237,
4
] | [
243,
46
] | python | en | ['en', 'cy', 'en'] | True |
ImageDraw.rectangle | (self, xy, fill=None, outline=None, width=1) | Draw a rectangle. | Draw a rectangle. | def rectangle(self, xy, fill=None, outline=None, width=1):
"""Draw a rectangle."""
ink, fill = self._getink(outline, fill)
if fill is not None:
self.draw.draw_rectangle(xy, fill, 1)
if ink is not None and ink != fill and width != 0:
self.draw.draw_rectangle(xy, in... | [
"def",
"rectangle",
"(",
"self",
",",
"xy",
",",
"fill",
"=",
"None",
",",
"outline",
"=",
"None",
",",
"width",
"=",
"1",
")",
":",
"ink",
",",
"fill",
"=",
"self",
".",
"_getink",
"(",
"outline",
",",
"fill",
")",
"if",
"fill",
"is",
"not",
"... | [
245,
4
] | [
251,
55
] | python | en | ['en', 'en', 'pt'] | True |
ImageDraw.textsize | (
self,
text,
font=None,
spacing=4,
direction=None,
features=None,
language=None,
stroke_width=0,
) | Get the size of a given string, in pixels. | Get the size of a given string, in pixels. | def textsize(
self,
text,
font=None,
spacing=4,
direction=None,
features=None,
language=None,
stroke_width=0,
):
"""Get the size of a given string, in pixels."""
if self._multiline_check(text):
return self.multiline_textsize... | [
"def",
"textsize",
"(",
"self",
",",
"text",
",",
"font",
"=",
"None",
",",
"spacing",
"=",
"4",
",",
"direction",
"=",
"None",
",",
"features",
"=",
"None",
",",
"language",
"=",
"None",
",",
"stroke_width",
"=",
"0",
",",
")",
":",
"if",
"self",
... | [
411,
4
] | [
429,
78
] | python | en | ['en', 'en', 'en'] | True |
FileField.get_prep_value | (self, value) | Returns field's value prepared for saving into a database. | Returns field's value prepared for saving into a database. | def get_prep_value(self, value):
"Returns field's value prepared for saving into a database."
value = super(FileField, self).get_prep_value(value)
# Need to convert File objects provided via a form to unicode for database insertion
if value is None:
return None
return... | [
"def",
"get_prep_value",
"(",
"self",
",",
"value",
")",
":",
"value",
"=",
"super",
"(",
"FileField",
",",
"self",
")",
".",
"get_prep_value",
"(",
"value",
")",
"# Need to convert File objects provided via a form to unicode for database insertion",
"if",
"value",
"i... | [
286,
4
] | [
292,
35
] | python | en | ['en', 'en', 'en'] | True |
FileField.pre_save | (self, model_instance, add) | Returns field's value just before saving. | Returns field's value just before saving. | def pre_save(self, model_instance, add):
"Returns field's value just before saving."
file = super(FileField, self).pre_save(model_instance, add)
if file and not file._committed:
# Commit the file to storage prior to saving the model
file.save(file.name, file, save=False)
... | [
"def",
"pre_save",
"(",
"self",
",",
"model_instance",
",",
"add",
")",
":",
"file",
"=",
"super",
"(",
"FileField",
",",
"self",
")",
".",
"pre_save",
"(",
"model_instance",
",",
"add",
")",
"if",
"file",
"and",
"not",
"file",
".",
"_committed",
":",
... | [
294,
4
] | [
300,
19
] | python | en | ['en', 'en', 'en'] | True |
ImageField.update_dimension_fields | (self, instance, force=False, *args, **kwargs) |
Updates field's width and height fields, if defined.
This method is hooked up to model's post_init signal to update
dimensions after instantiating a model instance. However, dimensions
won't be updated if the dimensions fields are already populated. This
avoids unnecessary re... |
Updates field's width and height fields, if defined. | def update_dimension_fields(self, instance, force=False, *args, **kwargs):
"""
Updates field's width and height fields, if defined.
This method is hooked up to model's post_init signal to update
dimensions after instantiating a model instance. However, dimensions
won't be updat... | [
"def",
"update_dimension_fields",
"(",
"self",
",",
"instance",
",",
"force",
"=",
"False",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# Nothing to update if the field doesn't have dimension fields.",
"has_dimension_fields",
"=",
"self",
".",
"width_field",... | [
418,
4
] | [
472,
56
] | python | en | ['en', 'error', 'th'] | False |
SessionStore._key_to_file | (self, session_key=None) |
Get the file associated with this session key.
|
Get the file associated with this session key.
| def _key_to_file(self, session_key=None):
"""
Get the file associated with this session key.
"""
if session_key is None:
session_key = self._get_or_create_session_key()
# Make sure we're not vulnerable to directory traversal. Session keys
# should always be m... | [
"def",
"_key_to_file",
"(",
"self",
",",
"session_key",
"=",
"None",
")",
":",
"if",
"session_key",
"is",
"None",
":",
"session_key",
"=",
"self",
".",
"_get_or_create_session_key",
"(",
")",
"# Make sure we're not vulnerable to directory traversal. Session keys",
"# sh... | [
40,
4
] | [
54,
78
] | python | en | ['en', 'error', 'th'] | False |
SessionStore._last_modification | (self) |
Return the modification time of the file storing the session's content.
|
Return the modification time of the file storing the session's content.
| def _last_modification(self):
"""
Return the modification time of the file storing the session's content.
"""
modification = os.stat(self._key_to_file()).st_mtime
if settings.USE_TZ:
modification = datetime.datetime.utcfromtimestamp(modification)
return mo... | [
"def",
"_last_modification",
"(",
"self",
")",
":",
"modification",
"=",
"os",
".",
"stat",
"(",
"self",
".",
"_key_to_file",
"(",
")",
")",
".",
"st_mtime",
"if",
"settings",
".",
"USE_TZ",
":",
"modification",
"=",
"datetime",
".",
"datetime",
".",
"ut... | [
56,
4
] | [
64,
60
] | python | en | ['en', 'error', 'th'] | False |
SessionStore._expiry_date | (self, session_data) |
Return the expiry time of the file storing the session's content.
|
Return the expiry time of the file storing the session's content.
| def _expiry_date(self, session_data):
"""
Return the expiry time of the file storing the session's content.
"""
return session_data.get('_session_expiry') or (
self._last_modification() + datetime.timedelta(seconds=self.get_session_cookie_age())
) | [
"def",
"_expiry_date",
"(",
"self",
",",
"session_data",
")",
":",
"return",
"session_data",
".",
"get",
"(",
"'_session_expiry'",
")",
"or",
"(",
"self",
".",
"_last_modification",
"(",
")",
"+",
"datetime",
".",
"timedelta",
"(",
"seconds",
"=",
"self",
... | [
66,
4
] | [
72,
9
] | python | en | ['en', 'error', 'th'] | False |
PackagesModule.path | (self) | Path to requirements file.
Returns:
Path: Path to file
| Path to requirements file. | def path(self):
"""Path to requirements file.
Returns:
Path: Path to file
"""
path = self.parent.path / self._path
return path | [
"def",
"path",
"(",
"self",
")",
":",
"path",
"=",
"self",
".",
"parent",
".",
"path",
"/",
"self",
".",
"_path",
"return",
"path"
] | [
43,
4
] | [
51,
19
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.pkg_path | (self) | Path to package data folder.
Returns:
Path: Path to folder.
| Path to package data folder. | def pkg_path(self):
"""Path to package data folder.
Returns:
Path: Path to folder.
"""
return self.parent.data_path / self.parent.name | [
"def",
"pkg_path",
"(",
"self",
")",
":",
"return",
"self",
".",
"parent",
".",
"data_path",
"/",
"self",
".",
"parent",
".",
"name"
] | [
54,
4
] | [
61,
55
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.config | (self) | Config values specific to component.
Returns:
Component config.
| Config values specific to component. | def config(self) -> Config:
"""Config values specific to component.
Returns:
Component config.
"""
return self.parent.config | [
"def",
"config",
"(",
"self",
")",
"->",
"Config",
":",
"return",
"self",
".",
"parent",
".",
"config"
] | [
64,
4
] | [
71,
33
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.context | (self) | Context values specific to component.
Returns:
Context values.
| Context values specific to component. | def context(self) -> Config:
"""Context values specific to component.
Returns:
Context values.
"""
return self.parent.context | [
"def",
"context",
"(",
"self",
")",
"->",
"Config",
":",
"return",
"self",
".",
"parent",
".",
"context"
] | [
74,
4
] | [
81,
34
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.cache | (self) | Project Cache.
Returns:
Project wide cache
| Project Cache. | def cache(self) -> Config:
"""Project Cache.
Returns:
Project wide cache
"""
return self.parent.cache | [
"def",
"cache",
"(",
"self",
")",
"->",
"Config",
":",
"return",
"self",
".",
"parent",
".",
"cache"
] | [
84,
4
] | [
91,
32
] | python | en | ['en', 'en', 'en'] | False |
PackagesModule.add_from_file | (self, path: Optional[Path] = None, dev: bool = False, **kwargs: Any) | Loads all requirements from file.
Args:
path: Path to file. Defaults to self.path.
dev: If dev requirements should be loaded.
Defaults to False.
| Loads all requirements from file. | def add_from_file(self, path: Optional[Path] = None, dev: bool = False, **kwargs: Any) -> dict:
"""Loads all requirements from file.
Args:
path: Path to file. Defaults to self.path.
dev: If dev requirements should be loaded.
Defaults to False.
"""
... | [
"def",
"add_from_file",
"(",
"self",
",",
"path",
":",
"Optional",
"[",
"Path",
"]",
"=",
"None",
",",
"dev",
":",
"bool",
"=",
"False",
",",
"*",
"*",
"kwargs",
":",
"Any",
")",
"->",
"dict",
":",
"path",
"=",
"path",
"or",
"self",
".",
"path",
... | [
110,
4
] | [
128,
28
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.add_package | (self, package, dev=False, **kwargs) | Add requirement to project.
Args:
package (str): package name/spec
dev (bool, optional): If dev requirements should be loaded.
Defaults to False.
Returns:
dict: Dictionary of packages
| Add requirement to project. | def add_package(self, package, dev=False, **kwargs):
"""Add requirement to project.
Args:
package (str): package name/spec
dev (bool, optional): If dev requirements should be loaded.
Defaults to False.
Returns:
dict: Dictionary of packages
... | [
"def",
"add_package",
"(",
"self",
",",
"package",
",",
"dev",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"f\"adding new dependency: {package}\"",
")",
"source",
"=",
"create_dependency_source",
"(",
"package",
",... | [
131,
4
] | [
164,
32
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.load | (self, fetch=True, **kwargs) | Retrieves and stubs project requirements. | Retrieves and stubs project requirements. | def load(self, fetch=True, **kwargs):
"""Retrieves and stubs project requirements."""
self.pkg_path.mkdir(parents=True, exist_ok=True)
if self.path.exists():
self.add_from_file(self.path)
pkg_keys = set(self.packages.keys())
pkg_cache = self.cache.get(self.name)
... | [
"def",
"load",
"(",
"self",
",",
"fetch",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"self",
".",
"pkg_path",
".",
"mkdir",
"(",
"parents",
"=",
"True",
",",
"exist_ok",
"=",
"True",
")",
"if",
"self",
".",
"path",
".",
"exists",
"(",
")",
... | [
166,
4
] | [
196,
52
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.create | (self) | Create project files. | Create project files. | def create(self):
"""Create project files."""
self.pkg_path.mkdir(parents=True, exist_ok=True)
if not self.config.get(self.name):
self.config.add(self.name, {})
return self.update() | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"pkg_path",
".",
"mkdir",
"(",
"parents",
"=",
"True",
",",
"exist_ok",
"=",
"True",
")",
"if",
"not",
"self",
".",
"config",
".",
"get",
"(",
"self",
".",
"name",
")",
":",
"self",
".",
"confi... | [
198,
4
] | [
203,
28
] | python | en | ['en', 'en', 'en'] | True |
PackagesModule.update | (self) | Dumps packages to file at path. | Dumps packages to file at path. | def update(self):
"""Dumps packages to file at path."""
if not self.path.exists():
self.path.touch()
pkgs = [Package.from_text(name, spec) for name, spec in self.config.get(self.name).items()]
self.log.debug(f"dumping to {self.path.name}")
with self.path.open("r+") as... | [
"def",
"update",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"path",
".",
"exists",
"(",
")",
":",
"self",
".",
"path",
".",
"touch",
"(",
")",
"pkgs",
"=",
"[",
"Package",
".",
"from_text",
"(",
"name",
",",
"spec",
")",
"for",
"name",
",... | [
205,
4
] | [
221,
66
] | python | en | ['en', 'en', 'en'] | True |
DevPackagesModule.create | (self) | Creates component. | Creates component. | def create(self):
"""Creates component."""
self.config.add(f"{self.name}/micropy-cli", "*")
super().create() | [
"def",
"create",
"(",
"self",
")",
":",
"self",
".",
"config",
".",
"add",
"(",
"f\"{self.name}/micropy-cli\"",
",",
"\"*\"",
")",
"super",
"(",
")",
".",
"create",
"(",
")"
] | [
233,
4
] | [
236,
24
] | python | de | ['de', 'sr', 'en'] | False |
DevPackagesModule.load | (self, *args, **kwargs) | Load component. | Load component. | def load(self, *args, **kwargs):
"""Load component."""
super().load(*args, **kwargs, fetch=False) | [
"def",
"load",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
")",
".",
"load",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
",",
"fetch",
"=",
"False",
")"
] | [
238,
4
] | [
240,
50
] | python | en | ['de', 'en', 'en'] | False |
DevPackagesModule.add_package | (self, package, **kwargs) | Adds package. | Adds package. | def add_package(self, package, **kwargs):
"""Adds package."""
return super().add_package(package, **kwargs) | [
"def",
"add_package",
"(",
"self",
",",
"package",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"add_package",
"(",
"package",
",",
"*",
"*",
"kwargs",
")"
] | [
243,
4
] | [
245,
53
] | python | en | ['fr', 'en', 'en'] | False |
DevPackagesModule.add_from_file | (self, path=None, **kwargs) | Adds packages from file. | Adds packages from file. | def add_from_file(self, path=None, **kwargs):
"""Adds packages from file."""
return super().add_from_file(path=path, **kwargs) | [
"def",
"add_from_file",
"(",
"self",
",",
"path",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
")",
".",
"add_from_file",
"(",
"path",
"=",
"path",
",",
"*",
"*",
"kwargs",
")"
] | [
248,
4
] | [
250,
57
] | python | en | ['en', 'en', 'en'] | True |
BasicExtractorTests.test_force_en_us_locale | (self) | Value of locale-munging option used by the command is the right one | Value of locale-munging option used by the command is the right one | def test_force_en_us_locale(self):
"""Value of locale-munging option used by the command is the right one"""
from django.core.management.commands.makemessages import Command
self.assertTrue(Command.leave_locale_alone) | [
"def",
"test_force_en_us_locale",
"(",
"self",
")",
":",
"from",
"django",
".",
"core",
".",
"management",
".",
"commands",
".",
"makemessages",
"import",
"Command",
"self",
".",
"assertTrue",
"(",
"Command",
".",
"leave_locale_alone",
")"
] | [
194,
4
] | [
197,
51
] | python | en | ['en', 'en', 'en'] | True |
BasicExtractorTests.test_extraction_warning | (self) | test xgettext warning about multiple bare interpolation placeholders | test xgettext warning about multiple bare interpolation placeholders | def test_extraction_warning(self):
"""test xgettext warning about multiple bare interpolation placeholders"""
os.chdir(self.test_dir)
shutil.copyfile('./code.sample', './code_sample.py')
self.addCleanup(self.rmfile, os.path.join(self.test_dir, 'code_sample.py'))
stdout = StringIO... | [
"def",
"test_extraction_warning",
"(",
"self",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"test_dir",
")",
"shutil",
".",
"copyfile",
"(",
"'./code.sample'",
",",
"'./code_sample.py'",
")",
"self",
".",
"addCleanup",
"(",
"self",
".",
"rmfile",
",",
"... | [
220,
4
] | [
227,
72
] | python | en | ['en', 'en', 'en'] | True |
BasicExtractorTests.test_template_message_context_extractor | (self) |
Ensure that message contexts are correctly extracted for the
{% trans %} and {% blocktrans %} template tags.
Refs #14806.
|
Ensure that message contexts are correctly extracted for the
{% trans %} and {% blocktrans %} template tags.
Refs #14806.
| def test_template_message_context_extractor(self):
"""
Ensure that message contexts are correctly extracted for the
{% trans %} and {% blocktrans %} template tags.
Refs #14806.
"""
os.chdir(self.test_dir)
management.call_command('makemessages', locale=[LOCALE], ve... | [
"def",
"test_template_message_context_extractor",
"(",
"self",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"test_dir",
")",
"management",
".",
"call_command",
"(",
"'makemessages'",
",",
"locale",
"=",
"[",
"LOCALE",
"]",
",",
"verbosity",
"=",
"0",
")",... | [
229,
4
] | [
258,
75
] | python | en | ['en', 'error', 'th'] | False |
BasicExtractorTests.test_template_comments | (self) | Template comment tags on the same line of other constructs (#19552) | Template comment tags on the same line of other constructs (#19552) | def test_template_comments(self):
"""Template comment tags on the same line of other constructs (#19552)"""
os.chdir(self.test_dir)
# Test detection/end user reporting of old, incorrect templates
# translator comments syntax
with warnings.catch_warnings(record=True) as ws:
... | [
"def",
"test_template_comments",
"(",
"self",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"test_dir",
")",
"# Test detection/end user reporting of old, incorrect templates",
"# translator comments syntax",
"with",
"warnings",
".",
"catch_warnings",
"(",
"record",
"=",... | [
274,
4
] | [
332,
69
] | python | en | ['en', 'en', 'en'] | True |
CopyPluralFormsExtractorTests.test_override_plural_forms | (self) | Ticket #20311. | Ticket #20311. | def test_override_plural_forms(self):
"""Ticket #20311."""
os.chdir(self.test_dir)
management.call_command('makemessages', locale=['es'], extensions=['djtpl'], verbosity=0)
self.assertTrue(os.path.exists(self.PO_FILE_ES))
with io.open(self.PO_FILE_ES, 'r', encoding='utf-8') as fp... | [
"def",
"test_override_plural_forms",
"(",
"self",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"test_dir",
")",
"management",
".",
"call_command",
"(",
"'makemessages'",
",",
"locale",
"=",
"[",
"'es'",
"]",
",",
"extensions",
"=",
"[",
"'djtpl'",
"]",
... | [
465,
4
] | [
473,
43
] | python | en | ['en', 'de', 'en'] | False |
LocationCommentsTests.test_no_location_enabled | (self) | Behavior is correct if --no-location switch is specified. See #16903. | Behavior is correct if --no-location switch is specified. See #16903. | def test_no_location_enabled(self):
"""Behavior is correct if --no-location switch is specified. See #16903."""
os.chdir(self.test_dir)
management.call_command('makemessages', locale=[LOCALE], verbosity=0, no_location=True)
self.assertTrue(os.path.exists(self.PO_FILE))
self.asser... | [
"def",
"test_no_location_enabled",
"(",
"self",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"test_dir",
")",
"management",
".",
"call_command",
"(",
"'makemessages'",
",",
"locale",
"=",
"[",
"LOCALE",
"]",
",",
"verbosity",
"=",
"0",
",",
"no_location... | [
497,
4
] | [
502,
91
] | python | en | ['en', 'en', 'en'] | True |
LocationCommentsTests.test_no_location_disabled | (self) | Behavior is correct if --no-location switch isn't specified. | Behavior is correct if --no-location switch isn't specified. | def test_no_location_disabled(self):
"""Behavior is correct if --no-location switch isn't specified."""
os.chdir(self.test_dir)
management.call_command('makemessages', locale=[LOCALE], verbosity=0, no_location=False)
self.assertTrue(os.path.exists(self.PO_FILE))
# #16903 -- Stand... | [
"def",
"test_no_location_disabled",
"(",
"self",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"test_dir",
")",
"management",
".",
"call_command",
"(",
"'makemessages'",
",",
"locale",
"=",
"[",
"LOCALE",
"]",
",",
"verbosity",
"=",
"0",
",",
"no_locatio... | [
504,
4
] | [
513,
93
] | python | en | ['en', 'en', 'en'] | True |
ExcludedLocaleExtractionTests._set_times_for_all_po_files | (self) |
Set access and modification times to the Unix epoch time for all the .po files.
|
Set access and modification times to the Unix epoch time for all the .po files.
| def _set_times_for_all_po_files(self):
"""
Set access and modification times to the Unix epoch time for all the .po files.
"""
for locale in self.LOCALES:
os.utime(self.PO_FILE % locale, (0, 0)) | [
"def",
"_set_times_for_all_po_files",
"(",
"self",
")",
":",
"for",
"locale",
"in",
"self",
".",
"LOCALES",
":",
"os",
".",
"utime",
"(",
"self",
".",
"PO_FILE",
"%",
"locale",
",",
"(",
"0",
",",
"0",
")",
")"
] | [
578,
4
] | [
583,
51
] | python | en | ['en', 'error', 'th'] | False |
CustomLayoutExtractionTests.test_project_locale_paths | (self) |
Test that:
* translations for an app containing a locale folder are stored in that folder
* translations outside of that app are in LOCALE_PATHS[0]
|
Test that:
* translations for an app containing a locale folder are stored in that folder
* translations outside of that app are in LOCALE_PATHS[0]
| def test_project_locale_paths(self):
"""
Test that:
* translations for an app containing a locale folder are stored in that folder
* translations outside of that app are in LOCALE_PATHS[0]
"""
os.chdir(self.test_dir)
self.addCleanup(shutil.rmtree,
... | [
"def",
"test_project_locale_paths",
"(",
"self",
")",
":",
"os",
".",
"chdir",
"(",
"self",
".",
"test_dir",
")",
"self",
".",
"addCleanup",
"(",
"shutil",
".",
"rmtree",
",",
"os",
".",
"path",
".",
"join",
"(",
"settings",
".",
"LOCALE_PATHS",
"[",
"... | [
646,
4
] | [
672,
76
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_duplicate_pk | (self) |
This is a regression test for ticket #3790.
|
This is a regression test for ticket #3790.
| def test_duplicate_pk(self):
"""
This is a regression test for ticket #3790.
"""
# Load a fixture that uses PK=1
management.call_command(
'loaddata',
'sequence',
verbosity=0,
)
# Create a new animal. Without a sequence reset, t... | [
"def",
"test_duplicate_pk",
"(",
"self",
")",
":",
"# Load a fixture that uses PK=1",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'sequence'",
",",
"verbosity",
"=",
"0",
",",
")",
"# Create a new animal. Without a sequence reset, this new object",
"# will t... | [
46,
4
] | [
67,
40
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_loaddata_not_found_fields_not_ignore | (self) |
Test for ticket #9279 -- Error is raised for entries in
the serialized data for fields that have been removed
from the database when not ignored.
|
Test for ticket #9279 -- Error is raised for entries in
the serialized data for fields that have been removed
from the database when not ignored.
| def test_loaddata_not_found_fields_not_ignore(self):
"""
Test for ticket #9279 -- Error is raised for entries in
the serialized data for fields that have been removed
from the database when not ignored.
"""
with self.assertRaises(DeserializationError):
managem... | [
"def",
"test_loaddata_not_found_fields_not_ignore",
"(",
"self",
")",
":",
"with",
"self",
".",
"assertRaises",
"(",
"DeserializationError",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'sequence_extra'",
",",
"verbosity",
"=",
"0",
")"
] | [
69,
4
] | [
80,
13
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_loaddata_not_found_fields_ignore | (self) |
Test for ticket #9279 -- Ignores entries in
the serialized data for fields that have been removed
from the database.
|
Test for ticket #9279 -- Ignores entries in
the serialized data for fields that have been removed
from the database.
| def test_loaddata_not_found_fields_ignore(self):
"""
Test for ticket #9279 -- Ignores entries in
the serialized data for fields that have been removed
from the database.
"""
management.call_command(
'loaddata',
'sequence_extra',
ignore=... | [
"def",
"test_loaddata_not_found_fields_ignore",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'sequence_extra'",
",",
"ignore",
"=",
"True",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"Animal",
"... | [
82,
4
] | [
94,
64
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_loaddata_not_found_fields_ignore_xml | (self) |
Test for ticket #19998 -- Ignore entries in the XML serialized data
for fields that have been removed from the model definition.
|
Test for ticket #19998 -- Ignore entries in the XML serialized data
for fields that have been removed from the model definition.
| def test_loaddata_not_found_fields_ignore_xml(self):
"""
Test for ticket #19998 -- Ignore entries in the XML serialized data
for fields that have been removed from the model definition.
"""
management.call_command(
'loaddata',
'sequence_extra_xml',
... | [
"def",
"test_loaddata_not_found_fields_ignore_xml",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'sequence_extra_xml'",
",",
"ignore",
"=",
"True",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"Anim... | [
96,
4
] | [
107,
64
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_pretty_print_xml | (self) |
Regression test for ticket #4558 -- pretty printing of XML fixtures
doesn't affect parsing of None values.
|
Regression test for ticket #4558 -- pretty printing of XML fixtures
doesn't affect parsing of None values.
| def test_pretty_print_xml(self):
"""
Regression test for ticket #4558 -- pretty printing of XML fixtures
doesn't affect parsing of None values.
"""
# Load a pretty-printed XML fixture with Nulls.
management.call_command(
'loaddata',
'pretty.xml',
... | [
"def",
"test_pretty_print_xml",
"(",
"self",
")",
":",
"# Load a pretty-printed XML fixture with Nulls.",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'pretty.xml'",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"Stuff",
".",
... | [
110,
4
] | [
122,
60
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_pretty_print_xml_empty_strings | (self) |
Regression test for ticket #4558 -- pretty printing of XML fixtures
doesn't affect parsing of None values.
|
Regression test for ticket #4558 -- pretty printing of XML fixtures
doesn't affect parsing of None values.
| def test_pretty_print_xml_empty_strings(self):
"""
Regression test for ticket #4558 -- pretty printing of XML fixtures
doesn't affect parsing of None values.
"""
# Load a pretty-printed XML fixture with Nulls.
management.call_command(
'loaddata',
'... | [
"def",
"test_pretty_print_xml_empty_strings",
"(",
"self",
")",
":",
"# Load a pretty-printed XML fixture with Nulls.",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'pretty.xml'",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"S... | [
125,
4
] | [
137,
60
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_absolute_path | (self) |
Regression test for ticket #6436 --
os.path.join will throw away the initial parts of a path if it
encounters an absolute path.
This means that if a fixture is specified as an absolute path,
we need to make sure we don't discover the absolute path in every
fixture direct... |
Regression test for ticket #6436 --
os.path.join will throw away the initial parts of a path if it
encounters an absolute path.
This means that if a fixture is specified as an absolute path,
we need to make sure we don't discover the absolute path in every
fixture direct... | def test_absolute_path(self):
"""
Regression test for ticket #6436 --
os.path.join will throw away the initial parts of a path if it
encounters an absolute path.
This means that if a fixture is specified as an absolute path,
we need to make sure we don't discover the abso... | [
"def",
"test_absolute_path",
"(",
"self",
")",
":",
"load_absolute_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"upath",
"(",
"__file__",
")",
")",
",",
"'fixtures'",
",",
"'absolute.json'",
")",
"management",
... | [
139,
4
] | [
158,
53
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_unknown_format | (self) |
Test for ticket #4371 -- Loading data of an unknown format should fail
Validate that error conditions are caught correctly
|
Test for ticket #4371 -- Loading data of an unknown format should fail
Validate that error conditions are caught correctly
| def test_unknown_format(self):
"""
Test for ticket #4371 -- Loading data of an unknown format should fail
Validate that error conditions are caught correctly
"""
with six.assertRaisesRegex(self, management.CommandError,
"Problem installing fixture 'bad_fixture1': ... | [
"def",
"test_unknown_format",
"(",
"self",
")",
":",
"with",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"management",
".",
"CommandError",
",",
"\"Problem installing fixture 'bad_fixture1': \"",
"\"unkn is not a known serialization format.\"",
")",
":",
"management"... | [
186,
4
] | [
198,
13
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_unimportable_serializer | (self) |
Test that failing serializer import raises the proper error
|
Test that failing serializer import raises the proper error
| def test_unimportable_serializer(self):
"""
Test that failing serializer import raises the proper error
"""
with six.assertRaisesRegex(self, ImportError,
r"No module named.*unexistent"):
management.call_command(
'loaddata',
'bad... | [
"def",
"test_unimportable_serializer",
"(",
"self",
")",
":",
"with",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"ImportError",
",",
"r\"No module named.*unexistent\"",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'bad_fixture1.unkn'",... | [
201,
4
] | [
211,
13
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_invalid_data | (self) |
Test for ticket #4371 -- Loading a fixture file with invalid data
using explicit filename.
Test for ticket #18213 -- warning conditions are caught correctly
|
Test for ticket #4371 -- Loading a fixture file with invalid data
using explicit filename.
Test for ticket #18213 -- warning conditions are caught correctly
| def test_invalid_data(self):
"""
Test for ticket #4371 -- Loading a fixture file with invalid data
using explicit filename.
Test for ticket #18213 -- warning conditions are caught correctly
"""
with warnings.catch_warnings(record=True) as warning_list:
warning... | [
"def",
"test_invalid_data",
"(",
"self",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
"record",
"=",
"True",
")",
"as",
"warning_list",
":",
"warnings",
".",
"simplefilter",
"(",
"\"always\"",
")",
"management",
".",
"call_command",
"(",
"'loaddat... | [
213,
4
] | [
228,
125
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_invalid_data_no_ext | (self) |
Test for ticket #4371 -- Loading a fixture file with invalid data
without file extension.
Test for ticket #18213 -- warning conditions are caught correctly
|
Test for ticket #4371 -- Loading a fixture file with invalid data
without file extension.
Test for ticket #18213 -- warning conditions are caught correctly
| def test_invalid_data_no_ext(self):
"""
Test for ticket #4371 -- Loading a fixture file with invalid data
without file extension.
Test for ticket #18213 -- warning conditions are caught correctly
"""
with warnings.catch_warnings(record=True) as warning_list:
w... | [
"def",
"test_invalid_data_no_ext",
"(",
"self",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
"record",
"=",
"True",
")",
"as",
"warning_list",
":",
"warnings",
".",
"simplefilter",
"(",
"\"always\"",
")",
"management",
".",
"call_command",
"(",
"'... | [
230,
4
] | [
245,
125
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_empty | (self) |
Test for ticket #18213 -- Loading a fixture file with no data output a warning.
Previously empty fixture raises an error exception, see ticket #4371.
|
Test for ticket #18213 -- Loading a fixture file with no data output a warning.
Previously empty fixture raises an error exception, see ticket #4371.
| def test_empty(self):
"""
Test for ticket #18213 -- Loading a fixture file with no data output a warning.
Previously empty fixture raises an error exception, see ticket #4371.
"""
with warnings.catch_warnings(record=True) as warning_list:
warnings.simplefilter("always... | [
"def",
"test_empty",
"(",
"self",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
"record",
"=",
"True",
")",
"as",
"warning_list",
":",
"warnings",
".",
"simplefilter",
"(",
"\"always\"",
")",
"management",
".",
"call_command",
"(",
"'loaddata'",
... | [
247,
4
] | [
261,
118
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_error_message | (self) |
Regression for #9011 - error message is correct.
Change from error to warning for ticket #18213.
|
Regression for #9011 - error message is correct.
Change from error to warning for ticket #18213.
| def test_error_message(self):
"""
Regression for #9011 - error message is correct.
Change from error to warning for ticket #18213.
"""
with warnings.catch_warnings(record=True) as warning_list:
warnings.simplefilter("always")
management.call_command(
... | [
"def",
"test_error_message",
"(",
"self",
")",
":",
"with",
"warnings",
".",
"catch_warnings",
"(",
"record",
"=",
"True",
")",
"as",
"warning_list",
":",
"warnings",
".",
"simplefilter",
"(",
"\"always\"",
")",
"management",
".",
"call_command",
"(",
"'loadda... | [
263,
4
] | [
278,
125
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_pg_sequence_resetting_checks | (self) |
Test for ticket #7565 -- PostgreSQL sequence resetting checks shouldn't
ascend to parent models when inheritance is used
(since they are treated individually).
|
Test for ticket #7565 -- PostgreSQL sequence resetting checks shouldn't
ascend to parent models when inheritance is used
(since they are treated individually).
| def test_pg_sequence_resetting_checks(self):
"""
Test for ticket #7565 -- PostgreSQL sequence resetting checks shouldn't
ascend to parent models when inheritance is used
(since they are treated individually).
"""
management.call_command(
'loaddata',
... | [
"def",
"test_pg_sequence_resetting_checks",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'model-inheritance.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"Parent",
".",
"objects",
".",
"all",... | [
280,
4
] | [
292,
54
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_close_connection_after_loaddata | (self) |
Test for ticket #7572 -- MySQL has a problem if the same connection is
used to create tables, load data, and then query over that data.
To compensate, we close the connection after running loaddata.
This ensures that a new connection is opened when test queries are
issued.
... |
Test for ticket #7572 -- MySQL has a problem if the same connection is
used to create tables, load data, and then query over that data.
To compensate, we close the connection after running loaddata.
This ensures that a new connection is opened when test queries are
issued.
... | def test_close_connection_after_loaddata(self):
"""
Test for ticket #7572 -- MySQL has a problem if the same connection is
used to create tables, load data, and then query over that data.
To compensate, we close the connection after running loaddata.
This ensures that a new conne... | [
"def",
"test_close_connection_after_loaddata",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'big-fixture.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"articles",
"=",
"Article",
".",
"objects",
".",
"exclude",
"(",
"id",
... | [
294,
4
] | [
318,
9
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_field_value_coerce | (self) |
Test for tickets #8298, #9942 - Field values should be coerced into the
correct type by the deserializer, not as part of the database write.
|
Test for tickets #8298, #9942 - Field values should be coerced into the
correct type by the deserializer, not as part of the database write.
| def test_field_value_coerce(self):
"""
Test for tickets #8298, #9942 - Field values should be coerced into the
correct type by the deserializer, not as part of the database write.
"""
self.pre_save_checks = []
signals.pre_save.connect(self.animal_pre_save_check)
t... | [
"def",
"test_field_value_coerce",
"(",
"self",
")",
":",
"self",
".",
"pre_save_checks",
"=",
"[",
"]",
"signals",
".",
"pre_save",
".",
"connect",
"(",
"self",
".",
"animal_pre_save_check",
")",
"try",
":",
"management",
".",
"call_command",
"(",
"'loaddata'"... | [
320,
4
] | [
341,
67
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_dumpdata_uses_default_manager | (self) |
Regression for #11286
Ensure that dumpdata honors the default manager
Dump the current contents of the database as a JSON fixture
|
Regression for #11286
Ensure that dumpdata honors the default manager
Dump the current contents of the database as a JSON fixture
| def test_dumpdata_uses_default_manager(self):
"""
Regression for #11286
Ensure that dumpdata honors the default manager
Dump the current contents of the database as a JSON fixture
"""
management.call_command(
'loaddata',
'animal.xml',
v... | [
"def",
"test_dumpdata_uses_default_manager",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'animal.xml'",
",",
"verbosity",
"=",
"0",
",",
")",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'sequence.json'",
",",
... | [
343,
4
] | [
391,
44
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_proxy_model_included | (self) |
Regression for #11428 - Proxy models aren't included when you dumpdata
|
Regression for #11428 - Proxy models aren't included when you dumpdata
| def test_proxy_model_included(self):
"""
Regression for #11428 - Proxy models aren't included when you dumpdata
"""
stdout = StringIO()
# Create an instance of the concrete class
widget = Widget.objects.create(name='grommet')
management.call_command(
'... | [
"def",
"test_proxy_model_included",
"(",
"self",
")",
":",
"stdout",
"=",
"StringIO",
"(",
")",
"# Create an instance of the concrete class",
"widget",
"=",
"Widget",
".",
"objects",
".",
"create",
"(",
"name",
"=",
"'grommet'",
")",
"management",
".",
"call_comma... | [
393,
4
] | [
411,
9
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_loaddata_works_when_fixture_has_forward_refs | (self) |
Regression for #3615 - Forward references cause fixtures not to load in MySQL (InnoDB)
|
Regression for #3615 - Forward references cause fixtures not to load in MySQL (InnoDB)
| def test_loaddata_works_when_fixture_has_forward_refs(self):
"""
Regression for #3615 - Forward references cause fixtures not to load in MySQL (InnoDB)
"""
management.call_command(
'loaddata',
'forward_ref.json',
verbosity=0,
)
self.ass... | [
"def",
"test_loaddata_works_when_fixture_has_forward_refs",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'forward_ref.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"Book",
".",
"objects",
".",
... | [
414,
4
] | [
424,
55
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_loaddata_raises_error_when_fixture_has_invalid_foreign_key | (self) |
Regression for #3615 - Ensure data with nonexistent child key references raises error
|
Regression for #3615 - Ensure data with nonexistent child key references raises error
| def test_loaddata_raises_error_when_fixture_has_invalid_foreign_key(self):
"""
Regression for #3615 - Ensure data with nonexistent child key references raises error
"""
with six.assertRaisesRegex(self, IntegrityError,
"Problem installing fixture"):
management.... | [
"def",
"test_loaddata_raises_error_when_fixture_has_invalid_foreign_key",
"(",
"self",
")",
":",
"with",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"IntegrityError",
",",
"\"Problem installing fixture\"",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddat... | [
426,
4
] | [
436,
13
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_loaddata_forward_refs_split_fixtures | (self) |
Regression for #17530 - should be able to cope with forward references
when the fixtures are not in the same files or directories.
|
Regression for #17530 - should be able to cope with forward references
when the fixtures are not in the same files or directories.
| def test_loaddata_forward_refs_split_fixtures(self):
"""
Regression for #17530 - should be able to cope with forward references
when the fixtures are not in the same files or directories.
"""
management.call_command(
'loaddata',
'forward_ref_1.json',
... | [
"def",
"test_loaddata_forward_refs_split_fixtures",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'forward_ref_1.json'",
",",
"'forward_ref_2.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"Book",
... | [
441,
4
] | [
453,
55
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_loaddata_no_fixture_specified | (self) |
Regression for #7043 - Error is quickly reported when no fixtures is provided in the command line.
|
Regression for #7043 - Error is quickly reported when no fixtures is provided in the command line.
| def test_loaddata_no_fixture_specified(self):
"""
Regression for #7043 - Error is quickly reported when no fixtures is provided in the command line.
"""
with six.assertRaisesRegex(self, management.CommandError,
"No database fixture specified. Please provide the path of "
... | [
"def",
"test_loaddata_no_fixture_specified",
"(",
"self",
")",
":",
"with",
"six",
".",
"assertRaisesRegex",
"(",
"self",
",",
"management",
".",
"CommandError",
",",
"\"No database fixture specified. Please provide the path of \"",
"\"at least one fixture in the command line.\""... | [
455,
4
] | [
465,
13
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_ticket_20820 | (self) |
Regression for ticket #20820 -- loaddata on a model that inherits
from a model with a M2M shouldn't blow up.
|
Regression for ticket #20820 -- loaddata on a model that inherits
from a model with a M2M shouldn't blow up.
| def test_ticket_20820(self):
"""
Regression for ticket #20820 -- loaddata on a model that inherits
from a model with a M2M shouldn't blow up.
"""
management.call_command(
'loaddata',
'special-article.json',
verbosity=0,
) | [
"def",
"test_ticket_20820",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'special-article.json'",
",",
"verbosity",
"=",
"0",
",",
")"
] | [
479,
4
] | [
488,
9
] | python | en | ['en', 'error', 'th'] | False |
TestFixtures.test_ticket_22421 | (self) |
Regression for ticket #22421 -- loaddata on a model that inherits from
a grand-parent model with a M2M but via an abstract parent shouldn't
blow up.
|
Regression for ticket #22421 -- loaddata on a model that inherits from
a grand-parent model with a M2M but via an abstract parent shouldn't
blow up.
| def test_ticket_22421(self):
"""
Regression for ticket #22421 -- loaddata on a model that inherits from
a grand-parent model with a M2M but via an abstract parent shouldn't
blow up.
"""
management.call_command(
'loaddata',
'feature.json',
... | [
"def",
"test_ticket_22421",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'feature.json'",
",",
"verbosity",
"=",
"0",
",",
")"
] | [
490,
4
] | [
500,
9
] | python | en | ['en', 'error', 'th'] | False |
NaturalKeyFixtureTests.test_nk_deserialize | (self) |
Test for ticket #13030 - Python based parser version
natural keys deserialize with fk to inheriting model
|
Test for ticket #13030 - Python based parser version
natural keys deserialize with fk to inheriting model
| def test_nk_deserialize(self):
"""
Test for ticket #13030 - Python based parser version
natural keys deserialize with fk to inheriting model
"""
management.call_command(
'loaddata',
'model-inheritance.json',
verbosity=0,
)
manag... | [
"def",
"test_nk_deserialize",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'model-inheritance.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'nk-inheritance.json'",
",... | [
505,
4
] | [
528,
9
] | python | en | ['en', 'error', 'th'] | False |
NaturalKeyFixtureTests.test_nk_deserialize_xml | (self) |
Test for ticket #13030 - XML version
natural keys deserialize with fk to inheriting model
|
Test for ticket #13030 - XML version
natural keys deserialize with fk to inheriting model
| def test_nk_deserialize_xml(self):
"""
Test for ticket #13030 - XML version
natural keys deserialize with fk to inheriting model
"""
management.call_command(
'loaddata',
'model-inheritance.json',
verbosity=0,
)
management.call_c... | [
"def",
"test_nk_deserialize_xml",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'model-inheritance.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'nk-inheritance.json'",
... | [
530,
4
] | [
557,
9
] | python | en | ['en', 'error', 'th'] | False |
NaturalKeyFixtureTests.test_nk_on_serialize | (self) |
Check that natural key requirements are taken into account
when serializing models
|
Check that natural key requirements are taken into account
when serializing models
| def test_nk_on_serialize(self):
"""
Check that natural key requirements are taken into account
when serializing models
"""
management.call_command(
'loaddata',
'forward_ref_lookup.json',
verbosity=0,
)
stdout = StringIO()
... | [
"def",
"test_nk_on_serialize",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'forward_ref_lookup.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"stdout",
"=",
"StringIO",
"(",
")",
"management",
".",
"call_command",
"(",
"'d... | [
559,
4
] | [
585,
9
] | python | en | ['en', 'error', 'th'] | False |
NaturalKeyFixtureTests.test_dependency_sorting | (self) |
Now lets check the dependency sorting explicitly
It doesn't matter what order you mention the models
Store *must* be serialized before then Person, and both
must be serialized before Book.
|
Now lets check the dependency sorting explicitly
It doesn't matter what order you mention the models
Store *must* be serialized before then Person, and both
must be serialized before Book.
| def test_dependency_sorting(self):
"""
Now lets check the dependency sorting explicitly
It doesn't matter what order you mention the models
Store *must* be serialized before then Person, and both
must be serialized before Book.
"""
sorted_deps = sort_dependencies(... | [
"def",
"test_dependency_sorting",
"(",
"self",
")",
":",
"sorted_deps",
"=",
"sort_dependencies",
"(",
"[",
"(",
"'fixtures_regress'",
",",
"[",
"Book",
",",
"Person",
",",
"Store",
"]",
")",
"]",
")",
"self",
".",
"assertEqual",
"(",
"sorted_deps",
",",
"... | [
587,
4
] | [
600,
9
] | python | en | ['en', 'error', 'th'] | False |
NaturalKeyFixtureTests.test_normal_pk | (self) |
Check that normal primary keys still work
on a model with natural key capabilities
|
Check that normal primary keys still work
on a model with natural key capabilities
| def test_normal_pk(self):
"""
Check that normal primary keys still work
on a model with natural key capabilities
"""
management.call_command(
'loaddata',
'non_natural_1.json',
verbosity=0,
)
management.call_command(
... | [
"def",
"test_normal_pk",
"(",
"self",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'non_natural_1.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'forward_ref_lookup.json'",
",",
... | [
697,
4
] | [
721,
9
] | python | en | ['en', 'error', 'th'] | False |
M2MNaturalKeyFixtureTests.test_dependency_sorting_m2m_simple | (self) |
M2M relations without explicit through models SHOULD count as dependencies
Regression test for bugs that could be caused by flawed fixes to
#14226, namely if M2M checks are removed from sort_dependencies
altogether.
|
M2M relations without explicit through models SHOULD count as dependencies | def test_dependency_sorting_m2m_simple(self):
"""
M2M relations without explicit through models SHOULD count as dependencies
Regression test for bugs that could be caused by flawed fixes to
#14226, namely if M2M checks are removed from sort_dependencies
altogether.
"""
... | [
"def",
"test_dependency_sorting_m2m_simple",
"(",
"self",
")",
":",
"sorted_deps",
"=",
"sort_dependencies",
"(",
"[",
"(",
"'fixtures_regress'",
",",
"[",
"M2MSimpleA",
",",
"M2MSimpleB",
"]",
")",
"]",
")",
"self",
".",
"assertEqual",
"(",
"sorted_deps",
",",
... | [
727,
4
] | [
738,
63
] | python | en | ['en', 'error', 'th'] | False |
M2MNaturalKeyFixtureTests.test_dependency_sorting_m2m_simple_circular | (self) |
Resolving circular M2M relations without explicit through models should
fail loudly
|
Resolving circular M2M relations without explicit through models should
fail loudly
| def test_dependency_sorting_m2m_simple_circular(self):
"""
Resolving circular M2M relations without explicit through models should
fail loudly
"""
self.assertRaisesMessage(
CommandError,
"Can't resolve dependencies for fixtures_regress.M2MSimpleCircularA, ... | [
"def",
"test_dependency_sorting_m2m_simple_circular",
"(",
"self",
")",
":",
"self",
".",
"assertRaisesMessage",
"(",
"CommandError",
",",
"\"Can't resolve dependencies for fixtures_regress.M2MSimpleCircularA, \"",
"\"fixtures_regress.M2MSimpleCircularB in serialized app list.\"",
",",
... | [
740,
4
] | [
751,
9
] | python | en | ['en', 'error', 'th'] | False |
M2MNaturalKeyFixtureTests.test_dependency_sorting_m2m_complex | (self) |
M2M relations with explicit through models should NOT count as
dependencies. The through model itself will have dependencies, though.
|
M2M relations with explicit through models should NOT count as
dependencies. The through model itself will have dependencies, though.
| def test_dependency_sorting_m2m_complex(self):
"""
M2M relations with explicit through models should NOT count as
dependencies. The through model itself will have dependencies, though.
"""
sorted_deps = sort_dependencies(
[('fixtures_regress', [M2MComplexA, M2MComple... | [
"def",
"test_dependency_sorting_m2m_complex",
"(",
"self",
")",
":",
"sorted_deps",
"=",
"sort_dependencies",
"(",
"[",
"(",
"'fixtures_regress'",
",",
"[",
"M2MComplexA",
",",
"M2MComplexB",
",",
"M2MThroughAB",
"]",
")",
"]",
")",
"# Order between M2MComplexA and M2... | [
753,
4
] | [
763,
55
] | python | en | ['en', 'error', 'th'] | False |
M2MNaturalKeyFixtureTests.test_dependency_sorting_m2m_complex_circular_1 | (self) |
Circular M2M relations with explicit through models should be serializable
|
Circular M2M relations with explicit through models should be serializable
| def test_dependency_sorting_m2m_complex_circular_1(self):
"""
Circular M2M relations with explicit through models should be serializable
"""
A, B, C, AtoB, BtoC, CtoA = (M2MComplexCircular1A, M2MComplexCircular1B,
M2MComplexCircular1C, M2MCircular1Thr... | [
"def",
"test_dependency_sorting_m2m_complex_circular_1",
"(",
"self",
")",
":",
"A",
",",
"B",
",",
"C",
",",
"AtoB",
",",
"BtoC",
",",
"CtoA",
"=",
"(",
"M2MComplexCircular1A",
",",
"M2MComplexCircular1B",
",",
"M2MComplexCircular1C",
",",
"M2MCircular1ThroughAB",
... | [
765,
4
] | [
785,
61
] | python | en | ['en', 'error', 'th'] | False |
M2MNaturalKeyFixtureTests.test_dependency_sorting_m2m_complex_circular_2 | (self) |
Circular M2M relations with explicit through models should be serializable
This test tests the circularity with explicit natural_key.dependencies
|
Circular M2M relations with explicit through models should be serializable
This test tests the circularity with explicit natural_key.dependencies
| def test_dependency_sorting_m2m_complex_circular_2(self):
"""
Circular M2M relations with explicit through models should be serializable
This test tests the circularity with explicit natural_key.dependencies
"""
try:
sorted_deps = sort_dependencies([
(... | [
"def",
"test_dependency_sorting_m2m_complex_circular_2",
"(",
"self",
")",
":",
"try",
":",
"sorted_deps",
"=",
"sort_dependencies",
"(",
"[",
"(",
"'fixtures_regress'",
",",
"[",
"M2MComplexCircular2A",
",",
"M2MComplexCircular2B",
",",
"M2MCircular2ThroughAB",
"]",
")... | [
787,
4
] | [
804,
66
] | python | en | ['en', 'error', 'th'] | False |
M2MNaturalKeyFixtureTests.test_dump_and_load_m2m_simple | (self) |
Test serializing and deserializing back models with simple M2M relations
|
Test serializing and deserializing back models with simple M2M relations
| def test_dump_and_load_m2m_simple(self):
"""
Test serializing and deserializing back models with simple M2M relations
"""
a = M2MSimpleA.objects.create(data="a")
b1 = M2MSimpleB.objects.create(data="b1")
b2 = M2MSimpleB.objects.create(data="b2")
a.b_set.add(b1)
... | [
"def",
"test_dump_and_load_m2m_simple",
"(",
"self",
")",
":",
"a",
"=",
"M2MSimpleA",
".",
"objects",
".",
"create",
"(",
"data",
"=",
"\"a\"",
")",
"b1",
"=",
"M2MSimpleB",
".",
"objects",
".",
"create",
"(",
"data",
"=",
"\"b1\"",
")",
"b2",
"=",
"M... | [
806,
4
] | [
836,
25
] | python | en | ['en', 'error', 'th'] | False |
TestTicket11101.test_ticket_11101 | (self) | Test that fixtures can be rolled back (ticket #11101). | Test that fixtures can be rolled back (ticket #11101). | def test_ticket_11101(self):
"""Test that fixtures can be rolled back (ticket #11101)."""
with transaction.atomic():
management.call_command(
'loaddata',
'thingy.json',
verbosity=0,
)
self.assertEqual(Thingy.objects.coun... | [
"def",
"test_ticket_11101",
"(",
"self",
")",
":",
"with",
"transaction",
".",
"atomic",
"(",
")",
":",
"management",
".",
"call_command",
"(",
"'loaddata'",
",",
"'thingy.json'",
",",
"verbosity",
"=",
"0",
",",
")",
"self",
".",
"assertEqual",
"(",
"Thin... | [
848,
4
] | [
858,
51
] | python | en | ['en', 'en', 'en'] | True |
parse_html | (html) |
Takes a string that contains *valid* HTML and turns it into a Python object
structure that can be easily compared against other HTML on semantic
equivalence. Syntactical differences like which quotation is used on
arguments will be ignored.
|
Takes a string that contains *valid* HTML and turns it into a Python object
structure that can be easily compared against other HTML on semantic
equivalence. Syntactical differences like which quotation is used on
arguments will be ignored. | def parse_html(html):
"""
Takes a string that contains *valid* HTML and turns it into a Python object
structure that can be easily compared against other HTML on semantic
equivalence. Syntactical differences like which quotation is used on
arguments will be ignored.
"""
parser = Parser()
... | [
"def",
"parse_html",
"(",
"html",
")",
":",
"parser",
"=",
"Parser",
"(",
")",
"parser",
".",
"feed",
"(",
"html",
")",
"parser",
".",
"close",
"(",
")",
"document",
"=",
"parser",
".",
"root",
"document",
".",
"finalize",
"(",
")",
"# Removing ROOT el... | [
220,
0
] | [
237,
19
] | python | en | ['en', 'error', 'th'] | False |
register_uuid | (oids=None, conn_or_curs=None) | Create the UUID type and an uuid.UUID adapter.
:param oids: oid for the PostgreSQL :sql:`uuid` type, or 2-items sequence
with oids of the type and the array. If not specified, use PostgreSQL
standard oids.
:param conn_or_curs: where to register the typecaster. If not specified,
register... | Create the UUID type and an uuid.UUID adapter. | def register_uuid(oids=None, conn_or_curs=None):
"""Create the UUID type and an uuid.UUID adapter.
:param oids: oid for the PostgreSQL :sql:`uuid` type, or 2-items sequence
with oids of the type and the array. If not specified, use PostgreSQL
standard oids.
:param conn_or_curs: where to reg... | [
"def",
"register_uuid",
"(",
"oids",
"=",
"None",
",",
"conn_or_curs",
"=",
"None",
")",
":",
"import",
"uuid",
"if",
"not",
"oids",
":",
"oid1",
"=",
"2950",
"oid2",
"=",
"2951",
"elif",
"isinstance",
"(",
"oids",
",",
"(",
"list",
",",
"tuple",
")"... | [
663,
0
] | [
692,
20
] | python | en | ['en', 'tg', 'en'] | True |
register_inet | (oid=None, conn_or_curs=None) | Create the INET type and an Inet adapter.
:param oid: oid for the PostgreSQL :sql:`inet` type, or 2-items sequence
with oids of the type and the array. If not specified, use PostgreSQL
standard oids.
:param conn_or_curs: where to register the typecaster. If not specified,
register it gl... | Create the INET type and an Inet adapter. | def register_inet(oid=None, conn_or_curs=None):
"""Create the INET type and an Inet adapter.
:param oid: oid for the PostgreSQL :sql:`inet` type, or 2-items sequence
with oids of the type and the array. If not specified, use PostgreSQL
standard oids.
:param conn_or_curs: where to register t... | [
"def",
"register_inet",
"(",
"oid",
"=",
"None",
",",
"conn_or_curs",
"=",
"None",
")",
":",
"import",
"warnings",
"warnings",
".",
"warn",
"(",
"\"the inet adapter is deprecated, it's not very useful\"",
",",
"DeprecationWarning",
")",
"if",
"not",
"oid",
":",
"o... | [
728,
0
] | [
758,
20
] | python | en | ['en', 'en', 'en'] | True |
wait_select | (conn) | Wait until a connection or cursor has data available.
The function is an example of a wait callback to be registered with
`~psycopg2.extensions.set_wait_callback()`. This function uses
:py:func:`~select.select()` to wait for data to become available, and
therefore is able to handle/receive SIGINT/Keybo... | Wait until a connection or cursor has data available. | def wait_select(conn):
"""Wait until a connection or cursor has data available.
The function is an example of a wait callback to be registered with
`~psycopg2.extensions.set_wait_callback()`. This function uses
:py:func:`~select.select()` to wait for data to become available, and
therefore is able ... | [
"def",
"wait_select",
"(",
"conn",
")",
":",
"import",
"select",
"from",
"psycopg2",
".",
"extensions",
"import",
"POLL_OK",
",",
"POLL_READ",
",",
"POLL_WRITE",
"while",
"True",
":",
"try",
":",
"state",
"=",
"conn",
".",
"poll",
"(",
")",
"if",
"state"... | [
761,
0
] | [
786,
20
] | python | en | ['en', 'en', 'en'] | True |
_solve_conn_curs | (conn_or_curs) | Return the connection and a DBAPI cursor from a connection or cursor. | Return the connection and a DBAPI cursor from a connection or cursor. | def _solve_conn_curs(conn_or_curs):
"""Return the connection and a DBAPI cursor from a connection or cursor."""
if conn_or_curs is None:
raise psycopg2.ProgrammingError("no connection or cursor provided")
if hasattr(conn_or_curs, 'execute'):
conn = conn_or_curs.connection
curs = con... | [
"def",
"_solve_conn_curs",
"(",
"conn_or_curs",
")",
":",
"if",
"conn_or_curs",
"is",
"None",
":",
"raise",
"psycopg2",
".",
"ProgrammingError",
"(",
"\"no connection or cursor provided\"",
")",
"if",
"hasattr",
"(",
"conn_or_curs",
",",
"'execute'",
")",
":",
"co... | [
789,
0
] | [
801,
21
] | python | en | ['en', 'en', 'en'] | True |
register_hstore | (conn_or_curs, globally=False, unicode=False,
oid=None, array_oid=None) | r"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions.
:param conn_or_curs: a connection or cursor: the typecaster will be
registered only on this object unless *globally* is set to `!True`
:param globally: register the adapter globally, not only on *conn_or_curs*
:param unicode: ... | r"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions. | def register_hstore(conn_or_curs, globally=False, unicode=False,
oid=None, array_oid=None):
r"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions.
:param conn_or_curs: a connection or cursor: the typecaster will be
registered only on this object unless *globally* i... | [
"def",
"register_hstore",
"(",
"conn_or_curs",
",",
"globally",
"=",
"False",
",",
"unicode",
"=",
"False",
",",
"oid",
"=",
"None",
",",
"array_oid",
"=",
"None",
")",
":",
"if",
"oid",
"is",
"None",
":",
"oid",
"=",
"HstoreAdapter",
".",
"get_oids",
... | [
941,
0
] | [
1003,
78
] | python | en | ['en', 'en', 'en'] | True |
register_composite | (name, conn_or_curs, globally=False, factory=None) | Register a typecaster to convert a composite type into a tuple.
:param name: the name of a PostgreSQL composite type, e.g. created using
the |CREATE TYPE|_ command
:param conn_or_curs: a connection or cursor used to find the type oid and
components; the typecaster is registered in a scope limit... | Register a typecaster to convert a composite type into a tuple. | def register_composite(name, conn_or_curs, globally=False, factory=None):
"""Register a typecaster to convert a composite type into a tuple.
:param name: the name of a PostgreSQL composite type, e.g. created using
the |CREATE TYPE|_ command
:param conn_or_curs: a connection or cursor used to find t... | [
"def",
"register_composite",
"(",
"name",
",",
"conn_or_curs",
",",
"globally",
"=",
"False",
",",
"factory",
"=",
"None",
")",
":",
"if",
"factory",
"is",
"None",
":",
"factory",
"=",
"CompositeCaster",
"caster",
"=",
"factory",
".",
"_from_db",
"(",
"nam... | [
1136,
0
] | [
1161,
17
] | python | en | ['en', 'en', 'en'] | True |
_paginate | (seq, page_size) | Consume an iterable and return it in chunks.
Every chunk is at most `page_size`. Never return an empty chunk.
| Consume an iterable and return it in chunks. | def _paginate(seq, page_size):
"""Consume an iterable and return it in chunks.
Every chunk is at most `page_size`. Never return an empty chunk.
"""
page = []
it = iter(seq)
while True:
try:
for i in range(page_size):
page.append(next(it))
yield pa... | [
"def",
"_paginate",
"(",
"seq",
",",
"page_size",
")",
":",
"page",
"=",
"[",
"]",
"it",
"=",
"iter",
"(",
"seq",
")",
"while",
"True",
":",
"try",
":",
"for",
"i",
"in",
"range",
"(",
"page_size",
")",
":",
"page",
".",
"append",
"(",
"next",
... | [
1164,
0
] | [
1180,
18
] | python | en | ['en', 'en', 'en'] | True |
execute_batch | (cur, sql, argslist, page_size=100) | r"""Execute groups of statements in fewer server roundtrips.
Execute *sql* several times, against all parameters set (sequences or
mappings) found in *argslist*.
The function is semantically similar to
.. parsed-literal::
*cur*\.\ `~cursor.executemany`\ (\ *sql*\ , *argslist*\ )
but has... | r"""Execute groups of statements in fewer server roundtrips. | def execute_batch(cur, sql, argslist, page_size=100):
r"""Execute groups of statements in fewer server roundtrips.
Execute *sql* several times, against all parameters set (sequences or
mappings) found in *argslist*.
The function is semantically similar to
.. parsed-literal::
*cur*\.\ `~c... | [
"def",
"execute_batch",
"(",
"cur",
",",
"sql",
",",
"argslist",
",",
"page_size",
"=",
"100",
")",
":",
"for",
"page",
"in",
"_paginate",
"(",
"argslist",
",",
"page_size",
"=",
"page_size",
")",
":",
"sqls",
"=",
"[",
"cur",
".",
"mogrify",
"(",
"s... | [
1183,
0
] | [
1205,
36
] | python | en | ['en', 'en', 'en'] | True |
execute_values | (cur, sql, argslist, template=None, page_size=100, fetch=False) | Execute a statement using :sql:`VALUES` with a sequence of parameters.
:param cur: the cursor to use to execute the query.
:param sql: the query to execute. It must contain a single ``%s``
placeholder, which will be replaced by a `VALUES list`__.
Example: ``"INSERT INTO mytable (id, f1, f2) VA... | Execute a statement using :sql:`VALUES` with a sequence of parameters. | def execute_values(cur, sql, argslist, template=None, page_size=100, fetch=False):
'''Execute a statement using :sql:`VALUES` with a sequence of parameters.
:param cur: the cursor to use to execute the query.
:param sql: the query to execute. It must contain a single ``%s``
placeholder, which will... | [
"def",
"execute_values",
"(",
"cur",
",",
"sql",
",",
"argslist",
",",
"template",
"=",
"None",
",",
"page_size",
"=",
"100",
",",
"fetch",
"=",
"False",
")",
":",
"from",
"psycopg2",
".",
"sql",
"import",
"Composable",
"if",
"isinstance",
"(",
"sql",
... | [
1208,
0
] | [
1292,
17
] | python | en | ['en', 'en', 'en'] | True |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.