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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
TestAccountUploadAvatar.test_no_value_preserves_current_avatar | (self) |
Tests that submitting a blank value for avatar doesn't remove it.
|
Tests that submitting a blank value for avatar doesn't remove it.
| def test_no_value_preserves_current_avatar(self):
"""
Tests that submitting a blank value for avatar doesn't remove it.
"""
profile = UserProfile.get_for_user(self.user)
profile.avatar = self.avatar
profile.save()
# Upload a new avatar
response = self.pos... | [
"def",
"test_no_value_preserves_current_avatar",
"(",
"self",
")",
":",
"profile",
"=",
"UserProfile",
".",
"get_for_user",
"(",
"self",
".",
"user",
")",
"profile",
".",
"avatar",
"=",
"self",
".",
"avatar",
"profile",
".",
"save",
"(",
")",
"# Upload a new a... | [
538,
4
] | [
553,
53
] | python | en | ['en', 'error', 'th'] | False |
TestAccountUploadAvatar.test_clear_removes_current_avatar | (self) |
Tests that submitting a blank value for avatar doesn't remove it.
|
Tests that submitting a blank value for avatar doesn't remove it.
| def test_clear_removes_current_avatar(self):
"""
Tests that submitting a blank value for avatar doesn't remove it.
"""
profile = UserProfile.get_for_user(self.user)
profile.avatar = self.avatar
profile.save()
# Upload a new avatar
response = self.post_for... | [
"def",
"test_clear_removes_current_avatar",
"(",
"self",
")",
":",
"profile",
"=",
"UserProfile",
".",
"get_for_user",
"(",
"self",
".",
"user",
")",
"profile",
".",
"avatar",
"=",
"self",
".",
"avatar",
"profile",
".",
"save",
"(",
")",
"# Upload a new avatar... | [
555,
4
] | [
572,
53
] | python | en | ['en', 'error', 'th'] | False |
TestAccountManagementForNonModerator.test_notification_preferences_panel_reduced_for_non_moderators | (self) |
This tests that a user without publish permissions is not shown the
notification preference for 'submitted' items
|
This tests that a user without publish permissions is not shown the
notification preference for 'submitted' items
| def test_notification_preferences_panel_reduced_for_non_moderators(self):
"""
This tests that a user without publish permissions is not shown the
notification preference for 'submitted' items
"""
response = self.client.get(reverse('wagtailadmin_account'))
# Find notifica... | [
"def",
"test_notification_preferences_panel_reduced_for_non_moderators",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_account'",
")",
")",
"# Find notifications panel through context",
"notifications_panel",
... | [
586,
4
] | [
605,
89
] | python | en | ['en', 'error', 'th'] | False |
TestAccountManagementForAdminOnlyUser.test_notification_preferences_not_rendered_for_admin_only_users | (self) |
Test that the user is not shown the notification preferences panel
|
Test that the user is not shown the notification preferences panel
| def test_notification_preferences_not_rendered_for_admin_only_users(self):
"""
Test that the user is not shown the notification preferences panel
"""
response = self.client.get(reverse('wagtailadmin_account'))
self.assertPanelNotActive(response, 'notifications') | [
"def",
"test_notification_preferences_not_rendered_for_admin_only_users",
"(",
"self",
")",
":",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_account'",
")",
")",
"self",
".",
"assertPanelNotActive",
"(",
"response",
",",
"... | [
626,
4
] | [
631,
60
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_view | (self) |
This tests that the password reset view returns a password reset page
|
This tests that the password reset view returns a password reset page
| def test_password_reset_view(self):
"""
This tests that the password reset view returns a password reset page
"""
# Get password reset page
response = self.client.get(reverse('wagtailadmin_password_reset'))
# Check that the user received a password reset page
sel... | [
"def",
"test_password_reset_view",
"(",
"self",
")",
":",
"# Get password reset page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_password_reset'",
")",
")",
"# Check that the user received a password reset page",
"self",
".",
... | [
642,
4
] | [
651,
90
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_view_post | (self) |
This posts an email address to the password reset view and
checks that a password reset email was sent
|
This posts an email address to the password reset view and
checks that a password reset email was sent
| def test_password_reset_view_post(self):
"""
This posts an email address to the password reset view and
checks that a password reset email was sent
"""
# Post email address to password reset view
post_data = {
'email': 'test@email.com',
}
respo... | [
"def",
"test_password_reset_view_post",
"(",
"self",
")",
":",
"# Post email address to password reset view",
"post_data",
"=",
"{",
"'email'",
":",
"'test@email.com'",
",",
"}",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmi... | [
653,
4
] | [
670,
66
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_view_post_unknown_email | (self) |
This posts an unknown email address to the password reset view and
checks that the password reset form raises a validation error
|
This posts an unknown email address to the password reset view and
checks that the password reset form raises a validation error
| def test_password_reset_view_post_unknown_email(self):
"""
This posts an unknown email address to the password reset view and
checks that the password reset form raises a validation error
"""
post_data = {
'email': 'unknown@email.com',
}
response = sel... | [
"def",
"test_password_reset_view_post_unknown_email",
"(",
"self",
")",
":",
"post_data",
"=",
"{",
"'email'",
":",
"'unknown@email.com'",
",",
"}",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_password_reset'",
")",
","... | [
672,
4
] | [
687,
45
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_view_post_invalid_email | (self) |
This posts an invalid email address to the password reset view and
checks that the password reset form raises a validation error
|
This posts an invalid email address to the password reset view and
checks that the password reset form raises a validation error
| def test_password_reset_view_post_invalid_email(self):
"""
This posts an invalid email address to the password reset view and
checks that the password reset form raises a validation error
"""
post_data = {
'email': 'Hello world!',
}
response = self.cli... | [
"def",
"test_password_reset_view_post_invalid_email",
"(",
"self",
")",
":",
"post_data",
"=",
"{",
"'email'",
":",
"'Hello world!'",
",",
"}",
"response",
"=",
"self",
".",
"client",
".",
"post",
"(",
"reverse",
"(",
"'wagtailadmin_password_reset'",
")",
",",
"... | [
689,
4
] | [
707,
45
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_confirm_view_invalid_link | (self) |
This tests that the password reset view shows an error message if the link is invalid
|
This tests that the password reset view shows an error message if the link is invalid
| def test_password_reset_confirm_view_invalid_link(self):
"""
This tests that the password reset view shows an error message if the link is invalid
"""
self.setup_password_reset_confirm_tests()
# Create invalid url_args
self.url_kwargs = dict(uidb64=self.password_reset_ui... | [
"def",
"test_password_reset_confirm_view_invalid_link",
"(",
"self",
")",
":",
"self",
".",
"setup_password_reset_confirm_tests",
"(",
")",
"# Create invalid url_args",
"self",
".",
"url_kwargs",
"=",
"dict",
"(",
"uidb64",
"=",
"self",
".",
"password_reset_uid",
",",
... | [
734,
4
] | [
751,
69
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_confirm_view | (self) |
This tests that the password reset confirm view returns a password reset confirm page
|
This tests that the password reset confirm view returns a password reset confirm page
| def test_password_reset_confirm_view(self):
"""
This tests that the password reset confirm view returns a password reset confirm page
"""
self.setup_password_reset_confirm_tests()
# Get password reset confirm page
response = self.client.get(reverse('wagtailadmin_password... | [
"def",
"test_password_reset_confirm_view",
"(",
"self",
")",
":",
"self",
".",
"setup_password_reset_confirm_tests",
"(",
")",
"# Get password reset confirm page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_password_reset_confi... | [
753,
4
] | [
764,
93
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_confirm_view_post | (self) |
This posts a new password to the password reset confirm view and checks
that the users password was changed
|
This posts a new password to the password reset confirm view and checks
that the users password was changed
| def test_password_reset_confirm_view_post(self):
"""
This posts a new password to the password reset confirm view and checks
that the users password was changed
"""
self.setup_password_reset_confirm_tests()
# Post new password to change password page
post_data = ... | [
"def",
"test_password_reset_confirm_view_post",
"(",
"self",
")",
":",
"self",
".",
"setup_password_reset_confirm_tests",
"(",
")",
"# Post new password to change password page",
"post_data",
"=",
"{",
"'new_password1'",
":",
"'newpassword'",
",",
"'new_password2'",
":",
"'... | [
766,
4
] | [
784,
107
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_confirm_view_post_password_mismatch | (self) |
This posts a two passwords that don't match to the password reset
confirm view and checks that a validation error was raised
|
This posts a two passwords that don't match to the password reset
confirm view and checks that a validation error was raised
| def test_password_reset_confirm_view_post_password_mismatch(self):
"""
This posts a two passwords that don't match to the password reset
confirm view and checks that a validation error was raised
"""
self.setup_password_reset_confirm_tests()
# Post new password to change... | [
"def",
"test_password_reset_confirm_view_post_password_mismatch",
"(",
"self",
")",
":",
"self",
".",
"setup_password_reset_confirm_tests",
"(",
")",
"# Post new password to change password page",
"post_data",
"=",
"{",
"'new_password1'",
":",
"'newpassword'",
",",
"'new_passwo... | [
786,
4
] | [
808,
104
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_done_view | (self) |
This tests that the password reset done view returns a password reset done page
|
This tests that the password reset done view returns a password reset done page
| def test_password_reset_done_view(self):
"""
This tests that the password reset done view returns a password reset done page
"""
# Get password reset done page
response = self.client.get(reverse('wagtailadmin_password_reset_done'))
# Check that the user received a passwo... | [
"def",
"test_password_reset_done_view",
"(",
"self",
")",
":",
"# Get password reset done page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_password_reset_done'",
")",
")",
"# Check that the user received a password reset done page... | [
810,
4
] | [
819,
90
] | python | en | ['en', 'error', 'th'] | False |
TestPasswordReset.test_password_reset_complete_view | (self) |
This tests that the password reset complete view returns a password reset complete page
|
This tests that the password reset complete view returns a password reset complete page
| def test_password_reset_complete_view(self):
"""
This tests that the password reset complete view returns a password reset complete page
"""
# Get password reset complete page
response = self.client.get(reverse('wagtailadmin_password_reset_complete'))
# Check that the us... | [
"def",
"test_password_reset_complete_view",
"(",
"self",
")",
":",
"# Get password reset complete page",
"response",
"=",
"self",
".",
"client",
".",
"get",
"(",
"reverse",
"(",
"'wagtailadmin_password_reset_complete'",
")",
")",
"# Check that the user received a password res... | [
821,
4
] | [
830,
94
] | python | en | ['en', 'error', 'th'] | False |
TestWorkflowDAGFunctional.workflow_job | (self, states=['new', 'new', 'new', 'new', 'new']) |
Workflow topology:
node[0]
/\
s/ \f
/ \
node[1] node[3]
/ \
s/ \f
/ \
node[2] node[4]
|
Workflow topology:
node[0]
/\
s/ \f
/ \
node[1] node[3]
/ \
s/ \f
/ \
node[2] node[4]
| def workflow_job(self, states=['new', 'new', 'new', 'new', 'new']):
"""
Workflow topology:
node[0]
/\
s/ \f
/ \
node[1] node[3]
/ \
s/ \f
/ \
node[2] node[4]... | [
"def",
"workflow_job",
"(",
"self",
",",
"states",
"=",
"[",
"'new'",
",",
"'new'",
",",
"'new'",
",",
"'new'",
",",
"'new'",
"]",
")",
":",
"wfj",
"=",
"WorkflowJob",
".",
"objects",
".",
"create",
"(",
")",
"jt",
"=",
"JobTemplate",
".",
"objects",... | [
24,
4
] | [
50,
18
] | python | en | ['en', 'error', 'th'] | False |
TestWorkflowDAGFunctional.test_build_WFJT_dag | (self) |
Test that building the graph uses 4 queries
1 to get the nodes
3 to get the related success, failure, and always connections
|
Test that building the graph uses 4 queries
1 to get the nodes
3 to get the related success, failure, and always connections
| def test_build_WFJT_dag(self):
"""
Test that building the graph uses 4 queries
1 to get the nodes
3 to get the related success, failure, and always connections
"""
dag = WorkflowDAG()
wfj = self.workflow_job()
with self.assertNumQueries(4):
d... | [
"def",
"test_build_WFJT_dag",
"(",
"self",
")",
":",
"dag",
"=",
"WorkflowDAG",
"(",
")",
"wfj",
"=",
"self",
".",
"workflow_job",
"(",
")",
"with",
"self",
".",
"assertNumQueries",
"(",
"4",
")",
":",
"dag",
".",
"_init_graph",
"(",
"wfj",
")"
] | [
52,
4
] | [
61,
32
] | python | en | ['en', 'error', 'th'] | False |
Operation.deconstruct | (self) |
Returns a 3-tuple of class import path (or just name if it lives
under django.db.migrations), positional arguments, and keyword
arguments.
|
Returns a 3-tuple of class import path (or just name if it lives
under django.db.migrations), positional arguments, and keyword
arguments.
| def deconstruct(self):
"""
Returns a 3-tuple of class import path (or just name if it lives
under django.db.migrations), positional arguments, and keyword
arguments.
"""
return (
self.__class__.__name__,
self._constructor_args[0],
self.... | [
"def",
"deconstruct",
"(",
"self",
")",
":",
"return",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"_constructor_args",
"[",
"0",
"]",
",",
"self",
".",
"_constructor_args",
"[",
"1",
"]",
",",
")"
] | [
43,
4
] | [
53,
9
] | python | en | ['en', 'error', 'th'] | False |
Operation.state_forwards | (self, app_label, state) |
Takes the state from the previous migration, and mutates it
so that it matches what this migration would perform.
|
Takes the state from the previous migration, and mutates it
so that it matches what this migration would perform.
| def state_forwards(self, app_label, state):
"""
Takes the state from the previous migration, and mutates it
so that it matches what this migration would perform.
"""
raise NotImplementedError('subclasses of Operation must provide a state_forwards() method') | [
"def",
"state_forwards",
"(",
"self",
",",
"app_label",
",",
"state",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of Operation must provide a state_forwards() method'",
")"
] | [
55,
4
] | [
60,
99
] | python | en | ['en', 'error', 'th'] | False |
Operation.database_forwards | (self, app_label, schema_editor, from_state, to_state) |
Performs the mutation on the database schema in the normal
(forwards) direction.
|
Performs the mutation on the database schema in the normal
(forwards) direction.
| def database_forwards(self, app_label, schema_editor, from_state, to_state):
"""
Performs the mutation on the database schema in the normal
(forwards) direction.
"""
raise NotImplementedError('subclasses of Operation must provide a database_forwards() method') | [
"def",
"database_forwards",
"(",
"self",
",",
"app_label",
",",
"schema_editor",
",",
"from_state",
",",
"to_state",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of Operation must provide a database_forwards() method'",
")"
] | [
62,
4
] | [
67,
102
] | python | en | ['en', 'error', 'th'] | False |
Operation.database_backwards | (self, app_label, schema_editor, from_state, to_state) |
Performs the mutation on the database schema in the reverse
direction - e.g. if this were CreateModel, it would in fact
drop the model's table.
|
Performs the mutation on the database schema in the reverse
direction - e.g. if this were CreateModel, it would in fact
drop the model's table.
| def database_backwards(self, app_label, schema_editor, from_state, to_state):
"""
Performs the mutation on the database schema in the reverse
direction - e.g. if this were CreateModel, it would in fact
drop the model's table.
"""
raise NotImplementedError('subclasses of O... | [
"def",
"database_backwards",
"(",
"self",
",",
"app_label",
",",
"schema_editor",
",",
"from_state",
",",
"to_state",
")",
":",
"raise",
"NotImplementedError",
"(",
"'subclasses of Operation must provide a database_backwards() method'",
")"
] | [
69,
4
] | [
75,
103
] | python | en | ['en', 'error', 'th'] | False |
Operation.describe | (self) |
Outputs a brief summary of what the action does.
|
Outputs a brief summary of what the action does.
| def describe(self):
"""
Outputs a brief summary of what the action does.
"""
return "%s: %s" % (self.__class__.__name__, self._constructor_args) | [
"def",
"describe",
"(",
"self",
")",
":",
"return",
"\"%s: %s\"",
"%",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"self",
".",
"_constructor_args",
")"
] | [
77,
4
] | [
81,
75
] | python | en | ['en', 'error', 'th'] | False |
Operation.references_model | (self, name, app_label=None) |
Returns True if there is a chance this operation references the given
model name (as a string), with an optional app label for accuracy.
Used for optimization. If in doubt, return True;
returning a false positive will merely make the optimizer a little
less efficient, while ret... |
Returns True if there is a chance this operation references the given
model name (as a string), with an optional app label for accuracy. | def references_model(self, name, app_label=None):
"""
Returns True if there is a chance this operation references the given
model name (as a string), with an optional app label for accuracy.
Used for optimization. If in doubt, return True;
returning a false positive will merely ... | [
"def",
"references_model",
"(",
"self",
",",
"name",
",",
"app_label",
"=",
"None",
")",
":",
"return",
"True"
] | [
83,
4
] | [
93,
19
] | python | en | ['en', 'error', 'th'] | False |
Operation.references_field | (self, model_name, name, app_label=None) |
Returns True if there is a chance this operation references the given
field name, with an optional app label for accuracy.
Used for optimization. If in doubt, return True.
|
Returns True if there is a chance this operation references the given
field name, with an optional app label for accuracy. | def references_field(self, model_name, name, app_label=None):
"""
Returns True if there is a chance this operation references the given
field name, with an optional app label for accuracy.
Used for optimization. If in doubt, return True.
"""
return self.references_model(... | [
"def",
"references_field",
"(",
"self",
",",
"model_name",
",",
"name",
",",
"app_label",
"=",
"None",
")",
":",
"return",
"self",
".",
"references_model",
"(",
"model_name",
",",
"app_label",
")"
] | [
95,
4
] | [
102,
59
] | python | en | ['en', 'error', 'th'] | False |
Operation.allow_migrate_model | (self, connection_alias, model) |
Returns if we're allowed to migrate the model.
This is a thin wrapper around router.allow_migrate_model() that
preemptively rejects any proxy, swapped out, or unmanaged model.
|
Returns if we're allowed to migrate the model. | def allow_migrate_model(self, connection_alias, model):
"""
Returns if we're allowed to migrate the model.
This is a thin wrapper around router.allow_migrate_model() that
preemptively rejects any proxy, swapped out, or unmanaged model.
"""
if not model._meta.can_migrate(... | [
"def",
"allow_migrate_model",
"(",
"self",
",",
"connection_alias",
",",
"model",
")",
":",
"if",
"not",
"model",
".",
"_meta",
".",
"can_migrate",
"(",
"connection_alias",
")",
":",
"return",
"False",
"return",
"router",
".",
"allow_migrate_model",
"(",
"conn... | [
104,
4
] | [
114,
66
] | python | en | ['en', 'error', 'th'] | False |
Operation.reduce | (self, operation, in_between, app_label=None) |
Return either a list of operations the actual operation should be
replaced with or a boolean that indicates whether or not the specified
operation can be optimized across.
|
Return either a list of operations the actual operation should be
replaced with or a boolean that indicates whether or not the specified
operation can be optimized across.
| def reduce(self, operation, in_between, app_label=None):
"""
Return either a list of operations the actual operation should be
replaced with or a boolean that indicates whether or not the specified
operation can be optimized across.
"""
if self.elidable:
retur... | [
"def",
"reduce",
"(",
"self",
",",
"operation",
",",
"in_between",
",",
"app_label",
"=",
"None",
")",
":",
"if",
"self",
".",
"elidable",
":",
"return",
"[",
"operation",
"]",
"elif",
"operation",
".",
"elidable",
":",
"return",
"[",
"self",
"]",
"ret... | [
116,
4
] | [
126,
20
] | python | en | ['en', 'error', 'th'] | False |
WalletNodeAPI.reject_removals_request | (self, response: wallet_protocol.RejectRemovalsRequest, peer: WSKaleConnection) |
The full node has rejected our request for removals.
|
The full node has rejected our request for removals.
| async def reject_removals_request(self, response: wallet_protocol.RejectRemovalsRequest, peer: WSKaleConnection):
"""
The full node has rejected our request for removals.
"""
pass | [
"async",
"def",
"reject_removals_request",
"(",
"self",
",",
"response",
":",
"wallet_protocol",
".",
"RejectRemovalsRequest",
",",
"peer",
":",
"WSKaleConnection",
")",
":",
"pass"
] | [
28,
4
] | [
32,
12
] | python | en | ['en', 'error', 'th'] | False |
WalletNodeAPI.reject_additions_request | (self, response: wallet_protocol.RejectAdditionsRequest) |
The full node has rejected our request for additions.
|
The full node has rejected our request for additions.
| async def reject_additions_request(self, response: wallet_protocol.RejectAdditionsRequest):
"""
The full node has rejected our request for additions.
"""
pass | [
"async",
"def",
"reject_additions_request",
"(",
"self",
",",
"response",
":",
"wallet_protocol",
".",
"RejectAdditionsRequest",
")",
":",
"pass"
] | [
35,
4
] | [
39,
12
] | python | en | ['en', 'error', 'th'] | False |
WalletNodeAPI.new_peak_wallet | (self, peak: wallet_protocol.NewPeakWallet, peer: WSKaleConnection) |
The full node sent as a new peak
|
The full node sent as a new peak
| async def new_peak_wallet(self, peak: wallet_protocol.NewPeakWallet, peer: WSKaleConnection):
"""
The full node sent as a new peak
"""
await self.wallet_node.new_peak_wallet(peak, peer) | [
"async",
"def",
"new_peak_wallet",
"(",
"self",
",",
"peak",
":",
"wallet_protocol",
".",
"NewPeakWallet",
",",
"peer",
":",
"WSKaleConnection",
")",
":",
"await",
"self",
".",
"wallet_node",
".",
"new_peak_wallet",
"(",
"peak",
",",
"peer",
")"
] | [
44,
4
] | [
48,
58
] | python | en | ['en', 'error', 'th'] | False |
WalletNodeAPI.reject_block_header | (self, response: wallet_protocol.RejectHeaderRequest) |
The full node has rejected our request for a header.
|
The full node has rejected our request for a header.
| async def reject_block_header(self, response: wallet_protocol.RejectHeaderRequest):
"""
The full node has rejected our request for a header.
"""
pass | [
"async",
"def",
"reject_block_header",
"(",
"self",
",",
"response",
":",
"wallet_protocol",
".",
"RejectHeaderRequest",
")",
":",
"pass"
] | [
51,
4
] | [
55,
12
] | python | en | ['en', 'error', 'th'] | False |
WalletNodeAPI.transaction_ack | (self, ack: wallet_protocol.TransactionAck, peer: WSKaleConnection) |
This is an ack for our previous SendTransaction call. This removes the transaction from
the send queue if we have sent it to enough nodes.
|
This is an ack for our previous SendTransaction call. This removes the transaction from
the send queue if we have sent it to enough nodes.
| async def transaction_ack(self, ack: wallet_protocol.TransactionAck, peer: WSKaleConnection):
"""
This is an ack for our previous SendTransaction call. This removes the transaction from
the send queue if we have sent it to enough nodes.
"""
assert peer.peer_node_id is not None
... | [
"async",
"def",
"transaction_ack",
"(",
"self",
",",
"ack",
":",
"wallet_protocol",
".",
"TransactionAck",
",",
"peer",
":",
"WSKaleConnection",
")",
":",
"assert",
"peer",
".",
"peer_node_id",
"is",
"not",
"None",
"name",
"=",
"peer",
".",
"peer_node_id",
"... | [
72,
4
] | [
91,
103
] | python | en | ['en', 'error', 'th'] | False |
SessionStore.create_model_instance | (self, data) |
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database.
|
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database.
| def create_model_instance(self, data):
"""
Return a new instance of the session model object, which represents the
current session state. Intended to be used for saving the session data
to the database.
"""
return self.model(
session_key=self._get_or_create_se... | [
"def",
"create_model_instance",
"(",
"self",
",",
"data",
")",
":",
"return",
"self",
".",
"model",
"(",
"session_key",
"=",
"self",
".",
"_get_or_create_session_key",
"(",
")",
",",
"session_data",
"=",
"self",
".",
"encode",
"(",
"data",
")",
",",
"expir... | [
60,
4
] | [
70,
9
] | python | en | ['en', 'error', 'th'] | False |
SessionStore.save | (self, must_create=False) |
Saves the current session data to the database. If 'must_create' is
True, a database error will be raised if the saving operation doesn't
create a *new* entry (as opposed to possibly updating an existing
entry).
|
Saves the current session data to the database. If 'must_create' is
True, a database error will be raised if the saving operation doesn't
create a *new* entry (as opposed to possibly updating an existing
entry).
| def save(self, must_create=False):
"""
Saves the current session data to the database. If 'must_create' is
True, a database error will be raised if the saving operation doesn't
create a *new* entry (as opposed to possibly updating an existing
entry).
"""
if self.s... | [
"def",
"save",
"(",
"self",
",",
"must_create",
"=",
"False",
")",
":",
"if",
"self",
".",
"session_key",
"is",
"None",
":",
"return",
"self",
".",
"create",
"(",
")",
"data",
"=",
"self",
".",
"_get_session",
"(",
"no_load",
"=",
"must_create",
")",
... | [
72,
4
] | [
94,
17
] | python | en | ['en', 'error', 'th'] | False |
SimpleTemplateResponse.__getstate__ | (self) |
Raise an exception if trying to pickle an unrendered response. Pickle
only rendered data, not the data used to construct the response.
|
Raise an exception if trying to pickle an unrendered response. Pickle
only rendered data, not the data used to construct the response.
| def __getstate__(self):
"""
Raise an exception if trying to pickle an unrendered response. Pickle
only rendered data, not the data used to construct the response.
"""
obj_dict = self.__dict__.copy()
if not self._is_rendered:
raise ContentNotRenderedError('The ... | [
"def",
"__getstate__",
"(",
"self",
")",
":",
"obj_dict",
"=",
"self",
".",
"__dict__",
".",
"copy",
"(",
")",
"if",
"not",
"self",
".",
"_is_rendered",
":",
"raise",
"ContentNotRenderedError",
"(",
"'The response content must be '",
"'rendered before it can be pick... | [
45,
4
] | [
58,
23
] | python | en | ['en', 'error', 'th'] | False |
SimpleTemplateResponse.resolve_template | (self, template) | Accepts a template object, path-to-template or list of paths | Accepts a template object, path-to-template or list of paths | def resolve_template(self, template):
"Accepts a template object, path-to-template or list of paths"
if isinstance(template, (list, tuple)):
return select_template(template, using=self.using)
elif isinstance(template, six.string_types):
return get_template(template, using... | [
"def",
"resolve_template",
"(",
"self",
",",
"template",
")",
":",
"if",
"isinstance",
"(",
"template",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"select_template",
"(",
"template",
",",
"using",
"=",
"self",
".",
"using",
")",
"elif",
"... | [
60,
4
] | [
67,
27
] | python | en | ['en', 'en', 'en'] | True |
SimpleTemplateResponse.rendered_content | (self) | Returns the freshly rendered content for the template and context
described by the TemplateResponse.
This *does not* set the final content of the response. To set the
response content, you must either call render(), or set the
content explicitly using the value of this property.
... | Returns the freshly rendered content for the template and context
described by the TemplateResponse. | def rendered_content(self):
"""Returns the freshly rendered content for the template and context
described by the TemplateResponse.
This *does not* set the final content of the response. To set the
response content, you must either call render(), or set the
content explicitly us... | [
"def",
"rendered_content",
"(",
"self",
")",
":",
"template",
"=",
"self",
".",
"resolve_template",
"(",
"self",
".",
"template_name",
")",
"context",
"=",
"self",
".",
"resolve_context",
"(",
"self",
".",
"context_data",
")",
"content",
"=",
"template",
"."... | [
73,
4
] | [
84,
22
] | python | en | ['en', 'en', 'en'] | True |
SimpleTemplateResponse.add_post_render_callback | (self, callback) | Adds a new post-rendering callback.
If the response has already been rendered,
invoke the callback immediately.
| Adds a new post-rendering callback. | def add_post_render_callback(self, callback):
"""Adds a new post-rendering callback.
If the response has already been rendered,
invoke the callback immediately.
"""
if self._is_rendered:
callback(self)
else:
self._post_render_callbacks.append(call... | [
"def",
"add_post_render_callback",
"(",
"self",
",",
"callback",
")",
":",
"if",
"self",
".",
"_is_rendered",
":",
"callback",
"(",
"self",
")",
"else",
":",
"self",
".",
"_post_render_callbacks",
".",
"append",
"(",
"callback",
")"
] | [
86,
4
] | [
95,
56
] | python | en | ['en', 'en', 'en'] | True |
SimpleTemplateResponse.render | (self) | Renders (thereby finalizing) the content of the response.
If the content has already been rendered, this is a no-op.
Returns the baked response instance.
| Renders (thereby finalizing) the content of the response. | def render(self):
"""Renders (thereby finalizing) the content of the response.
If the content has already been rendered, this is a no-op.
Returns the baked response instance.
"""
retval = self
if not self._is_rendered:
self.content = self.rendered_content
... | [
"def",
"render",
"(",
"self",
")",
":",
"retval",
"=",
"self",
"if",
"not",
"self",
".",
"_is_rendered",
":",
"self",
".",
"content",
"=",
"self",
".",
"rendered_content",
"for",
"post_callback",
"in",
"self",
".",
"_post_render_callbacks",
":",
"newretval",... | [
97,
4
] | [
111,
21
] | python | en | ['en', 'en', 'en'] | True |
SimpleTemplateResponse.content | (self, value) | Sets the content for the response
| Sets the content for the response
| def content(self, value):
"""Sets the content for the response
"""
HttpResponse.content.fset(self, value)
self._is_rendered = True | [
"def",
"content",
"(",
"self",
",",
"value",
")",
":",
"HttpResponse",
".",
"content",
".",
"fset",
"(",
"self",
",",
"value",
")",
"self",
".",
"_is_rendered",
"=",
"True"
] | [
133,
4
] | [
137,
32
] | python | en | ['en', 'en', 'en'] | True |
is_implicit_parent | (parent_role, child_role) |
Determine if the parent_role is an implicit parent as defined by
the model definition. This does not include any role parents that
might have been set by the user.
|
Determine if the parent_role is an implicit parent as defined by
the model definition. This does not include any role parents that
might have been set by the user.
| def is_implicit_parent(parent_role, child_role):
"""
Determine if the parent_role is an implicit parent as defined by
the model definition. This does not include any role parents that
might have been set by the user.
"""
if child_role.content_object is None:
# The only singleton implicit... | [
"def",
"is_implicit_parent",
"(",
"parent_role",
",",
"child_role",
")",
":",
"if",
"child_role",
".",
"content_object",
"is",
"None",
":",
"# The only singleton implicit parent is the system admin being",
"# a parent of the system auditor role",
"return",
"bool",
"(",
"child... | [
154,
0
] | [
184,
16
] | python | en | ['en', 'error', 'th'] | False |
update_role_parentage_for_instance | (instance) | update_role_parentage_for_instance
updates the parents listing for all the roles
of a given instance if they have changed
| update_role_parentage_for_instance
updates the parents listing for all the roles
of a given instance if they have changed
| def update_role_parentage_for_instance(instance):
"""update_role_parentage_for_instance
updates the parents listing for all the roles
of a given instance if they have changed
"""
parents_removed = set()
parents_added = set()
for implicit_role_field in getattr(instance.__class__, '__implicit_... | [
"def",
"update_role_parentage_for_instance",
"(",
"instance",
")",
":",
"parents_removed",
"=",
"set",
"(",
")",
"parents_added",
"=",
"set",
"(",
")",
"for",
"implicit_role_field",
"in",
"getattr",
"(",
"instance",
".",
"__class__",
",",
"'__implicit_role_fields'",... | [
187,
0
] | [
212,
43
] | python | en | ['en', 'en', 'en'] | False |
reject_check_generic_data | (accessor) |
Args:
accessor: tkp.db.accessor image accessor
Returns: A rejection reason if the image is bad, None otherwise
|
Args:
accessor: tkp.db.accessor image accessor | def reject_check_generic_data(accessor):
"""
Args:
accessor: tkp.db.accessor image accessor
Returns: A rejection reason if the image is bad, None otherwise
"""
flat = reject_check_flat_data(accessor)
if flat:
return flat
return None | [
"def",
"reject_check_generic_data",
"(",
"accessor",
")",
":",
"flat",
"=",
"reject_check_flat_data",
"(",
"accessor",
")",
"if",
"flat",
":",
"return",
"flat",
"return",
"None"
] | [
6,
0
] | [
16,
15
] | python | en | ['en', 'error', 'th'] | False |
reject_check_flat_data | (accessor) |
Checks if an image is flat (i.e. a uniform value throughout).
Flat implies bad data, since we always expect to see noise
even if no sources are present.
Args:
accessor: tkp.db.accessor image accessor
Returns: A rejection reason if the image is bad, None otherwise
|
Checks if an image is flat (i.e. a uniform value throughout). | def reject_check_flat_data(accessor):
"""
Checks if an image is flat (i.e. a uniform value throughout).
Flat implies bad data, since we always expect to see noise
even if no sources are present.
Args:
accessor: tkp.db.accessor image accessor
Returns: A rejection reason if the image i... | [
"def",
"reject_check_flat_data",
"(",
"accessor",
")",
":",
"data",
"=",
"accessor",
".",
"data",
"if",
"np",
".",
"ma",
".",
"min",
"(",
"data",
")",
"==",
"np",
".",
"ma",
".",
"max",
"(",
"data",
")",
":",
"logger",
".",
"warning",
"(",
"\"image... | [
19,
0
] | [
37,
19
] | python | en | ['en', 'error', 'th'] | False |
AbstractProvider.identify | (self, requirement_or_candidate) | Given a requirement or candidate, return an identifier for it.
This is used in many places to identify a requirement or candidate,
e.g. whether two requirements should have their specifier parts merged,
whether two candidates would conflict with each other (because they
have same name b... | Given a requirement or candidate, return an identifier for it. | def identify(self, requirement_or_candidate):
"""Given a requirement or candidate, return an identifier for it.
This is used in many places to identify a requirement or candidate,
e.g. whether two requirements should have their specifier parts merged,
whether two candidates would confli... | [
"def",
"identify",
"(",
"self",
",",
"requirement_or_candidate",
")",
":",
"raise",
"NotImplementedError"
] | [
3,
4
] | [
11,
33
] | python | en | ['en', 'en', 'en'] | True |
AbstractProvider.get_preference | (self, resolution, candidates, information) | Produce a sort key for given requirement based on preference.
The preference is defined as "I think this requirement should be
resolved first". The lower the return value is, the more preferred
this group of arguments is.
:param resolution: Currently pinned candidate, or `None`.
... | Produce a sort key for given requirement based on preference. | def get_preference(self, resolution, candidates, information):
"""Produce a sort key for given requirement based on preference.
The preference is defined as "I think this requirement should be
resolved first". The lower the return value is, the more preferred
this group of arguments is.... | [
"def",
"get_preference",
"(",
"self",
",",
"resolution",
",",
"candidates",
",",
"information",
")",
":",
"raise",
"NotImplementedError"
] | [
13,
4
] | [
52,
33
] | python | en | ['en', 'en', 'en'] | True |
AbstractProvider.find_matches | (self, requirements) | Find all possible candidates that satisfy the given requirements.
This should try to get candidates based on the requirements' types.
For VCS, local, and archive requirements, the one-and-only match is
returned, and for a "named" requirement, the index(es) should be
consulted to find co... | Find all possible candidates that satisfy the given requirements. | def find_matches(self, requirements):
"""Find all possible candidates that satisfy the given requirements.
This should try to get candidates based on the requirements' types.
For VCS, local, and archive requirements, the one-and-only match is
returned, and for a "named" requirement, the... | [
"def",
"find_matches",
"(",
"self",
",",
"requirements",
")",
":",
"raise",
"NotImplementedError"
] | [
54,
4
] | [
75,
33
] | python | en | ['en', 'en', 'en'] | True |
AbstractProvider.is_satisfied_by | (self, requirement, candidate) | Whether the given requirement can be satisfied by a candidate.
The candidate is guarenteed to have been generated from the
requirement.
A boolean should be returned to indicate whether `candidate` is a
viable solution to the requirement.
| Whether the given requirement can be satisfied by a candidate. | def is_satisfied_by(self, requirement, candidate):
"""Whether the given requirement can be satisfied by a candidate.
The candidate is guarenteed to have been generated from the
requirement.
A boolean should be returned to indicate whether `candidate` is a
viable solution to the... | [
"def",
"is_satisfied_by",
"(",
"self",
",",
"requirement",
",",
"candidate",
")",
":",
"raise",
"NotImplementedError"
] | [
77,
4
] | [
86,
33
] | python | en | ['en', 'en', 'en'] | True |
AbstractProvider.get_dependencies | (self, candidate) | Get dependencies of a candidate.
This should return a collection of requirements that `candidate`
specifies as its dependencies.
| Get dependencies of a candidate. | def get_dependencies(self, candidate):
"""Get dependencies of a candidate.
This should return a collection of requirements that `candidate`
specifies as its dependencies.
"""
raise NotImplementedError | [
"def",
"get_dependencies",
"(",
"self",
",",
"candidate",
")",
":",
"raise",
"NotImplementedError"
] | [
88,
4
] | [
94,
33
] | python | en | ['en', 'en', 'en'] | True |
AbstractResolver.resolve | (self, requirements, **kwargs) | Take a collection of constraints, spit out the resolution result.
This returns a representation of the final resolution state, with one
guarenteed attribute ``mapping`` that contains resolved candidates as
values. The keys are their respective identifiers.
:param requirements: A collec... | Take a collection of constraints, spit out the resolution result. | def resolve(self, requirements, **kwargs):
"""Take a collection of constraints, spit out the resolution result.
This returns a representation of the final resolution state, with one
guarenteed attribute ``mapping`` that contains resolved candidates as
values. The keys are their respecti... | [
"def",
"resolve",
"(",
"self",
",",
"requirements",
",",
"*",
"*",
"kwargs",
")",
":",
"raise",
"NotImplementedError"
] | [
106,
4
] | [
118,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.__init__ | (self, name) | Creates a Node
:arg name: The tag name associated with the node
| Creates a Node | def __init__(self, name):
"""Creates a Node
:arg name: The tag name associated with the node
"""
# The tag name associated with the node
self.name = name
# The parent of the current node (or None for the document node)
self.parent = None
# The value of t... | [
"def",
"__init__",
"(",
"self",
",",
"name",
")",
":",
"# The tag name associated with the node",
"self",
".",
"name",
"=",
"name",
"# The parent of the current node (or None for the document node)",
"self",
".",
"parent",
"=",
"None",
"# The value of the current node (applie... | [
24,
4
] | [
42,
24
] | python | en | ['en', 'gl', 'en'] | True |
Node.appendChild | (self, node) | Insert node as a child of the current node
:arg node: the node to insert
| Insert node as a child of the current node | def appendChild(self, node):
"""Insert node as a child of the current node
:arg node: the node to insert
"""
raise NotImplementedError | [
"def",
"appendChild",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
56,
4
] | [
62,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.insertText | (self, data, insertBefore=None) | Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.
:arg data: the data to insert
:arg insertBefore: True if you want to insert the text before the node
and False if you want to insert it after the node
... | Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text. | def insertText(self, data, insertBefore=None):
"""Insert data as text in the current node, positioned before the
start of node insertBefore or to the end of the node's text.
:arg data: the data to insert
:arg insertBefore: True if you want to insert the text before the node
... | [
"def",
"insertText",
"(",
"self",
",",
"data",
",",
"insertBefore",
"=",
"None",
")",
":",
"raise",
"NotImplementedError"
] | [
64,
4
] | [
74,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.insertBefore | (self, node, refNode) | Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node
:arg node: the node to insert
:arg refNode: the child node to insert the node before
| Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node | def insertBefore(self, node, refNode):
"""Insert node as a child of the current node, before refNode in the
list of child nodes. Raises ValueError if refNode is not a child of
the current node
:arg node: the node to insert
:arg refNode: the child node to insert the node before
... | [
"def",
"insertBefore",
"(",
"self",
",",
"node",
",",
"refNode",
")",
":",
"raise",
"NotImplementedError"
] | [
76,
4
] | [
86,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.removeChild | (self, node) | Remove node from the children of the current node
:arg node: the child node to remove
| Remove node from the children of the current node | def removeChild(self, node):
"""Remove node from the children of the current node
:arg node: the child node to remove
"""
raise NotImplementedError | [
"def",
"removeChild",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
88,
4
] | [
94,
33
] | python | en | ['en', 'en', 'en'] | True |
Node.reparentChildren | (self, newParent) | Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way
:arg newParent: the node to move all this node's children to
| Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way | def reparentChildren(self, newParent):
"""Move all the children of the current node to newParent.
This is needed so that trees that don't store text as nodes move the
text in the correct way
:arg newParent: the node to move all this node's children to
"""
# XXX - should... | [
"def",
"reparentChildren",
"(",
"self",
",",
"newParent",
")",
":",
"# XXX - should this method be made more general?",
"for",
"child",
"in",
"self",
".",
"childNodes",
":",
"newParent",
".",
"appendChild",
"(",
"child",
")",
"self",
".",
"childNodes",
"=",
"[",
... | [
96,
4
] | [
107,
28
] | python | en | ['en', 'en', 'en'] | True |
Node.cloneNode | (self) | Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
| Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
| def cloneNode(self):
"""Return a shallow copy of the current node i.e. a node with the same
name and attributes but with no parent or child nodes
"""
raise NotImplementedError | [
"def",
"cloneNode",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
109,
4
] | [
113,
33
] | python | en | ['en', 'pt', 'en'] | True |
Node.hasContent | (self) | Return true if the node has children or text, false otherwise
| Return true if the node has children or text, false otherwise
| def hasContent(self):
"""Return true if the node has children or text, false otherwise
"""
raise NotImplementedError | [
"def",
"hasContent",
"(",
"self",
")",
":",
"raise",
"NotImplementedError"
] | [
115,
4
] | [
118,
33
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.__init__ | (self, namespaceHTMLElements) | Create a TreeBuilder
:arg namespaceHTMLElements: whether or not to namespace HTML elements
| Create a TreeBuilder | def __init__(self, namespaceHTMLElements):
"""Create a TreeBuilder
:arg namespaceHTMLElements: whether or not to namespace HTML elements
"""
if namespaceHTMLElements:
self.defaultNamespace = "http://www.w3.org/1999/xhtml"
else:
self.defaultNamespace = No... | [
"def",
"__init__",
"(",
"self",
",",
"namespaceHTMLElements",
")",
":",
"if",
"namespaceHTMLElements",
":",
"self",
".",
"defaultNamespace",
"=",
"\"http://www.w3.org/1999/xhtml\"",
"else",
":",
"self",
".",
"defaultNamespace",
"=",
"None",
"self",
".",
"reset",
"... | [
171,
4
] | [
181,
20
] | python | en | ['en', 'ro', 'en'] | True |
TreeBuilder.elementInActiveFormattingElements | (self, name) | Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false | Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false | def elementInActiveFormattingElements(self, name):
"""Check if an element exists between the end of the active
formatting elements and the last marker. If it does, return it, else
return false"""
for item in self.activeFormattingElements[::-1]:
# Check for Marker first becau... | [
"def",
"elementInActiveFormattingElements",
"(",
"self",
",",
"name",
")",
":",
"for",
"item",
"in",
"self",
".",
"activeFormattingElements",
"[",
":",
":",
"-",
"1",
"]",
":",
"# Check for Marker first because if it's a Marker it doesn't have a",
"# name attribute.",
"... | [
268,
4
] | [
280,
20
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.createElement | (self, token) | Create an element but don't insert it anywhere | Create an element but don't insert it anywhere | def createElement(self, token):
"""Create an element but don't insert it anywhere"""
name = token["name"]
namespace = token.get("namespace", self.defaultNamespace)
element = self.elementClass(name, namespace)
element.attributes = token["data"]
return element | [
"def",
"createElement",
"(",
"self",
",",
"token",
")",
":",
"name",
"=",
"token",
"[",
"\"name\"",
"]",
"namespace",
"=",
"token",
".",
"get",
"(",
"\"namespace\"",
",",
"self",
".",
"defaultNamespace",
")",
"element",
"=",
"self",
".",
"elementClass",
... | [
300,
4
] | [
306,
22
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder._setInsertFromTable | (self, value) | Switch the function used to insert an element from the
normal one to the misnested table one and back again | Switch the function used to insert an element from the
normal one to the misnested table one and back again | def _setInsertFromTable(self, value):
"""Switch the function used to insert an element from the
normal one to the misnested table one and back again"""
self._insertFromTable = value
if value:
self.insertElement = self.insertElementTable
else:
self.insertEl... | [
"def",
"_setInsertFromTable",
"(",
"self",
",",
"value",
")",
":",
"self",
".",
"_insertFromTable",
"=",
"value",
"if",
"value",
":",
"self",
".",
"insertElement",
"=",
"self",
".",
"insertElementTable",
"else",
":",
"self",
".",
"insertElement",
"=",
"self"... | [
311,
4
] | [
318,
57
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.insertElementTable | (self, token) | Create an element and insert it into the tree | Create an element and insert it into the tree | def insertElementTable(self, token):
"""Create an element and insert it into the tree"""
element = self.createElement(token)
if self.openElements[-1].name not in tableInsertModeElements:
return self.insertElementNormal(token)
else:
# We should be in the InTable mo... | [
"def",
"insertElementTable",
"(",
"self",
",",
"token",
")",
":",
"element",
"=",
"self",
".",
"createElement",
"(",
"token",
")",
"if",
"self",
".",
"openElements",
"[",
"-",
"1",
"]",
".",
"name",
"not",
"in",
"tableInsertModeElements",
":",
"return",
... | [
332,
4
] | [
346,
22
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.insertText | (self, data, parent=None) | Insert text data. | Insert text data. | def insertText(self, data, parent=None):
"""Insert text data."""
if parent is None:
parent = self.openElements[-1]
if (not self.insertFromTable or (self.insertFromTable and
self.openElements[-1].name
n... | [
"def",
"insertText",
"(",
"self",
",",
"data",
",",
"parent",
"=",
"None",
")",
":",
"if",
"parent",
"is",
"None",
":",
"parent",
"=",
"self",
".",
"openElements",
"[",
"-",
"1",
"]",
"if",
"(",
"not",
"self",
".",
"insertFromTable",
"or",
"(",
"se... | [
348,
4
] | [
361,
49
] | python | en | ['fr', 'lb', 'en'] | False |
TreeBuilder.getTableMisnestedNodePosition | (self) | Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node | Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node | def getTableMisnestedNodePosition(self):
"""Get the foster parent element, and sibling to insert before
(or None) when inserting a misnested table node"""
# The foster parent element is the one which comes before the most
# recently opened table element
# XXX - this is really ine... | [
"def",
"getTableMisnestedNodePosition",
"(",
"self",
")",
":",
"# The foster parent element is the one which comes before the most",
"# recently opened table element",
"# XXX - this is really inelegant",
"lastTable",
"=",
"None",
"fosterParent",
"=",
"None",
"insertBefore",
"=",
"N... | [
363,
4
] | [
387,
41
] | python | en | ['en', 'en', 'en'] | True |
TreeBuilder.getDocument | (self) | Return the final tree | Return the final tree | def getDocument(self):
"""Return the final tree"""
return self.document | [
"def",
"getDocument",
"(",
"self",
")",
":",
"return",
"self",
".",
"document"
] | [
399,
4
] | [
401,
28
] | python | en | ['en', 'mt', 'en'] | True |
TreeBuilder.getFragment | (self) | Return the final fragment | Return the final fragment | def getFragment(self):
"""Return the final fragment"""
# assert self.innerHTML
fragment = self.fragmentClass()
self.openElements[0].reparentChildren(fragment)
return fragment | [
"def",
"getFragment",
"(",
"self",
")",
":",
"# assert self.innerHTML",
"fragment",
"=",
"self",
".",
"fragmentClass",
"(",
")",
"self",
".",
"openElements",
"[",
"0",
"]",
".",
"reparentChildren",
"(",
"fragment",
")",
"return",
"fragment"
] | [
403,
4
] | [
408,
23
] | python | en | ['en', 'no', 'en'] | True |
TreeBuilder.testSerializer | (self, node) | Serialize the subtree of node in the format required by unit tests
:arg node: the node from which to start serializing
| Serialize the subtree of node in the format required by unit tests | def testSerializer(self, node):
"""Serialize the subtree of node in the format required by unit tests
:arg node: the node from which to start serializing
"""
raise NotImplementedError | [
"def",
"testSerializer",
"(",
"self",
",",
"node",
")",
":",
"raise",
"NotImplementedError"
] | [
410,
4
] | [
416,
33
] | python | en | ['en', 'en', 'en'] | True |
configure_reproducible_wheels | () | Modifies the environment to make wheel building reproducible.
Wheels created from sdists are not reproducible by default. We can however workaround this by
patching in some configuration with environment variables.
| Modifies the environment to make wheel building reproducible. | def configure_reproducible_wheels() -> None:
"""Modifies the environment to make wheel building reproducible.
Wheels created from sdists are not reproducible by default. We can however workaround this by
patching in some configuration with environment variables.
"""
# wheel, by default, enables de... | [
"def",
"configure_reproducible_wheels",
"(",
")",
"->",
"None",
":",
"# wheel, by default, enables debug symbols in GCC. This incidentally captures the build path in the .so file",
"# We can override this behavior by disabling debug symbols entirely.",
"# https://github.com/pypa/pip/issues/6505",
... | [
17,
0
] | [
40,
42
] | python | en | ['en', 'gl', 'en'] | True |
main | () | Main program.
Exits zero on successful program termination, non-zero otherwise.
| Main program. | def main() -> None:
"""Main program.
Exits zero on successful program termination, non-zero otherwise.
"""
configure_reproducible_wheels()
parser = argparse.ArgumentParser(
description="Resolve and fetch artifacts transitively from PyPI"
)
parser.add_argument(
"--requireme... | [
"def",
"main",
"(",
")",
"->",
"None",
":",
"configure_reproducible_wheels",
"(",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Resolve and fetch artifacts transitively from PyPI\"",
")",
"parser",
".",
"add_argument",
"(",
"\"--re... | [
43,
0
] | [
93,
9
] | python | en | ['en', 'hi-Latn', 'en'] | False |
create_roles | (apps, schema_editor) |
Implicit role creation happens in our post_save hook for all of our
resources. Here we iterate through all of our resource types and call
.save() to ensure all that happens for every object in the system.
This can be used whenever new roles are introduced in a migration to
create those roles for p... |
Implicit role creation happens in our post_save hook for all of our
resources. Here we iterate through all of our resource types and call
.save() to ensure all that happens for every object in the system. | def create_roles(apps, schema_editor):
"""
Implicit role creation happens in our post_save hook for all of our
resources. Here we iterate through all of our resource types and call
.save() to ensure all that happens for every object in the system.
This can be used whenever new roles are introduced ... | [
"def",
"create_roles",
"(",
"apps",
",",
"schema_editor",
")",
":",
"models",
"=",
"[",
"apps",
".",
"get_model",
"(",
"'main'",
",",
"m",
")",
"for",
"m",
"in",
"[",
"'Organization'",
",",
"'Team'",
",",
"'Inventory'",
",",
"'Project'",
",",
"'Credentia... | [
11,
0
] | [
37,
26
] | python | en | ['en', 'error', 'th'] | False |
implicit_org_subquery | (UnifiedClass, cls, backward=False) | Returns a subquery that returns the so-called organization for objects
in the class in question, before migration to the explicit unified org field.
In some cases, this can still be applied post-migration.
| Returns a subquery that returns the so-called organization for objects
in the class in question, before migration to the explicit unified org field.
In some cases, this can still be applied post-migration.
| def implicit_org_subquery(UnifiedClass, cls, backward=False):
"""Returns a subquery that returns the so-called organization for objects
in the class in question, before migration to the explicit unified org field.
In some cases, this can still be applied post-migration.
"""
if cls._meta.model_name n... | [
"def",
"implicit_org_subquery",
"(",
"UnifiedClass",
",",
"cls",
",",
"backward",
"=",
"False",
")",
":",
"if",
"cls",
".",
"_meta",
".",
"model_name",
"not",
"in",
"UNIFIED_ORG_LOOKUPS",
":",
"return",
"None",
"cls_name",
"=",
"cls",
".",
"_meta",
".",
"m... | [
87,
0
] | [
119,
23
] | python | en | ['en', 'en', 'en'] | True |
_migrate_unified_organization | (apps, unified_cls_name, backward=False) | Given a unified base model (either UJT or UJ)
and a dict org_field_mapping which gives related model to get org from
saves organization for those objects to the temporary migration
variable tmp_organization on the unified model
(optimized method)
| Given a unified base model (either UJT or UJ)
and a dict org_field_mapping which gives related model to get org from
saves organization for those objects to the temporary migration
variable tmp_organization on the unified model
(optimized method)
| def _migrate_unified_organization(apps, unified_cls_name, backward=False):
"""Given a unified base model (either UJT or UJ)
and a dict org_field_mapping which gives related model to get org from
saves organization for those objects to the temporary migration
variable tmp_organization on the unified mode... | [
"def",
"_migrate_unified_organization",
"(",
"apps",
",",
"unified_cls_name",
",",
"backward",
"=",
"False",
")",
":",
"start",
"=",
"time",
"(",
")",
"UnifiedClass",
"=",
"apps",
".",
"get_model",
"(",
"'main'",
",",
"unified_cls_name",
")",
"ContentType",
"=... | [
122,
0
] | [
152,
100
] | python | en | ['en', 'en', 'en'] | True |
migrate_ujt_organization | (apps, schema_editor) | Move organization field to UJT and UJ models | Move organization field to UJT and UJ models | def migrate_ujt_organization(apps, schema_editor):
'''Move organization field to UJT and UJ models'''
_migrate_unified_organization(apps, 'UnifiedJobTemplate')
_migrate_unified_organization(apps, 'UnifiedJob') | [
"def",
"migrate_ujt_organization",
"(",
"apps",
",",
"schema_editor",
")",
":",
"_migrate_unified_organization",
"(",
"apps",
",",
"'UnifiedJobTemplate'",
")",
"_migrate_unified_organization",
"(",
"apps",
",",
"'UnifiedJob'",
")"
] | [
155,
0
] | [
158,
53
] | python | en | ['en', 'en', 'en'] | True |
migrate_ujt_organization_backward | (apps, schema_editor) | Move organization field from UJT and UJ models back to their original places | Move organization field from UJT and UJ models back to their original places | def migrate_ujt_organization_backward(apps, schema_editor):
'''Move organization field from UJT and UJ models back to their original places'''
_migrate_unified_organization(apps, 'UnifiedJobTemplate', backward=True)
_migrate_unified_organization(apps, 'UnifiedJob', backward=True) | [
"def",
"migrate_ujt_organization_backward",
"(",
"apps",
",",
"schema_editor",
")",
":",
"_migrate_unified_organization",
"(",
"apps",
",",
"'UnifiedJobTemplate'",
",",
"backward",
"=",
"True",
")",
"_migrate_unified_organization",
"(",
"apps",
",",
"'UnifiedJob'",
",",... | [
161,
0
] | [
164,
68
] | python | en | ['en', 'en', 'en'] | True |
_restore_inventory_admins | (apps, schema_editor, backward=False) | With the JT.organization changes, admins of organizations connected to
job templates via inventory will have their permissions demoted.
This maintains current permissions over the migration by granting the
permissions they used to have explicitly on the JT itself.
| With the JT.organization changes, admins of organizations connected to
job templates via inventory will have their permissions demoted.
This maintains current permissions over the migration by granting the
permissions they used to have explicitly on the JT itself.
| def _restore_inventory_admins(apps, schema_editor, backward=False):
"""With the JT.organization changes, admins of organizations connected to
job templates via inventory will have their permissions demoted.
This maintains current permissions over the migration by granting the
permissions they used to ha... | [
"def",
"_restore_inventory_admins",
"(",
"apps",
",",
"schema_editor",
",",
"backward",
"=",
"False",
")",
":",
"start",
"=",
"time",
"(",
")",
"JobTemplate",
"=",
"apps",
".",
"get_model",
"(",
"'main'",
",",
"'JobTemplate'",
")",
"User",
"=",
"apps",
"."... | [
167,
0
] | [
227,
150
] | python | en | ['en', 'en', 'en'] | True |
rebuild_role_hierarchy | (apps, schema_editor) |
This should be called in any migration when ownerships are changed.
Ex. I remove a user from the admin_role of a credential.
Ancestors are cached from parents for performance, this re-computes ancestors.
|
This should be called in any migration when ownerships are changed.
Ex. I remove a user from the admin_role of a credential.
Ancestors are cached from parents for performance, this re-computes ancestors.
| def rebuild_role_hierarchy(apps, schema_editor):
"""
This should be called in any migration when ownerships are changed.
Ex. I remove a user from the admin_role of a credential.
Ancestors are cached from parents for performance, this re-computes ancestors.
"""
logger.info('Computing role roots..... | [
"def",
"rebuild_role_hierarchy",
"(",
"apps",
",",
"schema_editor",
")",
":",
"logger",
".",
"info",
"(",
"'Computing role roots..'",
")",
"start",
"=",
"time",
"(",
")",
"roots",
"=",
"Role",
".",
"objects",
".",
"all",
"(",
")",
".",
"values_list",
"(",
... | [
238,
0
] | [
253,
24
] | python | en | ['en', 'error', 'th'] | False |
rebuild_role_parentage | (apps, schema_editor, models=None) |
This should be called in any migration when any parent_role entry
is modified so that the cached parent fields will be updated. Ex:
foo_role = ImplicitRoleField(
parent_role=['bar_role'] # change to parent_role=['admin_role']
)
This is like rebuild_role_hierarchy, but that met... |
This should be called in any migration when any parent_role entry
is modified so that the cached parent fields will be updated. Ex:
foo_role = ImplicitRoleField(
parent_role=['bar_role'] # change to parent_role=['admin_role']
) | def rebuild_role_parentage(apps, schema_editor, models=None):
"""
This should be called in any migration when any parent_role entry
is modified so that the cached parent fields will be updated. Ex:
foo_role = ImplicitRoleField(
parent_role=['bar_role'] # change to parent_role=['admin_ro... | [
"def",
"rebuild_role_parentage",
"(",
"apps",
",",
"schema_editor",
",",
"models",
"=",
"None",
")",
":",
"start",
"=",
"time",
"(",
")",
"seen_models",
"=",
"set",
"(",
")",
"model_ct",
"=",
"0",
"noop_ct",
"=",
"0",
"ContentType",
"=",
"apps",
".",
"... | [
256,
0
] | [
320,
68
] | python | en | ['en', 'error', 'th'] | False |
init_glacier_directories_from_rgitopo | (rgidf=None, dem_source=None,
resolution='default',
keep_dem_folders=False,
reset=False,
force=True) | Initialize a glacier directory from an RGI-TOPO DEM.
Wrapper around :func:`workflow.init_glacier_directories`, which selects
a default source for you (if not set manually with `dem_source`).
The default source is NASADEM for all latitudes between 60N and 56S,
and COPDEM elsewhere.
Parameters
... | Initialize a glacier directory from an RGI-TOPO DEM. | def init_glacier_directories_from_rgitopo(rgidf=None, dem_source=None,
resolution='default',
keep_dem_folders=False,
reset=False,
force=True):
"""In... | [
"def",
"init_glacier_directories_from_rgitopo",
"(",
"rgidf",
"=",
"None",
",",
"dem_source",
"=",
"None",
",",
"resolution",
"=",
"'default'",
",",
"keep_dem_folders",
"=",
"False",
",",
"reset",
"=",
"False",
",",
"force",
"=",
"True",
")",
":",
"if",
"res... | [
25,
0
] | [
85,
16
] | python | en | ['en', 'en', 'en'] | True |
select_dem_from_dir | (gdir, dem_source=None, keep_dem_folders=False) | Select a DEM from the ones available in an RGI-TOPO glacier directory.
Parameters
----------
gdir : :py:class:`oggm.GlacierDirectory`
the glacier directory
dem_source : str
the source to pick from (default: NASADEM and COPDEM)
keep_dem_folders : bool
the default is to delete... | Select a DEM from the ones available in an RGI-TOPO glacier directory. | def select_dem_from_dir(gdir, dem_source=None, keep_dem_folders=False):
"""Select a DEM from the ones available in an RGI-TOPO glacier directory.
Parameters
----------
gdir : :py:class:`oggm.GlacierDirectory`
the glacier directory
dem_source : str
the source to pick from (default: N... | [
"def",
"select_dem_from_dir",
"(",
"gdir",
",",
"dem_source",
"=",
"None",
",",
"keep_dem_folders",
"=",
"False",
")",
":",
"# Start by deleting noise",
"for",
"fn",
"in",
"[",
"'log.txt'",
",",
"'diagnostics.json'",
"]",
":",
"fp",
"=",
"os",
".",
"path",
"... | [
89,
0
] | [
127,
57
] | python | en | ['en', 'en', 'en'] | True |
dem_quality_check | (gdir) | Run a simple quality check on the rgitopo DEMs
Parameters
----------
gdir : GlacierDirectory
the glacier directory
Returns
-------
a dict of DEMSOURCE:frac pairs, where frac is the percentage of
valid DEM grid points on the glacier.
| Run a simple quality check on the rgitopo DEMs | def dem_quality_check(gdir):
"""Run a simple quality check on the rgitopo DEMs
Parameters
----------
gdir : GlacierDirectory
the glacier directory
Returns
-------
a dict of DEMSOURCE:frac pairs, where frac is the percentage of
valid DEM grid points on the glacier.
"""
... | [
"def",
"dem_quality_check",
"(",
"gdir",
")",
":",
"with",
"rasterio",
".",
"open",
"(",
"gdir",
".",
"get_filepath",
"(",
"'glacier_mask'",
")",
",",
"'r'",
",",
"driver",
"=",
"'GTiff'",
")",
"as",
"ds",
":",
"mask",
"=",
"ds",
".",
"read",
"(",
"1... | [
131,
0
] | [
176,
14
] | python | en | ['en', 'it', 'en'] | True |
addblu | (msg, user) |
Adds a user to site blacklist
:param msg: ChatExchange message
:param user:
:return: A string
|
Adds a user to site blacklist
:param msg: ChatExchange message
:param user:
:return: A string
| def addblu(msg, user):
"""
Adds a user to site blacklist
:param msg: ChatExchange message
:param user:
:return: A string
"""
uid, val = get_user_from_list_command(user)
if int(uid) > -1 and val != "":
message_url = "https://chat.{}/transcript/{}?m={}".format(msg._client.host, ms... | [
"def",
"addblu",
"(",
"msg",
",",
"user",
")",
":",
"uid",
",",
"val",
"=",
"get_user_from_list_command",
"(",
"user",
")",
"if",
"int",
"(",
"uid",
")",
">",
"-",
"1",
"and",
"val",
"!=",
"\"\"",
":",
"message_url",
"=",
"\"https://chat.{}/transcript/{}... | [
52,
0
] | [
69,
116
] | python | en | ['en', 'error', 'th'] | False |
isblu | (user) |
Check if a user is blacklisted
:param user:
:return: A string
|
Check if a user is blacklisted
:param user:
:return: A string
| def isblu(user):
"""
Check if a user is blacklisted
:param user:
:return: A string
"""
uid, val = get_user_from_list_command(user)
if int(uid) > -1 and val != "":
if is_blacklisted_user((uid, val)):
return "User is blacklisted (`{}` on `{}`).".format(uid, val)
e... | [
"def",
"isblu",
"(",
"user",
")",
":",
"uid",
",",
"val",
"=",
"get_user_from_list_command",
"(",
"user",
")",
"if",
"int",
"(",
"uid",
")",
">",
"-",
"1",
"and",
"val",
"!=",
"\"\"",
":",
"if",
"is_blacklisted_user",
"(",
"(",
"uid",
",",
"val",
"... | [
74,
0
] | [
91,
114
] | python | en | ['en', 'error', 'th'] | False |
rmblu | (user) |
Removes user from site blacklist
:param user:
:return: A string
|
Removes user from site blacklist
:param user:
:return: A string
| def rmblu(user):
"""
Removes user from site blacklist
:param user:
:return: A string
"""
uid, val = get_user_from_list_command(user)
if int(uid) > -1 and val != "":
if remove_blacklisted_user((uid, val)):
return "User removed from blacklist (`{}` on `{}`).".format(uid, v... | [
"def",
"rmblu",
"(",
"user",
")",
":",
"uid",
",",
"val",
"=",
"get_user_from_list_command",
"(",
"user",
")",
"if",
"int",
"(",
"uid",
")",
">",
"-",
"1",
"and",
"val",
"!=",
"\"\"",
":",
"if",
"remove_blacklisted_user",
"(",
"(",
"uid",
",",
"val",... | [
96,
0
] | [
112,
114
] | python | en | ['en', 'error', 'th'] | False |
addwlu | (user) |
Adds a user to site whitelist
:param user:
:return: A string
|
Adds a user to site whitelist
:param user:
:return: A string
| def addwlu(user):
"""
Adds a user to site whitelist
:param user:
:return: A string
"""
uid, val = get_user_from_list_command(user)
if int(uid) > -1 and val != "":
add_whitelisted_user((uid, val))
return "User whitelisted (`{}` on `{}`).".format(uid, val)
elif int(uid) ==... | [
"def",
"addwlu",
"(",
"user",
")",
":",
"uid",
",",
"val",
"=",
"get_user_from_list_command",
"(",
"user",
")",
"if",
"int",
"(",
"uid",
")",
">",
"-",
"1",
"and",
"val",
"!=",
"\"\"",
":",
"add_whitelisted_user",
"(",
"(",
"uid",
",",
"val",
")",
... | [
118,
0
] | [
132,
116
] | python | en | ['en', 'error', 'th'] | False |
iswlu | (user) |
Checks if a user is whitelisted
:param user:
:return: A string
|
Checks if a user is whitelisted
:param user:
:return: A string
| def iswlu(user):
"""
Checks if a user is whitelisted
:param user:
:return: A string
"""
uid, val = get_user_from_list_command(user)
if int(uid) > -1 and val != "":
if is_whitelisted_user((uid, val)):
return "User is whitelisted (`{}` on `{}`).".format(uid, val)
e... | [
"def",
"iswlu",
"(",
"user",
")",
":",
"uid",
",",
"val",
"=",
"get_user_from_list_command",
"(",
"user",
")",
"if",
"int",
"(",
"uid",
")",
">",
"-",
"1",
"and",
"val",
"!=",
"\"\"",
":",
"if",
"is_whitelisted_user",
"(",
"(",
"uid",
",",
"val",
"... | [
137,
0
] | [
153,
114
] | python | en | ['en', 'error', 'th'] | False |
rmwlu | (user) |
Removes a user from site whitelist
:param user:
:return: A string
|
Removes a user from site whitelist
:param user:
:return: A string
| def rmwlu(user):
"""
Removes a user from site whitelist
:param user:
:return: A string
"""
uid, val = get_user_from_list_command(user)
if int(uid) != -1 and val != "":
if remove_whitelisted_user((uid, val)):
return "User removed from whitelist (`{}` on `{}`).".format(uid... | [
"def",
"rmwlu",
"(",
"user",
")",
":",
"uid",
",",
"val",
"=",
"get_user_from_list_command",
"(",
"user",
")",
"if",
"int",
"(",
"uid",
")",
"!=",
"-",
"1",
"and",
"val",
"!=",
"\"\"",
":",
"if",
"remove_whitelisted_user",
"(",
"(",
"uid",
",",
"val"... | [
158,
0
] | [
174,
114
] | python | en | ['en', 'error', 'th'] | False |
blacklist | (_) |
Returns a string which explains the usage of the new blacklist commands.
:return: A string
|
Returns a string which explains the usage of the new blacklist commands.
:return: A string
| def blacklist(_):
"""
Returns a string which explains the usage of the new blacklist commands.
:return: A string
"""
raise CmdException("The `!!/blacklist` command has been deprecated. "
"Please use `!!/blacklist-website`, `!!/blacklist-username`, "
"`!!... | [
"def",
"blacklist",
"(",
"_",
")",
":",
"raise",
"CmdException",
"(",
"\"The `!!/blacklist` command has been deprecated. \"",
"\"Please use `!!/blacklist-website`, `!!/blacklist-username`, \"",
"\"`!!/blacklist-keyword`, or perhaps `!!/watch-keyword`. \"",
"\"Remember to escape dots in URLs ... | [
179,
0
] | [
187,
67
] | python | en | ['en', 'error', 'th'] | False |
minimally_validate_content_source | (msg) |
Raises a CmdException if the msg.content and msg.content_source don't match to the first space (i.e. same command).
|
Raises a CmdException if the msg.content and msg.content_source don't match to the first space (i.e. same command).
| def minimally_validate_content_source(msg):
"""
Raises a CmdException if the msg.content and msg.content_source don't match to the first space (i.e. same command).
"""
# If the chat message has been edited or deleted, then content_source can be invalid, or
# even a completely different command. Chec... | [
"def",
"minimally_validate_content_source",
"(",
"msg",
")",
":",
"# If the chat message has been edited or deleted, then content_source can be invalid, or",
"# even a completely different command. Checking that it's for the same command covers the deleted",
"# message case and that we don't use arg... | [
190,
0
] | [
202,
108
] | python | en | ['en', 'error', 'th'] | False |
get_pattern_from_content_source | (msg) |
Returns a string containing the raw chat message content, except for the !!/command .
:return: A string
|
Returns a string containing the raw chat message content, except for the !!/command .
:return: A string
| def get_pattern_from_content_source(msg):
"""
Returns a string containing the raw chat message content, except for the !!/command .
:return: A string
"""
try:
msg_parts = msg.content_source.split(" ", 1)
if msg_parts[0] == "sdc":
return msg_parts[1].split(" ", 1)[1]
... | [
"def",
"get_pattern_from_content_source",
"(",
"msg",
")",
":",
"try",
":",
"msg_parts",
"=",
"msg",
".",
"content_source",
".",
"split",
"(",
"\" \"",
",",
"1",
")",
"if",
"msg_parts",
"[",
"0",
"]",
"==",
"\"sdc\"",
":",
"return",
"msg_parts",
"[",
"1"... | [
205,
0
] | [
221,
113
] | python | en | ['en', 'error', 'th'] | False |
sub_to_unchanged | (reg_exp, replace, text, max_passes=10, count=0, flags=0) |
Applies a regex substitution as many times as is needed to no longer make a change.
:param regex:
:param replace:
:param text:
:param max_passes:
:param count:
:param flags:
:return: A string
|
Applies a regex substitution as many times as is needed to no longer make a change.
:param regex:
:param replace:
:param text:
:param max_passes:
:param count:
:param flags:
:return: A string
| def sub_to_unchanged(reg_exp, replace, text, max_passes=10, count=0, flags=0):
"""
Applies a regex substitution as many times as is needed to no longer make a change.
:param regex:
:param replace:
:param text:
:param max_passes:
:param count:
:param flags:
:return: A string
"""
... | [
"def",
"sub_to_unchanged",
"(",
"reg_exp",
",",
"replace",
",",
"text",
",",
"max_passes",
"=",
"10",
",",
"count",
"=",
"0",
",",
"flags",
"=",
"0",
")",
":",
"prev_text",
"=",
"\"\"",
"max_passes",
"=",
"max_passes",
"+",
"1",
"if",
"max_passes",
"el... | [
281,
0
] | [
298,
15
] | python | en | ['en', 'error', 'th'] | False |
get_test_text_from_regex | (pattern) |
Converts regex text supplied in a command to text which can be tested for double-dipping
:param A string:
:return: A string
|
Converts regex text supplied in a command to text which can be tested for double-dipping
:param A string:
:return: A string
| def get_test_text_from_regex(pattern):
"""
Converts regex text supplied in a command to text which can be tested for double-dipping
:param A string:
:return: A string
"""
# Handle a specific common pattern that's now matched by a watch for obfuscated gmail.com.
pattern = pattern.replace(r"(?... | [
"def",
"get_test_text_from_regex",
"(",
"pattern",
")",
":",
"# Handle a specific common pattern that's now matched by a watch for obfuscated gmail.com.",
"pattern",
"=",
"pattern",
".",
"replace",
"(",
"r\"(?:[\\W_]*+(?:at[\\W_]*+)?gmail(?:[\\W_]*+(?:dot[\\W_]*+)?com)?)?\"",
",",
"\"@... | [
301,
0
] | [
341,
18
] | python | en | ['en', 'error', 'th'] | False |
do_blacklist | (blacklist_type, msg, force=False) |
Adds a string to the website blacklist and commits/pushes to GitHub
:param raw_pattern:
:param blacklist_type:
:param msg:
:param force:
:return: A string
|
Adds a string to the website blacklist and commits/pushes to GitHub
:param raw_pattern:
:param blacklist_type:
:param msg:
:param force:
:return: A string
| def do_blacklist(blacklist_type, msg, force=False):
"""
Adds a string to the website blacklist and commits/pushes to GitHub
:param raw_pattern:
:param blacklist_type:
:param msg:
:param force:
:return: A string
"""
minimally_validate_content_source(msg)
chat_user_profile_link = ... | [
"def",
"do_blacklist",
"(",
"blacklist_type",
",",
"msg",
",",
"force",
"=",
"False",
")",
":",
"minimally_validate_content_source",
"(",
"msg",
")",
"chat_user_profile_link",
"=",
"\"https://chat.{host}/users/{id}\"",
".",
"format",
"(",
"host",
"=",
"msg",
".",
... | [
344,
0
] | [
457,
17
] | python | en | ['en', 'error', 'th'] | False |
blacklist_keyword | (msg, pattern, alias_used="blacklist-keyword") |
Adds a pattern to the blacklist and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
|
Adds a pattern to the blacklist and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
| def blacklist_keyword(msg, pattern, alias_used="blacklist-keyword"):
"""
Adds a pattern to the blacklist and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
"""
parts = alias_used.split("-")
return do_blacklist(parts[1], msg, force=len(parts) > 2) | [
"def",
"blacklist_keyword",
"(",
"msg",
",",
"pattern",
",",
"alias_used",
"=",
"\"blacklist-keyword\"",
")",
":",
"parts",
"=",
"alias_used",
".",
"split",
"(",
"\"-\"",
")",
"return",
"do_blacklist",
"(",
"parts",
"[",
"1",
"]",
",",
"msg",
",",
"force",... | [
469,
0
] | [
478,
60
] | python | en | ['en', 'error', 'th'] | False |
watch | (msg, pattern, alias_used="watch") |
Adds a pattern to the watched keywords list and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
|
Adds a pattern to the watched keywords list and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
| def watch(msg, pattern, alias_used="watch"):
"""
Adds a pattern to the watched keywords list and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
"""
return do_blacklist("watch_number" if "number" in alias_used else "watch_keyword",
msg, force=a... | [
"def",
"watch",
"(",
"msg",
",",
"pattern",
",",
"alias_used",
"=",
"\"watch\"",
")",
":",
"return",
"do_blacklist",
"(",
"\"watch_number\"",
"if",
"\"number\"",
"in",
"alias_used",
"else",
"\"watch_keyword\"",
",",
"msg",
",",
"force",
"=",
"alias_used",
".",... | [
485,
0
] | [
494,
72
] | python | en | ['en', 'error', 'th'] | False |
unblacklist | (msg, item, alias_used="unwatch") |
Removes a pattern from watchlist/blacklist and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
|
Removes a pattern from watchlist/blacklist and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
| def unblacklist(msg, item, alias_used="unwatch"):
"""
Removes a pattern from watchlist/blacklist and commits/pushes to GitHub
:param msg:
:param pattern:
:return: A string
"""
if alias_used == "unwatch":
blacklist_type = "watch"
elif alias_used == "unblacklist":
blacklist... | [
"def",
"unblacklist",
"(",
"msg",
",",
"item",
",",
"alias_used",
"=",
"\"unwatch\"",
")",
":",
"if",
"alias_used",
"==",
"\"unwatch\"",
":",
"blacklist_type",
"=",
"\"watch\"",
"elif",
"alias_used",
"==",
"\"unblacklist\"",
":",
"blacklist_type",
"=",
"\"blackl... | [
498,
0
] | [
543,
17
] | python | en | ['en', 'error', 'th'] | False |
brownie | () |
Returns a string equal to "Brown!" (This is a joke command)
:return: A string
|
Returns a string equal to "Brown!" (This is a joke command)
:return: A string
| def brownie():
"""
Returns a string equal to "Brown!" (This is a joke command)
:return: A string
"""
return "Brown!" | [
"def",
"brownie",
"(",
")",
":",
"return",
"\"Brown!\""
] | [
660,
0
] | [
665,
19
] | python | en | ['en', 'error', 'th'] | False |
coffee | (msg, other_user) |
Returns a string stating who the coffee is for (This is a joke command)
:param msg:
:param other_user:
:return: A string
|
Returns a string stating who the coffee is for (This is a joke command)
:param msg:
:param other_user:
:return: A string
| def coffee(msg, other_user):
"""
Returns a string stating who the coffee is for (This is a joke command)
:param msg:
:param other_user:
:return: A string
"""
if other_user is None:
return "*brews a cup of {} for @{}*".format(random.choice(COFFEES), msg.owner.name.replace(" ", ""))
... | [
"def",
"coffee",
"(",
"msg",
",",
"other_user",
")",
":",
"if",
"other_user",
"is",
"None",
":",
"return",
"\"*brews a cup of {} for @{}*\"",
".",
"format",
"(",
"random",
".",
"choice",
"(",
"COFFEES",
")",
",",
"msg",
".",
"owner",
".",
"name",
".",
"r... | [
673,
0
] | [
684,
87
] | python | en | ['en', 'error', 'th'] | False |
lick | () |
Returns a string when a user says 'lick' (This is a joke command)
:return: A string
|
Returns a string when a user says 'lick' (This is a joke command)
:return: A string
| def lick():
"""
Returns a string when a user says 'lick' (This is a joke command)
:return: A string
"""
return "*licks ice cream cone*" | [
"def",
"lick",
"(",
")",
":",
"return",
"\"*licks ice cream cone*\""
] | [
689,
0
] | [
694,
35
] | python | en | ['en', 'error', 'th'] | False |
tea | (msg, other_user) |
Returns a string stating who the tea is for (This is a joke command)
:param msg:
:param other_user:
:return: A string
|
Returns a string stating who the tea is for (This is a joke command)
:param msg:
:param other_user:
:return: A string
| def tea(msg, other_user):
"""
Returns a string stating who the tea is for (This is a joke command)
:param msg:
:param other_user:
:return: A string
"""
if other_user is None:
return "*brews a cup of {} tea for @{}*".format(random.choice(TEAS), msg.owner.name.replace(" ", ""))
el... | [
"def",
"tea",
"(",
"msg",
",",
"other_user",
")",
":",
"if",
"other_user",
"is",
"None",
":",
"return",
"\"*brews a cup of {} tea for @{}*\"",
".",
"format",
"(",
"random",
".",
"choice",
"(",
"TEAS",
")",
",",
"msg",
".",
"owner",
".",
"name",
".",
"rep... | [
702,
0
] | [
714,
88
] | python | en | ['en', 'error', 'th'] | False |
wut | () |
Returns a string when a user asks 'wut' (This is a joke command)
:return: A string
|
Returns a string when a user asks 'wut' (This is a joke command)
:return: A string
| def wut():
"""
Returns a string when a user asks 'wut' (This is a joke command)
:return: A string
"""
return "Whaddya mean, 'wut'? Humans..." | [
"def",
"wut",
"(",
")",
":",
"return",
"\"Whaddya mean, 'wut'? Humans...\""
] | [
719,
0
] | [
724,
43
] | python | en | ['en', 'error', 'th'] | False |
block | (msg, block_time, room_id) |
Blocks posts from application for a period of time
:param msg:
:param block_time:
:param room_id:
:return: None
|
Blocks posts from application for a period of time
:param msg:
:param block_time:
:param room_id:
:return: None
| def block(msg, block_time, room_id):
"""
Blocks posts from application for a period of time
:param msg:
:param block_time:
:param room_id:
:return: None
"""
time_to_block = block_time if 0 < block_time < 14400 else 900
which_room = "globally" if room_id is None else "in room {} on {... | [
"def",
"block",
"(",
"msg",
",",
"block_time",
",",
"room_id",
")",
":",
"time_to_block",
"=",
"block_time",
"if",
"0",
"<",
"block_time",
"<",
"14400",
"else",
"900",
"which_room",
"=",
"\"globally\"",
"if",
"room_id",
"is",
"None",
"else",
"\"in room {} on... | [
762,
0
] | [
776,
70
] | 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.