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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
ConnectionHandler.prepare_test_settings | (self, alias) |
Makes sure the test settings are available in the 'TEST' sub-dictionary.
|
Makes sure the test settings are available in the 'TEST' sub-dictionary.
| def prepare_test_settings(self, alias):
"""
Makes sure the test settings are available in the 'TEST' sub-dictionary.
"""
try:
conn = self.databases[alias]
except KeyError:
raise ConnectionDoesNotExist("The connection %s doesn't exist" % alias)
tes... | [
"def",
"prepare_test_settings",
"(",
"self",
",",
"alias",
")",
":",
"try",
":",
"conn",
"=",
"self",
".",
"databases",
"[",
"alias",
"]",
"except",
"KeyError",
":",
"raise",
"ConnectionDoesNotExist",
"(",
"\"The connection %s doesn't exist\"",
"%",
"alias",
")"... | [
190,
4
] | [
201,
47
] | python | en | ['en', 'error', 'th'] | False |
ConnectionRouter.__init__ | (self, routers=None) |
If routers is not specified, will default to settings.DATABASE_ROUTERS.
|
If routers is not specified, will default to settings.DATABASE_ROUTERS.
| def __init__(self, routers=None):
"""
If routers is not specified, will default to settings.DATABASE_ROUTERS.
"""
self._routers = routers | [
"def",
"__init__",
"(",
"self",
",",
"routers",
"=",
"None",
")",
":",
"self",
".",
"_routers",
"=",
"routers"
] | [
237,
4
] | [
241,
31
] | python | en | ['en', 'error', 'th'] | False |
ConnectionRouter.get_migratable_models | (self, app_config, db, include_auto_created=False) |
Return app models allowed to be synchronized on provided db.
|
Return app models allowed to be synchronized on provided db.
| def get_migratable_models(self, app_config, db, include_auto_created=False):
"""
Return app models allowed to be synchronized on provided db.
"""
models = app_config.get_models(include_auto_created=include_auto_created)
return [model for model in models if self.allow_migrate_mode... | [
"def",
"get_migratable_models",
"(",
"self",
",",
"app_config",
",",
"db",
",",
"include_auto_created",
"=",
"False",
")",
":",
"models",
"=",
"app_config",
".",
"get_models",
"(",
"include_auto_created",
"=",
"include_auto_created",
")",
"return",
"[",
"model",
... | [
313,
4
] | [
318,
81
] | python | en | ['en', 'error', 'th'] | False |
_get_named_url_graph | (url, auth) | Get the graph data structure AWX used to manage all named URLs.
Args:
url: String representing the URL of tower configuration endpoint where
to fetch graph information.
auth: Tuple of username + password to authenticate connection to AWX.
Return:
A dict of graph nodes that ... | Get the graph data structure AWX used to manage all named URLs. | def _get_named_url_graph(url, auth):
"""Get the graph data structure AWX used to manage all named URLs.
Args:
url: String representing the URL of tower configuration endpoint where
to fetch graph information.
auth: Tuple of username + password to authenticate connection to AWX.
... | [
"def",
"_get_named_url_graph",
"(",
"url",
",",
"auth",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"auth",
",",
"verify",
"=",
"False",
")",
"ret",
"=",
"r",
".",
"json",
"(",
")",
"[",
"'NAMED_URL_GRAPH_NODES'",
"]",
... | [
15,
0
] | [
32,
14
] | python | en | ['en', 'en', 'en'] | True |
_encode_uri | (text) | Properly encode input text to make it satisfy named URL convention.
Args:
text: the original string to be encoded.
Return:
The encoded string
Raises:
N/A
| Properly encode input text to make it satisfy named URL convention. | def _encode_uri(text):
"""Properly encode input text to make it satisfy named URL convention.
Args:
text: the original string to be encoded.
Return:
The encoded string
Raises:
N/A
"""
for c in URL_PATH_RESERVED_CHARSET:
if c in text:
text = text.rep... | [
"def",
"_encode_uri",
"(",
"text",
")",
":",
"for",
"c",
"in",
"URL_PATH_RESERVED_CHARSET",
":",
"if",
"c",
"in",
"text",
":",
"text",
"=",
"text",
".",
"replace",
"(",
"c",
",",
"URL_PATH_RESERVED_CHARSET",
"[",
"c",
"]",
")",
"text",
"=",
"text",
"."... | [
35,
0
] | [
51,
15
] | python | en | ['en', 'en', 'en'] | True |
_generate_identifier_component | (response, fields) | Generate an individual component of named URL identifier.
Args:
response: JSON containing the details of a particular resource object.
fields: name of resource object fields needed to generate a named URL
identifier component.
Return:
A string representing generated identif... | Generate an individual component of named URL identifier. | def _generate_identifier_component(response, fields):
"""Generate an individual component of named URL identifier.
Args:
response: JSON containing the details of a particular resource object.
fields: name of resource object fields needed to generate a named URL
identifier component.... | [
"def",
"_generate_identifier_component",
"(",
"response",
",",
"fields",
")",
":",
"ret",
"=",
"[",
"]",
"for",
"field_name",
"in",
"fields",
":",
"ret",
".",
"append",
"(",
"_encode_uri",
"(",
"response",
"[",
"field_name",
"]",
")",
")",
"return",
"NAMED... | [
54,
0
] | [
71,
50
] | python | en | ['en', 'en', 'en'] | True |
_get_named_url_identifier | (url, named_url_graph, resource, tower_host, auth, ret) | DFS the named URL graph structure to generate identifier for a resource object.
Args:
url: A string used to access a particular resource object to generate identifier
component from.
named_url_graph: The graph structure used to DFS against.
resource: Key name of the current grap... | DFS the named URL graph structure to generate identifier for a resource object. | def _get_named_url_identifier(url, named_url_graph, resource, tower_host, auth, ret):
"""DFS the named URL graph structure to generate identifier for a resource object.
Args:
url: A string used to access a particular resource object to generate identifier
component from.
named_url_g... | [
"def",
"_get_named_url_identifier",
"(",
"url",
",",
"named_url_graph",
",",
"resource",
",",
"tower_host",
",",
"auth",
",",
"ret",
")",
":",
"r",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"auth",
"=",
"auth",
",",
"verify",
"=",
"False",
")",
"."... | [
74,
0
] | [
100,
26
] | python | en | ['en', 'en', 'en'] | True |
main | (username=None, password=None, tower_host=None, resource=None, pk=None) | Main function for generating and printing named URL of a resource object given its pk.
Args:
username: String representing the username needed to authenticating AWX.
password: String representing the password needed to authenticating AWX.
tower_host: String representing the host name of AWX... | Main function for generating and printing named URL of a resource object given its pk. | def main(username=None, password=None, tower_host=None, resource=None, pk=None):
"""Main function for generating and printing named URL of a resource object given its pk.
Args:
username: String representing the username needed to authenticating AWX.
password: String representing the password ne... | [
"def",
"main",
"(",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"tower_host",
"=",
"None",
",",
"resource",
"=",
"None",
",",
"pk",
"=",
"None",
")",
":",
"start_url",
"=",
"'%s/api/v2/%s/%s/'",
"%",
"(",
"tower_host",
".",
"strip",
"("... | [
103,
0
] | [
126,
128
] | python | en | ['en', 'en', 'en'] | True |
NotificationTemplate.test | (self) | Create test notification | Create test notification | def test(self):
"""Create test notification"""
assert 'test' in self.related, "No such related attribute 'test'"
# trigger test notification
notification_id = self.related.test.post().notification
# return notification page
notifications_pg = self.get_related('notificat... | [
"def",
"test",
"(",
"self",
")",
":",
"assert",
"'test'",
"in",
"self",
".",
"related",
",",
"\"No such related attribute 'test'\"",
"# trigger test notification",
"notification_id",
"=",
"self",
".",
"related",
".",
"test",
".",
"post",
"(",
")",
".",
"notifica... | [
21,
4
] | [
34,
42
] | python | en | ['en', 'zh', 'en'] | True |
NotificationTemplate.silent_delete | (self) | Delete the Notification Template, ignoring the exception that is raised
if there are notifications pending.
| Delete the Notification Template, ignoring the exception that is raised
if there are notifications pending.
| def silent_delete(self):
"""Delete the Notification Template, ignoring the exception that is raised
if there are notifications pending.
"""
try:
super(NotificationTemplate, self).silent_delete()
except (exc.MethodNotAllowed):
pass | [
"def",
"silent_delete",
"(",
"self",
")",
":",
"try",
":",
"super",
"(",
"NotificationTemplate",
",",
"self",
")",
".",
"silent_delete",
"(",
")",
"except",
"(",
"exc",
".",
"MethodNotAllowed",
")",
":",
"pass"
] | [
36,
4
] | [
43,
16
] | python | en | ['en', 'en', 'en'] | True |
NotificationTemplate.associate | (self, resource, job_result='any') | Associates a NotificationTemplate with the provided resource | Associates a NotificationTemplate with the provided resource | def associate(self, resource, job_result='any'):
"""Associates a NotificationTemplate with the provided resource"""
return self._associate(resource, job_result) | [
"def",
"associate",
"(",
"self",
",",
"resource",
",",
"job_result",
"=",
"'any'",
")",
":",
"return",
"self",
".",
"_associate",
"(",
"resource",
",",
"job_result",
")"
] | [
118,
4
] | [
120,
52
] | python | en | ['en', 'en', 'en'] | True |
NotificationTemplate.disassociate | (self, resource, job_result='any') | Disassociates a NotificationTemplate with the provided resource | Disassociates a NotificationTemplate with the provided resource | def disassociate(self, resource, job_result='any'):
"""Disassociates a NotificationTemplate with the provided resource"""
return self._associate(resource, job_result, disassociate=True) | [
"def",
"disassociate",
"(",
"self",
",",
"resource",
",",
"job_result",
"=",
"'any'",
")",
":",
"return",
"self",
".",
"_associate",
"(",
"resource",
",",
"job_result",
",",
"disassociate",
"=",
"True",
")"
] | [
122,
4
] | [
124,
71
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.__init__ | (self, **kwargs) | Create a shape with size [100, 100]
and give it a label if it's named.
| Create a shape with size [100, 100]
and give it a label if it's named.
| def __init__(self, **kwargs):
'''Create a shape with size [100, 100]
and give it a label if it's named.
'''
super(BaseShape, self).__init__(**kwargs)
self.size_hint = (None, None)
self.add_widget(Label(text=self.name)) | [
"def",
"__init__",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"super",
"(",
"BaseShape",
",",
"self",
")",
".",
"__init__",
"(",
"*",
"*",
"kwargs",
")",
"self",
".",
"size_hint",
"=",
"(",
"None",
",",
"None",
")",
"self",
".",
"add_widget",
... | [
70,
4
] | [
76,
46
] | python | en | ['en', 'haw', 'en'] | True |
BaseShape.move_label | (self, x, y, *args) | Move label with shape name as the only child. | Move label with shape name as the only child. | def move_label(self, x, y, *args):
'''Move label with shape name as the only child.'''
self.children[0].pos = [x, y] | [
"def",
"move_label",
"(",
"self",
",",
"x",
",",
"y",
",",
"*",
"args",
")",
":",
"self",
".",
"children",
"[",
"0",
"]",
".",
"pos",
"=",
"[",
"x",
",",
"y",
"]"
] | [
78,
4
] | [
80,
37
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.move_collider | (self, offset_x, offset_y, *args) | Move debug collider when the shape moves. | Move debug collider when the shape moves. | def move_collider(self, offset_x, offset_y, *args):
'''Move debug collider when the shape moves.'''
points = self.debug_collider.points[:]
for i in range(0, self.debug_collider_len, 2):
points[i] += offset_x
points[i + 1] += offset_y
self.debug_collider.points = ... | [
"def",
"move_collider",
"(",
"self",
",",
"offset_x",
",",
"offset_y",
",",
"*",
"args",
")",
":",
"points",
"=",
"self",
".",
"debug_collider",
".",
"points",
"[",
":",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"self",
".",
"debug_collider_len",
... | [
82,
4
] | [
89,
43
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.on_debug_collider | (self, instance, value) | Recalculate length of collider points' array. | Recalculate length of collider points' array. | def on_debug_collider(self, instance, value):
'''Recalculate length of collider points' array.'''
self.debug_collider_len = len(value.points) | [
"def",
"on_debug_collider",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"self",
".",
"debug_collider_len",
"=",
"len",
"(",
"value",
".",
"points",
")"
] | [
91,
4
] | [
93,
51
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.on_poly | (self, instance, value) | Recalculate length of polygon points' array. | Recalculate length of polygon points' array. | def on_poly(self, instance, value):
'''Recalculate length of polygon points' array.'''
self.poly_len = len(value) | [
"def",
"on_poly",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"self",
".",
"poly_len",
"=",
"len",
"(",
"value",
")"
] | [
95,
4
] | [
97,
34
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.on_shape | (self, instance, value) | Recalculate length of Mesh vertices' array. | Recalculate length of Mesh vertices' array. | def on_shape(self, instance, value):
'''Recalculate length of Mesh vertices' array.'''
self.shape_len = len(value.vertices) | [
"def",
"on_shape",
"(",
"self",
",",
"instance",
",",
"value",
")",
":",
"self",
".",
"shape_len",
"=",
"len",
"(",
"value",
".",
"vertices",
")"
] | [
99,
4
] | [
101,
44
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.on_pos | (self, instance, pos) | Move polygon and its Mesh on each position change.
This event is above all and changes positions of the other
children-like components, so that a simple::
shape.pos = (100, 200)
would move everything, not just the widget itself.
| Move polygon and its Mesh on each position change.
This event is above all and changes positions of the other
children-like components, so that a simple:: | def on_pos(self, instance, pos):
'''Move polygon and its Mesh on each position change.
This event is above all and changes positions of the other
children-like components, so that a simple::
shape.pos = (100, 200)
would move everything, not just the widget itself.
'... | [
"def",
"on_pos",
"(",
"self",
",",
"instance",
",",
"pos",
")",
":",
"# position changed by touch",
"offset_x",
"=",
"self",
".",
"_new_touch",
"[",
"0",
"]",
"-",
"self",
".",
"_old_touch",
"[",
"0",
"]",
"offset_y",
"=",
"self",
".",
"_new_touch",
"[",... | [
103,
4
] | [
145,
36
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.on_touch_move | (self, touch, *args) | Move shape with dragging. | Move shape with dragging. | def on_touch_move(self, touch, *args):
'''Move shape with dragging.'''
# grab single touch for shape
if touch.grab_current is not self:
return
# get touches
x, y = touch.pos
new_pos = [x, y]
self._new_touch = new_pos
self._old_touch = [touch.... | [
"def",
"on_touch_move",
"(",
"self",
",",
"touch",
",",
"*",
"args",
")",
":",
"# grab single touch for shape",
"if",
"touch",
".",
"grab_current",
"is",
"not",
"self",
":",
"return",
"# get touches",
"x",
",",
"y",
"=",
"touch",
".",
"pos",
"new_pos",
"="... | [
147,
4
] | [
163,
57
] | python | en | ['en', 'en', 'en'] | True |
BaseShape.shape_collide | (self, x, y, *args) | Point to polygon collision through a list of points. | Point to polygon collision through a list of points. | def shape_collide(self, x, y, *args):
'''Point to polygon collision through a list of points.'''
# ignore if no polygon area is set
poly = self.poly
if not poly:
return False
n = self.poly_len
inside = False
p1x = poly[0]
p1y = poly[1]
... | [
"def",
"shape_collide",
"(",
"self",
",",
"x",
",",
"y",
",",
"*",
"args",
")",
":",
"# ignore if no polygon area is set",
"poly",
"=",
"self",
".",
"poly",
"if",
"not",
"poly",
":",
"return",
"False",
"n",
"=",
"self",
".",
"poly_len",
"inside",
"=",
... | [
165,
4
] | [
191,
21
] | python | en | ['en', 'en', 'en'] | True |
Collisions.collision_circles | (self, shapes=None, distance=100, debug=False, *args) | Simple circle <-> circle collision between the shapes i.e. there's
a simple line between the centers of the two shapes and the collision
is only about measuring distance -> 1+ radii intersections.
| Simple circle <-> circle collision between the shapes i.e. there's
a simple line between the centers of the two shapes and the collision
is only about measuring distance -> 1+ radii intersections.
| def collision_circles(self, shapes=None, distance=100, debug=False, *args):
'''Simple circle <-> circle collision between the shapes i.e. there's
a simple line between the centers of the two shapes and the collision
is only about measuring distance -> 1+ radii intersections.
'''
... | [
"def",
"collision_circles",
"(",
"self",
",",
"shapes",
"=",
"None",
",",
"distance",
"=",
"100",
",",
"debug",
"=",
"False",
",",
"*",
"args",
")",
":",
"# get all combinations from all available shapes",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'combins'",... | [
326,
4
] | [
358,
59
] | python | en | ['en', 'en', 'en'] | True |
Collisions.on_collision | (self, pair, *args) | Dispatched when objects collide, gives back colliding objects
as a "pair" argument holding their instances.
| Dispatched when objects collide, gives back colliding objects
as a "pair" argument holding their instances.
| def on_collision(self, pair, *args):
'''Dispatched when objects collide, gives back colliding objects
as a "pair" argument holding their instances.
'''
print('Collision {} x {}'.format(pair[0].name, pair[1].name)) | [
"def",
"on_collision",
"(",
"self",
",",
"pair",
",",
"*",
"args",
")",
":",
"print",
"(",
"'Collision {} x {}'",
".",
"format",
"(",
"pair",
"[",
"0",
"]",
".",
"name",
",",
"pair",
"[",
"1",
"]",
".",
"name",
")",
")"
] | [
360,
4
] | [
364,
69
] | python | en | ['en', 'en', 'en'] | True |
FixedOffsetTimezone.__new__ | (cls, offset=None, name=None) | Return a suitable instance created earlier if it exists
| Return a suitable instance created earlier if it exists
| def __new__(cls, offset=None, name=None):
"""Return a suitable instance created earlier if it exists
"""
key = (offset, name)
try:
return cls._cache[key]
except KeyError:
tz = super(FixedOffsetTimezone, cls).__new__(cls, offset, name)
cls._cach... | [
"def",
"__new__",
"(",
"cls",
",",
"offset",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"key",
"=",
"(",
"offset",
",",
"name",
")",
"try",
":",
"return",
"cls",
".",
"_cache",
"[",
"key",
"]",
"except",
"KeyError",
":",
"tz",
"=",
"super",... | [
59,
4
] | [
68,
21
] | python | en | ['en', 'en', 'en'] | True |
parse_fields_parameter | (fields_str) |
Parses the ?fields= GET parameter. As this parameter is supposed to be used
by developers, the syntax is quite tight (eg, not allowing any whitespace).
Having a strict syntax allows us to extend the it at a later date with less
chance of breaking anyone's code.
This function takes a string and ret... |
Parses the ?fields= GET parameter. As this parameter is supposed to be used
by developers, the syntax is quite tight (eg, not allowing any whitespace).
Having a strict syntax allows us to extend the it at a later date with less
chance of breaking anyone's code. | def parse_fields_parameter(fields_str):
"""
Parses the ?fields= GET parameter. As this parameter is supposed to be used
by developers, the syntax is quite tight (eg, not allowing any whitespace).
Having a strict syntax allows us to extend the it at a later date with less
chance of breaking anyone's ... | [
"def",
"parse_fields_parameter",
"(",
"fields_str",
")",
":",
"def",
"get_position",
"(",
"current_str",
")",
":",
"return",
"len",
"(",
"fields_str",
")",
"-",
"len",
"(",
"current_str",
")",
"def",
"parse_field_identifier",
"(",
"fields_str",
")",
":",
"firs... | [
58,
0
] | [
214,
17
] | python | en | ['en', 'error', 'th'] | False |
parse_boolean | (value) |
Parses strings into booleans using the following mapping (case-sensitive):
'true' => True
'false' => False
'1' => True
'0' => False
|
Parses strings into booleans using the following mapping (case-sensitive): | def parse_boolean(value):
"""
Parses strings into booleans using the following mapping (case-sensitive):
'true' => True
'false' => False
'1' => True
'0' => False
"""
if value in ['true', '1']:
return True
elif value in ['false', '0']:
return False
el... | [
"def",
"parse_boolean",
"(",
"value",
")",
":",
"if",
"value",
"in",
"[",
"'true'",
",",
"'1'",
"]",
":",
"return",
"True",
"elif",
"value",
"in",
"[",
"'false'",
",",
"'0'",
"]",
":",
"return",
"False",
"else",
":",
"raise",
"ValueError",
"(",
"\"ex... | [
217,
0
] | [
231,
72
] | python | en | ['en', 'error', 'th'] | False |
TestProofOfSpace.test_can_create_proof | (self) |
Tests that the change of getting a correct proof is exactly 1/target_filter.
|
Tests that the change of getting a correct proof is exactly 1/target_filter.
| def test_can_create_proof(self):
"""
Tests that the change of getting a correct proof is exactly 1/target_filter.
"""
num_trials = 100000
success_count = 0
target_filter = 2 ** DEFAULT_CONSTANTS.NUMBER_ZERO_BITS_PLOT_FILTER
for _ in range(num_trials):
... | [
"def",
"test_can_create_proof",
"(",
"self",
")",
":",
"num_trials",
"=",
"100000",
"success_count",
"=",
"0",
"target_filter",
"=",
"2",
"**",
"DEFAULT_CONSTANTS",
".",
"NUMBER_ZERO_BITS_PLOT_FILTER",
"for",
"_",
"in",
"range",
"(",
"num_trials",
")",
":",
"cha... | [
7,
4
] | [
22,
75
] | python | en | ['en', 'error', 'th'] | False |
register_json | (conn_or_curs=None, globally=False, loads=None,
oid=None, array_oid=None, name='json') | Create and register typecasters converting :sql:`json` type to Python objects.
:param conn_or_curs: a connection or cursor used to find the :sql:`json`
and :sql:`json[]` oids; the typecasters are registered in a scope
limited to this object, unless *globally* is set to `!True`. It can be
`!... | Create and register typecasters converting :sql:`json` type to Python objects. | def register_json(conn_or_curs=None, globally=False, loads=None,
oid=None, array_oid=None, name='json'):
"""Create and register typecasters converting :sql:`json` type to Python objects.
:param conn_or_curs: a connection or cursor used to find the :sql:`json`
and :sql:`json[]` oids; t... | [
"def",
"register_json",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
",",
"oid",
"=",
"None",
",",
"array_oid",
"=",
"None",
",",
"name",
"=",
"'json'",
")",
":",
"if",
"oid",
"is",
"None",
":",
"oid",
... | [
115,
0
] | [
151,
26
] | python | en | ['en', 'en', 'en'] | True |
register_default_json | (conn_or_curs=None, globally=False, loads=None) |
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.
Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
and fixed. This function allows specifying a customized *loads* function
for the default :sql:`json` type without querying the database.
All the ... |
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following. | def register_default_json(conn_or_curs=None, globally=False, loads=None):
"""
Create and register :sql:`json` typecasters for PostgreSQL 9.2 and following.
Since PostgreSQL 9.2 :sql:`json` is a builtin type, hence its oid is known
and fixed. This function allows specifying a customized *loads* function... | [
"def",
"register_default_json",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
")",
":",
"return",
"register_json",
"(",
"conn_or_curs",
"=",
"conn_or_curs",
",",
"globally",
"=",
"globally",
",",
"loads",
"=",
"l... | [
154,
0
] | [
164,
59
] | python | en | ['en', 'error', 'th'] | False |
register_default_jsonb | (conn_or_curs=None, globally=False, loads=None) |
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.
As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
PostgreSQL 9.4 and following versions. All the parameters have the same
mean... |
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following. | def register_default_jsonb(conn_or_curs=None, globally=False, loads=None):
"""
Create and register :sql:`jsonb` typecasters for PostgreSQL 9.4 and following.
As in `register_default_json()`, the function allows to register a
customized *loads* function for the :sql:`jsonb` type at its known oid for
... | [
"def",
"register_default_jsonb",
"(",
"conn_or_curs",
"=",
"None",
",",
"globally",
"=",
"False",
",",
"loads",
"=",
"None",
")",
":",
"return",
"register_json",
"(",
"conn_or_curs",
"=",
"conn_or_curs",
",",
"globally",
"=",
"globally",
",",
"loads",
"=",
"... | [
167,
0
] | [
177,
75
] | python | en | ['en', 'error', 'th'] | False |
_create_json_typecasters | (oid, array_oid, loads=None, name='JSON') | Create typecasters for json data type. | Create typecasters for json data type. | def _create_json_typecasters(oid, array_oid, loads=None, name='JSON'):
"""Create typecasters for json data type."""
if loads is None:
if json is None:
raise ImportError("no json module available")
else:
loads = json.loads
def typecast_json(s, cur):
if s is No... | [
"def",
"_create_json_typecasters",
"(",
"oid",
",",
"array_oid",
",",
"loads",
"=",
"None",
",",
"name",
"=",
"'JSON'",
")",
":",
"if",
"loads",
"is",
"None",
":",
"if",
"json",
"is",
"None",
":",
"raise",
"ImportError",
"(",
"\"no json module available\"",
... | [
180,
0
] | [
199,
26
] | python | en | ['en', 'en', 'en'] | True |
Json.dumps | (self, obj) | Serialize *obj* in JSON format.
The default is to call `!json.dumps()` or the *dumps* function
provided in the constructor. You can override this method to create a
customized JSON wrapper.
| Serialize *obj* in JSON format. | def dumps(self, obj):
"""Serialize *obj* in JSON format.
The default is to call `!json.dumps()` or the *dumps* function
provided in the constructor. You can override this method to create a
customized JSON wrapper.
"""
dumps = self._dumps
if dumps is not None:
... | [
"def",
"dumps",
"(",
"self",
",",
"obj",
")",
":",
"dumps",
"=",
"self",
".",
"_dumps",
"if",
"dumps",
"is",
"not",
"None",
":",
"return",
"dumps",
"(",
"obj",
")",
"else",
":",
"raise",
"ImportError",
"(",
"\"json module not available: \"",
"\"you should ... | [
81,
4
] | [
94,
54
] | python | en | ['en', 'fy', 'it'] | False |
canonicalize_version | (version) |
This is very similar to Version.__str__, but has one subtle difference
with the way it handles the release segment.
|
This is very similar to Version.__str__, but has one subtle difference
with the way it handles the release segment.
| def canonicalize_version(version):
# type: (Union[Version, str]) -> Union[Version, str]
"""
This is very similar to Version.__str__, but has one subtle difference
with the way it handles the release segment.
"""
if not isinstance(version, Version):
try:
version = Version(vers... | [
"def",
"canonicalize_version",
"(",
"version",
")",
":",
"# type: (Union[Version, str]) -> Union[Version, str]",
"if",
"not",
"isinstance",
"(",
"version",
",",
"Version",
")",
":",
"try",
":",
"version",
"=",
"Version",
"(",
"version",
")",
"except",
"InvalidVersio... | [
27,
0
] | [
66,
25
] | python | en | ['en', 'error', 'th'] | False |
get_chooser_context | () | construct context variables needed by the chooser JS | construct context variables needed by the chooser JS | def get_chooser_context():
"""construct context variables needed by the chooser JS"""
return {
'step': 'chooser',
'error_label': _("Server Error"),
'error_message': _("Report this error to your webmaster with the following information:"),
} | [
"def",
"get_chooser_context",
"(",
")",
":",
"return",
"{",
"'step'",
":",
"'chooser'",
",",
"'error_label'",
":",
"_",
"(",
"\"Server Error\"",
")",
",",
"'error_message'",
":",
"_",
"(",
"\"Report this error to your webmaster with the following information:\"",
")",
... | [
490,
0
] | [
496,
5
] | python | en | ['en', 'en', 'en'] | True |
get_task_result_data | (task) |
helper function: given a task, return the json data to pass back to the
chooser panel
|
helper function: given a task, return the json data to pass back to the
chooser panel
| def get_task_result_data(task):
"""
helper function: given a task, return the json data to pass back to the
chooser panel
"""
return {
'id': task.id,
'name': task.name,
'edit_url': reverse('wagtailadmin_workflows:edit_task', args=[task.id]),
} | [
"def",
"get_task_result_data",
"(",
"task",
")",
":",
"return",
"{",
"'id'",
":",
"task",
".",
"id",
",",
"'name'",
":",
"task",
".",
"name",
",",
"'edit_url'",
":",
"reverse",
"(",
"'wagtailadmin_workflows:edit_task'",
",",
"args",
"=",
"[",
"task",
".",
... | [
499,
0
] | [
509,
5
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_incident_open_multiple_services | (self) |
Tests if freshstatus incident open multiple services is handled correctly
|
Tests if freshstatus incident open multiple services is handled correctly
| def test_freshstatus_incident_open_multiple_services(self) -> None:
"""
Tests if freshstatus incident open multiple services is handled correctly
"""
expected_topic = "Degradation of Multiple Servers"
expected_message = """
The following incident has been opened: **Degradation of... | [
"def",
"test_freshstatus_incident_open_multiple_services",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Degradation of Multiple Servers\"",
"expected_message",
"=",
"\"\"\"\nThe following incident has been opened: **Degradation of Multiple Servers**\n**Description:** This... | [
11,
4
] | [
27,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_incident_open_multiple_services_over_limit | (self) |
Tests if freshstatus incident open multiple services over limit is handled correctly
|
Tests if freshstatus incident open multiple services over limit is handled correctly
| def test_freshstatus_incident_open_multiple_services_over_limit(self) -> None:
"""
Tests if freshstatus incident open multiple services over limit is handled correctly
"""
expected_topic = "Degradation of Multiple Servers"
expected_message = """
The following incident has been op... | [
"def",
"test_freshstatus_incident_open_multiple_services_over_limit",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Degradation of Multiple Servers\"",
"expected_message",
"=",
"\"\"\"\nThe following incident has been opened: **Degradation of Multiple Servers**\n**Descript... | [
29,
4
] | [
50,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_incident_open | (self) |
Tests if freshstatus incident open is handled correctly
|
Tests if freshstatus incident open is handled correctly
| def test_freshstatus_incident_open(self) -> None:
"""
Tests if freshstatus incident open is handled correctly
"""
expected_topic = "Degradation of Database Server"
expected_message = """
The following incident has been opened: **Degradation of Database Server**
**Description:** T... | [
"def",
"test_freshstatus_incident_open",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Degradation of Database Server\"",
"expected_message",
"=",
"\"\"\"\nThe following incident has been opened: **Degradation of Database Server**\n**Description:** This issue is being inve... | [
52,
4
] | [
64,
89
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_incident_note_created | (self) |
Tests if freshstatus incident note created is handled correctly
|
Tests if freshstatus incident note created is handled correctly
| def test_freshstatus_incident_note_created(self) -> None:
"""
Tests if freshstatus incident note created is handled correctly
"""
expected_topic = "Degradation of Database Server"
expected_message = """
The following note has been added to the incident: **Degradation of Database ... | [
"def",
"test_freshstatus_incident_note_created",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Degradation of Database Server\"",
"expected_message",
"=",
"\"\"\"\nThe following note has been added to the incident: **Degradation of Database Server**\n**Note:** The incident... | [
66,
4
] | [
75,
97
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_incident_closed | (self) |
Tests if freshstatus incident closed is handled correctly
|
Tests if freshstatus incident closed is handled correctly
| def test_freshstatus_incident_closed(self) -> None:
"""
Tests if freshstatus incident closed is handled correctly
"""
expected_topic = "Degradation of Database Server"
expected_message = """
The following incident has been closed: **Degradation of Database Server**
**Note:** The ... | [
"def",
"test_freshstatus_incident_closed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Degradation of Database Server\"",
"expected_message",
"=",
"\"\"\"\nThe following incident has been closed: **Degradation of Database Server**\n**Note:** The incident has been resolve... | [
77,
4
] | [
86,
91
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_scheduled_maintenance_planned | (self) |
Tests if freshstatus scheduled maintenance planned is handled correctly
|
Tests if freshstatus scheduled maintenance planned is handled correctly
| def test_freshstatus_scheduled_maintenance_planned(self) -> None:
"""
Tests if freshstatus scheduled maintenance planned is handled correctly
"""
expected_topic = "Expect some services downtime due to server maintenance"
expected_message = """
The following scheduled maintenance ... | [
"def",
"test_freshstatus_scheduled_maintenance_planned",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Expect some services downtime due to server maintenance\"",
"expected_message",
"=",
"\"\"\"\nThe following scheduled maintenance has been opened: **Expect some services ... | [
88,
4
] | [
103,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_scheduled_maintenance_planned_multiple_services | (self) |
Tests if freshstatus scheduled maintenance planned multiple services is handled correctly
|
Tests if freshstatus scheduled maintenance planned multiple services is handled correctly
| def test_freshstatus_scheduled_maintenance_planned_multiple_services(self) -> None:
"""
Tests if freshstatus scheduled maintenance planned multiple services is handled correctly
"""
expected_topic = "Expect some services downtime due to server maintenance"
expected_message = """
... | [
"def",
"test_freshstatus_scheduled_maintenance_planned_multiple_services",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Expect some services downtime due to server maintenance\"",
"expected_message",
"=",
"\"\"\"\nThe following scheduled maintenance has been opened: **Exp... | [
105,
4
] | [
123,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_scheduled_maintenance_planned_multiple_services_over_limit | (self) |
Tests if freshstatus scheduled maintenance planned multiple services over limit is handled correctly
|
Tests if freshstatus scheduled maintenance planned multiple services over limit is handled correctly
| def test_freshstatus_scheduled_maintenance_planned_multiple_services_over_limit(self) -> None:
"""
Tests if freshstatus scheduled maintenance planned multiple services over limit is handled correctly
"""
expected_topic = "Expect some services downtime due to server maintenance"
e... | [
"def",
"test_freshstatus_scheduled_maintenance_planned_multiple_services_over_limit",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Expect some services downtime due to server maintenance\"",
"expected_message",
"=",
"\"\"\"\nThe following scheduled maintenance has been op... | [
125,
4
] | [
147,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_scheduled_maintenance_note_created | (self) |
Tests if freshstatus scheduled maintenance note created is handled correctly
|
Tests if freshstatus scheduled maintenance note created is handled correctly
| def test_freshstatus_scheduled_maintenance_note_created(self) -> None:
"""
Tests if freshstatus scheduled maintenance note created is handled correctly
"""
expected_topic = "Scheduled Maintenance Test"
expected_message = """
The following note has been added to the scheduled main... | [
"def",
"test_freshstatus_scheduled_maintenance_note_created",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Scheduled Maintenance Test\"",
"expected_message",
"=",
"\"\"\"\nThe following note has been added to the scheduled maintenance: **Scheduled Maintenance Test**\n**No... | [
149,
4
] | [
160,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_scheduled_maintenance_closed | (self) |
Tests if freshstatus scheduled maintenance closed is handled correctly
|
Tests if freshstatus scheduled maintenance closed is handled correctly
| def test_freshstatus_scheduled_maintenance_closed(self) -> None:
"""
Tests if freshstatus scheduled maintenance closed is handled correctly
"""
expected_topic = "Scheduled Maintenance Test"
expected_message = """
The following scheduled maintenance has been closed: **Scheduled Ma... | [
"def",
"test_freshstatus_scheduled_maintenance_closed",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Scheduled Maintenance Test\"",
"expected_message",
"=",
"\"\"\"\nThe following scheduled maintenance has been closed: **Scheduled Maintenance Test**\n**Note:** The mainten... | [
162,
4
] | [
173,
9
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_test | (self) |
Tests if freshstatus test is handled correctly
|
Tests if freshstatus test is handled correctly
| def test_freshstatus_test(self) -> None:
"""
Tests if freshstatus test is handled correctly
"""
expected_topic = "Freshstatus"
expected_message = "Freshstatus webhook has been successfully configured."
self.check_webhook("freshstatus_test", expected_topic, expected_messag... | [
"def",
"test_freshstatus_test",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Freshstatus\"",
"expected_message",
"=",
"\"Freshstatus webhook has been successfully configured.\"",
"self",
".",
"check_webhook",
"(",
"\"freshstatus_test\"",
",",
"expected_topic... | [
175,
4
] | [
181,
80
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_event_not_supported | (self) |
Tests if freshstatus event not supported is handled correctly
|
Tests if freshstatus event not supported is handled correctly
| def test_freshstatus_event_not_supported(self) -> None:
"""
Tests if freshstatus event not supported is handled correctly
"""
expected_topic = "Sample title"
expected_message = "The event (INCIDENT_REOPEN) is not supported yet."
self.check_webhook("freshstatus_event_not_s... | [
"def",
"test_freshstatus_event_not_supported",
"(",
"self",
")",
"->",
"None",
":",
"expected_topic",
"=",
"\"Sample title\"",
"expected_message",
"=",
"\"The event (INCIDENT_REOPEN) is not supported yet.\"",
"self",
".",
"check_webhook",
"(",
"\"freshstatus_event_not_supported\"... | [
183,
4
] | [
189,
95
] | python | en | ['en', 'error', 'th'] | False |
FreshstatusHookTests.test_freshstatus_invalid_payload_with_missing_data | (self) |
Tests if invalid Freshstatus payloads are handled correctly
|
Tests if invalid Freshstatus payloads are handled correctly
| def test_freshstatus_invalid_payload_with_missing_data(self) -> None:
"""
Tests if invalid Freshstatus payloads are handled correctly
"""
self.url = self.build_webhook_url()
payload = self.get_body("freshstatus_invalid_payload_with_missing_data")
result = self.client_post... | [
"def",
"test_freshstatus_invalid_payload_with_missing_data",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"url",
"=",
"self",
".",
"build_webhook_url",
"(",
")",
"payload",
"=",
"self",
".",
"get_body",
"(",
"\"freshstatus_invalid_payload_with_missing_data\"",
")... | [
191,
4
] | [
207,
64
] | python | en | ['en', 'error', 'th'] | False |
JavaTestRunner._compile_scripts | (self) |
Compile .java files
|
Compile .java files
| def _compile_scripts(self):
"""
Compile .java files
"""
if not self._java_scripts:
return
self.log.debug("Compiling .java files started")
jar_path = join(self.engine.artifacts_dir, self.working_dir, self.settings.get("jar-name", "compiled.jar"))
if o... | [
"def",
"_compile_scripts",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_java_scripts",
":",
"return",
"self",
".",
"log",
".",
"debug",
"(",
"\"Compiling .java files started\"",
")",
"jar_path",
"=",
"join",
"(",
"self",
".",
"engine",
".",
"artifacts_... | [
126,
4
] | [
168,
24
] | python | en | ['en', 'error', 'th'] | False |
JavaTestRunner._make_jar | (self) |
move all .class files to compiled.jar
|
move all .class files to compiled.jar
| def _make_jar(self):
"""
move all .class files to compiled.jar
"""
self.log.debug("Making .jar started")
with open(join(self.engine.artifacts_dir, "jar.out"), 'ab') as jar_out:
with open(join(self.engine.artifacts_dir, "jar.err"), 'ab') as jar_err:
cl... | [
"def",
"_make_jar",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"\"Making .jar started\"",
")",
"with",
"open",
"(",
"join",
"(",
"self",
".",
"engine",
".",
"artifacts_dir",
",",
"\"jar.out\"",
")",
",",
"'ab'",
")",
"as",
"jar_out",
... | [
170,
4
] | [
199,
51
] | python | en | ['en', 'error', 'th'] | False |
CreateView.save_instance | (self) |
Called after the form is successfully validated - saves the object to the db
and returns the new object. Override this to implement custom save logic.
|
Called after the form is successfully validated - saves the object to the db
and returns the new object. Override this to implement custom save logic.
| def save_instance(self):
"""
Called after the form is successfully validated - saves the object to the db
and returns the new object. Override this to implement custom save logic.
"""
return self.form.save() | [
"def",
"save_instance",
"(",
"self",
")",
":",
"return",
"self",
".",
"form",
".",
"save",
"(",
")"
] | [
60,
4
] | [
65,
31
] | python | en | ['en', 'error', 'th'] | False |
EditView.save_instance | (self) |
Called after the form is successfully validated - saves the object to the db.
Override this to implement custom save logic.
|
Called after the form is successfully validated - saves the object to the db.
Override this to implement custom save logic.
| def save_instance(self):
"""
Called after the form is successfully validated - saves the object to the db.
Override this to implement custom save logic.
"""
return self.form.save() | [
"def",
"save_instance",
"(",
"self",
")",
":",
"return",
"self",
".",
"form",
".",
"save",
"(",
")"
] | [
117,
4
] | [
122,
31
] | python | en | ['en', 'error', 'th'] | False |
_date_from_string | (year, year_format, month='', month_format='', day='', day_format='', delim='__') |
Helper: get a datetime.date object given a format string and a year,
month, and day (only year is mandatory). Raise a 404 for an invalid date.
|
Helper: get a datetime.date object given a format string and a year,
month, and day (only year is mandatory). Raise a 404 for an invalid date.
| def _date_from_string(year, year_format, month='', month_format='', day='', day_format='', delim='__'):
"""
Helper: get a datetime.date object given a format string and a year,
month, and day (only year is mandatory). Raise a 404 for an invalid date.
"""
format = delim.join((year_format, month_forma... | [
"def",
"_date_from_string",
"(",
"year",
",",
"year_format",
",",
"month",
"=",
"''",
",",
"month_format",
"=",
"''",
",",
"day",
"=",
"''",
",",
"day_format",
"=",
"''",
",",
"delim",
"=",
"'__'",
")",
":",
"format",
"=",
"delim",
".",
"join",
"(",
... | [
683,
0
] | [
696,
10
] | python | en | ['en', 'error', 'th'] | False |
_get_next_prev | (generic_view, date, is_previous, period) |
Helper: Get the next or the previous valid date. The idea is to allow
links on month/day views to never be 404s by never providing a date
that'll be invalid for the given view.
This is a bit complicated since it handles different intervals of time,
hence the coupling to generic_view.
However ... |
Helper: Get the next or the previous valid date. The idea is to allow
links on month/day views to never be 404s by never providing a date
that'll be invalid for the given view. | def _get_next_prev(generic_view, date, is_previous, period):
"""
Helper: Get the next or the previous valid date. The idea is to allow
links on month/day views to never be 404s by never providing a date
that'll be invalid for the given view.
This is a bit complicated since it handles different inte... | [
"def",
"_get_next_prev",
"(",
"generic_view",
",",
"date",
",",
"is_previous",
",",
"period",
")",
":",
"date_field",
"=",
"generic_view",
".",
"get_date_field",
"(",
")",
"allow_empty",
"=",
"generic_view",
".",
"get_allow_empty",
"(",
")",
"allow_future",
"=",... | [
699,
0
] | [
786,
34
] | python | en | ['en', 'error', 'th'] | False |
timezone_today | () |
Return the current date in the current time zone.
|
Return the current date in the current time zone.
| def timezone_today():
"""
Return the current date in the current time zone.
"""
if settings.USE_TZ:
return timezone.localdate()
else:
return datetime.date.today() | [
"def",
"timezone_today",
"(",
")",
":",
"if",
"settings",
".",
"USE_TZ",
":",
"return",
"timezone",
".",
"localdate",
"(",
")",
"else",
":",
"return",
"datetime",
".",
"date",
".",
"today",
"(",
")"
] | [
789,
0
] | [
796,
36
] | python | en | ['en', 'error', 'th'] | False |
YearMixin.get_year_format | (self) |
Get a year format string in strptime syntax to be used to parse the
year from url variables.
|
Get a year format string in strptime syntax to be used to parse the
year from url variables.
| def get_year_format(self):
"""
Get a year format string in strptime syntax to be used to parse the
year from url variables.
"""
return self.year_format | [
"def",
"get_year_format",
"(",
"self",
")",
":",
"return",
"self",
".",
"year_format"
] | [
28,
4
] | [
33,
31
] | python | en | ['en', 'error', 'th'] | False |
YearMixin.get_year | (self) |
Return the year for which this view should display data.
|
Return the year for which this view should display data.
| def get_year(self):
"""
Return the year for which this view should display data.
"""
year = self.year
if year is None:
try:
year = self.kwargs['year']
except KeyError:
try:
year = self.request.GET['year']... | [
"def",
"get_year",
"(",
"self",
")",
":",
"year",
"=",
"self",
".",
"year",
"if",
"year",
"is",
"None",
":",
"try",
":",
"year",
"=",
"self",
".",
"kwargs",
"[",
"'year'",
"]",
"except",
"KeyError",
":",
"try",
":",
"year",
"=",
"self",
".",
"req... | [
35,
4
] | [
48,
19
] | python | en | ['en', 'error', 'th'] | False |
YearMixin.get_next_year | (self, date) |
Get the next valid year.
|
Get the next valid year.
| def get_next_year(self, date):
"""
Get the next valid year.
"""
return _get_next_prev(self, date, is_previous=False, period='year') | [
"def",
"get_next_year",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"False",
",",
"period",
"=",
"'year'",
")"
] | [
50,
4
] | [
54,
75
] | python | en | ['en', 'error', 'th'] | False |
YearMixin.get_previous_year | (self, date) |
Get the previous valid year.
|
Get the previous valid year.
| def get_previous_year(self, date):
"""
Get the previous valid year.
"""
return _get_next_prev(self, date, is_previous=True, period='year') | [
"def",
"get_previous_year",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"True",
",",
"period",
"=",
"'year'",
")"
] | [
56,
4
] | [
60,
74
] | python | en | ['en', 'error', 'th'] | False |
YearMixin._get_next_year | (self, date) |
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
|
Return the start date of the next interval. | def _get_next_year(self, date):
"""
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
"""
return date.replace(year=date.year + 1, month=1, day=1) | [
"def",
"_get_next_year",
"(",
"self",
",",
"date",
")",
":",
"return",
"date",
".",
"replace",
"(",
"year",
"=",
"date",
".",
"year",
"+",
"1",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
")"
] | [
62,
4
] | [
68,
63
] | python | en | ['en', 'error', 'th'] | False |
YearMixin._get_current_year | (self, date) |
Return the start date of the current interval.
|
Return the start date of the current interval.
| def _get_current_year(self, date):
"""
Return the start date of the current interval.
"""
return date.replace(month=1, day=1) | [
"def",
"_get_current_year",
"(",
"self",
",",
"date",
")",
":",
"return",
"date",
".",
"replace",
"(",
"month",
"=",
"1",
",",
"day",
"=",
"1",
")"
] | [
70,
4
] | [
74,
43
] | python | en | ['en', 'error', 'th'] | False |
MonthMixin.get_month_format | (self) |
Get a month format string in strptime syntax to be used to parse the
month from url variables.
|
Get a month format string in strptime syntax to be used to parse the
month from url variables.
| def get_month_format(self):
"""
Get a month format string in strptime syntax to be used to parse the
month from url variables.
"""
return self.month_format | [
"def",
"get_month_format",
"(",
"self",
")",
":",
"return",
"self",
".",
"month_format"
] | [
84,
4
] | [
89,
32
] | python | en | ['en', 'error', 'th'] | False |
MonthMixin.get_month | (self) |
Return the month for which this view should display data.
|
Return the month for which this view should display data.
| def get_month(self):
"""
Return the month for which this view should display data.
"""
month = self.month
if month is None:
try:
month = self.kwargs['month']
except KeyError:
try:
month = self.request.GET... | [
"def",
"get_month",
"(",
"self",
")",
":",
"month",
"=",
"self",
".",
"month",
"if",
"month",
"is",
"None",
":",
"try",
":",
"month",
"=",
"self",
".",
"kwargs",
"[",
"'month'",
"]",
"except",
"KeyError",
":",
"try",
":",
"month",
"=",
"self",
".",... | [
91,
4
] | [
104,
20
] | python | en | ['en', 'error', 'th'] | False |
MonthMixin.get_next_month | (self, date) |
Get the next valid month.
|
Get the next valid month.
| def get_next_month(self, date):
"""
Get the next valid month.
"""
return _get_next_prev(self, date, is_previous=False, period='month') | [
"def",
"get_next_month",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"False",
",",
"period",
"=",
"'month'",
")"
] | [
106,
4
] | [
110,
76
] | python | en | ['en', 'error', 'th'] | False |
MonthMixin.get_previous_month | (self, date) |
Get the previous valid month.
|
Get the previous valid month.
| def get_previous_month(self, date):
"""
Get the previous valid month.
"""
return _get_next_prev(self, date, is_previous=True, period='month') | [
"def",
"get_previous_month",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"True",
",",
"period",
"=",
"'month'",
")"
] | [
112,
4
] | [
116,
75
] | python | en | ['en', 'error', 'th'] | False |
MonthMixin._get_next_month | (self, date) |
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
|
Return the start date of the next interval. | def _get_next_month(self, date):
"""
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
"""
if date.month == 12:
return date.replace(year=date.year + 1, month=1, day=1)
else:
return da... | [
"def",
"_get_next_month",
"(",
"self",
",",
"date",
")",
":",
"if",
"date",
".",
"month",
"==",
"12",
":",
"return",
"date",
".",
"replace",
"(",
"year",
"=",
"date",
".",
"year",
"+",
"1",
",",
"month",
"=",
"1",
",",
"day",
"=",
"1",
")",
"el... | [
118,
4
] | [
127,
60
] | python | en | ['en', 'error', 'th'] | False |
MonthMixin._get_current_month | (self, date) |
Return the start date of the previous interval.
|
Return the start date of the previous interval.
| def _get_current_month(self, date):
"""
Return the start date of the previous interval.
"""
return date.replace(day=1) | [
"def",
"_get_current_month",
"(",
"self",
",",
"date",
")",
":",
"return",
"date",
".",
"replace",
"(",
"day",
"=",
"1",
")"
] | [
129,
4
] | [
133,
34
] | python | en | ['en', 'error', 'th'] | False |
DayMixin.get_day_format | (self) |
Get a day format string in strptime syntax to be used to parse the day
from url variables.
|
Get a day format string in strptime syntax to be used to parse the day
from url variables.
| def get_day_format(self):
"""
Get a day format string in strptime syntax to be used to parse the day
from url variables.
"""
return self.day_format | [
"def",
"get_day_format",
"(",
"self",
")",
":",
"return",
"self",
".",
"day_format"
] | [
143,
4
] | [
148,
30
] | python | en | ['en', 'error', 'th'] | False |
DayMixin.get_day | (self) |
Return the day for which this view should display data.
|
Return the day for which this view should display data.
| def get_day(self):
"""
Return the day for which this view should display data.
"""
day = self.day
if day is None:
try:
day = self.kwargs['day']
except KeyError:
try:
day = self.request.GET['day']
... | [
"def",
"get_day",
"(",
"self",
")",
":",
"day",
"=",
"self",
".",
"day",
"if",
"day",
"is",
"None",
":",
"try",
":",
"day",
"=",
"self",
".",
"kwargs",
"[",
"'day'",
"]",
"except",
"KeyError",
":",
"try",
":",
"day",
"=",
"self",
".",
"request",
... | [
150,
4
] | [
163,
18
] | python | en | ['en', 'error', 'th'] | False |
DayMixin.get_next_day | (self, date) |
Get the next valid day.
|
Get the next valid day.
| def get_next_day(self, date):
"""
Get the next valid day.
"""
return _get_next_prev(self, date, is_previous=False, period='day') | [
"def",
"get_next_day",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"False",
",",
"period",
"=",
"'day'",
")"
] | [
165,
4
] | [
169,
74
] | python | en | ['en', 'error', 'th'] | False |
DayMixin.get_previous_day | (self, date) |
Get the previous valid day.
|
Get the previous valid day.
| def get_previous_day(self, date):
"""
Get the previous valid day.
"""
return _get_next_prev(self, date, is_previous=True, period='day') | [
"def",
"get_previous_day",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"True",
",",
"period",
"=",
"'day'",
")"
] | [
171,
4
] | [
175,
73
] | python | en | ['en', 'error', 'th'] | False |
DayMixin._get_next_day | (self, date) |
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
|
Return the start date of the next interval. | def _get_next_day(self, date):
"""
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
"""
return date + datetime.timedelta(days=1) | [
"def",
"_get_next_day",
"(",
"self",
",",
"date",
")",
":",
"return",
"date",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")"
] | [
177,
4
] | [
183,
48
] | python | en | ['en', 'error', 'th'] | False |
DayMixin._get_current_day | (self, date) |
Return the start date of the current interval.
|
Return the start date of the current interval.
| def _get_current_day(self, date):
"""
Return the start date of the current interval.
"""
return date | [
"def",
"_get_current_day",
"(",
"self",
",",
"date",
")",
":",
"return",
"date"
] | [
185,
4
] | [
189,
19
] | python | en | ['en', 'error', 'th'] | False |
WeekMixin.get_week_format | (self) |
Get a week format string in strptime syntax to be used to parse the
week from url variables.
|
Get a week format string in strptime syntax to be used to parse the
week from url variables.
| def get_week_format(self):
"""
Get a week format string in strptime syntax to be used to parse the
week from url variables.
"""
return self.week_format | [
"def",
"get_week_format",
"(",
"self",
")",
":",
"return",
"self",
".",
"week_format"
] | [
199,
4
] | [
204,
31
] | python | en | ['en', 'error', 'th'] | False |
WeekMixin.get_week | (self) |
Return the week for which this view should display data
|
Return the week for which this view should display data
| def get_week(self):
"""
Return the week for which this view should display data
"""
week = self.week
if week is None:
try:
week = self.kwargs['week']
except KeyError:
try:
week = self.request.GET['week']
... | [
"def",
"get_week",
"(",
"self",
")",
":",
"week",
"=",
"self",
".",
"week",
"if",
"week",
"is",
"None",
":",
"try",
":",
"week",
"=",
"self",
".",
"kwargs",
"[",
"'week'",
"]",
"except",
"KeyError",
":",
"try",
":",
"week",
"=",
"self",
".",
"req... | [
206,
4
] | [
219,
19
] | python | en | ['en', 'error', 'th'] | False |
WeekMixin.get_next_week | (self, date) |
Get the next valid week.
|
Get the next valid week.
| def get_next_week(self, date):
"""
Get the next valid week.
"""
return _get_next_prev(self, date, is_previous=False, period='week') | [
"def",
"get_next_week",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"False",
",",
"period",
"=",
"'week'",
")"
] | [
221,
4
] | [
225,
75
] | python | en | ['en', 'error', 'th'] | False |
WeekMixin.get_previous_week | (self, date) |
Get the previous valid week.
|
Get the previous valid week.
| def get_previous_week(self, date):
"""
Get the previous valid week.
"""
return _get_next_prev(self, date, is_previous=True, period='week') | [
"def",
"get_previous_week",
"(",
"self",
",",
"date",
")",
":",
"return",
"_get_next_prev",
"(",
"self",
",",
"date",
",",
"is_previous",
"=",
"True",
",",
"period",
"=",
"'week'",
")"
] | [
227,
4
] | [
231,
74
] | python | en | ['en', 'error', 'th'] | False |
WeekMixin._get_next_week | (self, date) |
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
|
Return the start date of the next interval. | def _get_next_week(self, date):
"""
Return the start date of the next interval.
The interval is defined by start date <= item date < next start date.
"""
return date + datetime.timedelta(days=7 - self._get_weekday(date)) | [
"def",
"_get_next_week",
"(",
"self",
",",
"date",
")",
":",
"return",
"date",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"7",
"-",
"self",
".",
"_get_weekday",
"(",
"date",
")",
")"
] | [
233,
4
] | [
239,
74
] | python | en | ['en', 'error', 'th'] | False |
WeekMixin._get_current_week | (self, date) |
Return the start date of the current interval.
|
Return the start date of the current interval.
| def _get_current_week(self, date):
"""
Return the start date of the current interval.
"""
return date - datetime.timedelta(self._get_weekday(date)) | [
"def",
"_get_current_week",
"(",
"self",
",",
"date",
")",
":",
"return",
"date",
"-",
"datetime",
".",
"timedelta",
"(",
"self",
".",
"_get_weekday",
"(",
"date",
")",
")"
] | [
241,
4
] | [
245,
65
] | python | en | ['en', 'error', 'th'] | False |
WeekMixin._get_weekday | (self, date) |
Return the weekday for a given date.
The first day according to the week format is 0 and the last day is 6.
|
Return the weekday for a given date. | def _get_weekday(self, date):
"""
Return the weekday for a given date.
The first day according to the week format is 0 and the last day is 6.
"""
week_format = self.get_week_format()
if week_format == '%W': # week starts on Monday
return date.... | [
"def",
"_get_weekday",
"(",
"self",
",",
"date",
")",
":",
"week_format",
"=",
"self",
".",
"get_week_format",
"(",
")",
"if",
"week_format",
"==",
"'%W'",
":",
"# week starts on Monday",
"return",
"date",
".",
"weekday",
"(",
")",
"elif",
"week_format",
"==... | [
247,
4
] | [
259,
69
] | python | en | ['en', 'error', 'th'] | False |
DateMixin.get_date_field | (self) |
Get the name of the date field to be used to filter by.
|
Get the name of the date field to be used to filter by.
| def get_date_field(self):
"""
Get the name of the date field to be used to filter by.
"""
if self.date_field is None:
raise ImproperlyConfigured("%s.date_field is required." % self.__class__.__name__)
return self.date_field | [
"def",
"get_date_field",
"(",
"self",
")",
":",
"if",
"self",
".",
"date_field",
"is",
"None",
":",
"raise",
"ImproperlyConfigured",
"(",
"\"%s.date_field is required.\"",
"%",
"self",
".",
"__class__",
".",
"__name__",
")",
"return",
"self",
".",
"date_field"
] | [
269,
4
] | [
275,
30
] | python | en | ['en', 'error', 'th'] | False |
DateMixin.get_allow_future | (self) |
Returns `True` if the view should be allowed to display objects from
the future.
|
Returns `True` if the view should be allowed to display objects from
the future.
| def get_allow_future(self):
"""
Returns `True` if the view should be allowed to display objects from
the future.
"""
return self.allow_future | [
"def",
"get_allow_future",
"(",
"self",
")",
":",
"return",
"self",
".",
"allow_future"
] | [
277,
4
] | [
282,
32
] | python | en | ['en', 'error', 'th'] | False |
DateMixin.uses_datetime_field | (self) |
Return `True` if the date field is a `DateTimeField` and `False`
if it's a `DateField`.
|
Return `True` if the date field is a `DateTimeField` and `False`
if it's a `DateField`.
| def uses_datetime_field(self):
"""
Return `True` if the date field is a `DateTimeField` and `False`
if it's a `DateField`.
"""
model = self.get_queryset().model if self.model is None else self.model
field = model._meta.get_field(self.get_date_field())
return isins... | [
"def",
"uses_datetime_field",
"(",
"self",
")",
":",
"model",
"=",
"self",
".",
"get_queryset",
"(",
")",
".",
"model",
"if",
"self",
".",
"model",
"is",
"None",
"else",
"self",
".",
"model",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
... | [
288,
4
] | [
295,
54
] | python | en | ['en', 'error', 'th'] | False |
DateMixin._make_date_lookup_arg | (self, value) |
Convert a date into a datetime when the date field is a DateTimeField.
When time zone support is enabled, `date` is assumed to be in the
current time zone, so that displayed items are consistent with the URL.
|
Convert a date into a datetime when the date field is a DateTimeField. | def _make_date_lookup_arg(self, value):
"""
Convert a date into a datetime when the date field is a DateTimeField.
When time zone support is enabled, `date` is assumed to be in the
current time zone, so that displayed items are consistent with the URL.
"""
if self.uses_d... | [
"def",
"_make_date_lookup_arg",
"(",
"self",
",",
"value",
")",
":",
"if",
"self",
".",
"uses_datetime_field",
":",
"value",
"=",
"datetime",
".",
"datetime",
".",
"combine",
"(",
"value",
",",
"datetime",
".",
"time",
".",
"min",
")",
"if",
"settings",
... | [
297,
4
] | [
308,
20
] | python | en | ['en', 'error', 'th'] | False |
DateMixin._make_single_date_lookup | (self, date) |
Get the lookup kwargs for filtering on a single date.
If the date field is a DateTimeField, we can't just filter on
date_field=date because that doesn't take the time into account.
|
Get the lookup kwargs for filtering on a single date. | def _make_single_date_lookup(self, date):
"""
Get the lookup kwargs for filtering on a single date.
If the date field is a DateTimeField, we can't just filter on
date_field=date because that doesn't take the time into account.
"""
date_field = self.get_date_field()
... | [
"def",
"_make_single_date_lookup",
"(",
"self",
",",
"date",
")",
":",
"date_field",
"=",
"self",
".",
"get_date_field",
"(",
")",
"if",
"self",
".",
"uses_datetime_field",
":",
"since",
"=",
"self",
".",
"_make_date_lookup_arg",
"(",
"date",
")",
"until",
"... | [
310,
4
] | [
327,
37
] | python | en | ['en', 'error', 'th'] | False |
BaseDateListView.get_dated_items | (self) |
Obtain the list of dates and items.
|
Obtain the list of dates and items.
| def get_dated_items(self):
"""
Obtain the list of dates and items.
"""
raise NotImplementedError('A DateView must provide an implementation of get_dated_items()') | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"'A DateView must provide an implementation of get_dated_items()'",
")"
] | [
344,
4
] | [
348,
99
] | python | en | ['en', 'error', 'th'] | False |
BaseDateListView.get_ordering | (self) |
Returns the field or fields to use for ordering the queryset; uses the
date field by default.
|
Returns the field or fields to use for ordering the queryset; uses the
date field by default.
| def get_ordering(self):
"""
Returns the field or fields to use for ordering the queryset; uses the
date field by default.
"""
return '-%s' % self.get_date_field() if self.ordering is None else self.ordering | [
"def",
"get_ordering",
"(",
"self",
")",
":",
"return",
"'-%s'",
"%",
"self",
".",
"get_date_field",
"(",
")",
"if",
"self",
".",
"ordering",
"is",
"None",
"else",
"self",
".",
"ordering"
] | [
350,
4
] | [
355,
88
] | python | en | ['en', 'error', 'th'] | False |
BaseDateListView.get_dated_queryset | (self, **lookup) |
Get a queryset properly filtered according to `allow_future` and any
extra lookup kwargs.
|
Get a queryset properly filtered according to `allow_future` and any
extra lookup kwargs.
| def get_dated_queryset(self, **lookup):
"""
Get a queryset properly filtered according to `allow_future` and any
extra lookup kwargs.
"""
qs = self.get_queryset().filter(**lookup)
date_field = self.get_date_field()
allow_future = self.get_allow_future()
al... | [
"def",
"get_dated_queryset",
"(",
"self",
",",
"*",
"*",
"lookup",
")",
":",
"qs",
"=",
"self",
".",
"get_queryset",
"(",
")",
".",
"filter",
"(",
"*",
"*",
"lookup",
")",
"date_field",
"=",
"self",
".",
"get_date_field",
"(",
")",
"allow_future",
"=",... | [
357,
4
] | [
381,
17
] | python | en | ['en', 'error', 'th'] | False |
BaseDateListView.get_date_list_period | (self) |
Get the aggregation period for the list of dates: 'year', 'month', or 'day'.
|
Get the aggregation period for the list of dates: 'year', 'month', or 'day'.
| def get_date_list_period(self):
"""
Get the aggregation period for the list of dates: 'year', 'month', or 'day'.
"""
return self.date_list_period | [
"def",
"get_date_list_period",
"(",
"self",
")",
":",
"return",
"self",
".",
"date_list_period"
] | [
383,
4
] | [
387,
36
] | python | en | ['en', 'error', 'th'] | False |
BaseDateListView.get_date_list | (self, queryset, date_type=None, ordering='ASC') |
Get a date list by calling `queryset.dates/datetimes()`, checking
along the way for empty lists that aren't allowed.
|
Get a date list by calling `queryset.dates/datetimes()`, checking
along the way for empty lists that aren't allowed.
| def get_date_list(self, queryset, date_type=None, ordering='ASC'):
"""
Get a date list by calling `queryset.dates/datetimes()`, checking
along the way for empty lists that aren't allowed.
"""
date_field = self.get_date_field()
allow_empty = self.get_allow_empty()
... | [
"def",
"get_date_list",
"(",
"self",
",",
"queryset",
",",
"date_type",
"=",
"None",
",",
"ordering",
"=",
"'ASC'",
")",
":",
"date_field",
"=",
"self",
".",
"get_date_field",
"(",
")",
"allow_empty",
"=",
"self",
".",
"get_allow_empty",
"(",
")",
"if",
... | [
389,
4
] | [
408,
24
] | python | en | ['en', 'error', 'th'] | False |
BaseArchiveIndexView.get_dated_items | (self) |
Return (date_list, items, extra_context) for this request.
|
Return (date_list, items, extra_context) for this request.
| def get_dated_items(self):
"""
Return (date_list, items, extra_context) for this request.
"""
qs = self.get_dated_queryset()
date_list = self.get_date_list(qs, ordering='DESC')
if not date_list:
qs = qs.none()
return (date_list, qs, {}) | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"qs",
"=",
"self",
".",
"get_dated_queryset",
"(",
")",
"date_list",
"=",
"self",
".",
"get_date_list",
"(",
"qs",
",",
"ordering",
"=",
"'DESC'",
")",
"if",
"not",
"date_list",
":",
"qs",
"=",
"qs",
"."... | [
419,
4
] | [
429,
34
] | python | en | ['en', 'error', 'th'] | False |
BaseYearArchiveView.get_dated_items | (self) |
Return (date_list, items, extra_context) for this request.
|
Return (date_list, items, extra_context) for this request.
| def get_dated_items(self):
"""
Return (date_list, items, extra_context) for this request.
"""
year = self.get_year()
date_field = self.get_date_field()
date = _date_from_string(year, self.get_year_format())
since = self._make_date_lookup_arg(date)
until ... | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"year",
"=",
"self",
".",
"get_year",
"(",
")",
"date_field",
"=",
"self",
".",
"get_date_field",
"(",
")",
"date",
"=",
"_date_from_string",
"(",
"year",
",",
"self",
".",
"get_year_format",
"(",
")",
")"... | [
446,
4
] | [
474,
10
] | python | en | ['en', 'error', 'th'] | False |
BaseYearArchiveView.get_make_object_list | (self) |
Return `True` if this view should contain the full list of objects in
the given year.
|
Return `True` if this view should contain the full list of objects in
the given year.
| def get_make_object_list(self):
"""
Return `True` if this view should contain the full list of objects in
the given year.
"""
return self.make_object_list | [
"def",
"get_make_object_list",
"(",
"self",
")",
":",
"return",
"self",
".",
"make_object_list"
] | [
476,
4
] | [
481,
36
] | python | en | ['en', 'error', 'th'] | False |
BaseMonthArchiveView.get_dated_items | (self) |
Return (date_list, items, extra_context) for this request.
|
Return (date_list, items, extra_context) for this request.
| def get_dated_items(self):
"""
Return (date_list, items, extra_context) for this request.
"""
year = self.get_year()
month = self.get_month()
date_field = self.get_date_field()
date = _date_from_string(year, self.get_year_format(),
... | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"year",
"=",
"self",
".",
"get_year",
"(",
")",
"month",
"=",
"self",
".",
"get_month",
"(",
")",
"date_field",
"=",
"self",
".",
"get_date_field",
"(",
")",
"date",
"=",
"_date_from_string",
"(",
"year",
... | [
497,
4
] | [
522,
10
] | python | en | ['en', 'error', 'th'] | False |
BaseWeekArchiveView.get_dated_items | (self) |
Return (date_list, items, extra_context) for this request.
|
Return (date_list, items, extra_context) for this request.
| def get_dated_items(self):
"""
Return (date_list, items, extra_context) for this request.
"""
year = self.get_year()
week = self.get_week()
date_field = self.get_date_field()
week_format = self.get_week_format()
week_start = {
'%W': '1',
... | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"year",
"=",
"self",
".",
"get_year",
"(",
")",
"week",
"=",
"self",
".",
"get_week",
"(",
")",
"date_field",
"=",
"self",
".",
"get_date_field",
"(",
")",
"week_format",
"=",
"self",
".",
"get_week_format... | [
537,
4
] | [
567,
10
] | python | en | ['en', 'error', 'th'] | False |
BaseDayArchiveView.get_dated_items | (self) |
Return (date_list, items, extra_context) for this request.
|
Return (date_list, items, extra_context) for this request.
| def get_dated_items(self):
"""
Return (date_list, items, extra_context) for this request.
"""
year = self.get_year()
month = self.get_month()
day = self.get_day()
date = _date_from_string(year, self.get_year_format(),
month, self.... | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"year",
"=",
"self",
".",
"get_year",
"(",
")",
"month",
"=",
"self",
".",
"get_month",
"(",
")",
"day",
"=",
"self",
".",
"get_day",
"(",
")",
"date",
"=",
"_date_from_string",
"(",
"year",
",",
"self... | [
581,
4
] | [
593,
42
] | python | en | ['en', 'error', 'th'] | False |
BaseDayArchiveView._get_dated_items | (self, date) |
Do the actual heavy lifting of getting the dated items; this accepts a
date object so that TodayArchiveView can be trivial.
|
Do the actual heavy lifting of getting the dated items; this accepts a
date object so that TodayArchiveView can be trivial.
| def _get_dated_items(self, date):
"""
Do the actual heavy lifting of getting the dated items; this accepts a
date object so that TodayArchiveView can be trivial.
"""
lookup_kwargs = self._make_single_date_lookup(date)
qs = self.get_dated_queryset(**lookup_kwargs)
... | [
"def",
"_get_dated_items",
"(",
"self",
",",
"date",
")",
":",
"lookup_kwargs",
"=",
"self",
".",
"_make_single_date_lookup",
"(",
"date",
")",
"qs",
"=",
"self",
".",
"get_dated_queryset",
"(",
"*",
"*",
"lookup_kwargs",
")",
"return",
"(",
"None",
",",
"... | [
595,
4
] | [
609,
10
] | python | en | ['en', 'error', 'th'] | False |
BaseTodayArchiveView.get_dated_items | (self) |
Return (date_list, items, extra_context) for this request.
|
Return (date_list, items, extra_context) for this request.
| def get_dated_items(self):
"""
Return (date_list, items, extra_context) for this request.
"""
return self._get_dated_items(datetime.date.today()) | [
"def",
"get_dated_items",
"(",
"self",
")",
":",
"return",
"self",
".",
"_get_dated_items",
"(",
"datetime",
".",
"date",
".",
"today",
"(",
")",
")"
] | [
624,
4
] | [
628,
59
] | python | en | ['en', 'error', 'th'] | False |
BaseDateDetailView.get_object | (self, queryset=None) |
Get the object this request displays.
|
Get the object this request displays.
| def get_object(self, queryset=None):
"""
Get the object this request displays.
"""
year = self.get_year()
month = self.get_month()
day = self.get_day()
date = _date_from_string(year, self.get_year_format(),
month, self.get_month_fo... | [
"def",
"get_object",
"(",
"self",
",",
"queryset",
"=",
"None",
")",
":",
"year",
"=",
"self",
".",
"get_year",
"(",
")",
"month",
"=",
"self",
".",
"get_month",
"(",
")",
"day",
"=",
"self",
".",
"get_day",
"(",
")",
"date",
"=",
"_date_from_string"... | [
643,
4
] | [
672,
66
] | python | en | ['en', 'error', 'th'] | False |
TextFile.__init__ | (self, filename=None, file=None, **options) | Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'. | Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'. | def __init__(self, filename=None, file=None, **options):
"""Construct a new TextFile object. At least one of 'filename'
(a string) and 'file' (a file-like object) must be supplied.
They keyword argument options are described above and affect
the values returned by 'readline()'.... | [
"def",
"__init__",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"file",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"if",
"filename",
"is",
"None",
"and",
"file",
"is",
"None",
":",
"raise",
"RuntimeError",
"(",
"\"you must supply either or both of... | [
77,
4
] | [
108,
25
] | 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.