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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
BlockTools.get_plot_signature | (self, m: bytes32, plot_pk: G1Element) |
Returns the plot signature of the header data.
|
Returns the plot signature of the header data.
| def get_plot_signature(self, m: bytes32, plot_pk: G1Element) -> G2Element:
"""
Returns the plot signature of the header data.
"""
farmer_sk = master_sk_to_farmer_sk(self.all_sks[0])
for _, plot_info in self.plots.items():
if plot_pk == plot_info.plot_public_key:
... | [
"def",
"get_plot_signature",
"(",
"self",
",",
"m",
":",
"bytes32",
",",
"plot_pk",
":",
"G1Element",
")",
"->",
"G2Element",
":",
"farmer_sk",
"=",
"master_sk_to_farmer_sk",
"(",
"self",
".",
"all_sks",
"[",
"0",
"]",
")",
"for",
"_",
",",
"plot_info",
... | [
225,
4
] | [
245,
54
] | python | en | ['en', 'error', 'th'] | False |
Resource._can_paginate | (self) |
Check if resource can be paginated
:return: Can paginate
|
Check if resource can be paginated
:return: Can paginate
| def _can_paginate(self) -> bool:
"""
Check if resource can be paginated
:return: Can paginate
"""
return True | [
"def",
"_can_paginate",
"(",
"self",
")",
"->",
"bool",
":",
"return",
"True"
] | [
69,
4
] | [
74,
19
] | python | en | ['en', 'error', 'th'] | False |
Resource._handle_pagination_response | (self, response: dict) |
Pagination hook for every iteration
:param response: Response from pagination
:return: None
|
Pagination hook for every iteration
:param response: Response from pagination
:return: None
| def _handle_pagination_response(self, response: dict) -> List[T]:
"""
Pagination hook for every iteration
:param response: Response from pagination
:return: None
"""
elements: List[T] = [T(api=self._api, data=data) for data in response['data']]
return elements | [
"def",
"_handle_pagination_response",
"(",
"self",
",",
"response",
":",
"dict",
")",
"->",
"List",
"[",
"T",
"]",
":",
"elements",
":",
"List",
"[",
"T",
"]",
"=",
"[",
"T",
"(",
"api",
"=",
"self",
".",
"_api",
",",
"data",
"=",
"data",
")",
"f... | [
77,
4
] | [
85,
23
] | python | en | ['en', 'error', 'th'] | False |
Resource._next_page | (self, ignore_cache: bool = False) |
API Pagination
Get next page from API
:param ignore_cache: Whether to ignore API cache.
:return: Response
|
API Pagination
Get next page from API
:param ignore_cache: Whether to ignore API cache.
:return: Response
| def _next_page(self, ignore_cache: bool = False) -> dict:
"""
API Pagination
Get next page from API
:param ignore_cache: Whether to ignore API cache.
:return: Response
"""
# API Response
self._kwargs['after'] = self._cursor
response: dict = self._... | [
"def",
"_next_page",
"(",
"self",
",",
"ignore_cache",
":",
"bool",
"=",
"False",
")",
"->",
"dict",
":",
"# API Response",
"self",
".",
"_kwargs",
"[",
"'after'",
"]",
"=",
"self",
".",
"_cursor",
"response",
":",
"dict",
"=",
"self",
".",
"_api",
"."... | [
87,
4
] | [
102,
23
] | python | en | ['en', 'error', 'th'] | False |
get_pointer_arr | (n) | Gets a ctypes pointer array (of length `n`) for GEOSGeom_t opaque pointer. | Gets a ctypes pointer array (of length `n`) for GEOSGeom_t opaque pointer. | def get_pointer_arr(n):
"Gets a ctypes pointer array (of length `n`) for GEOSGeom_t opaque pointer."
GeomArr = GEOM_PTR * n
return GeomArr() | [
"def",
"get_pointer_arr",
"(",
"n",
")",
":",
"GeomArr",
"=",
"GEOM_PTR",
"*",
"n",
"return",
"GeomArr",
"(",
")"
] | [
132,
0
] | [
135,
20
] | python | en | ['en', 'en', 'en'] | True |
geos_version_info | () |
Returns a dictionary containing the various version metadata parsed from
the GEOS version string, including the version number, whether the version
is a release candidate (and what number release candidate), and the C API
version.
|
Returns a dictionary containing the various version metadata parsed from
the GEOS version string, including the version number, whether the version
is a release candidate (and what number release candidate), and the C API
version.
| def geos_version_info():
"""
Returns a dictionary containing the various version metadata parsed from
the GEOS version string, including the version number, whether the version
is a release candidate (and what number release candidate), and the C API
version.
"""
ver = geos_version().decode(... | [
"def",
"geos_version_info",
"(",
")",
":",
"ver",
"=",
"geos_version",
"(",
")",
".",
"decode",
"(",
")",
"m",
"=",
"version_regex",
".",
"match",
"(",
"ver",
")",
"if",
"not",
"m",
":",
"raise",
"GEOSException",
"(",
"'Could not parse version info string \"... | [
185,
0
] | [
197,
86
] | python | en | ['en', 'error', 'th'] | False |
TestImageEditView.test_reupload_same_name | (self) |
Checks that reuploading the image file with the same file name
changes the file name, to avoid browser cache issues (see #3817).
|
Checks that reuploading the image file with the same file name
changes the file name, to avoid browser cache issues (see #3817).
| def test_reupload_same_name(self):
"""
Checks that reuploading the image file with the same file name
changes the file name, to avoid browser cache issues (see #3817).
"""
old_file = self.image.file
old_size = self.image.file_size
old_data = self.get_content()
... | [
"def",
"test_reupload_same_name",
"(",
"self",
")",
":",
"old_file",
"=",
"self",
".",
"image",
".",
"file",
"old_size",
"=",
"self",
".",
"image",
".",
"file_size",
"old_data",
"=",
"self",
".",
"get_content",
"(",
")",
"old_rendition",
"=",
"self",
".",
... | [
609,
4
] | [
642,
47
] | python | en | ['en', 'error', 'th'] | False |
TestImageEditView.test_reupload_different_name | (self) |
Checks that reuploading the image file with a different file name
correctly uses the new file name.
|
Checks that reuploading the image file with a different file name
correctly uses the new file name.
| def test_reupload_different_name(self):
"""
Checks that reuploading the image file with a different file name
correctly uses the new file name.
"""
old_file = self.image.file
old_size = self.image.file_size
old_data = self.get_content()
old_rendition = se... | [
"def",
"test_reupload_different_name",
"(",
"self",
")",
":",
"old_file",
"=",
"self",
".",
"image",
".",
"file",
"old_size",
"=",
"self",
".",
"image",
".",
"file_size",
"old_data",
"=",
"self",
".",
"get_content",
"(",
")",
"old_rendition",
"=",
"self",
... | [
644,
4
] | [
677,
47
] | python | en | ['en', 'error', 'th'] | False |
TestImageChooserUploadView.test_select_format_flag_after_upload_form_error_bad_extension | (self) |
Check the error message is accruate for a valid imate bug invalid file extension.
|
Check the error message is accruate for a valid imate bug invalid file extension.
| def test_select_format_flag_after_upload_form_error_bad_extension(self):
"""
Check the error message is accruate for a valid imate bug invalid file extension.
"""
submit_url = reverse('wagtailimages:chooser_upload') + '?select_format=true'
response = self.client.post(submit_url, ... | [
"def",
"test_select_format_flag_after_upload_form_error_bad_extension",
"(",
"self",
")",
":",
"submit_url",
"=",
"reverse",
"(",
"'wagtailimages:chooser_upload'",
")",
"+",
"'?select_format=true'",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"submit_url",
... | [
1167,
4
] | [
1184,
59
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_add | (self) |
This tests that the add view responds correctly on a GET request
|
This tests that the add view responds correctly on a GET request
| def test_add(self):
"""
This tests that the add view responds correctly on a GET request
"""
# Send request
response = self.client.get(reverse('wagtailimages:add_multiple'))
# Check response
self.assertEqual(response.status_code, 200)
self.assertTemplateU... | [
"def",
"test_add",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:add_multiple'",
")",
")",
"# Check response",
"self",
".",
"assertEqual",
"(",
"response",
".",
"status_code",
... | [
1306,
4
] | [
1320,
71
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_add_post | (self) |
This tests that a POST request to the add view saves the image and returns an edit form
|
This tests that a POST request to the add view saves the image and returns an edit form
| def test_add_post(self):
"""
This tests that a POST request to the add view saves the image and returns an edit form
"""
response = self.client.post(reverse('wagtailimages:add_multiple'), {
'files[]': SimpleUploadedFile('test.png', get_test_image_file().file.getvalue()),
... | [
"def",
"test_add_post",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:add_multiple'",
")",
",",
"{",
"'files[]'",
":",
"SimpleUploadedFile",
"(",
"'test.png'",
",",
"get_test_image_file",
"(",
... | [
1331,
4
] | [
1360,
49
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_add_post_noajax | (self) |
This tests that only AJAX requests are allowed to POST to the add view
|
This tests that only AJAX requests are allowed to POST to the add view
| def test_add_post_noajax(self):
"""
This tests that only AJAX requests are allowed to POST to the add view
"""
response = self.client.post(reverse('wagtailimages:add_multiple'), {})
# Check response
self.assertEqual(response.status_code, 400) | [
"def",
"test_add_post_noajax",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:add_multiple'",
")",
",",
"{",
"}",
")",
"# Check response",
"self",
".",
"assertEqual",
"(",
"response",
".",
"st... | [
1362,
4
] | [
1369,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_add_post_nofile | (self) |
This tests that the add view checks for a file when a user POSTs to it
|
This tests that the add view checks for a file when a user POSTs to it
| def test_add_post_nofile(self):
"""
This tests that the add view checks for a file when a user POSTs to it
"""
response = self.client.post(reverse('wagtailimages:add_multiple'), {}, HTTP_X_REQUESTED_WITH='XMLHttpRequest')
# Check response
self.assertEqual(response.status... | [
"def",
"test_add_post_nofile",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:add_multiple'",
")",
",",
"{",
"}",
",",
"HTTP_X_REQUESTED_WITH",
"=",
"'XMLHttpRequest'",
")",
"# Check response",
"s... | [
1371,
4
] | [
1378,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_add_post_badfile | (self) |
The add view must check that the uploaded file is a valid image
|
The add view must check that the uploaded file is a valid image
| def test_add_post_badfile(self):
"""
The add view must check that the uploaded file is a valid image
"""
response = self.client.post(reverse('wagtailimages:add_multiple'), {
'files[]': SimpleUploadedFile('test.png', b"This is not an image!"),
}, HTTP_X_REQUESTED_WITH=... | [
"def",
"test_add_post_badfile",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:add_multiple'",
")",
",",
"{",
"'files[]'",
":",
"SimpleUploadedFile",
"(",
"'test.png'",
",",
"b\"This is not an image... | [
1380,
4
] | [
1401,
9
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_add_post_bad_extension | (self) |
The add view must check that the uploaded file extension is a valid
|
The add view must check that the uploaded file extension is a valid
| def test_add_post_bad_extension(self):
"""
The add view must check that the uploaded file extension is a valid
"""
response = self.client.post(reverse('wagtailimages:add_multiple'), {
'files[]': SimpleUploadedFile('test.txt', get_test_image_file().file.getvalue()),
},... | [
"def",
"test_add_post_bad_extension",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:add_multiple'",
")",
",",
"{",
"'files[]'",
":",
"SimpleUploadedFile",
"(",
"'test.txt'",
",",
"get_test_image_fi... | [
1403,
4
] | [
1424,
9
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_edit_get | (self) |
This tests that a GET request to the edit view returns a 405 "METHOD NOT ALLOWED" response
|
This tests that a GET request to the edit view returns a 405 "METHOD NOT ALLOWED" response
| def test_edit_get(self):
"""
This tests that a GET request to the edit view returns a 405 "METHOD NOT ALLOWED" response
"""
# Send request
response = self.client.get(reverse('wagtailimages:edit_multiple', args=(self.image.id, )))
# Check response
self.assertEqual... | [
"def",
"test_edit_get",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")",
")",
"# Chec... | [
1426,
4
] | [
1434,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_edit_post | (self) |
This tests that a POST request to the edit view edits the image
|
This tests that a POST request to the edit view edits the image
| def test_edit_post(self):
"""
This tests that a POST request to the edit view edits the image
"""
# Send request
response = self.client.post(reverse('wagtailimages:edit_multiple', args=(self.image.id, )), {
('image-%d-title' % self.image.id): "New title!",
... | [
"def",
"test_edit_post",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")",
",",
"{",
... | [
1436,
4
] | [
1461,
53
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_edit_post_noajax | (self) |
This tests that a POST request to the edit view without AJAX returns a 400 response
|
This tests that a POST request to the edit view without AJAX returns a 400 response
| def test_edit_post_noajax(self):
"""
This tests that a POST request to the edit view without AJAX returns a 400 response
"""
# Send request
response = self.client.post(reverse('wagtailimages:edit_multiple', args=(self.image.id, )), {
('image-%d-title' % self.image.id)... | [
"def",
"test_edit_post_noajax",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")",
",",
... | [
1463,
4
] | [
1474,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_edit_post_validation_error | (self) |
This tests that a POST request to the edit page returns a json document with "success=False"
and a form with the validation error indicated
|
This tests that a POST request to the edit page returns a json document with "success=False"
and a form with the validation error indicated
| def test_edit_post_validation_error(self):
"""
This tests that a POST request to the edit page returns a json document with "success=False"
and a form with the validation error indicated
"""
# Send request
response = self.client.post(reverse('wagtailimages:edit_multiple',... | [
"def",
"test_edit_post_validation_error",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:edit_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")... | [
1476,
4
] | [
1501,
50
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_delete_get | (self) |
This tests that a GET request to the delete view returns a 405 "METHOD NOT ALLOWED" response
|
This tests that a GET request to the delete view returns a 405 "METHOD NOT ALLOWED" response
| def test_delete_get(self):
"""
This tests that a GET request to the delete view returns a 405 "METHOD NOT ALLOWED" response
"""
# Send request
response = self.client.get(reverse('wagtailimages:delete_multiple', args=(self.image.id, )))
# Check response
self.asser... | [
"def",
"test_delete_get",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:delete_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")",
")",
"# ... | [
1503,
4
] | [
1511,
51
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_delete_post | (self) |
This tests that a POST request to the delete view deletes the image
|
This tests that a POST request to the delete view deletes the image
| def test_delete_post(self):
"""
This tests that a POST request to the delete view deletes the image
"""
# Send request
response = self.client.post(reverse(
'wagtailimages:delete_multiple', args=(self.image.id, )
), HTTP_X_REQUESTED_WITH='XMLHttpRequest')
... | [
"def",
"test_delete_post",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:delete_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")",
",",
"... | [
1513,
4
] | [
1534,
49
] | python | en | ['en', 'error', 'th'] | False |
TestMultipleImageUploader.test_delete_post_noajax | (self) |
This tests that a POST request to the delete view without AJAX returns a 400 response
|
This tests that a POST request to the delete view without AJAX returns a 400 response
| def test_delete_post_noajax(self):
"""
This tests that a POST request to the delete view without AJAX returns a 400 response
"""
# Send request
response = self.client.post(reverse('wagtailimages:delete_multiple', args=(self.image.id, )))
# Check response
self.ass... | [
"def",
"test_delete_post_noajax",
"(",
"self",
")",
":",
"# Send request",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailimages:delete_multiple'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")",
"... | [
1536,
4
] | [
1544,
51
] | python | en | ['en', 'error', 'th'] | False |
TestURLGeneratorView.test_get | (self) |
This tests that the view responds correctly for a user with edit permissions on this image
|
This tests that the view responds correctly for a user with edit permissions on this image
| def test_get(self):
"""
This tests that the view responds correctly for a user with edit permissions on this image
"""
# Get
response = self.client.get(reverse('wagtailimages:url_generator', args=(self.image.id, )))
# Check response
self.assertEqual(response.stat... | [
"def",
"test_get",
"(",
"self",
")",
":",
"# Get",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:url_generator'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
")",
")",
")",
"# Check response",
... | [
1953,
4
] | [
1962,
84
] | python | en | ['en', 'error', 'th'] | False |
TestURLGeneratorView.test_get_bad_permissions | (self) |
This tests that the view returns a "permission denied" redirect if a user without correct
permissions attempts to access it
|
This tests that the view returns a "permission denied" redirect if a user without correct
permissions attempts to access it
| def test_get_bad_permissions(self):
"""
This tests that the view returns a "permission denied" redirect if a user without correct
permissions attempts to access it
"""
# Remove privileges from user
self.user.is_superuser = False
self.user.user_permissions.add(
... | [
"def",
"test_get_bad_permissions",
"(",
"self",
")",
":",
"# Remove privileges from user",
"self",
".",
"user",
".",
"is_superuser",
"=",
"False",
"self",
".",
"user",
".",
"user_permissions",
".",
"add",
"(",
"Permission",
".",
"objects",
".",
"get",
"(",
"co... | [
1964,
4
] | [
1980,
68
] | python | en | ['en', 'error', 'th'] | False |
TestGenerateURLView.test_get | (self) |
This tests that the view responds correctly for a user with edit permissions on this image
|
This tests that the view responds correctly for a user with edit permissions on this image
| def test_get(self):
"""
This tests that the view responds correctly for a user with edit permissions on this image
"""
# Get
response = self.client.get(reverse('wagtailimages:generate_url', args=(self.image.id, 'fill-800x600')))
# Check response
self.assertEqual(... | [
"def",
"test_get",
"(",
"self",
")",
":",
"# Get",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:generate_url'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
"'fill-800x600'",
")",
")",
")",
"#... | [
1994,
4
] | [
2017,
75
] | python | en | ['en', 'error', 'th'] | False |
TestGenerateURLView.test_get_bad_permissions | (self) |
This tests that the view gives a 403 if a user without correct permissions attempts to access it
|
This tests that the view gives a 403 if a user without correct permissions attempts to access it
| def test_get_bad_permissions(self):
"""
This tests that the view gives a 403 if a user without correct permissions attempts to access it
"""
# Remove privileges from user
self.user.is_superuser = False
self.user.user_permissions.add(
Permission.objects.get(con... | [
"def",
"test_get_bad_permissions",
"(",
"self",
")",
":",
"# Remove privileges from user",
"self",
".",
"user",
".",
"is_superuser",
"=",
"False",
"self",
".",
"user",
".",
"user_permissions",
".",
"add",
"(",
"Permission",
".",
"objects",
".",
"get",
"(",
"co... | [
2019,
4
] | [
2040,
11
] | python | en | ['en', 'error', 'th'] | False |
TestGenerateURLView.test_get_bad_image | (self) |
This tests that the view gives a 404 response if a user attempts to use it with an image which doesn't exist
|
This tests that the view gives a 404 response if a user attempts to use it with an image which doesn't exist
| def test_get_bad_image(self):
"""
This tests that the view gives a 404 response if a user attempts to use it with an image which doesn't exist
"""
# Get
response = self.client.get(reverse('wagtailimages:generate_url', args=(self.image.id + 1, 'fill-800x600')))
# Check re... | [
"def",
"test_get_bad_image",
"(",
"self",
")",
":",
"# Get",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:generate_url'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
"+",
"1",
",",
"'fill-800x600'",
... | [
2042,
4
] | [
2056,
11
] | python | en | ['en', 'error', 'th'] | False |
TestGenerateURLView.test_get_bad_filter_spec | (self) |
This tests that the view gives a 400 response if the user attempts to use it with an invalid filter spec
|
This tests that the view gives a 400 response if the user attempts to use it with an invalid filter spec
| def test_get_bad_filter_spec(self):
"""
This tests that the view gives a 400 response if the user attempts to use it with an invalid filter spec
"""
# Get
response = self.client.get(reverse('wagtailimages:generate_url', args=(self.image.id, 'bad-filter-spec')))
# Check r... | [
"def",
"test_get_bad_filter_spec",
"(",
"self",
")",
":",
"# Get",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:generate_url'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
"'bad-filter-spec'",
")",... | [
2058,
4
] | [
2072,
11
] | python | en | ['en', 'error', 'th'] | False |
TestPreviewView.test_get | (self) |
Test a valid GET request to the view
|
Test a valid GET request to the view
| def test_get(self):
"""
Test a valid GET request to the view
"""
# Get the image
response = self.client.get(reverse('wagtailimages:preview', args=(self.image.id, 'fill-800x600')))
# Check response
self.assertEqual(response.status_code, 200)
self.assertEqu... | [
"def",
"test_get",
"(",
"self",
")",
":",
"# Get the image",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:preview'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
"'fill-800x600'",
")",
")",
")",... | [
2086,
4
] | [
2095,
63
] | python | en | ['en', 'error', 'th'] | False |
TestPreviewView.test_get_invalid_filter_spec | (self) |
Test that an invalid filter spec returns a 400 response
This is very unlikely to happen in reality. A user would have
to create signature for the invalid filter spec which can't be
done with Wagtails built in URL generator. We should test it
anyway though.
|
Test that an invalid filter spec returns a 400 response | def test_get_invalid_filter_spec(self):
"""
Test that an invalid filter spec returns a 400 response
This is very unlikely to happen in reality. A user would have
to create signature for the invalid filter spec which can't be
done with Wagtails built in URL generator. We should t... | [
"def",
"test_get_invalid_filter_spec",
"(",
"self",
")",
":",
"# Get the image",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailimages:preview'",
",",
"args",
"=",
"(",
"self",
".",
"image",
".",
"id",
",",
"'bad-filter-spec'... | [
2097,
4
] | [
2110,
51
] | python | en | ['en', 'error', 'th'] | False |
check_singleton | (func) |
check_singleton is a decorator that checks if a user given
to a `visible_roles` method is in either of our singleton roles (Admin, Auditor)
and if so, returns their full list of roles without filtering.
|
check_singleton is a decorator that checks if a user given
to a `visible_roles` method is in either of our singleton roles (Admin, Auditor)
and if so, returns their full list of roles without filtering.
| def check_singleton(func):
"""
check_singleton is a decorator that checks if a user given
to a `visible_roles` method is in either of our singleton roles (Admin, Auditor)
and if so, returns their full list of roles without filtering.
"""
def wrapper(*args, **kwargs):
sys_admin = Role.si... | [
"def",
"check_singleton",
"(",
"func",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"sys_admin",
"=",
"Role",
".",
"singleton",
"(",
"ROLE_SINGLETON_SYSTEM_ADMINISTRATOR",
")",
"sys_audit",
"=",
"Role",
".",
"singleton",
... | [
82,
0
] | [
99,
18
] | python | en | ['en', 'error', 'th'] | False |
batch_role_ancestor_rebuilding | (allow_nesting=False) |
Batches the role ancestor rebuild work necessary whenever role-role
relations change. This can result in a big speedup when performing
any bulk manipulation.
WARNING: Calls to anything related to checking access/permissions
while within the context of the batch_role_ancestor_rebuilding will
li... |
Batches the role ancestor rebuild work necessary whenever role-role
relations change. This can result in a big speedup when performing
any bulk manipulation. | def batch_role_ancestor_rebuilding(allow_nesting=False):
"""
Batches the role ancestor rebuild work necessary whenever role-role
relations change. This can result in a big speedup when performing
any bulk manipulation.
WARNING: Calls to anything related to checking access/permissions
while with... | [
"def",
"batch_role_ancestor_rebuilding",
"(",
"allow_nesting",
"=",
"False",
")",
":",
"batch_role_rebuilding",
"=",
"getattr",
"(",
"tls",
",",
"'batch_role_rebuilding'",
",",
"False",
")",
"try",
":",
"setattr",
"(",
"tls",
",",
"'batch_role_rebuilding'",
",",
"... | [
103,
0
] | [
131,
36
] | python | en | ['en', 'error', 'th'] | False |
get_roles_on_resource | (resource, accessor) |
Returns a string list of the roles a accessor has for a given resource.
An accessor can be either a User, Role, or an arbitrary resource that
contains one or more Roles associated with it.
|
Returns a string list of the roles a accessor has for a given resource.
An accessor can be either a User, Role, or an arbitrary resource that
contains one or more Roles associated with it.
| def get_roles_on_resource(resource, accessor):
"""
Returns a string list of the roles a accessor has for a given resource.
An accessor can be either a User, Role, or an arbitrary resource that
contains one or more Roles associated with it.
"""
if type(accessor) == User:
roles = accessor... | [
"def",
"get_roles_on_resource",
"(",
"resource",
",",
"accessor",
")",
":",
"if",
"type",
"(",
"accessor",
")",
"==",
"User",
":",
"roles",
"=",
"accessor",
".",
"roles",
".",
"all",
"(",
")",
"elif",
"type",
"(",
"accessor",
")",
"==",
"Role",
":",
... | [
462,
0
] | [
484,
5
] | python | en | ['en', 'error', 'th'] | False |
Role.rebuild_role_ancestor_list | (additions, removals) |
Updates our `ancestors` map to accurately reflect all of the ancestors for a role
You should never need to call this. Signal handlers should be calling
this method when the role hierachy changes automatically.
|
Updates our `ancestors` map to accurately reflect all of the ancestors for a role | def rebuild_role_ancestor_list(additions, removals):
"""
Updates our `ancestors` map to accurately reflect all of the ancestors for a role
You should never need to call this. Signal handlers should be calling
this method when the role hierachy changes automatically.
"""
... | [
"def",
"rebuild_role_ancestor_list",
"(",
"additions",
",",
"removals",
")",
":",
"# The ancestry table",
"# =================================================",
"#",
"# The role ancestors table denormalizes the parental relations",
"# between all roles in the system. If you have role A w... | [
211,
4
] | [
406,
45
] | python | en | ['en', 'error', 'th'] | False |
Role.filter_visible_roles | (user, roles_qs) |
Visible roles include all roles that are ancestors of any
roles that the user has access to.
Case in point - organization auditor_role must see all roles
in their organization, but some of those roles descend from
organization admin_role, but not auditor_role.
|
Visible roles include all roles that are ancestors of any
roles that the user has access to.
Case in point - organization auditor_role must see all roles
in their organization, but some of those roles descend from
organization admin_role, but not auditor_role.
| def filter_visible_roles(user, roles_qs):
"""
Visible roles include all roles that are ancestors of any
roles that the user has access to.
Case in point - organization auditor_role must see all roles
in their organization, but some of those roles descend from
organization... | [
"def",
"filter_visible_roles",
"(",
"user",
",",
"roles_qs",
")",
":",
"return",
"roles_qs",
".",
"filter",
"(",
"id__in",
"=",
"RoleAncestorEntry",
".",
"objects",
".",
"filter",
"(",
"descendent__in",
"=",
"RoleAncestorEntry",
".",
"objects",
".",
"filter",
... | [
414,
4
] | [
430,
9
] | python | en | ['en', 'error', 'th'] | False |
event_dict_type | (
required_keys: Sequence[Tuple[str, Any]],
optional_keys: Sequence[Tuple[str, Any]] = [],
) |
This is just a tiny wrapper on DictType, but it provides
some minor benefits:
- mark clearly that the schema is for a Zulip event
- make sure there's a type field
- add id field automatically
- sanity check that we have no duplicate keys
|
This is just a tiny wrapper on DictType, but it provides
some minor benefits: | def event_dict_type(
required_keys: Sequence[Tuple[str, Any]],
optional_keys: Sequence[Tuple[str, Any]] = [],
) -> DictType:
"""
This is just a tiny wrapper on DictType, but it provides
some minor benefits:
- mark clearly that the schema is for a Zulip event
- make sure there's a t... | [
"def",
"event_dict_type",
"(",
"required_keys",
":",
"Sequence",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
",",
"optional_keys",
":",
"Sequence",
"[",
"Tuple",
"[",
"str",
",",
"Any",
"]",
"]",
"=",
"[",
"]",
",",
")",
"->",
"DictType",
":",
... | [
242,
0
] | [
266,
5
] | python | en | ['en', 'error', 'th'] | False |
schema | (
var_name: str,
data_type: Any,
) | Returns a YAML-like string for our data type; these are used for
pretty-printing and comparison between the OpenAPI type
definitions and these Python data types, as part of
schema is a glorified repr of a data type, but it also includes a
var_name you pass in, plus we dumb things down a bit to match ou... | Returns a YAML-like string for our data type; these are used for
pretty-printing and comparison between the OpenAPI type
definitions and these Python data types, as part of | def schema(
var_name: str,
data_type: Any,
) -> str:
"""Returns a YAML-like string for our data type; these are used for
pretty-printing and comparison between the OpenAPI type
definitions and these Python data types, as part of
schema is a glorified repr of a data type, but it also includes a
... | [
"def",
"schema",
"(",
"var_name",
":",
"str",
",",
"data_type",
":",
"Any",
",",
")",
"->",
"str",
":",
"if",
"hasattr",
"(",
"data_type",
",",
"\"schema\"",
")",
":",
"return",
"data_type",
".",
"schema",
"(",
"var_name",
")",
"if",
"data_type",
"in",... | [
278,
0
] | [
294,
53
] | python | en | ['en', 'en', 'en'] | True |
check_data | (
data_type: Any,
var_name: str,
val: Any,
) | Check that val conforms to our data_type | Check that val conforms to our data_type | def check_data(
data_type: Any,
var_name: str,
val: Any,
) -> None:
"""Check that val conforms to our data_type"""
if hasattr(data_type, "check_data"):
data_type.check_data(var_name, val)
return
if not isinstance(val, data_type):
raise AssertionError(f"{var_name} is not t... | [
"def",
"check_data",
"(",
"data_type",
":",
"Any",
",",
"var_name",
":",
"str",
",",
"val",
":",
"Any",
",",
")",
"->",
"None",
":",
"if",
"hasattr",
"(",
"data_type",
",",
"\"check_data\"",
")",
":",
"data_type",
".",
"check_data",
"(",
"var_name",
",... | [
297,
0
] | [
307,
67
] | python | en | ['en', 'en', 'en'] | True |
BaseCloudTest.launch_test | (self) | launch cloud test | launch cloud test | def launch_test(self):
"""launch cloud test"""
pass | [
"def",
"launch_test",
"(",
"self",
")",
":",
"pass"
] | [
67,
4
] | [
69,
12
] | python | en | ['en', 'fr', 'en'] | True |
BaseCloudTest.sanitize_test | (self) | Sanitize cloud test | Sanitize cloud test | def sanitize_test(self):
"""Sanitize cloud test"""
pass | [
"def",
"sanitize_test",
"(",
"self",
")",
":",
"pass"
] | [
72,
4
] | [
74,
12
] | python | en | ['en', 'fr', 'it'] | False |
BaseCloudTest.start_if_ready | (self) | start cloud test if all engines are ready | start cloud test if all engines are ready | def start_if_ready(self):
"""start cloud test if all engines are ready"""
pass | [
"def",
"start_if_ready",
"(",
"self",
")",
":",
"pass"
] | [
77,
4
] | [
79,
12
] | python | en | ['en', 'en', 'en'] | True |
PdCli.do_show_tables | (self, line) |
show_tables
Lists all tables in the P4 program. Output can be optionally piped to Bash.
|
show_tables
Lists all tables in the P4 program. Output can be optionally piped to Bash.
| def do_show_tables(self, line):
"""
show_tables
Lists all tables in the P4 program. Output can be optionally piped to Bash.
"""
table_names = []
for table_name in self.get_table_names(None):
table_names.append(table_name)
self.pipe_to("\n".join(table_names), line) | [
"def",
"do_show_tables",
"(",
"self",
",",
"line",
")",
":",
"table_names",
"=",
"[",
"]",
"for",
"table_name",
"in",
"self",
".",
"get_table_names",
"(",
"None",
")",
":",
"table_names",
".",
"append",
"(",
"table_name",
")",
"self",
".",
"pipe_to",
"("... | [
36,
2
] | [
44,
46
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_show_actions | (self, line) |
show_actions TABLE_NAME [ | BASH_COMMANDS ]
Lists all action in TABLE_NAME. Output can be optionally piped to Bash.
|
show_actions TABLE_NAME [ | BASH_COMMANDS ]
Lists all action in TABLE_NAME. Output can be optionally piped to Bash.
| def do_show_actions(self, line):
"""
show_actions TABLE_NAME [ | BASH_COMMANDS ]
Lists all action in TABLE_NAME. Output can be optionally piped to Bash.
"""
words = collections.deque(line.split())
try:
table_name = self.get_table_name(words)
action_names = []
for action_name in... | [
"def",
"do_show_actions",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"action_names",
"=",
"["... | [
46,
2
] | [
59,
35
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_add_entry | (self, line) |
add_entry TABLE_NAME MATCH_FIELDS... ACTION_NAME ACTION_PARAMETERS...
Adds an entry with the specified MATCH_FIELDS, ACTION_NAME and
ACTION_PARAMETERS to TABLE_NAME. Prints the entry handle of the newly added
entry.
|
add_entry TABLE_NAME MATCH_FIELDS... ACTION_NAME ACTION_PARAMETERS...
Adds an entry with the specified MATCH_FIELDS, ACTION_NAME and
ACTION_PARAMETERS to TABLE_NAME. Prints the entry handle of the newly added
entry.
| def do_add_entry(self, line):
"""
add_entry TABLE_NAME MATCH_FIELDS... ACTION_NAME ACTION_PARAMETERS...
Adds an entry with the specified MATCH_FIELDS, ACTION_NAME and
ACTION_PARAMETERS to TABLE_NAME. Prints the entry handle of the newly added
entry.
"""
words = collections.deque(line.split()... | [
"def",
"do_add_entry",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"(",
"table_name",
",",
"match_tuple",
")",
"=",
"self",
".",
"get_table_name_and_match_tuple",
"(... | [
68,
2
] | [
92,
32
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_set_default_action | (self, line) |
set_default_action TABLE_NAME ACTION_NAME ACTION_PARAMETERS
This funciton sets the default action of a given table.
|
set_default_action TABLE_NAME ACTION_NAME ACTION_PARAMETERS
This funciton sets the default action of a given table.
| def do_set_default_action(self, line):
"""
set_default_action TABLE_NAME ACTION_NAME ACTION_PARAMETERS
This funciton sets the default action of a given table.
"""
words = collections.deque(line.split())
try:
table_name = self.get_table_name(words)
(action_name, action_tuple) = self.g... | [
"def",
"do_set_default_action",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"(",
"action_name",
... | [
94,
2
] | [
113,
41
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_add_entry_with_selector | (self, line) |
add_entry_with_selector TABLE_NAME MATCH_FIELDS GROUP_HANDLE
Adds an entry with the specified MATCH_FIELDS to TABLE_NAME. Prints the
entry handle of the newly added entry.
|
add_entry_with_selector TABLE_NAME MATCH_FIELDS GROUP_HANDLE
Adds an entry with the specified MATCH_FIELDS to TABLE_NAME. Prints the
entry handle of the newly added entry.
| def do_add_entry_with_selector(self, line):
"""
add_entry_with_selector TABLE_NAME MATCH_FIELDS GROUP_HANDLE
Adds an entry with the specified MATCH_FIELDS to TABLE_NAME. Prints the
entry handle of the newly added entry.
"""
words = collections.deque(line.split())
try:
(table_name, matc... | [
"def",
"do_add_entry_with_selector",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"(",
"table_name",
",",
"match_tuple",
")",
"=",
"self",
".",
"get_table_name_and_matc... | [
129,
2
] | [
145,
46
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_add_entry_with_member | (self, line) |
add_entry_with_member TABLE_NAME MATCH_FIELDS MEMBER_HANDLE
This command is valid for tables with have action profiles. It adds an entry
with the specified MATCH_FIELDS and MEMBER_HANDLE to TABLE_NAME. Prints the
entry handle of the newly added entry.
|
add_entry_with_member TABLE_NAME MATCH_FIELDS MEMBER_HANDLE
This command is valid for tables with have action profiles. It adds an entry
with the specified MATCH_FIELDS and MEMBER_HANDLE to TABLE_NAME. Prints the
entry handle of the newly added entry.
| def do_add_entry_with_member(self, line):
"""
add_entry_with_member TABLE_NAME MATCH_FIELDS MEMBER_HANDLE
This command is valid for tables with have action profiles. It adds an entry
with the specified MATCH_FIELDS and MEMBER_HANDLE to TABLE_NAME. Prints the
entry handle of the newly added entry.
... | [
"def",
"do_add_entry_with_member",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"(",
"table_name",
",",
"match_tuple",
")",
"=",
"self",
".",
"get_table_name_and_match_... | [
147,
2
] | [
164,
44
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_modify_entry | (self, line) |
modify_entry TABLE_NAME ENTRY_HANDLE ACTION_NAME ACTION_PARAMETERS...
Sets the ACTION_NAME and ACTION_PARAMETERS of the entry specified by
ENTRY_HANDLE in TABLE_NAME.
|
modify_entry TABLE_NAME ENTRY_HANDLE ACTION_NAME ACTION_PARAMETERS...
Sets the ACTION_NAME and ACTION_PARAMETERS of the entry specified by
ENTRY_HANDLE in TABLE_NAME.
| def do_modify_entry(self, line):
"""
modify_entry TABLE_NAME ENTRY_HANDLE ACTION_NAME ACTION_PARAMETERS...
Sets the ACTION_NAME and ACTION_PARAMETERS of the entry specified by
ENTRY_HANDLE in TABLE_NAME.
"""
words = collections.deque(line.split())
try:
table_name = self.get_table_name(... | [
"def",
"do_modify_entry",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"entry_handle",
"=",
"se... | [
166,
2
] | [
180,
35
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_delete_entry | (self, line) |
delete_entry TABLE_NAME ENTRY_HANDLE
Deletes an entry specified by ENTRY_HANDLE in TABLE_NAME.
|
delete_entry TABLE_NAME ENTRY_HANDLE
Deletes an entry specified by ENTRY_HANDLE in TABLE_NAME.
| def do_delete_entry(self, line):
"""
delete_entry TABLE_NAME ENTRY_HANDLE
Deletes an entry specified by ENTRY_HANDLE in TABLE_NAME.
"""
words = collections.deque(line.split())
try:
table_name = self.get_table_name(words)
entry_handle = self.get_handle(words, "entry handle")
if ... | [
"def",
"do_delete_entry",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"entry_handle",
"=",
"se... | [
182,
2
] | [
196,
35
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_add_member | (self, line) |
add_member ACTION_PROFILE_NAME ACTION_NAME ACTION_PARAMETERS...
Add an entry to an action profile. Print the member handle of the newly
added entry.
|
add_member ACTION_PROFILE_NAME ACTION_NAME ACTION_PARAMETERS...
Add an entry to an action profile. Print the member handle of the newly
added entry.
| def do_add_member(self, line):
"""
add_member ACTION_PROFILE_NAME ACTION_NAME ACTION_PARAMETERS...
Add an entry to an action profile. Print the member handle of the newly
added entry.
"""
words = collections.deque(line.split())
try:
action_profile_name = self.get_next_token(words, "act... | [
"def",
"do_add_member",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"action_profile_name",
"=",
"self",
".",
"get_next_token",
"(",
"words",
",",
"\"action profile nam... | [
201,
2
] | [
213,
33
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_delete_member | (self, line) |
delete_member ACTION_PROFILE_NAME MEMBER_HANDLE
Deletes an member specified by MEMBER_HANDLE in ACTION_PROFILE_NAME.
|
delete_member ACTION_PROFILE_NAME MEMBER_HANDLE
Deletes an member specified by MEMBER_HANDLE in ACTION_PROFILE_NAME.
| def do_delete_member(self, line):
"""
delete_member ACTION_PROFILE_NAME MEMBER_HANDLE
Deletes an member specified by MEMBER_HANDLE in ACTION_PROFILE_NAME.
"""
words = collections.deque(line.split())
try:
action_profile_name = self.get_next_token(words, "action profile name")
member_h... | [
"def",
"do_delete_member",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"action_profile_name",
"=",
"self",
".",
"get_next_token",
"(",
"words",
",",
"\"action profile ... | [
215,
2
] | [
229,
36
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_create_group | (self, line) |
create_group ACTION_PROFILE_NAME MAX_GROUP_SIZE
Creates a new group for an action profile. Prints the handle of the new
group.
|
create_group ACTION_PROFILE_NAME MAX_GROUP_SIZE
Creates a new group for an action profile. Prints the handle of the new
group.
| def do_create_group(self, line):
"""
create_group ACTION_PROFILE_NAME MAX_GROUP_SIZE
Creates a new group for an action profile. Prints the handle of the new
group.
"""
words = collections.deque(line.split())
try:
action_profile_name = self.get_next_token(words, "action profile name")
... | [
"def",
"do_create_group",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"action_profile_name",
"=",
"self",
".",
"get_next_token",
"(",
"words",
",",
"\"action profile n... | [
231,
2
] | [
243,
35
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_add_member_to_group | (self, line) |
add_member_to_group GROUP_HANDLE MEMBER_HANDLE
Adds a action profile member to an action profile group.
|
add_member_to_group GROUP_HANDLE MEMBER_HANDLE
Adds a action profile member to an action profile group.
| def do_add_member_to_group(self, line):
"""
add_member_to_group GROUP_HANDLE MEMBER_HANDLE
Adds a action profile member to an action profile group.
"""
words = collections.deque(line.split())
try:
action_profile_name = self.get_next_token(words, "action profile name")
group_handle = ... | [
"def",
"do_add_member_to_group",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"action_profile_name",
"=",
"self",
".",
"get_next_token",
"(",
"words",
",",
"\"action pr... | [
245,
2
] | [
257,
42
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_delete_group | (self, line) |
delete_group ACTION_PROFILE_NAME GROUP_HANDLE
Delete a group specified by GROUP_HANDLE
|
delete_group ACTION_PROFILE_NAME GROUP_HANDLE
Delete a group specified by GROUP_HANDLE
| def do_delete_group(self, line):
"""
delete_group ACTION_PROFILE_NAME GROUP_HANDLE
Delete a group specified by GROUP_HANDLE
"""
words = collections.deque(line.split())
try:
action_profile_name = self.get_next_token(words, "action profile name")
group_handle = self.get_handle(words, "... | [
"def",
"do_delete_group",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"action_profile_name",
"=",
"self",
".",
"get_next_token",
"(",
"words",
",",
"\"action profile n... | [
259,
2
] | [
273,
35
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_get_first_entry_handle | (self, line) |
get_first_entry_handle TABLE_NAME
Prints the first valid entry handle in TABLE_NAME. This command can be used
to begin iterating over all entry handles in a table.
|
get_first_entry_handle TABLE_NAME
Prints the first valid entry handle in TABLE_NAME. This command can be used
to begin iterating over all entry handles in a table.
| def do_get_first_entry_handle(self, line):
"""
get_first_entry_handle TABLE_NAME
Prints the first valid entry handle in TABLE_NAME. This command can be used
to begin iterating over all entry handles in a table.
"""
words = collections.deque(line.split())
try:
table_name = self.get_tabl... | [
"def",
"do_get_first_entry_handle",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"print",
"self",... | [
275,
2
] | [
286,
45
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_get_next_entry_handles | (self, line) |
get_next_entry_handles TABLE_NAME ENTRY_HANDLE NUM_ENTRY_HANDLES
Prints NUM_ENTRY_HANDLES valid entry handles following ENTRY_HANDLE in
TABLE_NAME.
|
get_next_entry_handles TABLE_NAME ENTRY_HANDLE NUM_ENTRY_HANDLES
Prints NUM_ENTRY_HANDLES valid entry handles following ENTRY_HANDLE in
TABLE_NAME.
| def do_get_next_entry_handles(self, line):
"""
get_next_entry_handles TABLE_NAME ENTRY_HANDLE NUM_ENTRY_HANDLES
Prints NUM_ENTRY_HANDLES valid entry handles following ENTRY_HANDLE in
TABLE_NAME.
"""
words = collections.deque(line.split())
try:
table_name = self.get_table_name(words)
... | [
"def",
"do_get_next_entry_handles",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"entry_handle",
... | [
291,
2
] | [
304,
45
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_show_entry | (self, line) |
show_entry TABLE_NAME ENTRY_HANDLE
Prints the match key and action type and parameters for the entry specified
by ENTRY_HANDLE in TABLE_NAME.
|
show_entry TABLE_NAME ENTRY_HANDLE
Prints the match key and action type and parameters for the entry specified
by ENTRY_HANDLE in TABLE_NAME.
| def do_show_entry(self, line):
"""
show_entry TABLE_NAME ENTRY_HANDLE
Prints the match key and action type and parameters for the entry specified
by ENTRY_HANDLE in TABLE_NAME.
"""
words = collections.deque(line.split())
try:
table_name = self.get_table_name(words)
entry_handle =... | [
"def",
"do_show_entry",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"entry_handle",
"=",
"self... | [
309,
2
] | [
321,
33
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_dump_table | (self, line) |
dump_table TABLE_NAME
Prints all entries in TABLE_NAME. Output can be optionally piped to Bash.
|
dump_table TABLE_NAME
Prints all entries in TABLE_NAME. Output can be optionally piped to Bash.
| def do_dump_table(self, line):
"""
dump_table TABLE_NAME
Prints all entries in TABLE_NAME. Output can be optionally piped to Bash.
"""
words = collections.deque(line.split())
try:
table_name = self.get_table_name(words)
entry_handle = self._thrift_client.get_first_entry_handle(table_... | [
"def",
"do_dump_table",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"table_name",
"=",
"self",
".",
"get_table_name",
"(",
"words",
")",
"entry_handle",
"=",
"self... | [
326,
2
] | [
348,
33
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_mc_mgrp_create | (self, line) |
mc_mgrp_create MGRP_ID
This function creates a multicast group with multicast index MGRP_ID.
For example: mc_mgrp_create 1
|
mc_mgrp_create MGRP_ID
This function creates a multicast group with multicast index MGRP_ID.
For example: mc_mgrp_create 1
| def do_mc_mgrp_create(self, line):
"""
mc_mgrp_create MGRP_ID
This function creates a multicast group with multicast index MGRP_ID.
For example: mc_mgrp_create 1
"""
words = collections.deque(line.split())
try:
mgid = self.get_handle(words, "MGRP_ID")
mgrp_hdl = self._thrift_clie... | [
"def",
"do_mc_mgrp_create",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"mgid",
"=",
"self",
".",
"get_handle",
"(",
"words",
",",
"\"MGRP_ID\"",
")",
"mgrp_hdl",
... | [
463,
2
] | [
479,
37
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_mc_node_create | (self, line) |
mc_node_create R_ID PORT_MAP LAG_MAP
This function creates a multicast node with replication id R_ID and with list of ports defined by PORT_MAP (as a bit vector).
Currently only port 0-7 can be configured with this function.
For exmaple: mc_node_create 0 30 -1
If PORT_MAP or LAG_MAP is -1, their va... |
mc_node_create R_ID PORT_MAP LAG_MAP
This function creates a multicast node with replication id R_ID and with list of ports defined by PORT_MAP (as a bit vector).
Currently only port 0-7 can be configured with this function.
For exmaple: mc_node_create 0 30 -1
If PORT_MAP or LAG_MAP is -1, their va... | def do_mc_node_create(self, line):
"""
mc_node_create R_ID PORT_MAP LAG_MAP
This function creates a multicast node with replication id R_ID and with list of ports defined by PORT_MAP (as a bit vector).
Currently only port 0-7 can be configured with this function.
For exmaple: mc_node_create 0 30 -1
... | [
"def",
"do_mc_node_create",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"rid",
"=",
"self",
".",
"get_handle",
"(",
"words",
",",
"\"R_ID\"",
")",
"port_map",
"=... | [
482,
2
] | [
510,
37
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_mc_node_update | (self, line) |
mc_node_update L1_HDL PORT_MAP LAG_MAP
This function updates a multicast node.
Currently only port 0-7 can be configured with this function.
For example: mc_node_update 1234321 14 -1
|
mc_node_update L1_HDL PORT_MAP LAG_MAP
This function updates a multicast node.
Currently only port 0-7 can be configured with this function.
For example: mc_node_update 1234321 14 -1
| def do_mc_node_update(self, line):
"""
mc_node_update L1_HDL PORT_MAP LAG_MAP
This function updates a multicast node.
Currently only port 0-7 can be configured with this function.
For example: mc_node_update 1234321 14 -1
"""
words = collections.deque(line.split())
try:
l1_hdl = se... | [
"def",
"do_mc_node_update",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"l1_hdl",
"=",
"self",
".",
"get_handle",
"(",
"words",
",",
"\"L1_HDL\"",
")",
"port_map",... | [
512,
2
] | [
539,
37
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_mc_mgrp_destroy | (self, line) |
mc_mgrp_destroy MGRP_HDL
This function removes multcast group MGRP_HDL
For example: mc_mgrp_destroy 1234321
|
mc_mgrp_destroy MGRP_HDL
This function removes multcast group MGRP_HDL
For example: mc_mgrp_destroy 1234321
| def do_mc_mgrp_destroy(self, line):
"""
mc_mgrp_destroy MGRP_HDL
This function removes multcast group MGRP_HDL
For example: mc_mgrp_destroy 1234321
"""
words = collections.deque(line.split())
try:
mgrp_hdl = self.get_handle(words, "MGRP_HDL")
self._thrift_client.mc_mgrp_destroy(m... | [
"def",
"do_mc_mgrp_destroy",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"mgrp_hdl",
"=",
"self",
".",
"get_handle",
"(",
"words",
",",
"\"MGRP_HDL\"",
")",
"self"... | [
541,
2
] | [
557,
38
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_mc_node_destroy | (self, line) |
mc_node_destroy L1_HDL
This function removes node L1_HDL
For example: mc_node_destroy 1234321
|
mc_node_destroy L1_HDL
This function removes node L1_HDL
For example: mc_node_destroy 1234321
| def do_mc_node_destroy(self, line):
"""
mc_node_destroy L1_HDL
This function removes node L1_HDL
For example: mc_node_destroy 1234321
"""
words = collections.deque(line.split())
try:
l1_hdl = self.get_handle(words, "L1_HDL")
self._thrift_client.mc_l1_node_destroy(l1_hdl)
pr... | [
"def",
"do_mc_node_destroy",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"l1_hdl",
"=",
"self",
".",
"get_handle",
"(",
"words",
",",
"\"L1_HDL\"",
")",
"self",
... | [
559,
2
] | [
575,
38
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_mc_associate_node | (self, line) |
mc_associate_node MGRP_HANDLE L1_HANDLE
This function associates a node to a multicast tree.
For example: mc_associate_node 1234321 1234567
|
mc_associate_node MGRP_HANDLE L1_HANDLE
This function associates a node to a multicast tree.
For example: mc_associate_node 1234321 1234567
| def do_mc_associate_node(self, line):
"""
mc_associate_node MGRP_HANDLE L1_HANDLE
This function associates a node to a multicast tree.
For example: mc_associate_node 1234321 1234567
"""
words = collections.deque(line.split())
try:
mgrp_hdl = self.get_handle(words, "MGRP_HANDLE")
... | [
"def",
"do_mc_associate_node",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"mgrp_hdl",
"=",
"self",
".",
"get_handle",
"(",
"words",
",",
"\"MGRP_HANDLE\"",
")",
"... | [
577,
2
] | [
594,
40
] | python | en | ['en', 'error', 'th'] | False |
PdCli.do_mc_dissociate_node | (self, line) |
mc_dissociate_node MGRP_HANDLE L1_HANDLE
This function dissociates a node from a multicast tree.
For example: mc_dissociate_node 1234321 1234567
|
mc_dissociate_node MGRP_HANDLE L1_HANDLE
This function dissociates a node from a multicast tree.
For example: mc_dissociate_node 1234321 1234567
| def do_mc_dissociate_node(self, line):
"""
mc_dissociate_node MGRP_HANDLE L1_HANDLE
This function dissociates a node from a multicast tree.
For example: mc_dissociate_node 1234321 1234567
"""
words = collections.deque(line.split())
try:
mgrp_hdl = self.get_handle(words, "MGRP_HANDLE")
... | [
"def",
"do_mc_dissociate_node",
"(",
"self",
",",
"line",
")",
":",
"words",
"=",
"collections",
".",
"deque",
"(",
"line",
".",
"split",
"(",
")",
")",
"try",
":",
"mgrp_hdl",
"=",
"self",
".",
"get_handle",
"(",
"words",
",",
"\"MGRP_HANDLE\"",
")",
... | [
596,
2
] | [
613,
41
] | python | en | ['en', 'error', 'th'] | False |
register_handler | (handler) |
Install application-specific BUFR image handler.
:param handler: Handler object.
|
Install application-specific BUFR image handler. | def register_handler(handler):
"""
Install application-specific BUFR image handler.
:param handler: Handler object.
"""
global _handler
_handler = handler | [
"def",
"register_handler",
"(",
"handler",
")",
":",
"global",
"_handler",
"_handler",
"=",
"handler"
] | [
16,
0
] | [
23,
22
] | python | en | ['en', 'error', 'th'] | False |
BaseEmailBackend.open | (self) | Open a network connection.
This method can be overwritten by backend implementations to
open a network connection.
It's up to the backend implementation to track the status of
a network connection if it's needed by the backend.
This method can be called by applications to forc... | Open a network connection. | def open(self):
"""Open a network connection.
This method can be overwritten by backend implementations to
open a network connection.
It's up to the backend implementation to track the status of
a network connection if it's needed by the backend.
This method can be cal... | [
"def",
"open",
"(",
"self",
")",
":",
"pass"
] | [
19,
4
] | [
35,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseEmailBackend.close | (self) | Close a network connection. | Close a network connection. | def close(self):
"""Close a network connection."""
pass | [
"def",
"close",
"(",
"self",
")",
":",
"pass"
] | [
37,
4
] | [
39,
12
] | python | en | ['en', 'en', 'en'] | True |
BaseEmailBackend.send_messages | (self, email_messages) |
Sends one or more EmailMessage objects and returns the number of email
messages sent.
|
Sends one or more EmailMessage objects and returns the number of email
messages sent.
| def send_messages(self, email_messages):
"""
Sends one or more EmailMessage objects and returns the number of email
messages sent.
"""
raise NotImplementedError('subclasses of BaseEmailBackend must override send_messages() method') | [
"def",
"send_messages",
"(",
"self",
",",
"email_messages",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of BaseEmailBackend must override send_messages() method'",
")"
] | [
52,
4
] | [
57,
104
] | python | en | ['en', 'error', 'th'] | False |
AzureRMModuleBaseExt.normalize_resource_id | (self, value, pattern) |
Return a proper resource id string..
:param resource_id: It could be a resource name, resource id or dict containing parts from the pattern.
:param pattern: pattern of resource is, just like in Azure Swagger
|
Return a proper resource id string.. | def normalize_resource_id(self, value, pattern):
'''
Return a proper resource id string..
:param resource_id: It could be a resource name, resource id or dict containing parts from the pattern.
:param pattern: pattern of resource is, just like in Azure Swagger
'''
value_... | [
"def",
"normalize_resource_id",
"(",
"self",
",",
"value",
",",
"pattern",
")",
":",
"value_dict",
"=",
"{",
"}",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
":",
"value_parts",
"=",
"value",
".",
"split",
"(",
"'/'",
")",
"if",
"len",
... | [
48,
4
] | [
83,
43
] | python | en | ['en', 'error', 'th'] | False |
AzureRMModuleBaseExt.idempotency_check | (self, old_params, new_params) |
Return True if something changed. Function will use fields from module_arg_spec to perform dependency checks.
:param old_params: old parameters dictionary, body from Get request.
:param new_params: new parameters dictionary, unpacked module parameters.
|
Return True if something changed. Function will use fields from module_arg_spec to perform dependency checks.
:param old_params: old parameters dictionary, body from Get request.
:param new_params: new parameters dictionary, unpacked module parameters.
| def idempotency_check(self, old_params, new_params):
'''
Return True if something changed. Function will use fields from module_arg_spec to perform dependency checks.
:param old_params: old parameters dictionary, body from Get request.
:param new_params: new parameters dictionary, unpack... | [
"def",
"idempotency_check",
"(",
"self",
",",
"old_params",
",",
"new_params",
")",
":",
"modifiers",
"=",
"{",
"}",
"result",
"=",
"{",
"}",
"self",
".",
"create_compare_modifiers",
"(",
"self",
".",
"module",
".",
"argument_spec",
",",
"''",
",",
"modifi... | [
85,
4
] | [
95,
88
] | python | en | ['en', 'error', 'th'] | False |
AzureRMModuleBaseExt.default_compare | (self, modifiers, new, old, path, result) |
Default dictionary comparison.
This function will work well with most of the Azure resources.
It correctly handles "location" comparison.
Value handling:
- if "new" value is None, it will be taken from "old" dictionary if "incremental_update"
... |
Default dictionary comparison.
This function will work well with most of the Azure resources.
It correctly handles "location" comparison. | def default_compare(self, modifiers, new, old, path, result):
'''
Default dictionary comparison.
This function will work well with most of the Azure resources.
It correctly handles "location" comparison.
Value handling:
- if "new" value is None, i... | [
"def",
"default_compare",
"(",
"self",
",",
"modifiers",
",",
"new",
",",
"old",
",",
"path",
",",
"result",
")",
":",
"if",
"new",
"is",
"None",
":",
"return",
"True",
"elif",
"isinstance",
"(",
"new",
",",
"dict",
")",
":",
"comparison_result",
"=",
... | [
114,
4
] | [
201,
27
] | python | en | ['en', 'error', 'th'] | False |
_rename_dem_folder | (gdir, source='') | Put the DEM files in a subfolder of the gdir.
Parameters
----------
gdir : GlacierDirectory
source : str
the DEM source
| Put the DEM files in a subfolder of the gdir. | def _rename_dem_folder(gdir, source=''):
"""Put the DEM files in a subfolder of the gdir.
Parameters
----------
gdir : GlacierDirectory
source : str
the DEM source
"""
# open tif-file to check if it's worth it
dem_f = gdir.get_filepath('dem')
try:
dem = gis.read_geo... | [
"def",
"_rename_dem_folder",
"(",
"gdir",
",",
"source",
"=",
"''",
")",
":",
"# open tif-file to check if it's worth it",
"dem_f",
"=",
"gdir",
".",
"get_filepath",
"(",
"'dem'",
")",
"try",
":",
"dem",
"=",
"gis",
".",
"read_geotiff_dem",
"(",
"gdir",
")",
... | [
28,
0
] | [
69,
60
] | python | en | ['en', 'en', 'en'] | True |
run_prepro_levels | (rgi_version=None, rgi_reg=None, border=None,
output_folder='', working_dir='', dem_source='',
is_test=False, test_ids=None, demo=False, test_rgidf=None,
test_intersects_file=None, test_topofile=None,
disable_mp=False, params_file=N... | Generate the preprocessed OGGM glacier directories for this OGGM version
Parameters
----------
rgi_version : str
the RGI version to use (defaults to cfg.PARAMS)
rgi_reg : str
the RGI region to process
border : int
the number of pixels at the maps border
output_folder : s... | Generate the preprocessed OGGM glacier directories for this OGGM version | def run_prepro_levels(rgi_version=None, rgi_reg=None, border=None,
output_folder='', working_dir='', dem_source='',
is_test=False, test_ids=None, demo=False, test_rgidf=None,
test_intersects_file=None, test_topofile=None,
disable_mp... | [
"def",
"run_prepro_levels",
"(",
"rgi_version",
"=",
"None",
",",
"rgi_reg",
"=",
"None",
",",
"border",
"=",
"None",
",",
"output_folder",
"=",
"''",
",",
"working_dir",
"=",
"''",
",",
"dem_source",
"=",
"''",
",",
"is_test",
"=",
"False",
",",
"test_i... | [
72,
0
] | [
627,
15
] | python | en | ['en', 'en', 'en'] | True |
parse_args | (args) | Check input arguments and env variables | Check input arguments and env variables | def parse_args(args):
"""Check input arguments and env variables"""
# CLI args
description = ('Generate the preprocessed OGGM glacier directories for '
'this OGGM version.')
parser = argparse.ArgumentParser(description=description)
parser.add_argument('--map-border', type=int,
... | [
"def",
"parse_args",
"(",
"args",
")",
":",
"# CLI args",
"description",
"=",
"(",
"'Generate the preprocessed OGGM glacier directories for '",
"'this OGGM version.'",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"description",
")",
"p... | [
630,
0
] | [
775,
17
] | python | en | ['en', 'en', 'en'] | True |
main | () | Script entry point | Script entry point | def main():
"""Script entry point"""
run_prepro_levels(**parse_args(sys.argv[1:])) | [
"def",
"main",
"(",
")",
":",
"run_prepro_levels",
"(",
"*",
"*",
"parse_args",
"(",
"sys",
".",
"argv",
"[",
"1",
":",
"]",
")",
")"
] | [
778,
0
] | [
781,
49
] | python | en | ['en', 'en', 'en'] | True |
PyAccess.__setitem__ | (self, xy, color) |
Modifies the pixel at x,y. The color is given as a single
numerical value for single band images, and a tuple for
multi-band images
:param xy: The pixel coordinate, given as (x, y). See
:ref:`coordinate-system`.
:param color: The pixel value.
|
Modifies the pixel at x,y. The color is given as a single
numerical value for single band images, and a tuple for
multi-band images | def __setitem__(self, xy, color):
"""
Modifies the pixel at x,y. The color is given as a single
numerical value for single band images, and a tuple for
multi-band images
:param xy: The pixel coordinate, given as (x, y). See
:ref:`coordinate-system`.
:param col... | [
"def",
"__setitem__",
"(",
"self",
",",
"xy",
",",
"color",
")",
":",
"if",
"self",
".",
"readonly",
":",
"raise",
"ValueError",
"(",
"\"Attempt to putpixel a read only image\"",
")",
"(",
"x",
",",
"y",
")",
"=",
"xy",
"if",
"x",
"<",
"0",
":",
"x",
... | [
70,
4
] | [
97,
42
] | python | en | ['en', 'error', 'th'] | False |
PyAccess.__getitem__ | (self, xy) |
Returns the pixel at x,y. The pixel is returned as a single
value for single band images or a tuple for multiple band
images
:param xy: The pixel coordinate, given as (x, y). See
:ref:`coordinate-system`.
:returns: a pixel value for single band images, a tuple of
... |
Returns the pixel at x,y. The pixel is returned as a single
value for single band images or a tuple for multiple band
images | def __getitem__(self, xy):
"""
Returns the pixel at x,y. The pixel is returned as a single
value for single band images or a tuple for multiple band
images
:param xy: The pixel coordinate, given as (x, y). See
:ref:`coordinate-system`.
:returns: a pixel value f... | [
"def",
"__getitem__",
"(",
"self",
",",
"xy",
")",
":",
"(",
"x",
",",
"y",
")",
"=",
"xy",
"if",
"x",
"<",
"0",
":",
"x",
"=",
"self",
".",
"xsize",
"+",
"x",
"if",
"y",
"<",
"0",
":",
"y",
"=",
"self",
".",
"ysize",
"+",
"y",
"(",
"x"... | [
99,
4
] | [
116,
35
] | python | en | ['en', 'error', 'th'] | False |
_save | (im, fp, tile, bufsize=0) | Helper to save image based on tile list
:param im: Image object.
:param fp: File object.
:param tile: Tile list.
:param bufsize: Optional buffer size
| Helper to save image based on tile list | def _save(im, fp, tile, bufsize=0):
"""Helper to save image based on tile list
:param im: Image object.
:param fp: File object.
:param tile: Tile list.
:param bufsize: Optional buffer size
"""
im.load()
if not hasattr(im, "encoderconfig"):
im.encoderconfig = ()
tile.sort(ke... | [
"def",
"_save",
"(",
"im",
",",
"fp",
",",
"tile",
",",
"bufsize",
"=",
"0",
")",
":",
"im",
".",
"load",
"(",
")",
"if",
"not",
"hasattr",
"(",
"im",
",",
"\"encoderconfig\"",
")",
":",
"im",
".",
"encoderconfig",
"=",
"(",
")",
"tile",
".",
"... | [
487,
0
] | [
546,
18
] | python | en | ['en', 'da', 'en'] | True |
_safe_read | (fp, size) |
Reads large blocks in a safe way. Unlike fp.read(n), this function
doesn't trust the user. If the requested size is larger than
SAFEBLOCK, the file is read block by block.
:param fp: File handle. Must implement a <b>read</b> method.
:param size: Number of bytes to read.
:returns: A string c... |
Reads large blocks in a safe way. Unlike fp.read(n), this function
doesn't trust the user. If the requested size is larger than
SAFEBLOCK, the file is read block by block. | def _safe_read(fp, size):
"""
Reads large blocks in a safe way. Unlike fp.read(n), this function
doesn't trust the user. If the requested size is larger than
SAFEBLOCK, the file is read block by block.
:param fp: File handle. Must implement a <b>read</b> method.
:param size: Number of bytes ... | [
"def",
"_safe_read",
"(",
"fp",
",",
"size",
")",
":",
"if",
"size",
"<=",
"0",
":",
"return",
"b\"\"",
"if",
"size",
"<=",
"SAFEBLOCK",
":",
"return",
"fp",
".",
"read",
"(",
"size",
")",
"data",
"=",
"[",
"]",
"while",
"size",
">",
"0",
":",
... | [
549,
0
] | [
570,
25
] | python | en | ['en', 'error', 'th'] | False |
ImageFile.__init__ | (self, fp=None, filename=None) | A list of tile descriptors, or ``None`` | A list of tile descriptors, or ``None`` | def __init__(self, fp=None, filename=None):
super().__init__()
self._min_frame = 0
self.custom_mimetype = None
self.tile = None
""" A list of tile descriptors, or ``None`` """
self.readonly = 1 # until we know better
self.decoderconfig = ()
self.deco... | [
"def",
"__init__",
"(",
"self",
",",
"fp",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"super",
"(",
")",
".",
"__init__",
"(",
")",
"self",
".",
"_min_frame",
"=",
"0",
"self",
".",
"custom_mimetype",
"=",
"None",
"self",
".",
"tile",
"="... | [
91,
4
] | [
136,
17
] | python | en | ['en', 'fr', 'en'] | True |
ImageFile.verify | (self) | Check file integrity | Check file integrity | def verify(self):
"""Check file integrity"""
# raise exception if something's wrong. must be called
# directly after open, and closes file when finished.
if self._exclusive_fp:
self.fp.close()
self.fp = None | [
"def",
"verify",
"(",
"self",
")",
":",
"# raise exception if something's wrong. must be called",
"# directly after open, and closes file when finished.",
"if",
"self",
".",
"_exclusive_fp",
":",
"self",
".",
"fp",
".",
"close",
"(",
")",
"self",
".",
"fp",
"=",
"Non... | [
144,
4
] | [
151,
22
] | python | en | ['en', 'en', 'en'] | True |
ImageFile.load | (self) | Load image data based on tile list | Load image data based on tile list | def load(self):
"""Load image data based on tile list"""
if self.tile is None:
raise OSError("cannot load this image")
pixel = Image.Image.load(self)
if not self.tile:
return pixel
self.map = None
use_mmap = self.filename and len(self.tile) == 1... | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"self",
".",
"tile",
"is",
"None",
":",
"raise",
"OSError",
"(",
"\"cannot load this image\"",
")",
"pixel",
"=",
"Image",
".",
"Image",
".",
"load",
"(",
"self",
")",
"if",
"not",
"self",
".",
"tile",
":",... | [
153,
4
] | [
285,
37
] | python | en | ['en', 'da', 'en'] | True |
StubImageFile._load | (self) | (Hook) Find actual image loader. | (Hook) Find actual image loader. | def _load(self):
"""(Hook) Find actual image loader."""
raise NotImplementedError("StubImageFile subclass must implement _load") | [
"def",
"_load",
"(",
"self",
")",
":",
"raise",
"NotImplementedError",
"(",
"\"StubImageFile subclass must implement _load\"",
")"
] | [
343,
4
] | [
345,
80
] | python | en | ['en', 'da', 'en'] | True |
Parser.reset | (self) |
(Consumer) Reset the parser. Note that you can only call this
method immediately after you've created a parser; parser
instances cannot be reused.
|
(Consumer) Reset the parser. Note that you can only call this
method immediately after you've created a parser; parser
instances cannot be reused.
| def reset(self):
"""
(Consumer) Reset the parser. Note that you can only call this
method immediately after you've created a parser; parser
instances cannot be reused.
"""
assert self.data is None, "cannot reuse parsers" | [
"def",
"reset",
"(",
"self",
")",
":",
"assert",
"self",
".",
"data",
"is",
"None",
",",
"\"cannot reuse parsers\""
] | [
361,
4
] | [
367,
56
] | python | en | ['en', 'error', 'th'] | False |
Parser.feed | (self, data) |
(Consumer) Feed data to the parser.
:param data: A string buffer.
:exception OSError: If the parser failed to parse the image file.
|
(Consumer) Feed data to the parser. | def feed(self, data):
"""
(Consumer) Feed data to the parser.
:param data: A string buffer.
:exception OSError: If the parser failed to parse the image file.
"""
# collect data
if self.finished:
return
if self.data is None:
self.... | [
"def",
"feed",
"(",
"self",
",",
"data",
")",
":",
"# collect data",
"if",
"self",
".",
"finished",
":",
"return",
"if",
"self",
".",
"data",
"is",
"None",
":",
"self",
".",
"data",
"=",
"data",
"else",
":",
"self",
".",
"data",
"=",
"self",
".",
... | [
369,
4
] | [
447,
31
] | python | en | ['en', 'error', 'th'] | False |
Parser.close | (self) |
(Consumer) Close the stream.
:returns: An image object.
:exception OSError: If the parser failed to parse the image file either
because it cannot be identified or cannot be
decoded.
|
(Consumer) Close the stream. | def close(self):
"""
(Consumer) Close the stream.
:returns: An image object.
:exception OSError: If the parser failed to parse the image file either
because it cannot be identified or cannot be
decoded.
"""
# finish... | [
"def",
"close",
"(",
"self",
")",
":",
"# finish decoding",
"if",
"self",
".",
"decoder",
":",
"# get rid of what's left in the buffers",
"self",
".",
"feed",
"(",
"b\"\"",
")",
"self",
".",
"data",
"=",
"self",
".",
"decoder",
"=",
"None",
"if",
"not",
"s... | [
455,
4
] | [
481,
25
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.init | (self, args) |
Override to perform decoder specific initialization
:param args: Array of args items from the tile entry
:returns: None
|
Override to perform decoder specific initialization | def init(self, args):
"""
Override to perform decoder specific initialization
:param args: Array of args items from the tile entry
:returns: None
"""
self.args = args | [
"def",
"init",
"(",
"self",
",",
"args",
")",
":",
"self",
".",
"args",
"=",
"args"
] | [
601,
4
] | [
608,
24
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.decode | (self, buffer) |
Override to perform the decoding process.
:param buffer: A bytes object with the data to be decoded.
:returns: A tuple of ``(bytes consumed, errcode)``.
If finished with decoding return <0 for the bytes consumed.
Err codes are from :data:`.ImageFile.ERRORS`.
|
Override to perform the decoding process. | def decode(self, buffer):
"""
Override to perform the decoding process.
:param buffer: A bytes object with the data to be decoded.
:returns: A tuple of ``(bytes consumed, errcode)``.
If finished with decoding return <0 for the bytes consumed.
Err codes are from :... | [
"def",
"decode",
"(",
"self",
",",
"buffer",
")",
":",
"raise",
"NotImplementedError",
"(",
")"
] | [
614,
4
] | [
623,
35
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.cleanup | (self) |
Override to perform decoder specific cleanup
:returns: None
|
Override to perform decoder specific cleanup | def cleanup(self):
"""
Override to perform decoder specific cleanup
:returns: None
"""
pass | [
"def",
"cleanup",
"(",
"self",
")",
":",
"pass"
] | [
625,
4
] | [
631,
12
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.setfd | (self, fd) |
Called from ImageFile to set the python file-like object
:param fd: A python file-like object
:returns: None
|
Called from ImageFile to set the python file-like object | def setfd(self, fd):
"""
Called from ImageFile to set the python file-like object
:param fd: A python file-like object
:returns: None
"""
self.fd = fd | [
"def",
"setfd",
"(",
"self",
",",
"fd",
")",
":",
"self",
".",
"fd",
"=",
"fd"
] | [
633,
4
] | [
640,
20
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.setimage | (self, im, extents=None) |
Called from ImageFile to set the core output image for the decoder
:param im: A core image object
:param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
for this tile
:returns: None
|
Called from ImageFile to set the core output image for the decoder | def setimage(self, im, extents=None):
"""
Called from ImageFile to set the core output image for the decoder
:param im: A core image object
:param extents: a 4 tuple of (x0, y0, x1, y1) defining the rectangle
for this tile
:returns: None
"""
# follow... | [
"def",
"setimage",
"(",
"self",
",",
"im",
",",
"extents",
"=",
"None",
")",
":",
"# following c code",
"self",
".",
"im",
"=",
"im",
"if",
"extents",
":",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
")",
"=",
"extents",
"else",
":",
"(",
"x0",
... | [
642,
4
] | [
675,
64
] | python | en | ['en', 'error', 'th'] | False |
PyDecoder.set_as_raw | (self, data, rawmode=None) |
Convenience method to set the internal image from a stream of raw data
:param data: Bytes to be set
:param rawmode: The rawmode to be used for the decoder.
If not specified, it will default to the mode of the image
:returns: None
|
Convenience method to set the internal image from a stream of raw data | def set_as_raw(self, data, rawmode=None):
"""
Convenience method to set the internal image from a stream of raw data
:param data: Bytes to be set
:param rawmode: The rawmode to be used for the decoder.
If not specified, it will default to the mode of the image
:retur... | [
"def",
"set_as_raw",
"(",
"self",
",",
"data",
",",
"rawmode",
"=",
"None",
")",
":",
"if",
"not",
"rawmode",
":",
"rawmode",
"=",
"self",
".",
"mode",
"d",
"=",
"Image",
".",
"_getdecoder",
"(",
"self",
".",
"mode",
",",
"\"raw\"",
",",
"(",
"rawm... | [
677,
4
] | [
696,
56
] | python | en | ['en', 'error', 'th'] | False |
test_content_types | (self) |
Test old `/json/messages` returns reactions.
|
Test old `/json/messages` returns reactions.
| def test_content_types(self) -> None:
"""
Test old `/json/messages` returns reactions.
"""
self.login("hamlet")
def get_content_type(apply_markdown: bool) -> str:
req: Dict[str, Any] = dict(
apply_markdown=orjson.dumps(apply_markdown).decode(),
... | [
"def",
"test_content_types",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"def",
"get_content_type",
"(",
"apply_markdown",
":",
"bool",
")",
"->",
"str",
":",
"req",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
"=",
... | [
1380,
4
] | [
1402,
9
] | python | en | ['en', 'error', 'th'] | False |
test_successful_get_messages_reaction | (self) |
Test old `/json/messages` returns reactions.
|
Test old `/json/messages` returns reactions.
| def test_successful_get_messages_reaction(self) -> None:
"""
Test old `/json/messages` returns reactions.
"""
self.login("hamlet")
messages = self.get_and_check_messages({})
message_id = messages["messages"][0]["id"]
self.login("othello")
reaction_name = ... | [
"def",
"test_successful_get_messages_reaction",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"messages",
"=",
"self",
".",
"get_and_check_messages",
"(",
"{",
"}",
")",
"message_id",
"=",
"messages",
"[",
"\"messages\"",
"... | [
1404,
4
] | [
1431,
88
] | python | en | ['en', 'error', 'th'] | False |
test_successful_get_messages | (self) |
A call to GET /json/messages with valid parameters returns a list of
messages.
|
A call to GET /json/messages with valid parameters returns a list of
messages.
| def test_successful_get_messages(self) -> None:
"""
A call to GET /json/messages with valid parameters returns a list of
messages.
"""
self.login("hamlet")
self.get_and_check_messages({})
othello_email = self.example_user("othello").email
# We have to su... | [
"def",
"test_successful_get_messages",
"(",
"self",
")",
"->",
"None",
":",
"self",
".",
"login",
"(",
"\"hamlet\"",
")",
"self",
".",
"get_and_check_messages",
"(",
"{",
"}",
")",
"othello_email",
"=",
"self",
".",
"example_user",
"(",
"\"othello\"",
")",
"... | [
1433,
4
] | [
1459,
9
] | python | en | ['en', 'error', 'th'] | False |
test_unauthenticated_get_messages_without_web_public | (self) |
An unauthenticated call to GET /json/messages with valid parameters
returns a 401.
|
An unauthenticated call to GET /json/messages with valid parameters
returns a 401.
| def test_unauthenticated_get_messages_without_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages with valid parameters
returns a 401.
"""
post_params = {
"anchor": 1,
"num_before": 1,
"num_after": 1,
"narrow... | [
"def",
"test_unauthenticated_get_messages_without_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
"\"num_before\"",
":",
"1",
",",
"\"num_after\"",
":",
"1",
",",
"\"narrow\"",
":",
"orjson",
".",
"dumps",
... | [
1473,
4
] | [
1497,
9
] | python | en | ['en', 'error', 'th'] | False |
test_unauthenticated_get_messages_with_web_public | (self) |
An unauthenticated call to GET /json/messages without valid
parameters in the `streams:web-public` narrow returns a 401.
|
An unauthenticated call to GET /json/messages without valid
parameters in the `streams:web-public` narrow returns a 401.
| def test_unauthenticated_get_messages_with_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages without valid
parameters in the `streams:web-public` narrow returns a 401.
"""
post_params: Dict[str, Union[int, str, bool]] = {
"anchor": 1,
... | [
"def",
"test_unauthenticated_get_messages_with_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"int",
",",
"str",
",",
"bool",
"]",
"]",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
"\"num_before\"",
"... | [
1499,
4
] | [
1519,
9
] | python | en | ['en', 'error', 'th'] | False |
test_unauthenticated_narrow_to_non_web_public_streams_without_web_public | (self) |
An unauthenticated call to GET /json/messages without `streams:web-public` narrow returns a 401.
|
An unauthenticated call to GET /json/messages without `streams:web-public` narrow returns a 401.
| def test_unauthenticated_narrow_to_non_web_public_streams_without_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages without `streams:web-public` narrow returns a 401.
"""
post_params: Dict[str, Union[int, str, bool]] = {
"anchor": 1,
"num... | [
"def",
"test_unauthenticated_narrow_to_non_web_public_streams_without_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"int",
",",
"str",
",",
"bool",
"]",
"]",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
... | [
1521,
4
] | [
1534,
9
] | python | en | ['en', 'error', 'th'] | False |
test_unauthenticated_narrow_to_non_web_public_streams_with_web_public | (self) |
An unauthenticated call to GET /json/messages with valid
parameters in the `streams:web-public` narrow + narrow to stream returns
a 400 if the target stream is not web-public.
|
An unauthenticated call to GET /json/messages with valid
parameters in the `streams:web-public` narrow + narrow to stream returns
a 400 if the target stream is not web-public.
| def test_unauthenticated_narrow_to_non_web_public_streams_with_web_public(self) -> None:
"""
An unauthenticated call to GET /json/messages with valid
parameters in the `streams:web-public` narrow + narrow to stream returns
a 400 if the target stream is not web-public.
"""
... | [
"def",
"test_unauthenticated_narrow_to_non_web_public_streams_with_web_public",
"(",
"self",
")",
"->",
"None",
":",
"post_params",
":",
"Dict",
"[",
"str",
",",
"Union",
"[",
"int",
",",
"str",
",",
"bool",
"]",
"]",
"=",
"{",
"\"anchor\"",
":",
"1",
",",
"... | [
1536,
4
] | [
1556,
9
] | python | en | ['en', 'error', 'th'] | False |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.