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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
Polygon.__iter__ | (self) | Iterate over each ring in the polygon. | Iterate over each ring in the polygon. | def __iter__(self):
"Iterate over each ring in the polygon."
for i in range(len(self)):
yield self[i] | [
"def",
"__iter__",
"(",
"self",
")",
":",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
":",
"yield",
"self",
"[",
"i",
"]"
] | [
48,
4
] | [
51,
25
] | python | en | ['en', 'en', 'en'] | True |
Polygon.__len__ | (self) | Return the number of rings in this Polygon. | Return the number of rings in this Polygon. | def __len__(self):
"Return the number of rings in this Polygon."
return self.num_interior_rings + 1 | [
"def",
"__len__",
"(",
"self",
")",
":",
"return",
"self",
".",
"num_interior_rings",
"+",
"1"
] | [
53,
4
] | [
55,
42
] | python | en | ['en', 'en', 'en'] | True |
Polygon.from_bbox | (cls, bbox) | Construct a Polygon from a bounding box (4-tuple). | Construct a Polygon from a bounding box (4-tuple). | def from_bbox(cls, bbox):
"Construct a Polygon from a bounding box (4-tuple)."
x0, y0, x1, y1 = bbox
for z in bbox:
if not isinstance(z, (float, int)):
return GEOSGeometry('POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))' %
(x0, y0, x0... | [
"def",
"from_bbox",
"(",
"cls",
",",
"bbox",
")",
":",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"bbox",
"for",
"z",
"in",
"bbox",
":",
"if",
"not",
"isinstance",
"(",
"z",
",",
"(",
"float",
",",
"int",
")",
")",
":",
"return",
"GEOSGeometry... | [
58,
4
] | [
65,
74
] | python | en | ['en', 'en', 'en'] | True |
Polygon._construct_ring | (self, param, msg=(
'Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings')) | Try to construct a ring from the given parameter. | Try to construct a ring from the given parameter. | def _construct_ring(self, param, msg=(
'Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings')):
"Try to construct a ring from the given parameter."
if isinstance(param, LinearRing):
return param
try:
ring = LinearRing(para... | [
"def",
"_construct_ring",
"(",
"self",
",",
"param",
",",
"msg",
"=",
"(",
"'Parameter must be a sequence of LinearRings or objects that can initialize to LinearRings'",
")",
")",
":",
"if",
"isinstance",
"(",
"param",
",",
"LinearRing",
")",
":",
"return",
"param",
"... | [
100,
4
] | [
109,
32
] | python | en | ['en', 'en', 'en'] | True |
Polygon._get_single_internal | (self, index) |
Return the ring at the specified index. The first index, 0, will
always return the exterior ring. Indices > 0 will return the
interior ring at the given index (e.g., poly[1] and poly[2] would
return the first and second interior ring, respectively).
CAREFUL: Internal/External ... |
Return the ring at the specified index. The first index, 0, will
always return the exterior ring. Indices > 0 will return the
interior ring at the given index (e.g., poly[1] and poly[2] would
return the first and second interior ring, respectively). | def _get_single_internal(self, index):
"""
Return the ring at the specified index. The first index, 0, will
always return the exterior ring. Indices > 0 will return the
interior ring at the given index (e.g., poly[1] and poly[2] would
return the first and second interior ring, r... | [
"def",
"_get_single_internal",
"(",
"self",
",",
"index",
")",
":",
"if",
"index",
"==",
"0",
":",
"return",
"capi",
".",
"get_extring",
"(",
"self",
".",
"ptr",
")",
"else",
":",
"# Getting the interior ring, have to subtract 1 from the index.",
"return",
"capi",... | [
121,
4
] | [
137,
56
] | python | en | ['en', 'error', 'th'] | False |
Polygon.num_interior_rings | (self) | Return the number of interior rings. | Return the number of interior rings. | def num_interior_rings(self):
"Return the number of interior rings."
# Getting the number of rings
return capi.get_nrings(self.ptr) | [
"def",
"num_interior_rings",
"(",
"self",
")",
":",
"# Getting the number of rings",
"return",
"capi",
".",
"get_nrings",
"(",
"self",
".",
"ptr",
")"
] | [
147,
4
] | [
150,
40
] | python | en | ['en', 'en', 'en'] | True |
Polygon._get_ext_ring | (self) | Get the exterior ring of the Polygon. | Get the exterior ring of the Polygon. | def _get_ext_ring(self):
"Get the exterior ring of the Polygon."
return self[0] | [
"def",
"_get_ext_ring",
"(",
"self",
")",
":",
"return",
"self",
"[",
"0",
"]"
] | [
152,
4
] | [
154,
22
] | python | en | ['en', 'en', 'en'] | True |
Polygon._set_ext_ring | (self, ring) | Set the exterior ring of the Polygon. | Set the exterior ring of the Polygon. | def _set_ext_ring(self, ring):
"Set the exterior ring of the Polygon."
self[0] = ring | [
"def",
"_set_ext_ring",
"(",
"self",
",",
"ring",
")",
":",
"self",
"[",
"0",
"]",
"=",
"ring"
] | [
156,
4
] | [
158,
22
] | python | en | ['en', 'en', 'en'] | True |
Polygon.tuple | (self) | Get the tuple for each ring in this Polygon. | Get the tuple for each ring in this Polygon. | def tuple(self):
"Get the tuple for each ring in this Polygon."
return tuple(self[i].tuple for i in range(len(self))) | [
"def",
"tuple",
"(",
"self",
")",
":",
"return",
"tuple",
"(",
"self",
"[",
"i",
"]",
".",
"tuple",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"self",
")",
")",
")"
] | [
165,
4
] | [
167,
61
] | python | en | ['en', 'en', 'en'] | True |
Polygon.kml | (self) | Return the KML representation of this Polygon. | Return the KML representation of this Polygon. | def kml(self):
"Return the KML representation of this Polygon."
inner_kml = ''.join(
"<innerBoundaryIs>%s</innerBoundaryIs>" % self[i + 1].kml
for i in range(self.num_interior_rings)
)
return "<Polygon><outerBoundaryIs>%s</outerBoundaryIs>%s</Polygon>" % (self[0].... | [
"def",
"kml",
"(",
"self",
")",
":",
"inner_kml",
"=",
"''",
".",
"join",
"(",
"\"<innerBoundaryIs>%s</innerBoundaryIs>\"",
"%",
"self",
"[",
"i",
"+",
"1",
"]",
".",
"kml",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"num_interior_rings",
")",
")",
"... | [
171,
4
] | [
177,
102
] | python | en | ['en', 'en', 'en'] | True |
HttpUtilTests.test_conditional_content_removal | (self) |
Tests that content is removed from regular and streaming responses with
a status_code of 100-199, 204, 304 or a method of "HEAD".
|
Tests that content is removed from regular and streaming responses with
a status_code of 100-199, 204, 304 or a method of "HEAD".
| def test_conditional_content_removal(self):
"""
Tests that content is removed from regular and streaming responses with
a status_code of 100-199, 204, 304 or a method of "HEAD".
"""
req = HttpRequest()
# Do nothing for 200 responses.
res = HttpResponse('abc')
... | [
"def",
"test_conditional_content_removal",
"(",
"self",
")",
":",
"req",
"=",
"HttpRequest",
"(",
")",
"# Do nothing for 200 responses.",
"res",
"=",
"HttpResponse",
"(",
"'abc'",
")",
"conditional_content_removal",
"(",
"req",
",",
"res",
")",
"self",
".",
"asser... | [
23,
4
] | [
70,
44
] | python | en | ['en', 'error', 'th'] | False |
HttpUtilTests.test_fix_location_without_get_host | (self) |
Tests that you can return an absolute redirect when the request
host is not in ALLOWED_HOSTS. Issue #20472
|
Tests that you can return an absolute redirect when the request
host is not in ALLOWED_HOSTS. Issue #20472
| def test_fix_location_without_get_host(self):
"""
Tests that you can return an absolute redirect when the request
host is not in ALLOWED_HOSTS. Issue #20472
"""
request = HttpRequest()
def bomb():
self.assertTrue(False)
request.get_host = bomb
... | [
"def",
"test_fix_location_without_get_host",
"(",
"self",
")",
":",
"request",
"=",
"HttpRequest",
"(",
")",
"def",
"bomb",
"(",
")",
":",
"self",
".",
"assertTrue",
"(",
"False",
")",
"request",
".",
"get_host",
"=",
"bomb",
"fix_location_header",
"(",
"req... | [
72,
4
] | [
82,
80
] | python | en | ['en', 'error', 'th'] | False |
AdminLogNodeTestCase.test_get_admin_log_templatetag_custom_user | (self) |
Regression test for ticket #20088: admin log depends on User model
having id field as primary key.
The old implementation raised an AttributeError when trying to use
the id field.
|
Regression test for ticket #20088: admin log depends on User model
having id field as primary key. | def test_get_admin_log_templatetag_custom_user(self):
"""
Regression test for ticket #20088: admin log depends on User model
having id field as primary key.
The old implementation raised an AttributeError when trying to use
the id field.
"""
context = Context({'u... | [
"def",
"test_get_admin_log_templatetag_custom_user",
"(",
"self",
")",
":",
"context",
"=",
"Context",
"(",
"{",
"'user'",
":",
"CustomIdUser",
"(",
")",
"}",
")",
"template_string",
"=",
"'{% load log %}{% get_admin_log 10 as admin_log for_user user %}'",
"template",
"="... | [
648,
4
] | [
663,
54
] | python | en | ['en', 'error', 'th'] | False |
Command._ipython_pre_011 | (self) | Start IPython pre-0.11 | Start IPython pre-0.11 | def _ipython_pre_011(self):
"""Start IPython pre-0.11"""
from IPython.Shell import IPShell
shell = IPShell(argv=[])
shell.mainloop() | [
"def",
"_ipython_pre_011",
"(",
"self",
")",
":",
"from",
"IPython",
".",
"Shell",
"import",
"IPShell",
"shell",
"=",
"IPShell",
"(",
"argv",
"=",
"[",
"]",
")",
"shell",
".",
"mainloop",
"(",
")"
] | [
18,
4
] | [
22,
24
] | python | de | ['en', 'de', 'hi'] | False |
Command._ipython_pre_100 | (self) | Start IPython pre-1.0.0 | Start IPython pre-1.0.0 | def _ipython_pre_100(self):
"""Start IPython pre-1.0.0"""
from IPython.frontend.terminal.ipapp import TerminalIPythonApp
app = TerminalIPythonApp.instance()
app.initialize(argv=[])
app.start() | [
"def",
"_ipython_pre_100",
"(",
"self",
")",
":",
"from",
"IPython",
".",
"frontend",
".",
"terminal",
".",
"ipapp",
"import",
"TerminalIPythonApp",
"app",
"=",
"TerminalIPythonApp",
".",
"instance",
"(",
")",
"app",
".",
"initialize",
"(",
"argv",
"=",
"[",... | [
24,
4
] | [
29,
19
] | python | en | ['en', 'de', 'en'] | True |
Command._ipython | (self) | Start IPython >= 1.0 | Start IPython >= 1.0 | def _ipython(self):
"""Start IPython >= 1.0"""
from IPython import start_ipython
start_ipython(argv=[]) | [
"def",
"_ipython",
"(",
"self",
")",
":",
"from",
"IPython",
"import",
"start_ipython",
"start_ipython",
"(",
"argv",
"=",
"[",
"]",
")"
] | [
31,
4
] | [
34,
30
] | python | en | ['en', 'ky', 'en'] | True |
Command.ipython | (self) | Start any version of IPython | Start any version of IPython | def ipython(self):
"""Start any version of IPython"""
for ip in (self._ipython, self._ipython_pre_100, self._ipython_pre_011):
try:
ip()
except ImportError:
pass
else:
return
# no IPython, raise ImportError
... | [
"def",
"ipython",
"(",
"self",
")",
":",
"for",
"ip",
"in",
"(",
"self",
".",
"_ipython",
",",
"self",
".",
"_ipython_pre_100",
",",
"self",
".",
"_ipython_pre_011",
")",
":",
"try",
":",
"ip",
"(",
")",
"except",
"ImportError",
":",
"pass",
"else",
... | [
36,
4
] | [
46,
39
] | python | en | ['en', 'ru-Latn', 'en'] | True |
str_to_display | (data, desc=None) |
For display or logging purposes, convert a bytes object (or text) to
text (e.g. unicode in Python 2) safe for output.
:param desc: An optional phrase describing the input data, for use in
the log message if a warning is logged. Defaults to "Bytes object".
This function should never error out ... |
For display or logging purposes, convert a bytes object (or text) to
text (e.g. unicode in Python 2) safe for output. | def str_to_display(data, desc=None):
# type: (Union[bytes, Text], Optional[str]) -> Text
"""
For display or logging purposes, convert a bytes object (or text) to
text (e.g. unicode in Python 2) safe for output.
:param desc: An optional phrase describing the input data, for use in
the log me... | [
"def",
"str_to_display",
"(",
"data",
",",
"desc",
"=",
"None",
")",
":",
"# type: (Union[bytes, Text], Optional[str]) -> Text",
"if",
"isinstance",
"(",
"data",
",",
"text_type",
")",
":",
"return",
"data",
"# Otherwise, data is a bytes object (str in Python 2).",
"# Fir... | [
88,
0
] | [
151,
23
] | python | en | ['en', 'error', 'th'] | False |
console_to_str | (data) | Return a string, safe for output, of subprocess output.
| Return a string, safe for output, of subprocess output.
| def console_to_str(data):
# type: (bytes) -> Text
"""Return a string, safe for output, of subprocess output.
"""
return str_to_display(data, desc='Subprocess output') | [
"def",
"console_to_str",
"(",
"data",
")",
":",
"# type: (bytes) -> Text",
"return",
"str_to_display",
"(",
"data",
",",
"desc",
"=",
"'Subprocess output'",
")"
] | [
154,
0
] | [
158,
57
] | python | en | ['en', 'en', 'en'] | True |
get_path_uid | (path) |
Return path's uid.
Does not follow symlinks:
https://github.com/pypa/pip/pull/935#discussion_r5307003
Placed this function in compat due to differences on AIX and
Jython, that should eventually go away.
:raises OSError: When path is a symlink or can't be read.
|
Return path's uid. | def get_path_uid(path):
# type: (str) -> int
"""
Return path's uid.
Does not follow symlinks:
https://github.com/pypa/pip/pull/935#discussion_r5307003
Placed this function in compat due to differences on AIX and
Jython, that should eventually go away.
:raises OSError: When path is... | [
"def",
"get_path_uid",
"(",
"path",
")",
":",
"# type: (str) -> int",
"if",
"hasattr",
"(",
"os",
",",
"'O_NOFOLLOW'",
")",
":",
"fd",
"=",
"os",
".",
"open",
"(",
"path",
",",
"os",
".",
"O_RDONLY",
"|",
"os",
".",
"O_NOFOLLOW",
")",
"file_uid",
"=",
... | [
161,
0
] | [
189,
19
] | python | en | ['en', 'error', 'th'] | False |
expanduser | (path) |
Expand ~ and ~user constructions.
Includes a workaround for https://bugs.python.org/issue14768
|
Expand ~ and ~user constructions. | def expanduser(path):
# type: (str) -> str
"""
Expand ~ and ~user constructions.
Includes a workaround for https://bugs.python.org/issue14768
"""
expanded = os.path.expanduser(path)
if path.startswith('~/') and expanded.startswith('//'):
expanded = expanded[1:]
return expanded | [
"def",
"expanduser",
"(",
"path",
")",
":",
"# type: (str) -> str",
"expanded",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"path",
")",
"if",
"path",
".",
"startswith",
"(",
"'~/'",
")",
"and",
"expanded",
".",
"startswith",
"(",
"'//'",
")",
":",
... | [
192,
0
] | [
202,
19
] | python | en | ['en', 'error', 'th'] | False |
samefile | (file1, file2) | Provide an alternative for os.path.samefile on Windows/Python2 | Provide an alternative for os.path.samefile on Windows/Python2 | def samefile(file1, file2):
# type: (str, str) -> bool
"""Provide an alternative for os.path.samefile on Windows/Python2"""
if hasattr(os.path, 'samefile'):
return os.path.samefile(file1, file2)
else:
path1 = os.path.normcase(os.path.abspath(file1))
path2 = os.path.normcase(os.pa... | [
"def",
"samefile",
"(",
"file1",
",",
"file2",
")",
":",
"# type: (str, str) -> bool",
"if",
"hasattr",
"(",
"os",
".",
"path",
",",
"'samefile'",
")",
":",
"return",
"os",
".",
"path",
".",
"samefile",
"(",
"file1",
",",
"file2",
")",
"else",
":",
"pa... | [
218,
0
] | [
226,
29
] | python | en | ['en', 'ga', 'en'] | True |
SpatiaLiteOperations.spatial_version | (self) | Determine the version of the SpatiaLite library. | Determine the version of the SpatiaLite library. | def spatial_version(self):
"""Determine the version of the SpatiaLite library."""
try:
version = self.spatialite_version_tuple()[1:]
except Exception as msg:
new_msg = (
'Cannot determine the SpatiaLite version for the "%s" '
'database (err... | [
"def",
"spatial_version",
"(",
"self",
")",
":",
"try",
":",
"version",
"=",
"self",
".",
"spatialite_version_tuple",
"(",
")",
"[",
"1",
":",
"]",
"except",
"Exception",
"as",
"msg",
":",
"new_msg",
"=",
"(",
"'Cannot determine the SpatiaLite version for the \"... | [
83,
4
] | [
96,
22
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.check_aggregate_support | (self, aggregate) |
Checks if the given aggregate name is supported (that is, if it's
in `self.valid_aggregates`).
|
Checks if the given aggregate name is supported (that is, if it's
in `self.valid_aggregates`).
| def check_aggregate_support(self, aggregate):
"""
Checks if the given aggregate name is supported (that is, if it's
in `self.valid_aggregates`).
"""
super(SpatiaLiteOperations, self).check_aggregate_support(aggregate)
agg_name = aggregate.__class__.__name__
return... | [
"def",
"check_aggregate_support",
"(",
"self",
",",
"aggregate",
")",
":",
"super",
"(",
"SpatiaLiteOperations",
",",
"self",
")",
".",
"check_aggregate_support",
"(",
"aggregate",
")",
"agg_name",
"=",
"aggregate",
".",
"__class__",
".",
"__name__",
"return",
"... | [
124,
4
] | [
131,
48
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.convert_extent | (self, box) |
Convert the polygon data received from Spatialite to min/max values.
|
Convert the polygon data received from Spatialite to min/max values.
| def convert_extent(self, box):
"""
Convert the polygon data received from Spatialite to min/max values.
"""
shell = Geometry(box).shell
xmin, ymin = shell[0][:2]
xmax, ymax = shell[2][:2]
return (xmin, ymin, xmax, ymax) | [
"def",
"convert_extent",
"(",
"self",
",",
"box",
")",
":",
"shell",
"=",
"Geometry",
"(",
"box",
")",
".",
"shell",
"xmin",
",",
"ymin",
"=",
"shell",
"[",
"0",
"]",
"[",
":",
"2",
"]",
"xmax",
",",
"ymax",
"=",
"shell",
"[",
"2",
"]",
"[",
... | [
133,
4
] | [
140,
39
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.convert_geom | (self, wkt, geo_field) |
Converts geometry WKT returned from a SpatiaLite aggregate.
|
Converts geometry WKT returned from a SpatiaLite aggregate.
| def convert_geom(self, wkt, geo_field):
"""
Converts geometry WKT returned from a SpatiaLite aggregate.
"""
if wkt:
return Geometry(wkt, geo_field.srid)
else:
return None | [
"def",
"convert_geom",
"(",
"self",
",",
"wkt",
",",
"geo_field",
")",
":",
"if",
"wkt",
":",
"return",
"Geometry",
"(",
"wkt",
",",
"geo_field",
".",
"srid",
")",
"else",
":",
"return",
"None"
] | [
142,
4
] | [
149,
23
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.geo_db_type | (self, f) |
Returns None because geometry columnas are added via the
`AddGeometryColumn` stored procedure on SpatiaLite.
|
Returns None because geometry columnas are added via the
`AddGeometryColumn` stored procedure on SpatiaLite.
| def geo_db_type(self, f):
"""
Returns None because geometry columnas are added via the
`AddGeometryColumn` stored procedure on SpatiaLite.
"""
return None | [
"def",
"geo_db_type",
"(",
"self",
",",
"f",
")",
":",
"return",
"None"
] | [
151,
4
] | [
156,
19
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.get_distance | (self, f, value, lookup_type) |
Returns the distance parameters for the given geometry field,
lookup value, and lookup type. SpatiaLite only supports regular
cartesian-based queries (no spheroid/sphere calculations for point
geometries like PostGIS).
|
Returns the distance parameters for the given geometry field,
lookup value, and lookup type. SpatiaLite only supports regular
cartesian-based queries (no spheroid/sphere calculations for point
geometries like PostGIS).
| def get_distance(self, f, value, lookup_type):
"""
Returns the distance parameters for the given geometry field,
lookup value, and lookup type. SpatiaLite only supports regular
cartesian-based queries (no spheroid/sphere calculations for point
geometries like PostGIS).
"... | [
"def",
"get_distance",
"(",
"self",
",",
"f",
",",
"value",
",",
"lookup_type",
")",
":",
"if",
"not",
"value",
":",
"return",
"[",
"]",
"value",
"=",
"value",
"[",
"0",
"]",
"if",
"isinstance",
"(",
"value",
",",
"Distance",
")",
":",
"if",
"f",
... | [
158,
4
] | [
178,
27
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.get_geom_placeholder | (self, f, value) |
Provides a proper substitution value for Geometries that are not in the
SRID of the field. Specifically, this routine will substitute in the
Transform() and GeomFromText() function call(s).
|
Provides a proper substitution value for Geometries that are not in the
SRID of the field. Specifically, this routine will substitute in the
Transform() and GeomFromText() function call(s).
| def get_geom_placeholder(self, f, value):
"""
Provides a proper substitution value for Geometries that are not in the
SRID of the field. Specifically, this routine will substitute in the
Transform() and GeomFromText() function call(s).
"""
def transform_value(value, srid... | [
"def",
"get_geom_placeholder",
"(",
"self",
",",
"f",
",",
"value",
")",
":",
"def",
"transform_value",
"(",
"value",
",",
"srid",
")",
":",
"return",
"not",
"(",
"value",
"is",
"None",
"or",
"value",
".",
"srid",
"==",
"srid",
")",
"if",
"hasattr",
... | [
180,
4
] | [
201,
62
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations._get_spatialite_func | (self, func) |
Helper routine for calling SpatiaLite functions and returning
their result.
Any error occurring in this method should be handled by the caller.
|
Helper routine for calling SpatiaLite functions and returning
their result.
Any error occurring in this method should be handled by the caller.
| def _get_spatialite_func(self, func):
"""
Helper routine for calling SpatiaLite functions and returning
their result.
Any error occurring in this method should be handled by the caller.
"""
cursor = self.connection._cursor()
try:
cursor.execute('SELECT... | [
"def",
"_get_spatialite_func",
"(",
"self",
",",
"func",
")",
":",
"cursor",
"=",
"self",
".",
"connection",
".",
"_cursor",
"(",
")",
"try",
":",
"cursor",
".",
"execute",
"(",
"'SELECT %s'",
"%",
"func",
")",
"row",
"=",
"cursor",
".",
"fetchone",
"(... | [
203,
4
] | [
215,
21
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.geos_version | (self) | Returns the version of GEOS used by SpatiaLite as a string. | Returns the version of GEOS used by SpatiaLite as a string. | def geos_version(self):
"Returns the version of GEOS used by SpatiaLite as a string."
return self._get_spatialite_func('geos_version()') | [
"def",
"geos_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_spatialite_func",
"(",
"'geos_version()'",
")"
] | [
217,
4
] | [
219,
58
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.proj4_version | (self) | Returns the version of the PROJ.4 library used by SpatiaLite. | Returns the version of the PROJ.4 library used by SpatiaLite. | def proj4_version(self):
"Returns the version of the PROJ.4 library used by SpatiaLite."
return self._get_spatialite_func('proj4_version()') | [
"def",
"proj4_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_spatialite_func",
"(",
"'proj4_version()'",
")"
] | [
221,
4
] | [
223,
59
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.spatialite_version | (self) | Returns the SpatiaLite library version as a string. | Returns the SpatiaLite library version as a string. | def spatialite_version(self):
"Returns the SpatiaLite library version as a string."
return self._get_spatialite_func('spatialite_version()') | [
"def",
"spatialite_version",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_spatialite_func",
"(",
"'spatialite_version()'",
")"
] | [
225,
4
] | [
227,
64
] | python | en | ['en', 'en', 'en'] | True |
SpatiaLiteOperations.spatialite_version_tuple | (self) |
Returns the SpatiaLite version as a tuple (version string, major,
minor, subminor).
|
Returns the SpatiaLite version as a tuple (version string, major,
minor, subminor).
| def spatialite_version_tuple(self):
"""
Returns the SpatiaLite version as a tuple (version string, major,
minor, subminor).
"""
version = self.spatialite_version()
m = self.version_regex.match(version)
if m:
major = int(m.group('major'))
m... | [
"def",
"spatialite_version_tuple",
"(",
"self",
")",
":",
"version",
"=",
"self",
".",
"spatialite_version",
"(",
")",
"m",
"=",
"self",
".",
"version_regex",
".",
"match",
"(",
"version",
")",
"if",
"m",
":",
"major",
"=",
"int",
"(",
"m",
".",
"group... | [
229,
4
] | [
244,
47
] | python | en | ['en', 'error', 'th'] | False |
SpatiaLiteOperations.spatial_aggregate_sql | (self, agg) |
Returns the spatial aggregate SQL template and function for the
given Aggregate instance.
|
Returns the spatial aggregate SQL template and function for the
given Aggregate instance.
| def spatial_aggregate_sql(self, agg):
"""
Returns the spatial aggregate SQL template and function for the
given Aggregate instance.
"""
agg_name = agg.__class__.__name__
if not self.check_aggregate_support(agg):
raise NotImplementedError('%s spatial aggregate ... | [
"def",
"spatial_aggregate_sql",
"(",
"self",
",",
"agg",
")",
":",
"agg_name",
"=",
"agg",
".",
"__class__",
".",
"__name__",
"if",
"not",
"self",
".",
"check_aggregate_support",
"(",
"agg",
")",
":",
"raise",
"NotImplementedError",
"(",
"'%s spatial aggregate i... | [
246,
4
] | [
259,
41
] | python | en | ['en', 'error', 'th'] | False |
LayoutSlice.wrapped_object | (self, LayoutClass, fields, *args, **kwargs) |
Returns a layout object of type `LayoutClass` with `args` and `kwargs` that
wraps `fields` inside.
|
Returns a layout object of type `LayoutClass` with `args` and `kwargs` that
wraps `fields` inside.
| def wrapped_object(self, LayoutClass, fields, *args, **kwargs):
"""
Returns a layout object of type `LayoutClass` with `args` and `kwargs` that
wraps `fields` inside.
"""
if args:
if isinstance(fields, list):
fields = tuple(fields)
... | [
"def",
"wrapped_object",
"(",
"self",
",",
"LayoutClass",
",",
"fields",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"args",
":",
"if",
"isinstance",
"(",
"fields",
",",
"list",
")",
":",
"fields",
"=",
"tuple",
"(",
"fields",
")",
"... | [
16,
4
] | [
37,
52
] | python | en | ['en', 'ja', 'th'] | False |
LayoutSlice.pre_map | (self, function) |
Iterates over layout objects pointed in `self.slice` executing `function` on them.
It passes `function` penultimate layout object and the position where to find last one
|
Iterates over layout objects pointed in `self.slice` executing `function` on them.
It passes `function` penultimate layout object and the position where to find last one
| def pre_map(self, function):
"""
Iterates over layout objects pointed in `self.slice` executing `function` on them.
It passes `function` penultimate layout object and the position where to find last one
"""
if isinstance(self.slice, slice):
for i in range(*self.... | [
"def",
"pre_map",
"(",
"self",
",",
"function",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"slice",
",",
"slice",
")",
":",
"for",
"i",
"in",
"range",
"(",
"*",
"self",
".",
"slice",
".",
"indices",
"(",
"len",
"(",
"self",
".",
"layout",
".... | [
39,
4
] | [
69,
25
] | python | en | ['en', 'ja', 'th'] | False |
LayoutSlice.wrap | (self, LayoutClass, *args, **kwargs) |
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with
`args` and `kwargs` passed.
|
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with
`args` and `kwargs` passed.
| def wrap(self, LayoutClass, *args, **kwargs):
"""
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with
`args` and `kwargs` passed.
"""
def wrap_object(layout_object, j):
layout_object.fields[j] = self.wrapped_object(LayoutClass... | [
"def",
"wrap",
"(",
"self",
",",
"LayoutClass",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrap_object",
"(",
"layout_object",
",",
"j",
")",
":",
"layout_object",
".",
"fields",
"[",
"j",
"]",
"=",
"self",
".",
"wrapped_object",
"(... | [
71,
4
] | [
80,
33
] | python | en | ['en', 'ja', 'th'] | False |
LayoutSlice.wrap_once | (self, LayoutClass, *args, **kwargs) |
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with
`args` and `kwargs` passed, unless layout object's parent is already a subclass of
`LayoutClass`.
|
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with
`args` and `kwargs` passed, unless layout object's parent is already a subclass of
`LayoutClass`.
| def wrap_once(self, LayoutClass, *args, **kwargs):
"""
Wraps every layout object pointed in `self.slice` under a `LayoutClass` instance with
`args` and `kwargs` passed, unless layout object's parent is already a subclass of
`LayoutClass`.
"""
def wrap_object_once(... | [
"def",
"wrap_once",
"(",
"self",
",",
"LayoutClass",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrap_object_once",
"(",
"layout_object",
",",
"j",
")",
":",
"if",
"not",
"isinstance",
"(",
"layout_object",
",",
"LayoutClass",
")",
":",
... | [
82,
4
] | [
93,
38
] | python | en | ['en', 'ja', 'th'] | False |
LayoutSlice.wrap_together | (self, LayoutClass, *args, **kwargs) |
Wraps all layout objects pointed in `self.slice` together under a `LayoutClass`
instance with `args` and `kwargs` passed.
|
Wraps all layout objects pointed in `self.slice` together under a `LayoutClass`
instance with `args` and `kwargs` passed.
| def wrap_together(self, LayoutClass, *args, **kwargs):
"""
Wraps all layout objects pointed in `self.slice` together under a `LayoutClass`
instance with `args` and `kwargs` passed.
"""
if isinstance(self.slice, slice):
# The start of the slice is replaced
... | [
"def",
"wrap_together",
"(",
"self",
",",
"LayoutClass",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"slice",
",",
"slice",
")",
":",
"# The start of the slice is replaced\r",
"start",
"=",
"self",
".",
"slice... | [
95,
4
] | [
113,
95
] | python | en | ['en', 'ja', 'th'] | False |
LayoutSlice.map | (self, function) |
Iterates over layout objects pointed in `self.slice` executing `function` on them
It passes `function` last layout object
|
Iterates over layout objects pointed in `self.slice` executing `function` on them
It passes `function` last layout object
| def map(self, function):
"""
Iterates over layout objects pointed in `self.slice` executing `function` on them
It passes `function` last layout object
"""
if isinstance(self.slice, slice):
for i in range(*self.slice.indices(len(self.layout.fields))):
... | [
"def",
"map",
"(",
"self",
",",
"function",
")",
":",
"if",
"isinstance",
"(",
"self",
".",
"slice",
",",
"slice",
")",
":",
"for",
"i",
"in",
"range",
"(",
"*",
"self",
".",
"slice",
".",
"indices",
"(",
"len",
"(",
"self",
".",
"layout",
".",
... | [
115,
4
] | [
138,
43
] | python | en | ['en', 'ja', 'th'] | False |
LayoutSlice.update_attributes | (self, **original_kwargs) |
Updates attributes of every layout object pointed in `self.slice` using kwargs
|
Updates attributes of every layout object pointed in `self.slice` using kwargs
| def update_attributes(self, **original_kwargs):
"""
Updates attributes of every layout object pointed in `self.slice` using kwargs
"""
def update_attrs(layout_object):
kwargs = original_kwargs.copy()
if hasattr(layout_object, "attrs"):
if ... | [
"def",
"update_attributes",
"(",
"self",
",",
"*",
"*",
"original_kwargs",
")",
":",
"def",
"update_attrs",
"(",
"layout_object",
")",
":",
"kwargs",
"=",
"original_kwargs",
".",
"copy",
"(",
")",
"if",
"hasattr",
"(",
"layout_object",
",",
"\"attrs\"",
")",... | [
140,
4
] | [
155,
30
] | python | en | ['en', 'ja', 'th'] | False |
SSHKeyListResource.clear | (self) | Removes all SSH keys from a user's system. | Removes all SSH keys from a user's system. | def clear(self):
"""Removes all SSH keys from a user's system."""
r = self._h._http_resource(
method='DELETE',
resource=('user', 'keys'),
)
return r.ok | [
"def",
"clear",
"(",
"self",
")",
":",
"r",
"=",
"self",
".",
"_h",
".",
"_http_resource",
"(",
"method",
"=",
"'DELETE'",
",",
"resource",
"=",
"(",
"'user'",
",",
"'keys'",
")",
",",
")",
"return",
"r",
".",
"ok"
] | [
107,
4
] | [
115,
19
] | python | en | ['en', 'en', 'en'] | True |
GPolygon.__init__ | (self, poly,
stroke_color='#0000ff', stroke_weight=2, stroke_opacity=1,
fill_color='#0000ff', fill_opacity=0.4) |
The GPolygon object initializes on a GEOS Polygon or a parameter that
may be instantiated into GEOS Polygon. Please note that this will not
depict a Polygon's internal rings.
Keyword Options:
stroke_color:
The color of the polygon outline. Defaults to '#0000ff' ... |
The GPolygon object initializes on a GEOS Polygon or a parameter that
may be instantiated into GEOS Polygon. Please note that this will not
depict a Polygon's internal rings. | def __init__(self, poly,
stroke_color='#0000ff', stroke_weight=2, stroke_opacity=1,
fill_color='#0000ff', fill_opacity=0.4):
"""
The GPolygon object initializes on a GEOS Polygon or a parameter that
may be instantiated into GEOS Polygon. Please note that this w... | [
"def",
"__init__",
"(",
"self",
",",
"poly",
",",
"stroke_color",
"=",
"'#0000ff'",
",",
"stroke_weight",
"=",
"2",
",",
"stroke_opacity",
"=",
"1",
",",
"fill_color",
"=",
"'#0000ff'",
",",
"fill_opacity",
"=",
"0.4",
")",
":",
"if",
"isinstance",
"(",
... | [
83,
4
] | [
129,
40
] | python | en | ['en', 'error', 'th'] | False |
GPolyline.__init__ | (self, geom, color='#0000ff', weight=2, opacity=1) |
The GPolyline object may be initialized on GEOS LineStirng, LinearRing,
and Polygon objects (internal rings not supported) or a parameter that
may instantiated into one of the above geometries.
Keyword Options:
color:
The color to use for the polyline. Defaults ... |
The GPolyline object may be initialized on GEOS LineStirng, LinearRing,
and Polygon objects (internal rings not supported) or a parameter that
may instantiated into one of the above geometries. | def __init__(self, geom, color='#0000ff', weight=2, opacity=1):
"""
The GPolyline object may be initialized on GEOS LineStirng, LinearRing,
and Polygon objects (internal rings not supported) or a parameter that
may instantiated into one of the above geometries.
Keyword Options:
... | [
"def",
"__init__",
"(",
"self",
",",
"geom",
",",
"color",
"=",
"'#0000ff'",
",",
"weight",
"=",
"2",
",",
"opacity",
"=",
"1",
")",
":",
"# If a GEOS geometry isn't passed in, try to construct one.",
"if",
"isinstance",
"(",
"geom",
",",
"six",
".",
"string_t... | [
143,
4
] | [
176,
41
] | python | en | ['en', 'error', 'th'] | False |
GMarker.__init__ | (self, geom, title=None, draggable=False, icon=None) |
The GMarker object may initialize on GEOS Points or a parameter
that may be instantiated into a GEOS point. Keyword options map to
GMarkerOptions -- so far only the title option is supported.
Keyword Options:
title:
Title option for GMarker, will be displayed as a ... |
The GMarker object may initialize on GEOS Points or a parameter
that may be instantiated into a GEOS point. Keyword options map to
GMarkerOptions -- so far only the title option is supported. | def __init__(self, geom, title=None, draggable=False, icon=None):
"""
The GMarker object may initialize on GEOS Points or a parameter
that may be instantiated into a GEOS point. Keyword options map to
GMarkerOptions -- so far only the title option is supported.
Keyword Options:... | [
"def",
"__init__",
"(",
"self",
",",
"geom",
",",
"title",
"=",
"None",
",",
"draggable",
"=",
"False",
",",
"icon",
"=",
"None",
")",
":",
"# If a GEOS geometry isn't passed in, try to construct one.",
"if",
"isinstance",
"(",
"geom",
",",
"six",
".",
"string... | [
280,
4
] | [
308,
39
] | python | en | ['en', 'error', 'th'] | False |
dump | (o, f, encoder=None) | Writes out dict as toml to a file
Args:
o: Object to dump into toml
f: File descriptor where the toml should be stored
encoder: The ``TomlEncoder`` to use for constructing the output string
Returns:
String containing the toml corresponding to dictionary
Raises:
Typ... | Writes out dict as toml to a file | def dump(o, f, encoder=None):
"""Writes out dict as toml to a file
Args:
o: Object to dump into toml
f: File descriptor where the toml should be stored
encoder: The ``TomlEncoder`` to use for constructing the output string
Returns:
String containing the toml corresponding t... | [
"def",
"dump",
"(",
"o",
",",
"f",
",",
"encoder",
"=",
"None",
")",
":",
"if",
"not",
"f",
".",
"write",
":",
"raise",
"TypeError",
"(",
"\"You can only dump an object to a file descriptor\"",
")",
"d",
"=",
"dumps",
"(",
"o",
",",
"encoder",
"=",
"enco... | [
11,
0
] | [
30,
12
] | python | en | ['en', 'en', 'en'] | True |
dumps | (o, encoder=None) | Stringifies input dict as toml
Args:
o: Object to dump into toml
encoder: The ``TomlEncoder`` to use for constructing the output string
Returns:
String containing the toml corresponding to dict
Examples:
```python
>>> import toml
>>> output = {
... ... | Stringifies input dict as toml | def dumps(o, encoder=None):
"""Stringifies input dict as toml
Args:
o: Object to dump into toml
encoder: The ``TomlEncoder`` to use for constructing the output string
Returns:
String containing the toml corresponding to dict
Examples:
```python
>>> import toml
... | [
"def",
"dumps",
"(",
"o",
",",
"encoder",
"=",
"None",
")",
":",
"retval",
"=",
"\"\"",
"if",
"encoder",
"is",
"None",
":",
"encoder",
"=",
"TomlEncoder",
"(",
"o",
".",
"__class__",
")",
"addtoretval",
",",
"sections",
"=",
"encoder",
".",
"dump_secti... | [
33,
0
] | [
82,
17
] | python | en | ['en', 'en', 'en'] | True |
TomlEncoder.dump_inline_table | (self, section) | Preserve inline table in its compact syntax instead of expanding
into subsection.
https://github.com/toml-lang/toml#user-content-inline-table
| Preserve inline table in its compact syntax instead of expanding
into subsection. | def dump_inline_table(self, section):
"""Preserve inline table in its compact syntax instead of expanding
into subsection.
https://github.com/toml-lang/toml#user-content-inline-table
"""
retval = ""
if isinstance(section, dict):
val_list = []
for ... | [
"def",
"dump_inline_table",
"(",
"self",
",",
"section",
")",
":",
"retval",
"=",
"\"\"",
"if",
"isinstance",
"(",
"section",
",",
"dict",
")",
":",
"val_list",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"section",
".",
"items",
"(",
")",
":",
"val... | [
156,
4
] | [
171,
52
] | python | en | ['en', 'en', 'en'] | True |
XFrameOptionsMiddleware.get_xframe_options_value | (self, request, response) |
Gets the value to set for the X_FRAME_OPTIONS header.
By default this uses the value from the X_FRAME_OPTIONS Django
settings. If not found in settings, defaults to 'SAMEORIGIN'.
This method can be overridden if needed, allowing it to vary based on
the request or response.
... |
Gets the value to set for the X_FRAME_OPTIONS header. | def get_xframe_options_value(self, request, response):
"""
Gets the value to set for the X_FRAME_OPTIONS header.
By default this uses the value from the X_FRAME_OPTIONS Django
settings. If not found in settings, defaults to 'SAMEORIGIN'.
This method can be overridden if needed,... | [
"def",
"get_xframe_options_value",
"(",
"self",
",",
"request",
",",
"response",
")",
":",
"return",
"getattr",
"(",
"settings",
",",
"'X_FRAME_OPTIONS'",
",",
"'SAMEORIGIN'",
")",
".",
"upper",
"(",
")"
] | [
41,
4
] | [
51,
73
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_unsaved_object | (self) |
#10811 -- Assigning an unsaved object to a OneToOneField
should raise an exception.
|
#10811 -- Assigning an unsaved object to a OneToOneField
should raise an exception.
| def test_unsaved_object(self):
"""
#10811 -- Assigning an unsaved object to a OneToOneField
should raise an exception.
"""
place = Place(name='User', address='London')
with self.assertRaisesMessage(ValueError,
'Cannot assign "%r": "%s" instance... | [
"def",
"test_unsaved_object",
"(",
"self",
")",
":",
"place",
"=",
"Place",
"(",
"name",
"=",
"'User'",
",",
"address",
"=",
"'London'",
")",
"with",
"self",
".",
"assertRaisesMessage",
"(",
"ValueError",
",",
"'Cannot assign \"%r\": \"%s\" instance isn\\'t saved in... | [
125,
4
] | [
140,
34
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_reverse_relationship_cache_cascade | (self) |
Regression test for #9023: accessing the reverse relationship shouldn't
result in a cascading delete().
|
Regression test for #9023: accessing the reverse relationship shouldn't
result in a cascading delete().
| def test_reverse_relationship_cache_cascade(self):
"""
Regression test for #9023: accessing the reverse relationship shouldn't
result in a cascading delete().
"""
bar = UndergroundBar.objects.create(place=self.p1, serves_cocktails=False)
# The bug in #9023: if you access... | [
"def",
"test_reverse_relationship_cache_cascade",
"(",
"self",
")",
":",
"bar",
"=",
"UndergroundBar",
".",
"objects",
".",
"create",
"(",
"place",
"=",
"self",
".",
"p1",
",",
"serves_cocktails",
"=",
"False",
")",
"# The bug in #9023: if you access the one-to-one re... | [
142,
4
] | [
158,
65
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_create_models_m2m | (self) |
Regression test for #1064 and #1506
Check that we create models via the m2m relation if the remote model
has a OneToOneField.
|
Regression test for #1064 and #1506 | def test_create_models_m2m(self):
"""
Regression test for #1064 and #1506
Check that we create models via the m2m relation if the remote model
has a OneToOneField.
"""
f = Favorites(name='Fred')
f.save()
f.restaurants = [self.r1]
self.assertQuerys... | [
"def",
"test_create_models_m2m",
"(",
"self",
")",
":",
"f",
"=",
"Favorites",
"(",
"name",
"=",
"'Fred'",
")",
"f",
".",
"save",
"(",
")",
"f",
".",
"restaurants",
"=",
"[",
"self",
".",
"r1",
"]",
"self",
".",
"assertQuerysetEqual",
"(",
"f",
".",
... | [
160,
4
] | [
173,
9
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_reverse_object_cache | (self) |
Regression test for #7173
Check that the name of the cache for the reverse object is correct.
|
Regression test for #7173 | def test_reverse_object_cache(self):
"""
Regression test for #7173
Check that the name of the cache for the reverse object is correct.
"""
self.assertEqual(self.p1.restaurant, self.r1)
self.assertEqual(self.p1.bar, self.b1) | [
"def",
"test_reverse_object_cache",
"(",
"self",
")",
":",
"self",
".",
"assertEqual",
"(",
"self",
".",
"p1",
".",
"restaurant",
",",
"self",
".",
"r1",
")",
"self",
".",
"assertEqual",
"(",
"self",
".",
"p1",
".",
"bar",
",",
"self",
".",
"b1",
")"... | [
175,
4
] | [
182,
46
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_related_object_cache | (self) | Regression test for #6886 (the related-object cache) | Regression test for #6886 (the related-object cache) | def test_related_object_cache(self):
""" Regression test for #6886 (the related-object cache) """
# Look up the objects again so that we get "fresh" objects
p = Place.objects.get(name="Demon Dogs")
r = p.restaurant
# Accessing the related object again returns the exactly same o... | [
"def",
"test_related_object_cache",
"(",
"self",
")",
":",
"# Look up the objects again so that we get \"fresh\" objects",
"p",
"=",
"Place",
".",
"objects",
".",
"get",
"(",
"name",
"=",
"\"Demon Dogs\"",
")",
"r",
"=",
"p",
".",
"restaurant",
"# Accessing the relate... | [
184,
4
] | [
226,
36
] | python | en | ['en', 'en', 'en'] | True |
OneToOneTests.test_filter_one_to_one_relations | (self) |
Regression test for #9968
filtering reverse one-to-one relations with primary_key=True was
misbehaving. We test both (primary_key=True & False) cases here to
prevent any reappearance of the problem.
|
Regression test for #9968 | def test_filter_one_to_one_relations(self):
"""
Regression test for #9968
filtering reverse one-to-one relations with primary_key=True was
misbehaving. We test both (primary_key=True & False) cases here to
prevent any reappearance of the problem.
"""
Target.objec... | [
"def",
"test_filter_one_to_one_relations",
"(",
"self",
")",
":",
"Target",
".",
"objects",
".",
"create",
"(",
")",
"self",
".",
"assertQuerysetEqual",
"(",
"Target",
".",
"objects",
".",
"filter",
"(",
"pointer",
"=",
"None",
")",
",",
"[",
"'<Target: Targ... | [
228,
4
] | [
253,
9
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_reverse_object_does_not_exist_cache | (self) |
Regression for #13839 and #17439.
DoesNotExist on a reverse one-to-one relation is cached.
|
Regression for #13839 and #17439. | def test_reverse_object_does_not_exist_cache(self):
"""
Regression for #13839 and #17439.
DoesNotExist on a reverse one-to-one relation is cached.
"""
p = Place(name='Zombie Cats', address='Not sure')
p.save()
with self.assertNumQueries(1):
with self.... | [
"def",
"test_reverse_object_does_not_exist_cache",
"(",
"self",
")",
":",
"p",
"=",
"Place",
"(",
"name",
"=",
"'Zombie Cats'",
",",
"address",
"=",
"'Not sure'",
")",
"p",
".",
"save",
"(",
")",
"with",
"self",
".",
"assertNumQueries",
"(",
"1",
")",
":",... | [
255,
4
] | [
268,
28
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_reverse_object_cached_when_related_is_accessed | (self) |
Regression for #13839 and #17439.
The target of a one-to-one relation is cached
when the origin is accessed through the reverse relation.
|
Regression for #13839 and #17439. | def test_reverse_object_cached_when_related_is_accessed(self):
"""
Regression for #13839 and #17439.
The target of a one-to-one relation is cached
when the origin is accessed through the reverse relation.
"""
# Use a fresh object without caches
r = Restaurant.obj... | [
"def",
"test_reverse_object_cached_when_related_is_accessed",
"(",
"self",
")",
":",
"# Use a fresh object without caches",
"r",
"=",
"Restaurant",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"self",
".",
"r1",
".",
"pk",
")",
"p",
"=",
"r",
".",
"place",
"wit... | [
270,
4
] | [
281,
45
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_related_object_cached_when_reverse_is_accessed | (self) |
Regression for #13839 and #17439.
The origin of a one-to-one relation is cached
when the target is accessed through the reverse relation.
|
Regression for #13839 and #17439. | def test_related_object_cached_when_reverse_is_accessed(self):
"""
Regression for #13839 and #17439.
The origin of a one-to-one relation is cached
when the target is accessed through the reverse relation.
"""
# Use a fresh object without caches
p = Place.objects.... | [
"def",
"test_related_object_cached_when_reverse_is_accessed",
"(",
"self",
")",
":",
"# Use a fresh object without caches",
"p",
"=",
"Place",
".",
"objects",
".",
"get",
"(",
"pk",
"=",
"self",
".",
"p1",
".",
"pk",
")",
"r",
"=",
"p",
".",
"restaurant",
"wit... | [
283,
4
] | [
294,
40
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_reverse_object_cached_when_related_is_set | (self) |
Regression for #13839 and #17439.
The target of a one-to-one relation is always cached.
|
Regression for #13839 and #17439. | def test_reverse_object_cached_when_related_is_set(self):
"""
Regression for #13839 and #17439.
The target of a one-to-one relation is always cached.
"""
p = Place(name='Zombie Cats', address='Not sure')
p.save()
self.r1.place = p
self.r1.save()
w... | [
"def",
"test_reverse_object_cached_when_related_is_set",
"(",
"self",
")",
":",
"p",
"=",
"Place",
"(",
"name",
"=",
"'Zombie Cats'",
",",
"address",
"=",
"'Not sure'",
")",
"p",
".",
"save",
"(",
")",
"self",
".",
"r1",
".",
"place",
"=",
"p",
"self",
"... | [
296,
4
] | [
307,
51
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_reverse_object_cached_when_related_is_unset | (self) |
Regression for #13839 and #17439.
The target of a one-to-one relation is always cached.
|
Regression for #13839 and #17439. | def test_reverse_object_cached_when_related_is_unset(self):
"""
Regression for #13839 and #17439.
The target of a one-to-one relation is always cached.
"""
b = UndergroundBar(place=self.p1, serves_cocktails=True)
b.save()
with self.assertNumQueries(0):
... | [
"def",
"test_reverse_object_cached_when_related_is_unset",
"(",
"self",
")",
":",
"b",
"=",
"UndergroundBar",
"(",
"place",
"=",
"self",
".",
"p1",
",",
"serves_cocktails",
"=",
"True",
")",
"b",
".",
"save",
"(",
")",
"with",
"self",
".",
"assertNumQueries",
... | [
309,
4
] | [
323,
38
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_get_reverse_on_unsaved_object | (self) |
Regression for #18153 and #19089.
Accessing the reverse relation on an unsaved object
always raises an exception.
|
Regression for #18153 and #19089. | def test_get_reverse_on_unsaved_object(self):
"""
Regression for #18153 and #19089.
Accessing the reverse relation on an unsaved object
always raises an exception.
"""
p = Place()
# When there's no instance of the origin of the one-to-one
with self.asser... | [
"def",
"test_get_reverse_on_unsaved_object",
"(",
"self",
")",
":",
"p",
"=",
"Place",
"(",
")",
"# When there's no instance of the origin of the one-to-one",
"with",
"self",
".",
"assertNumQueries",
"(",
"0",
")",
":",
"with",
"self",
".",
"assertRaises",
"(",
"Und... | [
325,
4
] | [
355,
36
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_set_reverse_on_unsaved_object | (self) |
Writing to the reverse relation on an unsaved object
is impossible too.
|
Writing to the reverse relation on an unsaved object
is impossible too.
| def test_set_reverse_on_unsaved_object(self):
"""
Writing to the reverse relation on an unsaved object
is impossible too.
"""
p = Place()
b = UndergroundBar.objects.create()
with self.assertNumQueries(0):
with self.assertRaises(ValueError):
... | [
"def",
"test_set_reverse_on_unsaved_object",
"(",
"self",
")",
":",
"p",
"=",
"Place",
"(",
")",
"b",
"=",
"UndergroundBar",
".",
"objects",
".",
"create",
"(",
")",
"with",
"self",
".",
"assertNumQueries",
"(",
"0",
")",
":",
"with",
"self",
".",
"asser... | [
357,
4
] | [
366,
36
] | python | en | ['en', 'error', 'th'] | False |
OneToOneTests.test_hidden_accessor | (self) |
When a '+' ending related name is specified no reverse accessor should
be added to the related model.
|
When a '+' ending related name is specified no reverse accessor should
be added to the related model.
| def test_hidden_accessor(self):
"""
When a '+' ending related name is specified no reverse accessor should
be added to the related model.
"""
self.assertFalse(
hasattr(Target, HiddenPointer._meta.get_field('target').related.get_accessor_name())
) | [
"def",
"test_hidden_accessor",
"(",
"self",
")",
":",
"self",
".",
"assertFalse",
"(",
"hasattr",
"(",
"Target",
",",
"HiddenPointer",
".",
"_meta",
".",
"get_field",
"(",
"'target'",
")",
".",
"related",
".",
"get_accessor_name",
"(",
")",
")",
")"
] | [
376,
4
] | [
383,
9
] | python | en | ['en', 'error', 'th'] | False |
LoggingFiltersTest.test_require_debug_false_filter | (self) |
Test the RequireDebugFalse filter class.
|
Test the RequireDebugFalse filter class.
| def test_require_debug_false_filter(self):
"""
Test the RequireDebugFalse filter class.
"""
filter_ = RequireDebugFalse()
with self.settings(DEBUG=True):
self.assertEqual(filter_.filter("record is not used"), False)
with self.settings(DEBUG=False):
... | [
"def",
"test_require_debug_false_filter",
"(",
"self",
")",
":",
"filter_",
"=",
"RequireDebugFalse",
"(",
")",
"with",
"self",
".",
"settings",
"(",
"DEBUG",
"=",
"True",
")",
":",
"self",
".",
"assertEqual",
"(",
"filter_",
".",
"filter",
"(",
"\"record is... | [
42,
4
] | [
52,
72
] | python | en | ['en', 'error', 'th'] | False |
LoggingFiltersTest.test_require_debug_true_filter | (self) |
Test the RequireDebugTrue filter class.
|
Test the RequireDebugTrue filter class.
| def test_require_debug_true_filter(self):
"""
Test the RequireDebugTrue filter class.
"""
filter_ = RequireDebugTrue()
with self.settings(DEBUG=True):
self.assertEqual(filter_.filter("record is not used"), True)
with self.settings(DEBUG=False):
s... | [
"def",
"test_require_debug_true_filter",
"(",
"self",
")",
":",
"filter_",
"=",
"RequireDebugTrue",
"(",
")",
"with",
"self",
".",
"settings",
"(",
"DEBUG",
"=",
"True",
")",
":",
"self",
".",
"assertEqual",
"(",
"filter_",
".",
"filter",
"(",
"\"record is n... | [
54,
4
] | [
64,
73
] | python | en | ['en', 'error', 'th'] | False |
DefaultLoggingTest.test_django_logger | (self) |
The 'django' base logger only output anything when DEBUG=True.
|
The 'django' base logger only output anything when DEBUG=True.
| def test_django_logger(self):
"""
The 'django' base logger only output anything when DEBUG=True.
"""
output = StringIO()
self.logger.handlers[0].stream = output
self.logger.error("Hey, this is an error.")
self.assertEqual(output.getvalue(), '')
with self.... | [
"def",
"test_django_logger",
"(",
"self",
")",
":",
"output",
"=",
"StringIO",
"(",
")",
"self",
".",
"logger",
".",
"handlers",
"[",
"0",
"]",
".",
"stream",
"=",
"output",
"self",
".",
"logger",
".",
"error",
"(",
"\"Hey, this is an error.\"",
")",
"se... | [
75,
4
] | [
86,
75
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandlerTest.test_accepts_args | (self) |
Ensure that user-supplied arguments and the EMAIL_SUBJECT_PREFIX
setting are used to compose the email subject.
Refs #16736.
|
Ensure that user-supplied arguments and the EMAIL_SUBJECT_PREFIX
setting are used to compose the email subject.
Refs #16736.
| def test_accepts_args(self):
"""
Ensure that user-supplied arguments and the EMAIL_SUBJECT_PREFIX
setting are used to compose the email subject.
Refs #16736.
"""
message = "Custom message that says '%s' and '%s'"
token1 = 'ping'
token2 = 'pong'
ad... | [
"def",
"test_accepts_args",
"(",
"self",
")",
":",
"message",
"=",
"\"Custom message that says '%s' and '%s'\"",
"token1",
"=",
"'ping'",
"token2",
"=",
"'pong'",
"admin_email_handler",
"=",
"self",
".",
"get_admin_email_handler",
"(",
"self",
".",
"logger",
")",
"#... | [
185,
4
] | [
209,
54
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandlerTest.test_accepts_args_and_request | (self) |
Ensure that the subject is also handled if being
passed a request object.
|
Ensure that the subject is also handled if being
passed a request object.
| def test_accepts_args_and_request(self):
"""
Ensure that the subject is also handled if being
passed a request object.
"""
message = "Custom message that says '%s' and '%s'"
token1 = 'ping'
token2 = 'pong'
admin_email_handler = self.get_admin_email_handle... | [
"def",
"test_accepts_args_and_request",
"(",
"self",
")",
":",
"message",
"=",
"\"Custom message that says '%s' and '%s'\"",
"token1",
"=",
"'ping'",
"token2",
"=",
"'pong'",
"admin_email_handler",
"=",
"self",
".",
"get_admin_email_handler",
"(",
"self",
".",
"logger",... | [
216,
4
] | [
244,
54
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandlerTest.test_subject_accepts_newlines | (self) |
Ensure that newlines in email reports' subjects are escaped to avoid
AdminErrorHandler to fail.
Refs #17281.
|
Ensure that newlines in email reports' subjects are escaped to avoid
AdminErrorHandler to fail.
Refs #17281.
| def test_subject_accepts_newlines(self):
"""
Ensure that newlines in email reports' subjects are escaped to avoid
AdminErrorHandler to fail.
Refs #17281.
"""
message = 'Message \r\n with newlines'
expected_subject = 'ERROR: Message \\r\\n with newlines'
s... | [
"def",
"test_subject_accepts_newlines",
"(",
"self",
")",
":",
"message",
"=",
"'Message \\r\\n with newlines'",
"expected_subject",
"=",
"'ERROR: Message \\\\r\\\\n with newlines'",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"mail",
".",
"outbox",
")",
",",
"0",
")... | [
251,
4
] | [
267,
66
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandlerTest.test_truncate_subject | (self) |
RFC 2822's hard limit is 998 characters per line.
So, minus "Subject: ", the actual subject must be no longer than 989
characters.
Refs #17281.
|
RFC 2822's hard limit is 998 characters per line.
So, minus "Subject: ", the actual subject must be no longer than 989
characters.
Refs #17281.
| def test_truncate_subject(self):
"""
RFC 2822's hard limit is 998 characters per line.
So, minus "Subject: ", the actual subject must be no longer than 989
characters.
Refs #17281.
"""
message = 'a' * 1000
expected_subject = 'ERROR: aa' + 'a' * 980
... | [
"def",
"test_truncate_subject",
"(",
"self",
")",
":",
"message",
"=",
"'a'",
"*",
"1000",
"expected_subject",
"=",
"'ERROR: aa'",
"+",
"'a'",
"*",
"980",
"self",
".",
"assertEqual",
"(",
"len",
"(",
"mail",
".",
"outbox",
")",
",",
"0",
")",
"self",
"... | [
274,
4
] | [
289,
66
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandlerTest.test_uses_custom_email_backend | (self) |
Refs #19325
|
Refs #19325
| def test_uses_custom_email_backend(self):
"""
Refs #19325
"""
message = 'All work and no play makes Jack a dull boy'
admin_email_handler = self.get_admin_email_handler(self.logger)
mail_admins_called = {'called': False}
def my_mail_admins(*args, **kwargs):
... | [
"def",
"test_uses_custom_email_backend",
"(",
"self",
")",
":",
"message",
"=",
"'All work and no play makes Jack a dull boy'",
"admin_email_handler",
"=",
"self",
".",
"get_admin_email_handler",
"(",
"self",
".",
"logger",
")",
"mail_admins_called",
"=",
"{",
"'called'",... | [
295,
4
] | [
321,
66
] | python | en | ['en', 'error', 'th'] | False |
AdminEmailHandlerTest.test_emit_non_ascii | (self) |
#23593 - AdminEmailHandler should allow Unicode characters in the
request.
|
#23593 - AdminEmailHandler should allow Unicode characters in the
request.
| def test_emit_non_ascii(self):
"""
#23593 - AdminEmailHandler should allow Unicode characters in the
request.
"""
handler = self.get_admin_email_handler(self.logger)
record = self.logger.makeRecord('name', logging.ERROR, 'function', 'lno', 'message', None, None)
r... | [
"def",
"test_emit_non_ascii",
"(",
"self",
")",
":",
"handler",
"=",
"self",
".",
"get_admin_email_handler",
"(",
"self",
".",
"logger",
")",
"record",
"=",
"self",
".",
"logger",
".",
"makeRecord",
"(",
"'name'",
",",
"logging",
".",
"ERROR",
",",
"'funct... | [
326,
4
] | [
341,
53
] | python | en | ['en', 'error', 'th'] | False |
ModelBasicCNNTFE.fprop | (self, x) |
Forward propagation throught the network
:return: dictionary with layer names mapping to activation values.
|
Forward propagation throught the network
:return: dictionary with layer names mapping to activation values.
| def fprop(self, x):
"""
Forward propagation throught the network
:return: dictionary with layer names mapping to activation values.
"""
# Feed forward through the network layers
for layer_name in self.layer_names:
if layer_name == "input":
pre... | [
"def",
"fprop",
"(",
"self",
",",
"x",
")",
":",
"# Feed forward through the network layers",
"for",
"layer_name",
"in",
"self",
".",
"layer_names",
":",
"if",
"layer_name",
"==",
"\"input\"",
":",
"prev_layer_act",
"=",
"x",
"continue",
"else",
":",
"self",
"... | [
61,
4
] | [
78,
30
] | python | en | ['en', 'error', 'th'] | False |
ModelBasicCNNTFE.get_layer_params | (self, layer_name) |
Provides access to the parameters of the given layer.
Works arounds the non-availability of graph collections in
eager mode.
:layer_name: name of the layer for which parameters are
required, must be one of the string in the
list layer_... |
Provides access to the parameters of the given layer.
Works arounds the non-availability of graph collections in
eager mode.
:layer_name: name of the layer for which parameters are
required, must be one of the string in the
list layer_... | def get_layer_params(self, layer_name):
"""
Provides access to the parameters of the given layer.
Works arounds the non-availability of graph collections in
eager mode.
:layer_name: name of the layer for which parameters are
required, must be one o... | [
"def",
"get_layer_params",
"(",
"self",
",",
"layer_name",
")",
":",
"assert",
"layer_name",
"in",
"self",
".",
"layer_names",
"out",
"=",
"[",
"]",
"layer",
"=",
"self",
".",
"layers",
"[",
"layer_name",
"]",
"layer_variables",
"=",
"layer",
".",
"variabl... | [
80,
4
] | [
101,
18
] | python | en | ['en', 'error', 'th'] | False |
ModelBasicCNNTFE.get_params | (self) |
Provides access to the model's parameters.
Works arounds the non-availability of graph collections in
eager mode.
:return: A list of all Variables defining the model parameters.
|
Provides access to the model's parameters.
Works arounds the non-availability of graph collections in
eager mode.
:return: A list of all Variables defining the model parameters.
| def get_params(self):
"""
Provides access to the model's parameters.
Works arounds the non-availability of graph collections in
eager mode.
:return: A list of all Variables defining the model parameters.
"""
assert tf.executing_eagerly()
ou... | [
"def",
"get_params",
"(",
"self",
")",
":",
"assert",
"tf",
".",
"executing_eagerly",
"(",
")",
"out",
"=",
"[",
"]",
"# Collecting params from each layer.",
"for",
"layer_name",
"in",
"self",
".",
"layers",
":",
"out",
"+=",
"self",
".",
"get_layer_params",
... | [
103,
4
] | [
116,
18
] | python | en | ['en', 'error', 'th'] | False |
ModelBasicCNNTFE.get_layer_names | (self) | :return: the list of exposed layers for this model. | :return: the list of exposed layers for this model. | def get_layer_names(self):
""":return: the list of exposed layers for this model."""
return self.layer_names | [
"def",
"get_layer_names",
"(",
"self",
")",
":",
"return",
"self",
".",
"layer_names"
] | [
118,
4
] | [
120,
31
] | python | en | ['en', 'en', 'en'] | True |
make_msgid | (idstring=None) | Returns a string suitable for RFC 2822 compliant Message-ID, e.g:
<20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
uniqueness of the message id.
| Returns a string suitable for RFC 2822 compliant Message-ID, e.g: | def make_msgid(idstring=None):
"""Returns a string suitable for RFC 2822 compliant Message-ID, e.g:
<20020201195627.33539.96671@nightshade.la.mastaler.com>
Optional idstring if given is a string used to strengthen the
uniqueness of the message id.
"""
timeval = time.time()
utcdate = time.s... | [
"def",
"make_msgid",
"(",
"idstring",
"=",
"None",
")",
":",
"timeval",
"=",
"time",
".",
"time",
"(",
")",
"utcdate",
"=",
"time",
".",
"strftime",
"(",
"'%Y%m%d%H%M%S'",
",",
"time",
".",
"gmtime",
"(",
"timeval",
")",
")",
"try",
":",
"pid",
"=",
... | [
40,
0
] | [
62,
16
] | python | en | ['en', 'en', 'en'] | True |
forbid_multi_line_headers | (name, val, encoding) | Forbids multi-line headers, to prevent header injection. | Forbids multi-line headers, to prevent header injection. | def forbid_multi_line_headers(name, val, encoding):
"""Forbids multi-line headers, to prevent header injection."""
encoding = encoding or settings.DEFAULT_CHARSET
val = force_text(val)
if '\n' in val or '\r' in val:
raise BadHeaderError("Header values can't contain newlines (got %r for header %r... | [
"def",
"forbid_multi_line_headers",
"(",
"name",
",",
"val",
",",
"encoding",
")",
":",
"encoding",
"=",
"encoding",
"or",
"settings",
".",
"DEFAULT_CHARSET",
"val",
"=",
"force_text",
"(",
"val",
")",
"if",
"'\\n'",
"in",
"val",
"or",
"'\\r'",
"in",
"val"... | [
81,
0
] | [
98,
25
] | python | en | ['nb', 'en', 'en'] | True |
MIMEMixin.as_string | (self, unixfrom=False) | Return the entire formatted message as a string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This overrides the default as_string() implementation to not mangle
lines that begin with 'From '. See bug #13433 for details.
| Return the entire formatted message as a string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header. | def as_string(self, unixfrom=False):
"""Return the entire formatted message as a string.
Optional `unixfrom' when True, means include the Unix From_ envelope
header.
This overrides the default as_string() implementation to not mangle
lines that begin with 'From '. See bug #13433... | [
"def",
"as_string",
"(",
"self",
",",
"unixfrom",
"=",
"False",
")",
":",
"fp",
"=",
"six",
".",
"StringIO",
"(",
")",
"g",
"=",
"generator",
".",
"Generator",
"(",
"fp",
",",
"mangle_from_",
"=",
"False",
")",
"g",
".",
"flatten",
"(",
"self",
","... | [
125,
4
] | [
136,
28
] | python | en | ['en', 'en', 'en'] | True |
EmailMessage.__init__ | (self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, cc=None) |
Initialize a single email message (which can be sent to multiple
recipients).
All strings used to create the message can be unicode strings
(or UTF-8 bytestrings). The SafeMIMEText class will handle any
necessary encoding conversions.
|
Initialize a single email message (which can be sent to multiple
recipients). | def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, cc=None):
"""
Initialize a single email message (which can be sent to multiple
recipients).
All strings used to create the message can be unicode... | [
"def",
"__init__",
"(",
"self",
",",
"subject",
"=",
"''",
",",
"body",
"=",
"''",
",",
"from_email",
"=",
"None",
",",
"to",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"attachments",
"=",
"None",
",",
"headers",
"="... | [
208,
4
] | [
238,
36
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage.recipients | (self) |
Returns a list of all recipients of the email (includes direct
addressees as well as Cc and Bcc entries).
|
Returns a list of all recipients of the email (includes direct
addressees as well as Cc and Bcc entries).
| def recipients(self):
"""
Returns a list of all recipients of the email (includes direct
addressees as well as Cc and Bcc entries).
"""
return self.to + self.cc + self.bcc | [
"def",
"recipients",
"(",
"self",
")",
":",
"return",
"self",
".",
"to",
"+",
"self",
".",
"cc",
"+",
"self",
".",
"bcc"
] | [
269,
4
] | [
274,
43
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage.send | (self, fail_silently=False) | Sends the email message. | Sends the email message. | def send(self, fail_silently=False):
"""Sends the email message."""
if not self.recipients():
# Don't bother creating the network connection if there's nobody to
# send to.
return 0
return self.get_connection(fail_silently).send_messages([self]) | [
"def",
"send",
"(",
"self",
",",
"fail_silently",
"=",
"False",
")",
":",
"if",
"not",
"self",
".",
"recipients",
"(",
")",
":",
"# Don't bother creating the network connection if there's nobody to",
"# send to.",
"return",
"0",
"return",
"self",
".",
"get_connectio... | [
276,
4
] | [
282,
71
] | python | en | ['en', 'en', 'en'] | True |
EmailMessage.attach | (self, filename=None, content=None, mimetype=None) |
Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the resulting message attachments.
|
Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided. | def attach(self, filename=None, content=None, mimetype=None):
"""
Attaches a file with the given filename and content. The filename can
be omitted and the mimetype is guessed, if not provided.
If the first parameter is a MIMEBase subclass it is inserted directly
into the resulti... | [
"def",
"attach",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"content",
"=",
"None",
",",
"mimetype",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"filename",
",",
"MIMEBase",
")",
":",
"assert",
"content",
"is",
"None",
"assert",
"mimetype",
"i... | [
284,
4
] | [
298,
66
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage.attach_file | (self, path, mimetype=None) | Attaches a file from the filesystem. | Attaches a file from the filesystem. | def attach_file(self, path, mimetype=None):
"""Attaches a file from the filesystem."""
filename = os.path.basename(path)
with open(path, 'rb') as f:
content = f.read()
self.attach(filename, content, mimetype) | [
"def",
"attach_file",
"(",
"self",
",",
"path",
",",
"mimetype",
"=",
"None",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"basename",
"(",
"path",
")",
"with",
"open",
"(",
"path",
",",
"'rb'",
")",
"as",
"f",
":",
"content",
"=",
"f",
"."... | [
300,
4
] | [
305,
48
] | python | en | ['en', 'en', 'en'] | True |
EmailMessage._create_mime_attachment | (self, content, mimetype) |
Converts the content, mimetype pair into a MIME attachment object.
If the mimetype is message/rfc822, content may be an
email.Message or EmailMessage object, as well as a str.
|
Converts the content, mimetype pair into a MIME attachment object. | def _create_mime_attachment(self, content, mimetype):
"""
Converts the content, mimetype pair into a MIME attachment object.
If the mimetype is message/rfc822, content may be an
email.Message or EmailMessage object, as well as a str.
"""
basetype, subtype = mimetype.spli... | [
"def",
"_create_mime_attachment",
"(",
"self",
",",
"content",
",",
"mimetype",
")",
":",
"basetype",
",",
"subtype",
"=",
"mimetype",
".",
"split",
"(",
"'/'",
",",
"1",
")",
"if",
"basetype",
"==",
"'text'",
":",
"encoding",
"=",
"self",
".",
"encoding... | [
324,
4
] | [
352,
25
] | python | en | ['en', 'error', 'th'] | False |
EmailMessage._create_attachment | (self, filename, content, mimetype=None) |
Converts the filename, content, mimetype triple into a MIME attachment
object.
|
Converts the filename, content, mimetype triple into a MIME attachment
object.
| def _create_attachment(self, filename, content, mimetype=None):
"""
Converts the filename, content, mimetype triple into a MIME attachment
object.
"""
if mimetype is None:
mimetype, _ = mimetypes.guess_type(filename)
if mimetype is None:
mi... | [
"def",
"_create_attachment",
"(",
"self",
",",
"filename",
",",
"content",
",",
"mimetype",
"=",
"None",
")",
":",
"if",
"mimetype",
"is",
"None",
":",
"mimetype",
",",
"_",
"=",
"mimetypes",
".",
"guess_type",
"(",
"filename",
")",
"if",
"mimetype",
"is... | [
354,
4
] | [
373,
25
] | python | en | ['en', 'error', 'th'] | False |
EmailMultiAlternatives.__init__ | (self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, alternatives=None,
cc=None) |
Initialize a single email message (which can be sent to multiple
recipients).
All strings used to create the message can be unicode strings (or UTF-8
bytestrings). The SafeMIMEText class will handle any necessary encoding
conversions.
|
Initialize a single email message (which can be sent to multiple
recipients). | def __init__(self, subject='', body='', from_email=None, to=None, bcc=None,
connection=None, attachments=None, headers=None, alternatives=None,
cc=None):
"""
Initialize a single email message (which can be sent to multiple
recipients).
All strings used to create ... | [
"def",
"__init__",
"(",
"self",
",",
"subject",
"=",
"''",
",",
"body",
"=",
"''",
",",
"from_email",
"=",
"None",
",",
"to",
"=",
"None",
",",
"bcc",
"=",
"None",
",",
"connection",
"=",
"None",
",",
"attachments",
"=",
"None",
",",
"headers",
"="... | [
384,
4
] | [
398,
46
] | python | en | ['en', 'error', 'th'] | False |
EmailMultiAlternatives.attach_alternative | (self, content, mimetype) | Attach an alternative content representation. | Attach an alternative content representation. | def attach_alternative(self, content, mimetype):
"""Attach an alternative content representation."""
assert content is not None
assert mimetype is not None
self.alternatives.append((content, mimetype)) | [
"def",
"attach_alternative",
"(",
"self",
",",
"content",
",",
"mimetype",
")",
":",
"assert",
"content",
"is",
"not",
"None",
"assert",
"mimetype",
"is",
"not",
"None",
"self",
".",
"alternatives",
".",
"append",
"(",
"(",
"content",
",",
"mimetype",
")",... | [
400,
4
] | [
404,
53
] | python | en | ['en', 'lb', 'en'] | True |
_group_matching | (tlist, cls) | Groups Tokens that have beginning and end. | Groups Tokens that have beginning and end. | def _group_matching(tlist, cls):
"""Groups Tokens that have beginning and end."""
opens = []
tidx_offset = 0
for idx, token in enumerate(list(tlist)):
tidx = idx - tidx_offset
if token.is_whitespace:
# ~50% of tokens will be whitespace. Will checking early
# for ... | [
"def",
"_group_matching",
"(",
"tlist",
",",
"cls",
")",
":",
"opens",
"=",
"[",
"]",
"tidx_offset",
"=",
"0",
"for",
"idx",
",",
"token",
"in",
"enumerate",
"(",
"list",
"(",
"tlist",
")",
")",
":",
"tidx",
"=",
"idx",
"-",
"tidx_offset",
"if",
"t... | [
17,
0
] | [
49,
47
] | python | en | ['en', 'en', 'en'] | True |
group_order | (tlist) | Group together Identifier and Asc/Desc token | Group together Identifier and Asc/Desc token | def group_order(tlist):
"""Group together Identifier and Asc/Desc token"""
tidx, token = tlist.token_next_by(t=T.Keyword.Order)
while token:
pidx, prev_ = tlist.token_prev(tidx)
if imt(prev_, i=sql.Identifier, t=T.Number):
tlist.group_tokens(sql.Identifier, pidx, tidx)
... | [
"def",
"group_order",
"(",
"tlist",
")",
":",
"tidx",
",",
"token",
"=",
"tlist",
".",
"token_next_by",
"(",
"t",
"=",
"T",
".",
"Keyword",
".",
"Order",
")",
"while",
"token",
":",
"pidx",
",",
"prev_",
"=",
"tlist",
".",
"token_prev",
"(",
"tidx",
... | [
353,
0
] | [
361,
70
] | python | en | ['en', 'en', 'en'] | True |
_group | (tlist, cls, match,
valid_prev=lambda t: True,
valid_next=lambda t: True,
post=None,
extend=True,
recurse=True
) | Groups together tokens that are joined by a middle token. i.e. x < y | Groups together tokens that are joined by a middle token. i.e. x < y | def _group(tlist, cls, match,
valid_prev=lambda t: True,
valid_next=lambda t: True,
post=None,
extend=True,
recurse=True
):
"""Groups together tokens that are joined by a middle token. i.e. x < y"""
tidx_offset = 0
pidx, prev_ = None, None
... | [
"def",
"_group",
"(",
"tlist",
",",
"cls",
",",
"match",
",",
"valid_prev",
"=",
"lambda",
"t",
":",
"True",
",",
"valid_next",
"=",
"lambda",
"t",
":",
"True",
",",
"post",
"=",
"None",
",",
"extend",
"=",
"True",
",",
"recurse",
"=",
"True",
")",... | [
422,
0
] | [
452,
33
] | python | en | ['en', 'en', 'en'] | True |
load | (f, _dict=dict) | Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictio... | Parses named file or files as toml and returns a dictionary | def load(f, _dict=dict):
"""Parses named file or files as toml and returns a dictionary
Args:
f: Path to the file to open, array of files to read into single dict
or a file descriptor
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed t... | [
"def",
"load",
"(",
"f",
",",
"_dict",
"=",
"dict",
")",
":",
"if",
"isinstance",
"(",
"f",
",",
"basestring",
")",
":",
"with",
"io",
".",
"open",
"(",
"f",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"ffile",
":",
"return",
"loads",
"(",
"ffile... | [
68,
0
] | [
111,
35
] | python | en | ['en', 'en', 'en'] | True |
loads | (s, _dict=dict) | Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
TomlDecodeError: Error while decoding toml
... | Parses string as toml | def loads(s, _dict=dict):
"""Parses string as toml
Args:
s: String to be parsed
_dict: (optional) Specifies the class of the returned toml dictionary
Returns:
Parsed toml file represented as a dictionary
Raises:
TypeError: When a non-string is passed
TomlDecode... | [
"def",
"loads",
"(",
"s",
",",
"_dict",
"=",
"dict",
")",
":",
"implicitgroups",
"=",
"[",
"]",
"retval",
"=",
"_dict",
"(",
")",
"currentlevel",
"=",
"retval",
"if",
"not",
"isinstance",
"(",
"s",
",",
"basestring",
")",
":",
"raise",
"TypeError",
"... | [
117,
0
] | [
404,
17
] | python | en | ['en', 'en', 'en'] | True |
_unescape | (v) | Unescape characters in a TOML string. | Unescape characters in a TOML string. | def _unescape(v):
"""Unescape characters in a TOML string."""
i = 0
backslash = False
while i < len(v):
if backslash:
backslash = False
if v[i] in _escapes:
v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:]
elif v[i] == '\\':
... | [
"def",
"_unescape",
"(",
"v",
")",
":",
"i",
"=",
"0",
"backslash",
"=",
"False",
"while",
"i",
"<",
"len",
"(",
"v",
")",
":",
"if",
"backslash",
":",
"backslash",
"=",
"False",
"if",
"v",
"[",
"i",
"]",
"in",
"_escapes",
":",
"v",
"=",
"v",
... | [
630,
0
] | [
649,
12
] | python | en | ['en', 'en', 'en'] | True |
dump | (o, f) | Writes out dict as toml to a file
Args:
o: Object to dump into toml
f: File descriptor where the toml should be stored
Returns:
String containing the toml corresponding to dictionary
Raises:
TypeError: When anything other than file descriptor is passed
| Writes out dict as toml to a file | def dump(o, f):
"""Writes out dict as toml to a file
Args:
o: Object to dump into toml
f: File descriptor where the toml should be stored
Returns:
String containing the toml corresponding to dictionary
Raises:
TypeError: When anything other than file descriptor is pass... | [
"def",
"dump",
"(",
"o",
",",
"f",
")",
":",
"if",
"not",
"f",
".",
"write",
":",
"raise",
"TypeError",
"(",
"\"You can only dump an object to a file descriptor\"",
")",
"d",
"=",
"dumps",
"(",
"o",
")",
"f",
".",
"write",
"(",
"d",
")",
"return",
"d"
... | [
854,
0
] | [
872,
12
] | python | en | ['en', 'en', 'en'] | True |
dumps | (o, preserve=False) | Stringifies input dict as toml
Args:
o: Object to dump into toml
preserve: Boolean parameter. If true, preserve inline tables.
Returns:
String containing the toml corresponding to dict
| Stringifies input dict as toml | def dumps(o, preserve=False):
"""Stringifies input dict as toml
Args:
o: Object to dump into toml
preserve: Boolean parameter. If true, preserve inline tables.
Returns:
String containing the toml corresponding to dict
"""
retval = ""
addtoretval, sections = _dump_sect... | [
"def",
"dumps",
"(",
"o",
",",
"preserve",
"=",
"False",
")",
":",
"retval",
"=",
"\"\"",
"addtoretval",
",",
"sections",
"=",
"_dump_sections",
"(",
"o",
",",
"\"\"",
")",
"retval",
"+=",
"addtoretval",
"while",
"sections",
"!=",
"{",
"}",
":",
"newse... | [
875,
0
] | [
904,
17
] | python | en | ['en', 'en', 'en'] | True |
_dump_inline_table | (section) | Preserve inline table in its compact syntax instead of expanding
into subsection.
https://github.com/toml-lang/toml#user-content-inline-table
| Preserve inline table in its compact syntax instead of expanding
into subsection. | def _dump_inline_table(section):
"""Preserve inline table in its compact syntax instead of expanding
into subsection.
https://github.com/toml-lang/toml#user-content-inline-table
"""
retval = ""
if isinstance(section, dict):
val_list = []
for k, v in section.items():
... | [
"def",
"_dump_inline_table",
"(",
"section",
")",
":",
"retval",
"=",
"\"\"",
"if",
"isinstance",
"(",
"section",
",",
"dict",
")",
":",
"val_list",
"=",
"[",
"]",
"for",
"k",
",",
"v",
"in",
"section",
".",
"items",
"(",
")",
":",
"val",
"=",
"_du... | [
962,
0
] | [
977,
44
] | python | en | ['en', 'en', 'en'] | True |
Guitarist.url | (self) | Returns the URL for this guitarist. | Returns the URL for this guitarist. | def url(self):
"Returns the URL for this guitarist."
return ('guitarist_detail', [self.slug]) | [
"def",
"url",
"(",
"self",
")",
":",
"return",
"(",
"'guitarist_detail'",
",",
"[",
"self",
".",
"slug",
"]",
")"
] | [
15,
4
] | [
17,
48
] | python | en | ['en', 'en', 'en'] | True |
Guitarist.url_with_attribute | (self) | Returns the URL for this guitarist and holds an attribute | Returns the URL for this guitarist and holds an attribute | def url_with_attribute(self):
"Returns the URL for this guitarist and holds an attribute"
return ('guitarist_detail', [self.slug]) | [
"def",
"url_with_attribute",
"(",
"self",
")",
":",
"return",
"(",
"'guitarist_detail'",
",",
"[",
"self",
".",
"slug",
"]",
")"
] | [
21,
4
] | [
23,
48
] | 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.