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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
build_py.run | (self) | Build modules, packages, and copy data files to build directory | Build modules, packages, and copy data files to build directory | def run(self):
"""Build modules, packages, and copy data files to build directory"""
if not self.py_modules and not self.packages:
return
if self.py_modules:
self.build_modules()
if self.packages:
self.build_packages()
self.build_package_... | [
"def",
"run",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"py_modules",
"and",
"not",
"self",
".",
"packages",
":",
"return",
"if",
"self",
".",
"py_modules",
":",
"self",
".",
"build_modules",
"(",
")",
"if",
"self",
".",
"packages",
":",
"self... | [
44,
4
] | [
62,
78
] | python | en | ['en', 'en', 'en'] | True |
build_py.__getattr__ | (self, attr) | lazily compute data files | lazily compute data files | def __getattr__(self, attr):
"lazily compute data files"
if attr == 'data_files':
self.data_files = self._get_data_files()
return self.data_files
return orig.build_py.__getattr__(self, attr) | [
"def",
"__getattr__",
"(",
"self",
",",
"attr",
")",
":",
"if",
"attr",
"==",
"'data_files'",
":",
"self",
".",
"data_files",
"=",
"self",
".",
"_get_data_files",
"(",
")",
"return",
"self",
".",
"data_files",
"return",
"orig",
".",
"build_py",
".",
"__g... | [
64,
4
] | [
69,
52
] | python | it | ['it', 'it', 'it'] | True |
build_py._get_data_files | (self) | Generate list of '(package,src_dir,build_dir,filenames)' tuples | Generate list of '(package,src_dir,build_dir,filenames)' tuples | def _get_data_files(self):
"""Generate list of '(package,src_dir,build_dir,filenames)' tuples"""
self.analyze_manifest()
return list(map(self._get_pkg_data_files, self.packages or ())) | [
"def",
"_get_data_files",
"(",
"self",
")",
":",
"self",
".",
"analyze_manifest",
"(",
")",
"return",
"list",
"(",
"map",
"(",
"self",
".",
"_get_pkg_data_files",
",",
"self",
".",
"packages",
"or",
"(",
")",
")",
")"
] | [
78,
4
] | [
81,
71
] | python | en | ['en', 'af', 'en'] | True |
build_py.find_data_files | (self, package, src_dir) | Return filenames for package's data files in 'src_dir | Return filenames for package's data files in 'src_dir | def find_data_files(self, package, src_dir):
"""Return filenames for package's data files in 'src_dir'"""
patterns = self._get_platform_patterns(
self.package_data,
package,
src_dir,
)
globs_expanded = map(glob, patterns)
# flatten the expanded... | [
"def",
"find_data_files",
"(",
"self",
",",
"package",
",",
"src_dir",
")",
":",
"patterns",
"=",
"self",
".",
"_get_platform_patterns",
"(",
"self",
".",
"package_data",
",",
"package",
",",
"src_dir",
",",
")",
"globs_expanded",
"=",
"map",
"(",
"glob",
... | [
97,
4
] | [
112,
63
] | python | en | ['en', 'no', 'en'] | True |
build_py.build_package_data | (self) | Copy data files into build directory | Copy data files into build directory | def build_package_data(self):
"""Copy data files into build directory"""
for package, src_dir, build_dir, filenames in self.data_files:
for filename in filenames:
target = os.path.join(build_dir, filename)
self.mkpath(os.path.dirname(target))
s... | [
"def",
"build_package_data",
"(",
"self",
")",
":",
"for",
"package",
",",
"src_dir",
",",
"build_dir",
",",
"filenames",
"in",
"self",
".",
"data_files",
":",
"for",
"filename",
"in",
"filenames",
":",
"target",
"=",
"os",
".",
"path",
".",
"join",
"(",... | [
114,
4
] | [
126,
53
] | python | en | ['en', 'en', 'en'] | True |
build_py.check_package | (self, package, package_dir) | Check namespace packages' __init__ for declare_namespace | Check namespace packages' __init__ for declare_namespace | def check_package(self, package, package_dir):
"""Check namespace packages' __init__ for declare_namespace"""
try:
return self.packages_checked[package]
except KeyError:
pass
init_py = orig.build_py.check_package(self, package, package_dir)
self.packages_... | [
"def",
"check_package",
"(",
"self",
",",
"package",
",",
"package_dir",
")",
":",
"try",
":",
"return",
"self",
".",
"packages_checked",
"[",
"package",
"]",
"except",
"KeyError",
":",
"pass",
"init_py",
"=",
"orig",
".",
"build_py",
".",
"check_package",
... | [
155,
4
] | [
183,
22
] | python | en | ['es', 'en', 'en'] | True |
build_py.exclude_data_files | (self, package, src_dir, files) | Filter filenames for package's data files in 'src_dir | Filter filenames for package's data files in 'src_dir | def exclude_data_files(self, package, src_dir, files):
"""Filter filenames for package's data files in 'src_dir'"""
files = list(files)
patterns = self._get_platform_patterns(
self.exclude_package_data,
package,
src_dir,
)
match_groups = (
... | [
"def",
"exclude_data_files",
"(",
"self",
",",
"package",
",",
"src_dir",
",",
"files",
")",
":",
"files",
"=",
"list",
"(",
"files",
")",
"patterns",
"=",
"self",
".",
"_get_platform_patterns",
"(",
"self",
".",
"exclude_package_data",
",",
"package",
",",
... | [
195,
4
] | [
216,
46
] | python | en | ['en', 'en', 'en'] | True |
build_py._get_platform_patterns | (spec, package, src_dir) |
yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
|
yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
| def _get_platform_patterns(spec, package, src_dir):
"""
yield platform-specific path patterns (suitable for glob
or fn_match) from a glob-based spec (such as
self.package_data or self.exclude_package_data)
matching package in src_dir.
"""
raw_patterns = itertools.... | [
"def",
"_get_platform_patterns",
"(",
"spec",
",",
"package",
",",
"src_dir",
")",
":",
"raw_patterns",
"=",
"itertools",
".",
"chain",
"(",
"spec",
".",
"get",
"(",
"''",
",",
"[",
"]",
")",
",",
"spec",
".",
"get",
"(",
"package",
",",
"[",
"]",
... | [
219,
4
] | [
234,
9
] | python | en | ['en', 'error', 'th'] | False |
fix_upload_links | (data: TableData, message_table: TableName) |
Because the URLs for uploaded files encode the realm ID of the
organization being imported (which is only determined at import
time), we need to rewrite the URLs of links to uploaded files
during the import process.
|
Because the URLs for uploaded files encode the realm ID of the
organization being imported (which is only determined at import
time), we need to rewrite the URLs of links to uploaded files
during the import process.
| def fix_upload_links(data: TableData, message_table: TableName) -> None:
"""
Because the URLs for uploaded files encode the realm ID of the
organization being imported (which is only determined at import
time), we need to rewrite the URLs of links to uploaded files
during the import process.
"""... | [
"def",
"fix_upload_links",
"(",
"data",
":",
"TableData",
",",
"message_table",
":",
"TableName",
")",
"->",
"None",
":",
"for",
"message",
"in",
"data",
"[",
"message_table",
"]",
":",
"if",
"message",
"[",
"\"has_attachment\"",
"]",
"is",
"True",
":",
"f... | [
158,
0
] | [
173,
25
] | python | en | ['en', 'error', 'th'] | False |
create_subscription_events | (data: TableData, realm_id: int) |
When the export data doesn't contain the table `zerver_realmauditlog`,
this function creates RealmAuditLog objects for `subscription_created`
type event for all the existing Stream subscriptions.
This is needed for all the export tools which do not include the
table `zerver_realmauditlog` (Slack, ... |
When the export data doesn't contain the table `zerver_realmauditlog`,
this function creates RealmAuditLog objects for `subscription_created`
type event for all the existing Stream subscriptions. | def create_subscription_events(data: TableData, realm_id: int) -> None:
"""
When the export data doesn't contain the table `zerver_realmauditlog`,
this function creates RealmAuditLog objects for `subscription_created`
type event for all the existing Stream subscriptions.
This is needed for all the ... | [
"def",
"create_subscription_events",
"(",
"data",
":",
"TableData",
",",
"realm_id",
":",
"int",
")",
"->",
"None",
":",
"all_subscription_logs",
"=",
"[",
"]",
"event_last_message_id",
"=",
"get_last_message_id",
"(",
")",
"event_time",
"=",
"timezone_now",
"(",
... | [
176,
0
] | [
216,
60
] | python | en | ['en', 'error', 'th'] | False |
fix_service_tokens | (data: TableData, table: TableName) |
The tokens in the services are created by 'generate_api_key'.
As the tokens are unique, they should be re-created for the imports.
|
The tokens in the services are created by 'generate_api_key'.
As the tokens are unique, they should be re-created for the imports.
| def fix_service_tokens(data: TableData, table: TableName) -> None:
"""
The tokens in the services are created by 'generate_api_key'.
As the tokens are unique, they should be re-created for the imports.
"""
for item in data[table]:
item["token"] = generate_api_key() | [
"def",
"fix_service_tokens",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
")",
"->",
"None",
":",
"for",
"item",
"in",
"data",
"[",
"table",
"]",
":",
"item",
"[",
"\"token\"",
"]",
"=",
"generate_api_key",
"(",
")"
] | [
219,
0
] | [
225,
42
] | python | en | ['en', 'error', 'th'] | False |
process_huddle_hash | (data: TableData, table: TableName) |
Build new huddle hashes with the updated ids of the users
|
Build new huddle hashes with the updated ids of the users
| def process_huddle_hash(data: TableData, table: TableName) -> None:
"""
Build new huddle hashes with the updated ids of the users
"""
for huddle in data[table]:
user_id_list = id_map_to_list["huddle_to_user_list"][huddle["id"]]
huddle["huddle_hash"] = get_huddle_hash(user_id_list) | [
"def",
"process_huddle_hash",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
")",
"->",
"None",
":",
"for",
"huddle",
"in",
"data",
"[",
"table",
"]",
":",
"user_id_list",
"=",
"id_map_to_list",
"[",
"\"huddle_to_user_list\"",
"]",
"[",
"hudd... | [
228,
0
] | [
234,
61
] | python | en | ['en', 'error', 'th'] | False |
get_huddles_from_subscription | (data: TableData, table: TableName) |
Extract the IDs of the user_profiles involved in a huddle from the subscription object
This helps to generate a unique huddle hash from the updated user_profile ids
|
Extract the IDs of the user_profiles involved in a huddle from the subscription object
This helps to generate a unique huddle hash from the updated user_profile ids
| def get_huddles_from_subscription(data: TableData, table: TableName) -> None:
"""
Extract the IDs of the user_profiles involved in a huddle from the subscription object
This helps to generate a unique huddle hash from the updated user_profile ids
"""
id_map_to_list["huddle_to_user_list"] = {
... | [
"def",
"get_huddles_from_subscription",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
")",
"->",
"None",
":",
"id_map_to_list",
"[",
"\"huddle_to_user_list\"",
"]",
"=",
"{",
"value",
":",
"[",
"]",
"for",
"value",
"in",
"ID_MAP",
"[",
"\"re... | [
237,
0
] | [
249,
100
] | python | en | ['en', 'error', 'th'] | False |
fix_customprofilefield | (data: TableData) |
In CustomProfileField with 'field_type' like 'USER', the IDs need to be
re-mapped.
|
In CustomProfileField with 'field_type' like 'USER', the IDs need to be
re-mapped.
| def fix_customprofilefield(data: TableData) -> None:
"""
In CustomProfileField with 'field_type' like 'USER', the IDs need to be
re-mapped.
"""
field_type_USER_id_list = []
for item in data["zerver_customprofilefield"]:
if item["field_type"] == CustomProfileField.USER:
field_... | [
"def",
"fix_customprofilefield",
"(",
"data",
":",
"TableData",
")",
"->",
"None",
":",
"field_type_USER_id_list",
"=",
"[",
"]",
"for",
"item",
"in",
"data",
"[",
"\"zerver_customprofilefield\"",
"]",
":",
"if",
"item",
"[",
"\"field_type\"",
"]",
"==",
"Cust... | [
252,
0
] | [
272,
62
] | python | en | ['en', 'error', 'th'] | False |
fix_message_rendered_content | (
realm: Realm, sender_map: Dict[int, Record], messages: List[Record]
) |
This function sets the rendered_content of all the messages
after the messages have been imported from a non-Zulip platform.
|
This function sets the rendered_content of all the messages
after the messages have been imported from a non-Zulip platform.
| def fix_message_rendered_content(
realm: Realm, sender_map: Dict[int, Record], messages: List[Record]
) -> None:
"""
This function sets the rendered_content of all the messages
after the messages have been imported from a non-Zulip platform.
"""
for message in messages:
if message["rende... | [
"def",
"fix_message_rendered_content",
"(",
"realm",
":",
"Realm",
",",
"sender_map",
":",
"Dict",
"[",
"int",
",",
"Record",
"]",
",",
"messages",
":",
"List",
"[",
"Record",
"]",
")",
"->",
"None",
":",
"for",
"message",
"in",
"messages",
":",
"if",
... | [
275,
0
] | [
361,
13
] | python | en | ['en', 'error', 'th'] | False |
current_table_ids | (data: TableData, table: TableName) |
Returns the ids present in the current table
|
Returns the ids present in the current table
| def current_table_ids(data: TableData, table: TableName) -> List[int]:
"""
Returns the ids present in the current table
"""
id_list = []
for item in data[table]:
id_list.append(item["id"])
return id_list | [
"def",
"current_table_ids",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
")",
"->",
"List",
"[",
"int",
"]",
":",
"id_list",
"=",
"[",
"]",
"for",
"item",
"in",
"data",
"[",
"table",
"]",
":",
"id_list",
".",
"append",
"(",
"item",
... | [
364,
0
] | [
371,
18
] | python | en | ['en', 'error', 'th'] | False |
allocate_ids | (model_class: Any, count: int) |
Increases the sequence number for a given table by the amount of objects being
imported into that table. Hence, this gives a reserved range of IDs to import the
converted Slack objects into the tables.
|
Increases the sequence number for a given table by the amount of objects being
imported into that table. Hence, this gives a reserved range of IDs to import the
converted Slack objects into the tables.
| def allocate_ids(model_class: Any, count: int) -> List[int]:
"""
Increases the sequence number for a given table by the amount of objects being
imported into that table. Hence, this gives a reserved range of IDs to import the
converted Slack objects into the tables.
"""
conn = connection.cursor(... | [
"def",
"allocate_ids",
"(",
"model_class",
":",
"Any",
",",
"count",
":",
"int",
")",
"->",
"List",
"[",
"int",
"]",
":",
"conn",
"=",
"connection",
".",
"cursor",
"(",
")",
"sequence",
"=",
"idseq",
"(",
"model_class",
")",
"conn",
".",
"execute",
"... | [
384,
0
] | [
396,
38
] | python | en | ['en', 'error', 'th'] | False |
convert_to_id_fields | (data: TableData, table: TableName, field_name: Field) |
When Django gives us dict objects via model_to_dict, the foreign
key fields are `foo`, but we want `foo_id` for the bulk insert.
This function handles the simple case where we simply rename
the fields. For cases where we need to munge ids in the
database, see re_map_foreign_keys.
|
When Django gives us dict objects via model_to_dict, the foreign
key fields are `foo`, but we want `foo_id` for the bulk insert.
This function handles the simple case where we simply rename
the fields. For cases where we need to munge ids in the
database, see re_map_foreign_keys.
| def convert_to_id_fields(data: TableData, table: TableName, field_name: Field) -> None:
"""
When Django gives us dict objects via model_to_dict, the foreign
key fields are `foo`, but we want `foo_id` for the bulk insert.
This function handles the simple case where we simply rename
the fields. For c... | [
"def",
"convert_to_id_fields",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
",",
"field_name",
":",
"Field",
")",
"->",
"None",
":",
"for",
"item",
"in",
"data",
"[",
"table",
"]",
":",
"item",
"[",
"field_name",
"+",
"\"_id\"",
"]",
... | [
399,
0
] | [
409,
28
] | python | en | ['en', 'error', 'th'] | False |
re_map_foreign_keys | (
data: TableData,
table: TableName,
field_name: Field,
related_table: TableName,
verbose: bool = False,
id_field: bool = False,
recipient_field: bool = False,
reaction_field: bool = False,
) |
This is a wrapper function for all the realm data tables
and only avatar and attachment records need to be passed through the internal function
because of the difference in data format (TableData corresponding to realm data tables
and List[Record] corresponding to the avatar and attachment records)
... |
This is a wrapper function for all the realm data tables
and only avatar and attachment records need to be passed through the internal function
because of the difference in data format (TableData corresponding to realm data tables
and List[Record] corresponding to the avatar and attachment records)
... | def re_map_foreign_keys(
data: TableData,
table: TableName,
field_name: Field,
related_table: TableName,
verbose: bool = False,
id_field: bool = False,
recipient_field: bool = False,
reaction_field: bool = False,
) -> None:
"""
This is a wrapper function for all the realm data ta... | [
"def",
"re_map_foreign_keys",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
",",
"field_name",
":",
"Field",
",",
"related_table",
":",
"TableName",
",",
"verbose",
":",
"bool",
"=",
"False",
",",
"id_field",
":",
"bool",
"=",
"False",
","... | [
412,
0
] | [
441,
5
] | python | en | ['en', 'error', 'th'] | False |
re_map_foreign_keys_internal | (
data_table: List[Record],
table: TableName,
field_name: Field,
related_table: TableName,
verbose: bool = False,
id_field: bool = False,
recipient_field: bool = False,
reaction_field: bool = False,
) |
We occasionally need to assign new ids to rows during the
import/export process, to accommodate things like existing rows
already being in tables. See bulk_import_client for more context.
The tricky part is making sure that foreign key references
are in sync with the new ids, and this fixer funct... |
We occasionally need to assign new ids to rows during the
import/export process, to accommodate things like existing rows
already being in tables. See bulk_import_client for more context. | def re_map_foreign_keys_internal(
data_table: List[Record],
table: TableName,
field_name: Field,
related_table: TableName,
verbose: bool = False,
id_field: bool = False,
recipient_field: bool = False,
reaction_field: bool = False,
) -> None:
"""
We occasionally need to assign new... | [
"def",
"re_map_foreign_keys_internal",
"(",
"data_table",
":",
"List",
"[",
"Record",
"]",
",",
"table",
":",
"TableName",
",",
"field_name",
":",
"Field",
",",
"related_table",
":",
"TableName",
",",
"verbose",
":",
"bool",
"=",
"False",
",",
"id_field",
":... | [
444,
0
] | [
500,
41
] | python | en | ['en', 'error', 'th'] | False |
re_map_foreign_keys_many_to_many | (
data: TableData,
table: TableName,
field_name: Field,
related_table: TableName,
verbose: bool = False,
) |
We need to assign new ids to rows during the import/export
process.
The tricky part is making sure that foreign key references
are in sync with the new ids, and this wrapper function does
the re-mapping only for ManyToMany fields.
|
We need to assign new ids to rows during the import/export
process. | def re_map_foreign_keys_many_to_many(
data: TableData,
table: TableName,
field_name: Field,
related_table: TableName,
verbose: bool = False,
) -> None:
"""
We need to assign new ids to rows during the import/export
process.
The tricky part is making sure that foreign key references
... | [
"def",
"re_map_foreign_keys_many_to_many",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
",",
"field_name",
":",
"Field",
",",
"related_table",
":",
"TableName",
",",
"verbose",
":",
"bool",
"=",
"False",
",",
")",
"->",
"None",
":",
"for",
... | [
503,
0
] | [
524,
28
] | python | en | ['en', 'error', 'th'] | False |
re_map_foreign_keys_many_to_many_internal | (
table: TableName,
field_name: Field,
related_table: TableName,
old_id_list: List[int],
verbose: bool = False,
) |
This is an internal function for tables with ManyToMany fields,
which takes the old ID list of the ManyToMany relation and returns the
new updated ID list.
|
This is an internal function for tables with ManyToMany fields,
which takes the old ID list of the ManyToMany relation and returns the
new updated ID list.
| def re_map_foreign_keys_many_to_many_internal(
table: TableName,
field_name: Field,
related_table: TableName,
old_id_list: List[int],
verbose: bool = False,
) -> List[int]:
"""
This is an internal function for tables with ManyToMany fields,
which takes the old ID list of the ManyToMany r... | [
"def",
"re_map_foreign_keys_many_to_many_internal",
"(",
"table",
":",
"TableName",
",",
"field_name",
":",
"Field",
",",
"related_table",
":",
"TableName",
",",
"old_id_list",
":",
"List",
"[",
"int",
"]",
",",
"verbose",
":",
"bool",
"=",
"False",
",",
")",
... | [
527,
0
] | [
551,
22
] | python | en | ['en', 'error', 'th'] | False |
fix_realm_authentication_bitfield | (data: TableData, table: TableName, field_name: Field) | Used to fixup the authentication_methods bitfield to be a string | Used to fixup the authentication_methods bitfield to be a string | def fix_realm_authentication_bitfield(data: TableData, table: TableName, field_name: Field) -> None:
"""Used to fixup the authentication_methods bitfield to be a string"""
for item in data[table]:
values_as_bitstring = "".join("1" if field[1] else "0" for field in item[field_name])
values_as_int... | [
"def",
"fix_realm_authentication_bitfield",
"(",
"data",
":",
"TableData",
",",
"table",
":",
"TableName",
",",
"field_name",
":",
"Field",
")",
"->",
"None",
":",
"for",
"item",
"in",
"data",
"[",
"table",
"]",
":",
"values_as_bitstring",
"=",
"\"\"",
".",
... | [
560,
0
] | [
565,
40
] | python | en | ['en', 'en', 'en'] | True |
remove_denormalized_recipient_column_from_data | (data: TableData) |
The recipient column shouldn't be imported, we'll set the correct values
when Recipient table gets imported.
|
The recipient column shouldn't be imported, we'll set the correct values
when Recipient table gets imported.
| def remove_denormalized_recipient_column_from_data(data: TableData) -> None:
"""
The recipient column shouldn't be imported, we'll set the correct values
when Recipient table gets imported.
"""
for stream_dict in data["zerver_stream"]:
if "recipient" in stream_dict:
del stream_di... | [
"def",
"remove_denormalized_recipient_column_from_data",
"(",
"data",
":",
"TableData",
")",
"->",
"None",
":",
"for",
"stream_dict",
"in",
"data",
"[",
"\"zerver_stream\"",
"]",
":",
"if",
"\"recipient\"",
"in",
"stream_dict",
":",
"del",
"stream_dict",
"[",
"\"r... | [
568,
0
] | [
583,
40
] | python | en | ['en', 'error', 'th'] | False |
get_db_table | (model_class: Any) | E.g. (RealmDomain -> 'zerver_realmdomain') | E.g. (RealmDomain -> 'zerver_realmdomain') | def get_db_table(model_class: Any) -> str:
"""E.g. (RealmDomain -> 'zerver_realmdomain')"""
return model_class._meta.db_table | [
"def",
"get_db_table",
"(",
"model_class",
":",
"Any",
")",
"->",
"str",
":",
"return",
"model_class",
".",
"_meta",
".",
"db_table"
] | [
586,
0
] | [
588,
37
] | python | de | ['de', 'mg', 'ur'] | False |
get_incoming_message_ids | (import_dir: Path, sort_by_date: bool) |
This function reads in our entire collection of message
ids, which can be millions of integers for some installations.
And then we sort the list. This is necessary to ensure
that the sort order of incoming ids matches the sort order
of date_sent, which isn't always guaranteed by our
utilities ... |
This function reads in our entire collection of message
ids, which can be millions of integers for some installations.
And then we sort the list. This is necessary to ensure
that the sort order of incoming ids matches the sort order
of date_sent, which isn't always guaranteed by our
utilities ... | def get_incoming_message_ids(import_dir: Path, sort_by_date: bool) -> List[int]:
"""
This function reads in our entire collection of message
ids, which can be millions of integers for some installations.
And then we sort the list. This is necessary to ensure
that the sort order of incoming ids matc... | [
"def",
"get_incoming_message_ids",
"(",
"import_dir",
":",
"Path",
",",
"sort_by_date",
":",
"bool",
")",
"->",
"List",
"[",
"int",
"]",
":",
"if",
"sort_by_date",
":",
"tups",
":",
"List",
"[",
"Tuple",
"[",
"int",
",",
"int",
"]",
"]",
"=",
"[",
"]... | [
1277,
0
] | [
1332,
22
] | python | en | ['en', 'error', 'th'] | False |
EventsEndpointTest.test_events_get_events_endpoint_guest_cant_use_all_public_streams_param | (self) |
This test is meant to execute the very beginning of the codepath
to ensure guest users are immediately disallowed to use the
all_public_streams param. Deeper testing is hard (and not necessary for this case)
due to the codepath expecting AsyncDjangoHandler to be attached to the request,... |
This test is meant to execute the very beginning of the codepath
to ensure guest users are immediately disallowed to use the
all_public_streams param. Deeper testing is hard (and not necessary for this case)
due to the codepath expecting AsyncDjangoHandler to be attached to the request,... | def test_events_get_events_endpoint_guest_cant_use_all_public_streams_param(self) -> None:
"""
This test is meant to execute the very beginning of the codepath
to ensure guest users are immediately disallowed to use the
all_public_streams param. Deeper testing is hard (and not necessary ... | [
"def",
"test_events_get_events_endpoint_guest_cant_use_all_public_streams_param",
"(",
"self",
")",
"->",
"None",
":",
"guest_user",
"=",
"self",
".",
"example_user",
"(",
"\"polonius\"",
")",
"self",
".",
"assertEqual",
"(",
"guest_user",
".",
"role",
",",
"UserProfi... | [
160,
4
] | [
173,
76
] | python | en | ['en', 'error', 'th'] | False |
ContinuousServoMotor.map_speed_to_pwm_us | (self, speed: Real) |
Continuous rotation servos may have a non-linear speed response to the PWM signal.
This method should convert the speed into PWM values such that the servo speed
varies linearly as the speed varies linearly.
By default, this method simply scales speeds from (0, 1] to (center_pwm_us, fu... |
Continuous rotation servos may have a non-linear speed response to the PWM signal.
This method should convert the speed into PWM values such that the servo speed
varies linearly as the speed varies linearly. | def map_speed_to_pwm_us(self, speed: Real) -> Real:
"""
Continuous rotation servos may have a non-linear speed response to the PWM signal.
This method should convert the speed into PWM values such that the servo speed
varies linearly as the speed varies linearly.
By default, thi... | [
"def",
"map_speed_to_pwm_us",
"(",
"self",
",",
"speed",
":",
"Real",
")",
"->",
"Real",
":",
"if",
"speed",
">",
"0",
":",
"return",
"scale",
"(",
"speed",
",",
"Point",
"(",
"0",
",",
"self",
".",
"center_pwm_us",
")",
",",
"Point",
"(",
"1",
","... | [
56,
4
] | [
72,
37
] | 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 |
pprint | (value, break_after=10) | A wrapper around pprint.pprint -- for debugging, really. | A wrapper around pprint.pprint -- for debugging, really. | def pprint(value, break_after=10):
"""A wrapper around pprint.pprint -- for debugging, really."""
from pprint import pformat
value = pformat(value)
return '\u200B'.join([value[i:i+break_after] for i in range(0, len(value), break_after)]) | [
"def",
"pprint",
"(",
"value",
",",
"break_after",
"=",
"10",
")",
":",
"from",
"pprint",
"import",
"pformat",
"value",
"=",
"pformat",
"(",
"value",
")",
"return",
"'\\u200B'",
".",
"join",
"(",
"[",
"value",
"[",
"i",
":",
"i",
"+",
"break_after",
... | [
18,
0
] | [
24,
93
] | python | en | ['en', 'en', 'en'] | True |
truncatechars | (value, arg) |
Truncates a string after a certain number of chars.
Argument: Number of chars to truncate after.
|
Truncates a string after a certain number of chars. | def truncatechars(value, arg):
"""
Truncates a string after a certain number of chars.
Argument: Number of chars to truncate after.
"""
try:
length = int(arg)
except ValueError: # Invalid literal for int().
return value # Fail silently.
if len(value) > length:
return... | [
"def",
"truncatechars",
"(",
"value",
",",
"arg",
")",
":",
"try",
":",
"length",
"=",
"int",
"(",
"arg",
")",
"except",
"ValueError",
":",
"# Invalid literal for int().",
"return",
"value",
"# Fail silently.",
"if",
"len",
"(",
"value",
")",
">",
"length",
... | [
152,
0
] | [
164,
16
] | python | en | ['en', 'error', 'th'] | False |
paginate | (context, queryset_or_list, request, asvar, per_page=25, is_endless=True) | {% paginate queryset_or_list from request as foo[ per_page 25][ is_endless False %} | {% paginate queryset_or_list from request as foo[ per_page 25][ is_endless False %} | def paginate(context, queryset_or_list, request, asvar, per_page=25, is_endless=True):
"""{% paginate queryset_or_list from request as foo[ per_page 25][ is_endless False %}"""
paging_context = paginate_func(request, queryset_or_list, per_page, endless=is_endless)
paging = mark_safe(render_to_string('sentry... | [
"def",
"paginate",
"(",
"context",
",",
"queryset_or_list",
",",
"request",
",",
"asvar",
",",
"per_page",
"=",
"25",
",",
"is_endless",
"=",
"True",
")",
":",
"paging_context",
"=",
"paginate_func",
"(",
"request",
",",
"queryset_or_list",
",",
"per_page",
... | [
174,
0
] | [
183,
17
] | python | en | ['en', 'en', 'en'] | True |
test_append_descriptions | (html_test_table, header_index, description, expected_html) | Testing if appending description (wrapped in HTML tags) to the element works properly. | Testing if appending description (wrapped in HTML tags) to the element works properly. | def test_append_descriptions(html_test_table, header_index, description, expected_html):
"""Testing if appending description (wrapped in HTML tags) to the element works properly."""
html_table = BeautifulSoup(html_test_table, "html.parser")
actual_html = str(append_description(description, html_table))
... | [
"def",
"test_append_descriptions",
"(",
"html_test_table",
",",
"header_index",
",",
"description",
",",
"expected_html",
")",
":",
"html_table",
"=",
"BeautifulSoup",
"(",
"html_test_table",
",",
"\"html.parser\"",
")",
"actual_html",
"=",
"str",
"(",
"append_descrip... | [
26,
0
] | [
31,
39
] | python | en | ['en', 'en', 'en'] | True |
test_assess_model_names | (input_tuple_list, expected_names) | Testing if replacing duplicate model names in a tuple of (model, values) works correctly. | Testing if replacing duplicate model names in a tuple of (model, values) works correctly. | def test_assess_model_names(input_tuple_list, expected_names):
"""Testing if replacing duplicate model names in a tuple of (model, values) works correctly."""
expected_results = []
for name, tp in zip(expected_names, input_tuple_list):
expected_results.append((name, tp[1]))
actual_results = ass... | [
"def",
"test_assess_model_names",
"(",
"input_tuple_list",
",",
"expected_names",
")",
":",
"expected_results",
"=",
"[",
"]",
"for",
"name",
",",
"tp",
"in",
"zip",
"(",
"expected_names",
",",
"input_tuple_list",
")",
":",
"expected_results",
".",
"append",
"("... | [
55,
0
] | [
62,
45
] | python | en | ['en', 'en', 'en'] | True |
test_calculate_numerical_bins | (input_series, expected_result) | Testing if calculate_numerical_bins() correctly calculates the number of bins. | Testing if calculate_numerical_bins() correctly calculates the number of bins. | def test_calculate_numerical_bins(input_series, expected_result):
"""Testing if calculate_numerical_bins() correctly calculates the number of bins."""
srs = pd.Series(input_series)
actual_result = calculate_numerical_bins(srs)
assert actual_result == expected_result | [
"def",
"test_calculate_numerical_bins",
"(",
"input_series",
",",
"expected_result",
")",
":",
"srs",
"=",
"pd",
".",
"Series",
"(",
"input_series",
")",
"actual_result",
"=",
"calculate_numerical_bins",
"(",
"srs",
")",
"assert",
"actual_result",
"==",
"expected_re... | [
75,
0
] | [
79,
43
] | python | en | ['en', 'en', 'en'] | True |
test_make_pandas_data | (input_data, expected_pandas_obj, expected_result) | Testing if make_pandas_data returns correct output when different input data is provided. | Testing if make_pandas_data returns correct output when different input data is provided. | def test_make_pandas_data(input_data, expected_pandas_obj, expected_result):
"""Testing if make_pandas_data returns correct output when different input data is provided."""
actual_result = make_pandas_data(input_data, expected_pandas_obj)
assert str(actual_result) == str(expected_result) | [
"def",
"test_make_pandas_data",
"(",
"input_data",
",",
"expected_pandas_obj",
",",
"expected_result",
")",
":",
"actual_result",
"=",
"make_pandas_data",
"(",
"input_data",
",",
"expected_pandas_obj",
")",
"assert",
"str",
"(",
"actual_result",
")",
"==",
"str",
"(... | [
117,
0
] | [
120,
53
] | python | en | ['en', 'en', 'en'] | True |
test_make_pandas_data_error | (wrong_input) | Testing if make_pandas raises an error when incorrect input is provided. | Testing if make_pandas raises an error when incorrect input is provided. | def test_make_pandas_data_error(wrong_input):
"""Testing if make_pandas raises an error when incorrect input is provided."""
with pytest.raises(Exception):
make_pandas_data(wrong_input, pd.DataFrame) | [
"def",
"test_make_pandas_data_error",
"(",
"wrong_input",
")",
":",
"with",
"pytest",
".",
"raises",
"(",
"Exception",
")",
":",
"make_pandas_data",
"(",
"wrong_input",
",",
"pd",
".",
"DataFrame",
")"
] | [
131,
0
] | [
134,
51
] | python | en | ['en', 'en', 'en'] | True |
test_modify_histogram_edges | (input_edges, interval_percentage, expected_right_edge) | Testing if modify_histogram_edges() correctly returns arrays for left and right edges. | Testing if modify_histogram_edges() correctly returns arrays for left and right edges. | def test_modify_histogram_edges(input_edges, interval_percentage, expected_right_edge):
"""Testing if modify_histogram_edges() correctly returns arrays for left and right edges."""
expected_left_edge = input_edges[:-1]
actual_left_edge, actual_right_edge = modify_histogram_edges(input_edges, interval_perce... | [
"def",
"test_modify_histogram_edges",
"(",
"input_edges",
",",
"interval_percentage",
",",
"expected_right_edge",
")",
":",
"expected_left_edge",
"=",
"input_edges",
"[",
":",
"-",
"1",
"]",
"actual_left_edge",
",",
"actual_right_edge",
"=",
"modify_histogram_edges",
"(... | [
145,
0
] | [
152,
51
] | python | en | ['en', 'en', 'en'] | True |
test_obj_name | (obj, expected_result) | Testing if returned string representation of object from obj_name() function is correct. | Testing if returned string representation of object from obj_name() function is correct. | def test_obj_name(obj, expected_result):
"""Testing if returned string representation of object from obj_name() function is correct."""
actual_result = obj_name(obj)
assert actual_result == expected_result | [
"def",
"test_obj_name",
"(",
"obj",
",",
"expected_result",
")",
":",
"actual_result",
"=",
"obj_name",
"(",
"obj",
")",
"assert",
"actual_result",
"==",
"expected_result"
] | [
173,
0
] | [
176,
43
] | python | en | ['en', 'en', 'en'] | True |
test_replace_duplicate_str | (input_list, expected_result) | Testing if replacing duplicate entries in a list works correctly. | Testing if replacing duplicate entries in a list works correctly. | def test_replace_duplicate_str(input_list, expected_result):
"""Testing if replacing duplicate entries in a list works correctly."""
actual_result = replace_duplicate_str(input_list)
assert actual_result == expected_result | [
"def",
"test_replace_duplicate_str",
"(",
"input_list",
",",
"expected_result",
")",
":",
"actual_result",
"=",
"replace_duplicate_str",
"(",
"input_list",
")",
"assert",
"actual_result",
"==",
"expected_result"
] | [
189,
0
] | [
192,
43
] | python | en | ['en', 'en', 'en'] | True |
test_reverse_sorting_order | (input_str, expected_result) | Testing if assessment of sorting order from reverse_sorting_order() is correct. | Testing if assessment of sorting order from reverse_sorting_order() is correct. | def test_reverse_sorting_order(input_str, expected_result):
"""Testing if assessment of sorting order from reverse_sorting_order() is correct."""
assert reverse_sorting_order(input_str) == expected_result | [
"def",
"test_reverse_sorting_order",
"(",
"input_str",
",",
"expected_result",
")",
":",
"assert",
"reverse_sorting_order",
"(",
"input_str",
")",
"==",
"expected_result"
] | [
210,
0
] | [
212,
62
] | python | en | ['en', 'en', 'en'] | True |
test_sanitize_input | (input_list, expected_result) | Testing if sanitizing input list (replacing invalid characters) works properly. | Testing if sanitizing input list (replacing invalid characters) works properly. | def test_sanitize_input(input_list, expected_result):
"""Testing if sanitizing input list (replacing invalid characters) works properly."""
actual_result = sanitize_input(input_list)
assert actual_result == expected_result | [
"def",
"test_sanitize_input",
"(",
"input_list",
",",
"expected_result",
")",
":",
"actual_result",
"=",
"sanitize_input",
"(",
"input_list",
")",
"assert",
"actual_result",
"==",
"expected_result"
] | [
224,
0
] | [
227,
43
] | python | en | ['en', 'en', 'en'] | True |
test_series_to_dict | (param_series, expected_result) | Testing if converting series to dict works correctly. | Testing if converting series to dict works correctly. | def test_series_to_dict(param_series, expected_result):
"""Testing if converting series to dict works correctly."""
actual_result = series_to_dict(param_series)
assert actual_result == expected_result | [
"def",
"test_series_to_dict",
"(",
"param_series",
",",
"expected_result",
")",
":",
"actual_result",
"=",
"series_to_dict",
"(",
"param_series",
")",
"assert",
"actual_result",
"==",
"expected_result"
] | [
262,
0
] | [
265,
43
] | python | en | ['en', 'en', 'en'] | True |
test_sort_strings | (input_string, expected_output) | Testing if sort_strings sorting works correctly. | Testing if sort_strings sorting works correctly. | def test_sort_strings(input_string, expected_output):
"""Testing if sort_strings sorting works correctly."""
assert sorted(input_string) != expected_output
actual_output = sort_strings(input_string)
assert actual_output == expected_output | [
"def",
"test_sort_strings",
"(",
"input_string",
",",
"expected_output",
")",
":",
"assert",
"sorted",
"(",
"input_string",
")",
"!=",
"expected_output",
"actual_output",
"=",
"sort_strings",
"(",
"input_string",
")",
"assert",
"actual_output",
"==",
"expected_output"... | [
276,
0
] | [
280,
43
] | python | en | ['en', 'en', 'en'] | True |
test_logxml_makedir | (testdir) | --junitxml should automatically create directories for the xml file | --junitxml should automatically create directories for the xml file | def test_logxml_makedir(testdir):
"""--junitxml should automatically create directories for the xml file"""
testdir.makepyfile("""
def test_pass():
pass
""")
result = testdir.runpytest("--junitxml=path/to/results.xml")
assert result.ret == 0
assert testdir.tmpdir.join("path/t... | [
"def",
"test_logxml_makedir",
"(",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n def test_pass():\n pass\n \"\"\"",
")",
"result",
"=",
"testdir",
".",
"runpytest",
"(",
"\"--junitxml=path/to/results.xml\"",
")",
"assert",
"result",
... | [
753,
0
] | [
761,
61
] | python | en | ['en', 'en', 'en'] | True |
test_logxml_check_isdir | (testdir) | Give an error if --junit-xml is a directory (#2089) | Give an error if --junit-xml is a directory (#2089) | def test_logxml_check_isdir(testdir):
"""Give an error if --junit-xml is a directory (#2089)"""
result = testdir.runpytest("--junit-xml=.")
result.stderr.fnmatch_lines(["*--junitxml must be a filename*"]) | [
"def",
"test_logxml_check_isdir",
"(",
"testdir",
")",
":",
"result",
"=",
"testdir",
".",
"runpytest",
"(",
"\"--junit-xml=.\"",
")",
"result",
".",
"stderr",
".",
"fnmatch_lines",
"(",
"[",
"\"*--junitxml must be a filename*\"",
"]",
")"
] | [
764,
0
] | [
767,
68
] | python | en | ['en', 'en', 'en'] | True |
test_random_report_log_xdist | (testdir) | xdist calls pytest_runtest_logreport as they are executed by the slaves,
with nodes from several nodes overlapping, so junitxml must cope with that
to produce correct reports. #1064
| xdist calls pytest_runtest_logreport as they are executed by the slaves,
with nodes from several nodes overlapping, so junitxml must cope with that
to produce correct reports. #1064
| def test_random_report_log_xdist(testdir):
"""xdist calls pytest_runtest_logreport as they are executed by the slaves,
with nodes from several nodes overlapping, so junitxml must cope with that
to produce correct reports. #1064
"""
pytest.importorskip('xdist')
testdir.makepyfile("""
impo... | [
"def",
"test_random_report_log_xdist",
"(",
"testdir",
")",
":",
"pytest",
".",
"importorskip",
"(",
"'xdist'",
")",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n import pytest, time\n @pytest.mark.parametrize('i', list(range(30)))\n def test_x(i):\n as... | [
902,
0
] | [
921,
35
] | python | en | ['en', 'en', 'en'] | True |
TestPython.test_assertion_binchars | (self, testdir) | this test did fail when the escaping wasnt strict | this test did fail when the escaping wasnt strict | def test_assertion_binchars(self, testdir):
"""this test did fail when the escaping wasnt strict"""
testdir.makepyfile("""
M1 = '\x01\x02\x03\x04'
M2 = '\x01\x02\x03\x05'
def test_str_compare():
assert M1 == M2
""")
result, dom = ... | [
"def",
"test_assertion_binchars",
"(",
"self",
",",
"testdir",
")",
":",
"testdir",
".",
"makepyfile",
"(",
"\"\"\"\n\n M1 = '\\x01\\x02\\x03\\x04'\n M2 = '\\x01\\x02\\x03\\x05'\n\n def test_str_compare():\n assert M1 == M2\n \"\"\""... | [
511,
4
] | [
522,
26
] | python | en | ['en', 'en', 'en'] | True |
ExtraExtension.extendMarkdown | (self, md, md_globals) | Register extension instances. | Register extension instances. | def extendMarkdown(self, md, md_globals):
""" Register extension instances. """
md.registerExtensions(extensions, self.config) | [
"def",
"extendMarkdown",
"(",
"self",
",",
"md",
",",
"md_globals",
")",
":",
"md",
".",
"registerExtensions",
"(",
"extensions",
",",
"self",
".",
"config",
")"
] | [
43,
4
] | [
45,
54
] | python | da | ['da', 'fr', 'en'] | False |
insort_right | (a, x, lo=0, hi=None) | Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the right of the rightmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
| Insert item x in list a, and keep it sorted assuming a is sorted. | def insort_right(a, x, lo=0, hi=None):
"""Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the right of the rightmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
"""
if lo < 0:
raise V... | [
"def",
"insort_right",
"(",
"a",
",",
"x",
",",
"lo",
"=",
"0",
",",
"hi",
"=",
"None",
")",
":",
"if",
"lo",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'lo must be non-negative'",
")",
"if",
"hi",
"is",
"None",
":",
"hi",
"=",
"len",
"(",
"a",
... | [
2,
0
] | [
19,
19
] | python | en | ['en', 'en', 'en'] | True |
bisect_right | (a, x, lo=0, hi=None) | Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e <= x, and all e in
a[i:] have e > x. So if x already appears in the list, a.insert(x) will
insert just after the rightmost x already there.
Optional args lo (default 0) and h... | Return the index where to insert item x in list a, assuming a is sorted. | def bisect_right(a, x, lo=0, hi=None):
"""Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e <= x, and all e in
a[i:] have e > x. So if x already appears in the list, a.insert(x) will
insert just after the rightmost x already ... | [
"def",
"bisect_right",
"(",
"a",
",",
"x",
",",
"lo",
"=",
"0",
",",
"hi",
"=",
"None",
")",
":",
"if",
"lo",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'lo must be non-negative'",
")",
"if",
"hi",
"is",
"None",
":",
"hi",
"=",
"len",
"(",
"a",
... | [
23,
0
] | [
42,
13
] | python | en | ['en', 'en', 'en'] | True |
insort_left | (a, x, lo=0, hi=None) | Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the left of the leftmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
| Insert item x in list a, and keep it sorted assuming a is sorted. | def insort_left(a, x, lo=0, hi=None):
"""Insert item x in list a, and keep it sorted assuming a is sorted.
If x is already in a, insert it to the left of the leftmost x.
Optional args lo (default 0) and hi (default len(a)) bound the
slice of a to be searched.
"""
if lo < 0:
raise Valu... | [
"def",
"insort_left",
"(",
"a",
",",
"x",
",",
"lo",
"=",
"0",
",",
"hi",
"=",
"None",
")",
":",
"if",
"lo",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'lo must be non-negative'",
")",
"if",
"hi",
"is",
"None",
":",
"hi",
"=",
"len",
"(",
"a",
... | [
46,
0
] | [
63,
19
] | python | en | ['en', 'en', 'en'] | True |
bisect_left | (a, x, lo=0, hi=None) | Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e < x, and all e in
a[i:] have e >= x. So if x already appears in the list, a.insert(x) will
insert just before the leftmost x already there.
Optional args lo (default 0) and h... | Return the index where to insert item x in list a, assuming a is sorted. | def bisect_left(a, x, lo=0, hi=None):
"""Return the index where to insert item x in list a, assuming a is sorted.
The return value i is such that all e in a[:i] have e < x, and all e in
a[i:] have e >= x. So if x already appears in the list, a.insert(x) will
insert just before the leftmost x already t... | [
"def",
"bisect_left",
"(",
"a",
",",
"x",
",",
"lo",
"=",
"0",
",",
"hi",
"=",
"None",
")",
":",
"if",
"lo",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"'lo must be non-negative'",
")",
"if",
"hi",
"is",
"None",
":",
"hi",
"=",
"len",
"(",
"a",
... | [
66,
0
] | [
85,
13
] | python | en | ['en', 'en', 'en'] | True |
queries_captured | (
include_savepoints: bool = False, keep_cache_warm: bool = False
) |
Allow a user to capture just the queries executed during
the with statement.
|
Allow a user to capture just the queries executed during
the with statement.
| def queries_captured(
include_savepoints: bool = False, keep_cache_warm: bool = False
) -> Generator[List[Dict[str, Union[str, bytes]]], None, None]:
"""
Allow a user to capture just the queries executed during
the with statement.
"""
queries: List[Dict[str, Union[str, bytes]]] = []
def wr... | [
"def",
"queries_captured",
"(",
"include_savepoints",
":",
"bool",
"=",
"False",
",",
"keep_cache_warm",
":",
"bool",
"=",
"False",
")",
"->",
"Generator",
"[",
"List",
"[",
"Dict",
"[",
"str",
",",
"Union",
"[",
"str",
",",
"bytes",
"]",
"]",
"]",
","... | [
173,
0
] | [
219,
21
] | python | en | ['en', 'error', 'th'] | False |
stdout_suppressed | () | Redirect stdout to /dev/null. | Redirect stdout to /dev/null. | def stdout_suppressed() -> Iterator[IO[str]]:
"""Redirect stdout to /dev/null."""
with open(os.devnull, "a") as devnull:
stdout, sys.stdout = sys.stdout, devnull
yield stdout
sys.stdout = stdout | [
"def",
"stdout_suppressed",
"(",
")",
"->",
"Iterator",
"[",
"IO",
"[",
"str",
"]",
"]",
":",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"\"a\"",
")",
"as",
"devnull",
":",
"stdout",
",",
"sys",
".",
"stdout",
"=",
"sys",
".",
"stdout",
",",
... | [
223,
0
] | [
229,
27
] | python | en | ['en', 'en', 'it'] | True |
_running_under_venv | () | Checks if sys.base_prefix and sys.prefix match.
This handles PEP 405 compliant virtual environments.
| Checks if sys.base_prefix and sys.prefix match. | def _running_under_venv():
# type: () -> bool
"""Checks if sys.base_prefix and sys.prefix match.
This handles PEP 405 compliant virtual environments.
"""
return sys.prefix != getattr(sys, "base_prefix", sys.prefix) | [
"def",
"_running_under_venv",
"(",
")",
":",
"# type: () -> bool",
"return",
"sys",
".",
"prefix",
"!=",
"getattr",
"(",
"sys",
",",
"\"base_prefix\"",
",",
"sys",
".",
"prefix",
")"
] | [
20,
0
] | [
26,
64
] | python | en | ['en', 'ht', 'en'] | True |
_running_under_regular_virtualenv | () | Checks if sys.real_prefix is set.
This handles virtual environments created with pypa's virtualenv.
| Checks if sys.real_prefix is set. | def _running_under_regular_virtualenv():
# type: () -> bool
"""Checks if sys.real_prefix is set.
This handles virtual environments created with pypa's virtualenv.
"""
# pypa/virtualenv case
return hasattr(sys, 'real_prefix') | [
"def",
"_running_under_regular_virtualenv",
"(",
")",
":",
"# type: () -> bool",
"# pypa/virtualenv case",
"return",
"hasattr",
"(",
"sys",
",",
"'real_prefix'",
")"
] | [
29,
0
] | [
36,
38
] | python | en | ['en', 'en', 'en'] | True |
running_under_virtualenv | () | Return True if we're running inside a virtualenv, False otherwise.
| Return True if we're running inside a virtualenv, False otherwise.
| def running_under_virtualenv():
# type: () -> bool
"""Return True if we're running inside a virtualenv, False otherwise.
"""
return _running_under_venv() or _running_under_regular_virtualenv() | [
"def",
"running_under_virtualenv",
"(",
")",
":",
"# type: () -> bool",
"return",
"_running_under_venv",
"(",
")",
"or",
"_running_under_regular_virtualenv",
"(",
")"
] | [
39,
0
] | [
43,
71
] | python | en | ['en', 'en', 'en'] | True |
_get_pyvenv_cfg_lines | () | Reads {sys.prefix}/pyvenv.cfg and returns its contents as list of lines
Returns None, if it could not read/access the file.
| Reads {sys.prefix}/pyvenv.cfg and returns its contents as list of lines | def _get_pyvenv_cfg_lines():
# type: () -> Optional[List[str]]
"""Reads {sys.prefix}/pyvenv.cfg and returns its contents as list of lines
Returns None, if it could not read/access the file.
"""
pyvenv_cfg_file = os.path.join(sys.prefix, 'pyvenv.cfg')
try:
# Although PEP 405 does not spe... | [
"def",
"_get_pyvenv_cfg_lines",
"(",
")",
":",
"# type: () -> Optional[List[str]]",
"pyvenv_cfg_file",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sys",
".",
"prefix",
",",
"'pyvenv.cfg'",
")",
"try",
":",
"# Although PEP 405 does not specify, the built-in venv module alwa... | [
46,
0
] | [
59,
19
] | python | en | ['en', 'en', 'en'] | True |
_no_global_under_venv | () | Check `{sys.prefix}/pyvenv.cfg` for system site-packages inclusion
PEP 405 specifies that when system site-packages are not supposed to be
visible from a virtual environment, `pyvenv.cfg` must contain the following
line:
include-system-site-packages = false
Additionally, log a warning if acce... | Check `{sys.prefix}/pyvenv.cfg` for system site-packages inclusion | def _no_global_under_venv():
# type: () -> bool
"""Check `{sys.prefix}/pyvenv.cfg` for system site-packages inclusion
PEP 405 specifies that when system site-packages are not supposed to be
visible from a virtual environment, `pyvenv.cfg` must contain the following
line:
include-system-sit... | [
"def",
"_no_global_under_venv",
"(",
")",
":",
"# type: () -> bool",
"cfg_lines",
"=",
"_get_pyvenv_cfg_lines",
"(",
")",
"if",
"cfg_lines",
"is",
"None",
":",
"# We're not in a \"sane\" venv, so assume there is no system",
"# site-packages access (since that's PEP 405's default st... | [
62,
0
] | [
89,
16
] | python | en | ['en', 'en', 'en'] | True |
_no_global_under_regular_virtualenv | () | Check if "no-global-site-packages.txt" exists beside site.py
This mirrors logic in pypa/virtualenv for determining whether system
site-packages are visible in the virtual environment.
| Check if "no-global-site-packages.txt" exists beside site.py | def _no_global_under_regular_virtualenv():
# type: () -> bool
"""Check if "no-global-site-packages.txt" exists beside site.py
This mirrors logic in pypa/virtualenv for determining whether system
site-packages are visible in the virtual environment.
"""
site_mod_dir = os.path.dirname(os.path.abs... | [
"def",
"_no_global_under_regular_virtualenv",
"(",
")",
":",
"# type: () -> bool",
"site_mod_dir",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"os",
".",
"path",
".",
"abspath",
"(",
"site",
".",
"__file__",
")",
")",
"no_global_site_packages_file",
"=",
"os",
... | [
92,
0
] | [
103,
55
] | python | en | ['en', 'en', 'en'] | True |
virtualenv_no_global | () | Returns a boolean, whether running in venv with no system site-packages.
| Returns a boolean, whether running in venv with no system site-packages.
| def virtualenv_no_global():
# type: () -> bool
"""Returns a boolean, whether running in venv with no system site-packages.
"""
# PEP 405 compliance needs to be checked first since virtualenv >=20 would
# return True for both checks, but is only able to use the PEP 405 config.
if _running_under_v... | [
"def",
"virtualenv_no_global",
"(",
")",
":",
"# type: () -> bool",
"# PEP 405 compliance needs to be checked first since virtualenv >=20 would",
"# return True for both checks, but is only able to use the PEP 405 config.",
"if",
"_running_under_venv",
"(",
")",
":",
"return",
"_no_globa... | [
106,
0
] | [
118,
16
] | python | en | ['en', 'en', 'en'] | True |
Binding.__init__ | (self, wsdl) |
@param wsdl: A wsdl.
@type wsdl: L{wsdl.Definitions}
| def __init__(self, wsdl):
"""
@param wsdl: A wsdl.
@type wsdl: L{wsdl.Definitions}
"""
self.wsdl = wsdl
self.multiref = MultiRef() | [
"def",
"__init__",
"(",
"self",
",",
"wsdl",
")",
":",
"self",
".",
"wsdl",
"=",
"wsdl",
"self",
".",
"multiref",
"=",
"MultiRef",
"(",
")"
] | [
59,
4
] | [
65,
34
] | python | en | ['en', 'error', 'th'] | False | |
Binding.unmarshaller | (self, typed=True) |
Get the appropriate XML decoder.
@return: Either the (basic|typed) unmarshaller.
@rtype: L{UmxTyped}
|
Get the appropriate XML decoder.
| def unmarshaller(self, typed=True):
"""
Get the appropriate XML decoder.
@return: Either the (basic|typed) unmarshaller.
@rtype: L{UmxTyped}
"""
if typed:
return UmxTyped(self.schema())
else:
return UmxBasic() | [
"def",
"unmarshaller",
"(",
"self",
",",
"typed",
"=",
"True",
")",
":",
"if",
"typed",
":",
"return",
"UmxTyped",
"(",
"self",
".",
"schema",
"(",
")",
")",
"else",
":",
"return",
"UmxBasic",
"(",
")"
] | [
73,
4
] | [
82,
29
] | python | en | ['en', 'error', 'th'] | False |
Binding.marshaller | (self) |
Get the appropriate XML encoder.
@return: An L{MxLiteral} marshaller.
@rtype: L{MxLiteral}
|
Get the appropriate XML encoder.
| def marshaller(self):
"""
Get the appropriate XML encoder.
@return: An L{MxLiteral} marshaller.
@rtype: L{MxLiteral}
"""
return MxLiteral(self.schema(), self.options().xstq) | [
"def",
"marshaller",
"(",
"self",
")",
":",
"return",
"MxLiteral",
"(",
"self",
".",
"schema",
"(",
")",
",",
"self",
".",
"options",
"(",
")",
".",
"xstq",
")"
] | [
84,
4
] | [
90,
60
] | python | en | ['en', 'error', 'th'] | False |
Binding.param_defs | (self, method) |
Get parameter definitions.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A servic emethod.
@type method: I{service.Method}
@return: A collection of parameter definitions
@rtype: [I{pdef},..]
|
Get parameter definitions.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
| def param_defs(self, method):
"""
Get parameter definitions.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A servic emethod.
@type method: I{service.Method}
@return: A collection of parameter definitions
@rtype: [I{pdef},..]
... | [
"def",
"param_defs",
"(",
"self",
",",
"method",
")",
":",
"raise",
"Exception",
",",
"'not implemented'"
] | [
92,
4
] | [
101,
42
] | python | en | ['en', 'error', 'th'] | False |
Binding.get_message | (self, method, args, kwargs) |
Get the soap message for the specified method, args and soapheaders.
This is the entry point for creating the outbound soap message.
@param method: The method being invoked.
@type method: I{service.Method}
@param args: A list of args for the method invoked.
@type args: l... |
Get the soap message for the specified method, args and soapheaders.
This is the entry point for creating the outbound soap message.
| def get_message(self, method, args, kwargs):
"""
Get the soap message for the specified method, args and soapheaders.
This is the entry point for creating the outbound soap message.
@param method: The method being invoked.
@type method: I{service.Method}
@param args: A li... | [
"def",
"get_message",
"(",
"self",
",",
"method",
",",
"args",
",",
"kwargs",
")",
":",
"content",
"=",
"self",
".",
"headercontent",
"(",
"method",
")",
"header",
"=",
"self",
".",
"header",
"(",
"content",
")",
"content",
"=",
"self",
".",
"bodyconte... | [
103,
4
] | [
127,
28
] | python | en | ['en', 'error', 'th'] | False |
Binding.get_reply | (self, method, reply) |
Process the I{reply} for the specified I{method} by sax parsing the I{reply}
and then unmarshalling into python object(s).
@param method: The name of the invoked method.
@type method: str
@param reply: The reply XML received after invoking the specified method.
@type rep... |
Process the I{reply} for the specified I{method} by sax parsing the I{reply}
and then unmarshalling into python object(s).
| def get_reply(self, method, reply):
"""
Process the I{reply} for the specified I{method} by sax parsing the I{reply}
and then unmarshalling into python object(s).
@param method: The name of the invoked method.
@type method: str
@param reply: The reply XML received after i... | [
"def",
"get_reply",
"(",
"self",
",",
"method",
",",
"reply",
")",
":",
"reply",
"=",
"self",
".",
"replyfilter",
"(",
"reply",
")",
"sax",
"=",
"Parser",
"(",
")",
"replyroot",
"=",
"sax",
".",
"parse",
"(",
"string",
"=",
"reply",
")",
"plugins",
... | [
129,
4
] | [
166,
32
] | python | en | ['en', 'error', 'th'] | False |
Binding.detect_fault | (self, body) |
Detect I{hidden} soapenv:Fault element in the soap body.
@param body: The soap envelope body.
@type body: L{Element}
@raise WebFault: When found.
|
Detect I{hidden} soapenv:Fault element in the soap body.
| def detect_fault(self, body):
"""
Detect I{hidden} soapenv:Fault element in the soap body.
@param body: The soap envelope body.
@type body: L{Element}
@raise WebFault: When found.
"""
fault = body.getChild('Fault', envns)
if fault is None:
retu... | [
"def",
"detect_fault",
"(",
"self",
",",
"body",
")",
":",
"fault",
"=",
"body",
".",
"getChild",
"(",
"'Fault'",
",",
"envns",
")",
"if",
"fault",
"is",
"None",
":",
"return",
"unmarshaller",
"=",
"self",
".",
"unmarshaller",
"(",
"False",
")",
"p",
... | [
168,
4
] | [
182,
19
] | python | en | ['en', 'error', 'th'] | False |
Binding.replylist | (self, rt, nodes) |
Construct a I{list} reply. This mehod is called when it has been detected
that the reply is a list.
@param rt: The return I{type}.
@type rt: L{suds.xsd.sxbase.SchemaObject}
@param nodes: A collection of XML nodes.
@type nodes: [L{Element},...]
@return: A list of... |
Construct a I{list} reply. This mehod is called when it has been detected
that the reply is a list.
| def replylist(self, rt, nodes):
"""
Construct a I{list} reply. This mehod is called when it has been detected
that the reply is a list.
@param rt: The return I{type}.
@type rt: L{suds.xsd.sxbase.SchemaObject}
@param nodes: A collection of XML nodes.
@type nodes: ... | [
"def",
"replylist",
"(",
"self",
",",
"rt",
",",
"nodes",
")",
":",
"result",
"=",
"[",
"]",
"resolved",
"=",
"rt",
".",
"resolve",
"(",
"nobuiltin",
"=",
"True",
")",
"unmarshaller",
"=",
"self",
".",
"unmarshaller",
"(",
")",
"for",
"node",
"in",
... | [
185,
4
] | [
202,
21
] | python | en | ['en', 'error', 'th'] | False |
Binding.replycomposite | (self, rtypes, nodes) |
Construct a I{composite} reply. This method is called when it has been
detected that the reply has multiple root nodes.
@param rtypes: A list of known return I{types}.
@type rtypes: [L{suds.xsd.sxbase.SchemaObject},...]
@param nodes: A collection of XML nodes.
@type nod... |
Construct a I{composite} reply. This method is called when it has been
detected that the reply has multiple root nodes.
| def replycomposite(self, rtypes, nodes):
"""
Construct a I{composite} reply. This method is called when it has been
detected that the reply has multiple root nodes.
@param rtypes: A list of known return I{types}.
@type rtypes: [L{suds.xsd.sxbase.SchemaObject},...]
@param... | [
"def",
"replycomposite",
"(",
"self",
",",
"rtypes",
",",
"nodes",
")",
":",
"dictionary",
"=",
"{",
"}",
"for",
"rt",
"in",
"rtypes",
":",
"dictionary",
"[",
"rt",
".",
"name",
"]",
"=",
"rt",
"unmarshaller",
"=",
"self",
".",
"unmarshaller",
"(",
"... | [
204,
4
] | [
243,
24
] | python | en | ['en', 'error', 'th'] | False |
Binding.get_fault | (self, reply) |
Extract the fault from the specified soap reply. If I{faults} is True, an
exception is raised. Otherwise, the I{unmarshalled} fault L{Object} is
returned. This method is called when the server raises a I{web fault}.
@param reply: A soap reply message.
@type reply: str
... |
Extract the fault from the specified soap reply. If I{faults} is True, an
exception is raised. Otherwise, the I{unmarshalled} fault L{Object} is
returned. This method is called when the server raises a I{web fault}.
| def get_fault(self, reply):
"""
Extract the fault from the specified soap reply. If I{faults} is True, an
exception is raised. Otherwise, the I{unmarshalled} fault L{Object} is
returned. This method is called when the server raises a I{web fault}.
@param reply: A soap reply me... | [
"def",
"get_fault",
"(",
"self",
",",
"reply",
")",
":",
"reply",
"=",
"self",
".",
"replyfilter",
"(",
"reply",
")",
"sax",
"=",
"Parser",
"(",
")",
"faultroot",
"=",
"sax",
".",
"parse",
"(",
"string",
"=",
"reply",
")",
"soapenv",
"=",
"faultroot"... | [
245,
4
] | [
265,
36
] | python | en | ['en', 'error', 'th'] | False |
Binding.mkparam | (self, method, pdef, object) |
Builds a parameter for the specified I{method} using the parameter
definition (pdef) and the specified value (object).
@param method: A method name.
@type method: str
@param pdef: A parameter definition.
@type pdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject})
@p... |
Builds a parameter for the specified I{method} using the parameter
definition (pdef) and the specified value (object).
| def mkparam(self, method, pdef, object):
"""
Builds a parameter for the specified I{method} using the parameter
definition (pdef) and the specified value (object).
@param method: A method name.
@type method: str
@param pdef: A parameter definition.
@type pdef: tup... | [
"def",
"mkparam",
"(",
"self",
",",
"method",
",",
"pdef",
",",
"object",
")",
":",
"marshaller",
"=",
"self",
".",
"marshaller",
"(",
")",
"content",
"=",
"Content",
"(",
"tag",
"=",
"pdef",
"[",
"0",
"]",
",",
"value",
"=",
"object",
",",
"type",... | [
267,
4
] | [
286,
42
] | python | en | ['en', 'error', 'th'] | False |
Binding.mkheader | (self, method, hdef, object) |
Builds a soapheader for the specified I{method} using the header
definition (hdef) and the specified value (object).
@param method: A method name.
@type method: str
@param hdef: A header definition.
@type hdef: tuple: (I{name}, L{xsd.sxbase.SchemaObject})
@param ... |
Builds a soapheader for the specified I{method} using the header
definition (hdef) and the specified value (object).
| def mkheader(self, method, hdef, object):
"""
Builds a soapheader for the specified I{method} using the header
definition (hdef) and the specified value (object).
@param method: A method name.
@type method: str
@param hdef: A header definition.
@type hdef: tuple: ... | [
"def",
"mkheader",
"(",
"self",
",",
"method",
",",
"hdef",
",",
"object",
")",
":",
"marshaller",
"=",
"self",
".",
"marshaller",
"(",
")",
"if",
"isinstance",
"(",
"object",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"tags",
"=",
"[",
"]",
... | [
288,
4
] | [
308,
42
] | python | en | ['en', 'error', 'th'] | False |
Binding.envelope | (self, header, body) |
Build the B{<Envelope/>} for an soap outbound message.
@param header: The soap message B{header}.
@type header: L{Element}
@param body: The soap message B{body}.
@type body: L{Element}
@return: The soap envelope containing the body and header.
@rtype: L{Element}
... |
Build the B{<Envelope/>} for an soap outbound message.
| def envelope(self, header, body):
"""
Build the B{<Envelope/>} for an soap outbound message.
@param header: The soap message B{header}.
@type header: L{Element}
@param body: The soap message B{body}.
@type body: L{Element}
@return: The soap envelope containing the... | [
"def",
"envelope",
"(",
"self",
",",
"header",
",",
"body",
")",
":",
"env",
"=",
"Element",
"(",
"'Envelope'",
",",
"ns",
"=",
"envns",
")",
"env",
".",
"addPrefix",
"(",
"Namespace",
".",
"xsins",
"[",
"0",
"]",
",",
"Namespace",
".",
"xsins",
"[... | [
310,
4
] | [
324,
18
] | python | en | ['en', 'error', 'th'] | False |
Binding.header | (self, content) |
Build the B{<Body/>} for an soap outbound message.
@param content: The header content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}
|
Build the B{<Body/>} for an soap outbound message.
| def header(self, content):
"""
Build the B{<Body/>} for an soap outbound message.
@param content: The header content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}
"""
header = Element('Header', ns=envns)
header.appe... | [
"def",
"header",
"(",
"self",
",",
"content",
")",
":",
"header",
"=",
"Element",
"(",
"'Header'",
",",
"ns",
"=",
"envns",
")",
"header",
".",
"append",
"(",
"content",
")",
"return",
"header"
] | [
326,
4
] | [
336,
21
] | python | en | ['en', 'error', 'th'] | False |
Binding.bodycontent | (self, method, args, kwargs) |
Get the content for the soap I{body} node.
@param method: A service method.
@type method: I{service.Method}
@param args: method parameter values
@type args: list
@param kwargs: Named (keyword) args for the method invoked.
@type kwargs: dict
@return: The x... |
Get the content for the soap I{body} node.
| def bodycontent(self, method, args, kwargs):
"""
Get the content for the soap I{body} node.
@param method: A service method.
@type method: I{service.Method}
@param args: method parameter values
@type args: list
@param kwargs: Named (keyword) args for the method in... | [
"def",
"bodycontent",
"(",
"self",
",",
"method",
",",
"args",
",",
"kwargs",
")",
":",
"raise",
"Exception",
",",
"'not implemented'"
] | [
338,
4
] | [
350,
42
] | python | en | ['en', 'error', 'th'] | False |
Binding.headercontent | (self, method) |
Get the content for the soap I{Header} node.
@param method: A service method.
@type method: I{service.Method}
@return: The xml content for the <body/>
@rtype: [L{Element},..]
|
Get the content for the soap I{Header} node.
| def headercontent(self, method):
"""
Get the content for the soap I{Header} node.
@param method: A service method.
@type method: I{service.Method}
@return: The xml content for the <body/>
@rtype: [L{Element},..]
"""
n = 0
content = []
wsse ... | [
"def",
"headercontent",
"(",
"self",
",",
"method",
")",
":",
"n",
"=",
"0",
"content",
"=",
"[",
"]",
"wsse",
"=",
"self",
".",
"options",
"(",
")",
".",
"wsse",
"if",
"wsse",
"is",
"not",
"None",
":",
"content",
".",
"append",
"(",
"wsse",
".",... | [
352,
4
] | [
391,
22
] | python | en | ['en', 'error', 'th'] | False |
Binding.replycontent | (self, method, body) |
Get the reply body content.
@param method: A service method.
@type method: I{service.Method}
@param body: The soap body
@type body: L{Element}
@return: the body content
@rtype: [L{Element},...]
|
Get the reply body content.
| def replycontent(self, method, body):
"""
Get the reply body content.
@param method: A service method.
@type method: I{service.Method}
@param body: The soap body
@type body: L{Element}
@return: the body content
@rtype: [L{Element},...]
"""
... | [
"def",
"replycontent",
"(",
"self",
",",
"method",
",",
"body",
")",
":",
"raise",
"Exception",
",",
"'not implemented'"
] | [
393,
4
] | [
403,
42
] | python | en | ['en', 'error', 'th'] | False |
Binding.body | (self, content) |
Build the B{<Body/>} for an soap outbound message.
@param content: The body content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}
|
Build the B{<Body/>} for an soap outbound message.
| def body(self, content):
"""
Build the B{<Body/>} for an soap outbound message.
@param content: The body content.
@type content: L{Element}
@return: the soap body fragment.
@rtype: L{Element}
"""
body = Element('Body', ns=envns)
body.append(content... | [
"def",
"body",
"(",
"self",
",",
"content",
")",
":",
"body",
"=",
"Element",
"(",
"'Body'",
",",
"ns",
"=",
"envns",
")",
"body",
".",
"append",
"(",
"content",
")",
"return",
"body"
] | [
405,
4
] | [
415,
19
] | python | en | ['en', 'error', 'th'] | False |
Binding.bodypart_types | (self, method, input=True) |
Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A service method.
@type method: I{service.Method}
@param input: Defines input/output message.
@type input: boolean... |
Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
| def bodypart_types(self, method, input=True):
"""
Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A service method.
@type method: I{service.Method}
@param input: D... | [
"def",
"bodypart_types",
"(",
"self",
",",
"method",
",",
"input",
"=",
"True",
")",
":",
"result",
"=",
"[",
"]",
"if",
"input",
":",
"parts",
"=",
"method",
".",
"soap",
".",
"input",
".",
"body",
".",
"parts",
"else",
":",
"parts",
"=",
"method"... | [
417,
4
] | [
450,
21
] | python | en | ['en', 'error', 'th'] | False |
Binding.headpart_types | (self, method, input=True) |
Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A service method.
@type method: I{service.Method}
@param input: Defines input/output message.
@type input: boolean... |
Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
| def headpart_types(self, method, input=True):
"""
Get a list of I{parameter definitions} (pdef) defined for the specified method.
Each I{pdef} is a tuple (I{name}, L{xsd.sxbase.SchemaObject})
@param method: A service method.
@type method: I{service.Method}
@param input: D... | [
"def",
"headpart_types",
"(",
"self",
",",
"method",
",",
"input",
"=",
"True",
")",
":",
"result",
"=",
"[",
"]",
"if",
"input",
":",
"headers",
"=",
"method",
".",
"soap",
".",
"input",
".",
"headers",
"else",
":",
"headers",
"=",
"method",
".",
... | [
452,
4
] | [
486,
21
] | python | en | ['en', 'error', 'th'] | False |
Binding.returned_types | (self, method) |
Get the L{xsd.sxbase.SchemaObject} returned by the I{method}.
@param method: A service method.
@type method: I{service.Method}
@return: The name of the type return by the method.
@rtype: [I{rtype},..]
|
Get the L{xsd.sxbase.SchemaObject} returned by the I{method}.
| def returned_types(self, method):
"""
Get the L{xsd.sxbase.SchemaObject} returned by the I{method}.
@param method: A service method.
@type method: I{service.Method}
@return: The name of the type return by the method.
@rtype: [I{rtype},..]
"""
result = []
... | [
"def",
"returned_types",
"(",
"self",
",",
"method",
")",
":",
"result",
"=",
"[",
"]",
"for",
"rt",
"in",
"self",
".",
"bodypart_types",
"(",
"method",
",",
"input",
"=",
"False",
")",
":",
"result",
".",
"append",
"(",
"rt",
")",
"return",
"result"... | [
488,
4
] | [
499,
21
] | python | en | ['en', 'error', 'th'] | False |
PartElement.__init__ | (self, name, resolved) |
@param name: The part name.
@type name: str
@param resolved: The part type.
@type resolved: L{suds.xsd.sxbase.SchemaObject}
| def __init__(self, name, resolved):
"""
@param name: The part name.
@type name: str
@param resolved: The part type.
@type resolved: L{suds.xsd.sxbase.SchemaObject}
"""
root = Element('element', ns=Namespace.xsdns)
SchemaElement.__init__(self, resolved.sche... | [
"def",
"__init__",
"(",
"self",
",",
"name",
",",
"resolved",
")",
":",
"root",
"=",
"Element",
"(",
"'element'",
",",
"ns",
"=",
"Namespace",
".",
"xsdns",
")",
"SchemaElement",
".",
"__init__",
"(",
"self",
",",
"resolved",
".",
"schema",
",",
"root"... | [
510,
4
] | [
521,
35
] | python | en | ['en', 'error', 'th'] | False | |
_xml_escape | (data) | Escape &, <, >, ", ', etc. in a string of data. | Escape &, <, >, ", ', etc. in a string of data. | def _xml_escape(data):
"""Escape &, <, >, ", ', etc. in a string of data."""
# ampersand must be replaced first
from_symbols = '&><"\''
to_symbols = ('&'+s+';' for s in "amp gt lt quot apos".split())
for from_,to_ in zip(from_symbols, to_symbols):
data = data.replace(from_, to_)
return ... | [
"def",
"_xml_escape",
"(",
"data",
")",
":",
"# ampersand must be replaced first",
"from_symbols",
"=",
"'&><\"\\''",
"to_symbols",
"=",
"(",
"'&'",
"+",
"s",
"+",
"';'",
"for",
"s",
"in",
"\"amp gt lt quot apos\"",
".",
"split",
"(",
")",
")",
"for",
"from_",... | [
184,
0
] | [
192,
15
] | python | en | ['en', 'en', 'en'] | True |
col | (loc,strg) | Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
on p... | Returns current column within a string, counting newlines as line separators.
The first column is number 1. | def col (loc,strg):
"""Returns current column within a string, counting newlines as line separators.
The first column is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseString>} f... | [
"def",
"col",
"(",
"loc",
",",
"strg",
")",
":",
"s",
"=",
"strg",
"return",
"1",
"if",
"0",
"<",
"loc",
"<",
"len",
"(",
"s",
")",
"and",
"s",
"[",
"loc",
"-",
"1",
"]",
"==",
"'\\n'",
"else",
"loc",
"-",
"s",
".",
"rfind",
"(",
"\"\\n\"",... | [
967,
0
] | [
978,
82
] | python | en | ['en', 'en', 'en'] | True |
lineno | (loc,strg) | Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseString>} for more information
o... | Returns current line number within a string, counting newlines as line separators.
The first line is number 1. | def lineno(loc,strg):
"""Returns current line number within a string, counting newlines as line separators.
The first line is number 1.
Note: the default parsing behavior is to expand tabs in the input string
before starting the parsing process. See L{I{ParserElement.parseString}<ParserElement.parseStrin... | [
"def",
"lineno",
"(",
"loc",
",",
"strg",
")",
":",
"return",
"strg",
".",
"count",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"+",
"1"
] | [
980,
0
] | [
990,
37
] | python | en | ['en', 'en', 'en'] | True |
line | ( loc, strg ) | Returns the line of text containing loc within a string, counting newlines as line separators.
| Returns the line of text containing loc within a string, counting newlines as line separators.
| def line( loc, strg ):
"""Returns the line of text containing loc within a string, counting newlines as line separators.
"""
lastCR = strg.rfind("\n", 0, loc)
nextCR = strg.find("\n", loc)
if nextCR >= 0:
return strg[lastCR+1:nextCR]
else:
return strg[lastCR+1:] | [
"def",
"line",
"(",
"loc",
",",
"strg",
")",
":",
"lastCR",
"=",
"strg",
".",
"rfind",
"(",
"\"\\n\"",
",",
"0",
",",
"loc",
")",
"nextCR",
"=",
"strg",
".",
"find",
"(",
"\"\\n\"",
",",
"loc",
")",
"if",
"nextCR",
">=",
"0",
":",
"return",
"st... | [
992,
0
] | [
1000,
30
] | python | en | ['en', 'en', 'en'] | True |
nullDebugAction | (*args) | Do-nothing' debug action, to suppress debugging output during parsing. | Do-nothing' debug action, to suppress debugging output during parsing. | def nullDebugAction(*args):
"""'Do-nothing' debug action, to suppress debugging output during parsing."""
pass | [
"def",
"nullDebugAction",
"(",
"*",
"args",
")",
":",
"pass"
] | [
1011,
0
] | [
1013,
8
] | python | en | ['en', 'jv', 'en'] | True |
ParseBaseException._from_exception | (cls, pe) |
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
|
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
| def _from_exception(cls, pe):
"""
internal factory method to simplify creating one type of ParseException
from another - avoids having __init__ signature conflicts among subclasses
"""
return cls(pe.pstr, pe.loc, pe.msg, pe.parserElement) | [
"def",
"_from_exception",
"(",
"cls",
",",
"pe",
")",
":",
"return",
"cls",
"(",
"pe",
".",
"pstr",
",",
"pe",
".",
"loc",
",",
"pe",
".",
"msg",
",",
"pe",
".",
"parserElement",
")"
] | [
220,
4
] | [
225,
61
] | python | en | ['en', 'error', 'th'] | False |
ParseBaseException.__getattr__ | ( self, aname ) | supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
| def __getattr__( self, aname ):
"""supported attributes by name are:
- lineno - returns the line number of the exception text
- col - returns the column number of the exception text
- line - returns the line containing the exception text
"""
if( aname == "line... | [
"def",
"__getattr__",
"(",
"self",
",",
"aname",
")",
":",
"if",
"(",
"aname",
"==",
"\"lineno\"",
")",
":",
"return",
"lineno",
"(",
"self",
".",
"loc",
",",
"self",
".",
"pstr",
")",
"elif",
"(",
"aname",
"in",
"(",
"\"col\"",
",",
"\"column\"",
... | [
227,
4
] | [
240,
39
] | python | en | ['en', 'en', 'en'] | True |
ParseBaseException.markInputline | ( self, markerString = ">!<" ) | Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
| def markInputline( self, markerString = ">!<" ):
"""Extracts the exception line from the input string, and marks
the location of the exception with a special symbol.
"""
line_str = self.line
line_column = self.column - 1
if markerString:
line_str = "".join(... | [
"def",
"markInputline",
"(",
"self",
",",
"markerString",
"=",
"\">!<\"",
")",
":",
"line_str",
"=",
"self",
".",
"line",
"line_column",
"=",
"self",
".",
"column",
"-",
"1",
"if",
"markerString",
":",
"line_str",
"=",
"\"\"",
".",
"join",
"(",
"(",
"l... | [
247,
4
] | [
256,
31
] | python | en | ['en', 'en', 'en'] | True |
ParseResults.haskeys | ( self ) | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names. | def haskeys( self ):
"""Since keys() returns an iterator, this method is helpful in bypassing
code that looks for the existence of any defined results names."""
return bool(self.__tokdict) | [
"def",
"haskeys",
"(",
"self",
")",
":",
"return",
"bool",
"(",
"self",
".",
"__tokdict",
")"
] | [
505,
4
] | [
508,
35
] | python | en | ['en', 'en', 'en'] | True |
ParseResults.pop | ( self, *args, **kwargs) |
Removes and returns item at specified index (default=C{last}).
Supports both C{list} and C{dict} semantics for C{pop()}. If passed no
argument or an integer argument, it will use C{list} semantics
and pop tokens from the list of parsed tokens. If passed a
non-integer argument (... |
Removes and returns item at specified index (default=C{last}).
Supports both C{list} and C{dict} semantics for C{pop()}. If passed no
argument or an integer argument, it will use C{list} semantics
and pop tokens from the list of parsed tokens. If passed a
non-integer argument (... | def pop( self, *args, **kwargs):
"""
Removes and returns item at specified index (default=C{last}).
Supports both C{list} and C{dict} semantics for C{pop()}. If passed no
argument or an integer argument, it will use C{list} semantics
and pop tokens from the list of parsed tokens.... | [
"def",
"pop",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
":",
"args",
"=",
"[",
"-",
"1",
"]",
"for",
"k",
",",
"v",
"in",
"kwargs",
".",
"items",
"(",
")",
":",
"if",
"k",
"==",
"'default'",
":",... | [
510,
4
] | [
560,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.get | (self, key, defaultValue=None) |
Returns named result matching the given key, or if there is no
such name, then returns the given C{defaultValue} or C{None} if no
C{defaultValue} is specified.
Similar to C{dict.get()}.
Example::
integer = Word(nums)
date_str = integer("year") +... |
Returns named result matching the given key, or if there is no
such name, then returns the given C{defaultValue} or C{None} if no
C{defaultValue} is specified. | def get(self, key, defaultValue=None):
"""
Returns named result matching the given key, or if there is no
such name, then returns the given C{defaultValue} or C{None} if no
C{defaultValue} is specified.
Similar to C{dict.get()}.
Example::
integer = W... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"defaultValue",
"=",
"None",
")",
":",
"if",
"key",
"in",
"self",
":",
"return",
"self",
"[",
"key",
"]",
"else",
":",
"return",
"defaultValue"
] | [
562,
4
] | [
582,
31
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.insert | ( self, index, insStr ) |
Inserts new element at location index in the list of parsed tokens.
Similar to C{list.insert()}.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to insert the parse location in the front of the pars... |
Inserts new element at location index in the list of parsed tokens.
Similar to C{list.insert()}. | def insert( self, index, insStr ):
"""
Inserts new element at location index in the list of parsed tokens.
Similar to C{list.insert()}.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to inse... | [
"def",
"insert",
"(",
"self",
",",
"index",
",",
"insStr",
")",
":",
"self",
".",
"__toklist",
".",
"insert",
"(",
"index",
",",
"insStr",
")",
"# fixup indices in token dictionary",
"for",
"name",
",",
"occurrences",
"in",
"self",
".",
"__tokdict",
".",
"... | [
584,
4
] | [
602,
94
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.append | ( self, item ) |
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to the end
def append_sum(tok... |
Add single element to end of ParseResults list of elements. | def append( self, item ):
"""
Add single element to end of ParseResults list of elements.
Example::
print(OneOrMore(Word(nums)).parseString("0 123 321")) # -> ['0', '123', '321']
# use a parse action to compute the sum of the parsed integers, and add it to t... | [
"def",
"append",
"(",
"self",
",",
"item",
")",
":",
"self",
".",
"__toklist",
".",
"append",
"(",
"item",
")"
] | [
604,
4
] | [
616,
35
] | python | en | ['en', 'error', 'th'] | False |
ParseResults.extend | ( self, itemseq ) |
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrome(tokens):
tokens.extend... |
Add sequence of elements to end of ParseResults list of elements. | def extend( self, itemseq ):
"""
Add sequence of elements to end of ParseResults list of elements.
Example::
patt = OneOrMore(Word(alphas))
# use a parse action to append the reverse of the matched strings, to make a palindrome
def make_palindrom... | [
"def",
"extend",
"(",
"self",
",",
"itemseq",
")",
":",
"if",
"isinstance",
"(",
"itemseq",
",",
"ParseResults",
")",
":",
"self",
"+=",
"itemseq",
"else",
":",
"self",
".",
"__toklist",
".",
"extend",
"(",
"itemseq",
")"
] | [
618,
4
] | [
634,
42
] | 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.