repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens listlengths 20 707 | docstring stringlengths 3 17.3k | docstring_tokens listlengths 3 222 | sha stringlengths 40 40 | url stringlengths 87 242 | partition stringclasses 1
value | idx int64 0 252k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser._example_from_definition | def _example_from_definition(self, prop_spec):
"""Get an example from a property specification linked to a definition.
Args:
prop_spec: specification of the property you want an example of.
Returns:
An example.
"""
# Get value from definition
def... | python | def _example_from_definition(self, prop_spec):
"""Get an example from a property specification linked to a definition.
Args:
prop_spec: specification of the property you want an example of.
Returns:
An example.
"""
# Get value from definition
def... | [
"def",
"_example_from_definition",
"(",
"self",
",",
"prop_spec",
")",
":",
"# Get value from definition",
"definition_name",
"=",
"self",
".",
"get_definition_name_from_ref",
"(",
"prop_spec",
"[",
"'$ref'",
"]",
")",
"if",
"self",
".",
"build_one_definition_example",
... | Get an example from a property specification linked to a definition.
Args:
prop_spec: specification of the property you want an example of.
Returns:
An example. | [
"Get",
"an",
"example",
"from",
"a",
"property",
"specification",
"linked",
"to",
"a",
"definition",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L332-L349 | train | 30,000 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser._example_from_complex_def | def _example_from_complex_def(self, prop_spec):
"""Get an example from a property specification.
In case there is no "type" key in the root of the dictionary.
Args:
prop_spec: property specification you want an example of.
Returns:
An example.
"""
... | python | def _example_from_complex_def(self, prop_spec):
"""Get an example from a property specification.
In case there is no "type" key in the root of the dictionary.
Args:
prop_spec: property specification you want an example of.
Returns:
An example.
"""
... | [
"def",
"_example_from_complex_def",
"(",
"self",
",",
"prop_spec",
")",
":",
"if",
"'schema'",
"not",
"in",
"prop_spec",
":",
"return",
"[",
"{",
"}",
"]",
"elif",
"'type'",
"not",
"in",
"prop_spec",
"[",
"'schema'",
"]",
":",
"definition_name",
"=",
"self... | Get an example from a property specification.
In case there is no "type" key in the root of the dictionary.
Args:
prop_spec: property specification you want an example of.
Returns:
An example. | [
"Get",
"an",
"example",
"from",
"a",
"property",
"specification",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L351-L380 | train | 30,001 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser._example_from_array_spec | def _example_from_array_spec(self, prop_spec):
"""Get an example from a property specification of an array.
Args:
prop_spec: property specification you want an example of.
Returns:
An example array.
"""
# if items is a list, then each item has its own sp... | python | def _example_from_array_spec(self, prop_spec):
"""Get an example from a property specification of an array.
Args:
prop_spec: property specification you want an example of.
Returns:
An example array.
"""
# if items is a list, then each item has its own sp... | [
"def",
"_example_from_array_spec",
"(",
"self",
",",
"prop_spec",
")",
":",
"# if items is a list, then each item has its own spec",
"if",
"isinstance",
"(",
"prop_spec",
"[",
"'items'",
"]",
",",
"list",
")",
":",
"return",
"[",
"self",
".",
"get_example_from_prop_sp... | Get an example from a property specification of an array.
Args:
prop_spec: property specification you want an example of.
Returns:
An example array. | [
"Get",
"an",
"example",
"from",
"a",
"property",
"specification",
"of",
"an",
"array",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L382-L429 | train | 30,002 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.get_dict_definition | def get_dict_definition(self, dict, get_list=False):
"""Get the definition name of the given dict.
Args:
dict: dict to test.
get_list: if set to true, return a list of definition that match the body.
if False, only return the first.
Returns:
... | python | def get_dict_definition(self, dict, get_list=False):
"""Get the definition name of the given dict.
Args:
dict: dict to test.
get_list: if set to true, return a list of definition that match the body.
if False, only return the first.
Returns:
... | [
"def",
"get_dict_definition",
"(",
"self",
",",
"dict",
",",
"get_list",
"=",
"False",
")",
":",
"list_def_candidate",
"=",
"[",
"]",
"for",
"definition_name",
"in",
"self",
".",
"specification",
"[",
"'definitions'",
"]",
".",
"keys",
"(",
")",
":",
"if",... | Get the definition name of the given dict.
Args:
dict: dict to test.
get_list: if set to true, return a list of definition that match the body.
if False, only return the first.
Returns:
The definition name or None if the dict does not match any... | [
"Get",
"the",
"definition",
"name",
"of",
"the",
"given",
"dict",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L431-L451 | train | 30,003 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.validate_additional_properties | def validate_additional_properties(self, valid_response, response):
"""Validates additional properties. In additional properties, we only
need to compare the values of the dict, not the keys
Args:
valid_response: An example response (for example generated in
... | python | def validate_additional_properties(self, valid_response, response):
"""Validates additional properties. In additional properties, we only
need to compare the values of the dict, not the keys
Args:
valid_response: An example response (for example generated in
... | [
"def",
"validate_additional_properties",
"(",
"self",
",",
"valid_response",
",",
"response",
")",
":",
"assert",
"isinstance",
"(",
"valid_response",
",",
"dict",
")",
"assert",
"isinstance",
"(",
"response",
",",
"dict",
")",
"# the type of the value of the first ke... | Validates additional properties. In additional properties, we only
need to compare the values of the dict, not the keys
Args:
valid_response: An example response (for example generated in
_get_example_from_properties(self, spec))
Ty... | [
"Validates",
"additional",
"properties",
".",
"In",
"additional",
"properties",
"we",
"only",
"need",
"to",
"compare",
"the",
"values",
"of",
"the",
"dict",
"not",
"the",
"keys"
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L453-L500 | train | 30,004 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.validate_definition | def validate_definition(self, definition_name, dict_to_test, definition=None):
"""Validate the given dict according to the given definition.
Args:
definition_name: name of the the definition.
dict_to_test: dict to test.
Returns:
True if the given dict match ... | python | def validate_definition(self, definition_name, dict_to_test, definition=None):
"""Validate the given dict according to the given definition.
Args:
definition_name: name of the the definition.
dict_to_test: dict to test.
Returns:
True if the given dict match ... | [
"def",
"validate_definition",
"(",
"self",
",",
"definition_name",
",",
"dict_to_test",
",",
"definition",
"=",
"None",
")",
":",
"if",
"(",
"definition_name",
"not",
"in",
"self",
".",
"specification",
"[",
"'definitions'",
"]",
".",
"keys",
"(",
")",
"and"... | Validate the given dict according to the given definition.
Args:
definition_name: name of the the definition.
dict_to_test: dict to test.
Returns:
True if the given dict match the definition, False otherwise. | [
"Validate",
"the",
"given",
"dict",
"according",
"to",
"the",
"given",
"definition",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L502-L533 | train | 30,005 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser._validate_type | def _validate_type(self, properties_spec, value):
"""Validate the given value with the given property spec.
Args:
properties_dict: specification of the property to check (From definition not route).
value: value to check.
Returns:
True if the value is valid ... | python | def _validate_type(self, properties_spec, value):
"""Validate the given value with the given property spec.
Args:
properties_dict: specification of the property to check (From definition not route).
value: value to check.
Returns:
True if the value is valid ... | [
"def",
"_validate_type",
"(",
"self",
",",
"properties_spec",
",",
"value",
")",
":",
"if",
"'type'",
"not",
"in",
"properties_spec",
".",
"keys",
"(",
")",
":",
"# Validate sub definition",
"def_name",
"=",
"self",
".",
"get_definition_name_from_ref",
"(",
"pro... | Validate the given value with the given property spec.
Args:
properties_dict: specification of the property to check (From definition not route).
value: value to check.
Returns:
True if the value is valid for the given spec. | [
"Validate",
"the",
"given",
"value",
"with",
"the",
"given",
"property",
"spec",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L535-L569 | train | 30,006 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.get_paths_data | def get_paths_data(self):
"""Get data for each paths in the swagger specification.
Get also the list of operationId.
"""
for path, path_spec in self.specification['paths'].items():
path = u'{0}{1}'.format(self.base_path, path)
self.paths[path] = {}
#... | python | def get_paths_data(self):
"""Get data for each paths in the swagger specification.
Get also the list of operationId.
"""
for path, path_spec in self.specification['paths'].items():
path = u'{0}{1}'.format(self.base_path, path)
self.paths[path] = {}
#... | [
"def",
"get_paths_data",
"(",
"self",
")",
":",
"for",
"path",
",",
"path_spec",
"in",
"self",
".",
"specification",
"[",
"'paths'",
"]",
".",
"items",
"(",
")",
":",
"path",
"=",
"u'{0}{1}'",
".",
"format",
"(",
"self",
".",
"base_path",
",",
"path",
... | Get data for each paths in the swagger specification.
Get also the list of operationId. | [
"Get",
"data",
"for",
"each",
"paths",
"in",
"the",
"swagger",
"specification",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L571-L614 | train | 30,007 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser._add_parameters | def _add_parameters(self, parameter_map, parameter_list):
"""Populates the given parameter map with the list of parameters provided, resolving any reference objects encountered.
Args:
parameter_map: mapping from parameter names to parameter objects
parameter_list: list of either... | python | def _add_parameters(self, parameter_map, parameter_list):
"""Populates the given parameter map with the list of parameters provided, resolving any reference objects encountered.
Args:
parameter_map: mapping from parameter names to parameter objects
parameter_list: list of either... | [
"def",
"_add_parameters",
"(",
"self",
",",
"parameter_map",
",",
"parameter_list",
")",
":",
"for",
"parameter",
"in",
"parameter_list",
":",
"if",
"parameter",
".",
"get",
"(",
"'$ref'",
")",
":",
"# expand parameter from $ref if not specified inline",
"parameter",
... | Populates the given parameter map with the list of parameters provided, resolving any reference objects encountered.
Args:
parameter_map: mapping from parameter names to parameter objects
parameter_list: list of either parameter objects or reference objects | [
"Populates",
"the",
"given",
"parameter",
"map",
"with",
"the",
"list",
"of",
"parameters",
"provided",
"resolving",
"any",
"reference",
"objects",
"encountered",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L616-L627 | train | 30,008 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.get_path_spec | def get_path_spec(self, path, action=None):
"""Get the specification matching with the given path.
Args:
path: path we want the specification.
action: get the specification for the given action.
Returns:
A tuple with the base name of the path and the specifi... | python | def get_path_spec(self, path, action=None):
"""Get the specification matching with the given path.
Args:
path: path we want the specification.
action: get the specification for the given action.
Returns:
A tuple with the base name of the path and the specifi... | [
"def",
"get_path_spec",
"(",
"self",
",",
"path",
",",
"action",
"=",
"None",
")",
":",
"# Get the specification of the given path",
"path_spec",
"=",
"None",
"path_name",
"=",
"None",
"for",
"base_path",
"in",
"self",
".",
"paths",
".",
"keys",
"(",
")",
":... | Get the specification matching with the given path.
Args:
path: path we want the specification.
action: get the specification for the given action.
Returns:
A tuple with the base name of the path and the specification.
Or (None, None) if no specification... | [
"Get",
"the",
"specification",
"matching",
"with",
"the",
"given",
"path",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L643-L677 | train | 30,009 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.validate_request | def validate_request(self, path, action, body=None, query=None):
"""Check if the given request is valid.
Validates the body and the query
# Rules to validate the BODY:
# Let's limit this to mime types that either contain 'text' or 'json'
# 1. if body is None, there m... | python | def validate_request(self, path, action, body=None, query=None):
"""Check if the given request is valid.
Validates the body and the query
# Rules to validate the BODY:
# Let's limit this to mime types that either contain 'text' or 'json'
# 1. if body is None, there m... | [
"def",
"validate_request",
"(",
"self",
",",
"path",
",",
"action",
",",
"body",
"=",
"None",
",",
"query",
"=",
"None",
")",
":",
"path_name",
",",
"path_spec",
"=",
"self",
".",
"get_path_spec",
"(",
"path",
")",
"if",
"path_spec",
"is",
"None",
":",... | Check if the given request is valid.
Validates the body and the query
# Rules to validate the BODY:
# Let's limit this to mime types that either contain 'text' or 'json'
# 1. if body is None, there must not be any required parameters in
# the given schema
... | [
"Check",
"if",
"the",
"given",
"request",
"is",
"valid",
".",
"Validates",
"the",
"body",
"and",
"the",
"query"
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L679-L744 | train | 30,010 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser._validate_query_parameters | def _validate_query_parameters(self, query, action_spec):
"""Check the query parameter for the action specification.
Args:
query: query parameter to check.
action_spec: specification of the action.
Returns:
True if the query is valid.
"""
pro... | python | def _validate_query_parameters(self, query, action_spec):
"""Check the query parameter for the action specification.
Args:
query: query parameter to check.
action_spec: specification of the action.
Returns:
True if the query is valid.
"""
pro... | [
"def",
"_validate_query_parameters",
"(",
"self",
",",
"query",
",",
"action_spec",
")",
":",
"processed_params",
"=",
"[",
"]",
"for",
"param_name",
",",
"param_value",
"in",
"query",
".",
"items",
"(",
")",
":",
"if",
"param_name",
"in",
"action_spec",
"["... | Check the query parameter for the action specification.
Args:
query: query parameter to check.
action_spec: specification of the action.
Returns:
True if the query is valid. | [
"Check",
"the",
"query",
"parameter",
"for",
"the",
"action",
"specification",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L746-L777 | train | 30,011 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser._validate_body_parameters | def _validate_body_parameters(self, body, action_spec):
"""Check the body parameter for the action specification.
Args:
body: body parameter to check.
action_spec: specification of the action.
Returns:
True if the body is valid.
A string containi... | python | def _validate_body_parameters(self, body, action_spec):
"""Check the body parameter for the action specification.
Args:
body: body parameter to check.
action_spec: specification of the action.
Returns:
True if the body is valid.
A string containi... | [
"def",
"_validate_body_parameters",
"(",
"self",
",",
"body",
",",
"action_spec",
")",
":",
"processed_params",
"=",
"[",
"]",
"for",
"param_name",
",",
"param_spec",
"in",
"action_spec",
"[",
"'parameters'",
"]",
".",
"items",
"(",
")",
":",
"if",
"param_sp... | Check the body parameter for the action specification.
Args:
body: body parameter to check.
action_spec: specification of the action.
Returns:
True if the body is valid.
A string containing an error msg in case the body did not validate,
othe... | [
"Check",
"the",
"body",
"parameter",
"for",
"the",
"action",
"specification",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L779-L824 | train | 30,012 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.get_response_example | def get_response_example(self, resp_spec):
"""Get a response example from a response spec.
"""
if 'schema' in resp_spec.keys():
if '$ref' in resp_spec['schema']: # Standard definition
definition_name = self.get_definition_name_from_ref(resp_spec['schema']['$ref'])
... | python | def get_response_example(self, resp_spec):
"""Get a response example from a response spec.
"""
if 'schema' in resp_spec.keys():
if '$ref' in resp_spec['schema']: # Standard definition
definition_name = self.get_definition_name_from_ref(resp_spec['schema']['$ref'])
... | [
"def",
"get_response_example",
"(",
"self",
",",
"resp_spec",
")",
":",
"if",
"'schema'",
"in",
"resp_spec",
".",
"keys",
"(",
")",
":",
"if",
"'$ref'",
"in",
"resp_spec",
"[",
"'schema'",
"]",
":",
"# Standard definition",
"definition_name",
"=",
"self",
".... | Get a response example from a response spec. | [
"Get",
"a",
"response",
"example",
"from",
"a",
"response",
"spec",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L826-L848 | train | 30,013 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.get_request_data | def get_request_data(self, path, action, body=None):
"""Get the default data and status code of the given path + action request.
Args:
path: path of the request.
action: action of the request(get, post, delete...)
body: body sent, used to sent it back for post reques... | python | def get_request_data(self, path, action, body=None):
"""Get the default data and status code of the given path + action request.
Args:
path: path of the request.
action: action of the request(get, post, delete...)
body: body sent, used to sent it back for post reques... | [
"def",
"get_request_data",
"(",
"self",
",",
"path",
",",
"action",
",",
"body",
"=",
"None",
")",
":",
"body",
"=",
"body",
"or",
"''",
"path_name",
",",
"path_spec",
"=",
"self",
".",
"get_path_spec",
"(",
"path",
")",
"response",
"=",
"{",
"}",
"#... | Get the default data and status code of the given path + action request.
Args:
path: path of the request.
action: action of the request(get, post, delete...)
body: body sent, used to sent it back for post request.
Returns:
A tuple with the default respon... | [
"Get",
"the",
"default",
"data",
"and",
"status",
"code",
"of",
"the",
"given",
"path",
"+",
"action",
"request",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L850-L878 | train | 30,014 |
Trax-air/swagger-parser | swagger_parser/swagger_parser.py | SwaggerParser.get_send_request_correct_body | def get_send_request_correct_body(self, path, action):
"""Get an example body which is correct to send to the given path with the given action.
Args:
path: path of the request
action: action of the request (get, post, put, delete)
Returns:
A dict representin... | python | def get_send_request_correct_body(self, path, action):
"""Get an example body which is correct to send to the given path with the given action.
Args:
path: path of the request
action: action of the request (get, post, put, delete)
Returns:
A dict representin... | [
"def",
"get_send_request_correct_body",
"(",
"self",
",",
"path",
",",
"action",
")",
":",
"path_name",
",",
"path_spec",
"=",
"self",
".",
"get_path_spec",
"(",
"path",
")",
"if",
"path_spec",
"is",
"not",
"None",
"and",
"action",
"in",
"path_spec",
".",
... | Get an example body which is correct to send to the given path with the given action.
Args:
path: path of the request
action: action of the request (get, post, put, delete)
Returns:
A dict representing a correct body for the request or None if no
body is... | [
"Get",
"an",
"example",
"body",
"which",
"is",
"correct",
"to",
"send",
"to",
"the",
"given",
"path",
"with",
"the",
"given",
"action",
"."
] | d97f962a417e76320c59c33dcb223e4373e516d5 | https://github.com/Trax-air/swagger-parser/blob/d97f962a417e76320c59c33dcb223e4373e516d5/swagger_parser/swagger_parser.py#L880-L917 | train | 30,015 |
ubernostrum/webcolors | webcolors.py | normalize_hex | def normalize_hex(hex_value):
"""
Normalize a hexadecimal color value to 6 digits, lowercase.
"""
match = HEX_COLOR_RE.match(hex_value)
if match is None:
raise ValueError(
u"'{}' is not a valid hexadecimal color value.".format(hex_value)
)
hex_digits = match.group(1)... | python | def normalize_hex(hex_value):
"""
Normalize a hexadecimal color value to 6 digits, lowercase.
"""
match = HEX_COLOR_RE.match(hex_value)
if match is None:
raise ValueError(
u"'{}' is not a valid hexadecimal color value.".format(hex_value)
)
hex_digits = match.group(1)... | [
"def",
"normalize_hex",
"(",
"hex_value",
")",
":",
"match",
"=",
"HEX_COLOR_RE",
".",
"match",
"(",
"hex_value",
")",
"if",
"match",
"is",
"None",
":",
"raise",
"ValueError",
"(",
"u\"'{}' is not a valid hexadecimal color value.\"",
".",
"format",
"(",
"hex_value... | Normalize a hexadecimal color value to 6 digits, lowercase. | [
"Normalize",
"a",
"hexadecimal",
"color",
"value",
"to",
"6",
"digits",
"lowercase",
"."
] | 558bd81a917647ea2b392f5f4e9cd7ae5ff162a5 | https://github.com/ubernostrum/webcolors/blob/558bd81a917647ea2b392f5f4e9cd7ae5ff162a5/webcolors.py#L329-L342 | train | 30,016 |
ubernostrum/webcolors | webcolors.py | html5_parse_simple_color | def html5_parse_simple_color(input):
"""
Apply the simple color parsing algorithm from section 2.4.6 of
HTML5.
"""
# 1. Let input be the string being parsed.
#
# 2. If input is not exactly seven characters long, then return an
# error.
if not isinstance(input, unicode) or len(inp... | python | def html5_parse_simple_color(input):
"""
Apply the simple color parsing algorithm from section 2.4.6 of
HTML5.
"""
# 1. Let input be the string being parsed.
#
# 2. If input is not exactly seven characters long, then return an
# error.
if not isinstance(input, unicode) or len(inp... | [
"def",
"html5_parse_simple_color",
"(",
"input",
")",
":",
"# 1. Let input be the string being parsed.",
"#",
"# 2. If input is not exactly seven characters long, then return an",
"# error.",
"if",
"not",
"isinstance",
"(",
"input",
",",
"unicode",
")",
"or",
"len",
"(",
... | Apply the simple color parsing algorithm from section 2.4.6 of
HTML5. | [
"Apply",
"the",
"simple",
"color",
"parsing",
"algorithm",
"from",
"section",
"2",
".",
"4",
".",
"6",
"of",
"HTML5",
"."
] | 558bd81a917647ea2b392f5f4e9cd7ae5ff162a5 | https://github.com/ubernostrum/webcolors/blob/558bd81a917647ea2b392f5f4e9cd7ae5ff162a5/webcolors.py#L651-L698 | train | 30,017 |
ubernostrum/webcolors | webcolors.py | html5_serialize_simple_color | def html5_serialize_simple_color(simple_color):
"""
Apply the serialization algorithm for a simple color from section
2.4.6 of HTML5.
"""
red, green, blue = simple_color
# 1. Let result be a string consisting of a single "#" (U+0023)
# character.
result = u'#'
# 2. Convert the ... | python | def html5_serialize_simple_color(simple_color):
"""
Apply the serialization algorithm for a simple color from section
2.4.6 of HTML5.
"""
red, green, blue = simple_color
# 1. Let result be a string consisting of a single "#" (U+0023)
# character.
result = u'#'
# 2. Convert the ... | [
"def",
"html5_serialize_simple_color",
"(",
"simple_color",
")",
":",
"red",
",",
"green",
",",
"blue",
"=",
"simple_color",
"# 1. Let result be a string consisting of a single \"#\" (U+0023)",
"# character.",
"result",
"=",
"u'#'",
"# 2. Convert the red, green, and blue compo... | Apply the serialization algorithm for a simple color from section
2.4.6 of HTML5. | [
"Apply",
"the",
"serialization",
"algorithm",
"for",
"a",
"simple",
"color",
"from",
"section",
"2",
".",
"4",
".",
"6",
"of",
"HTML5",
"."
] | 558bd81a917647ea2b392f5f4e9cd7ae5ff162a5 | https://github.com/ubernostrum/webcolors/blob/558bd81a917647ea2b392f5f4e9cd7ae5ff162a5/webcolors.py#L701-L723 | train | 30,018 |
ubernostrum/webcolors | webcolors.py | html5_parse_legacy_color | def html5_parse_legacy_color(input):
"""
Apply the legacy color parsing algorithm from section 2.4.6 of
HTML5.
"""
# 1. Let input be the string being parsed.
if not isinstance(input, unicode):
raise ValueError(
u"HTML5 legacy color parsing requires a Unicode string as input.... | python | def html5_parse_legacy_color(input):
"""
Apply the legacy color parsing algorithm from section 2.4.6 of
HTML5.
"""
# 1. Let input be the string being parsed.
if not isinstance(input, unicode):
raise ValueError(
u"HTML5 legacy color parsing requires a Unicode string as input.... | [
"def",
"html5_parse_legacy_color",
"(",
"input",
")",
":",
"# 1. Let input be the string being parsed.",
"if",
"not",
"isinstance",
"(",
"input",
",",
"unicode",
")",
":",
"raise",
"ValueError",
"(",
"u\"HTML5 legacy color parsing requires a Unicode string as input.\"",
")",
... | Apply the legacy color parsing algorithm from section 2.4.6 of
HTML5. | [
"Apply",
"the",
"legacy",
"color",
"parsing",
"algorithm",
"from",
"section",
"2",
".",
"4",
".",
"6",
"of",
"HTML5",
"."
] | 558bd81a917647ea2b392f5f4e9cd7ae5ff162a5 | https://github.com/ubernostrum/webcolors/blob/558bd81a917647ea2b392f5f4e9cd7ae5ff162a5/webcolors.py#L726-L901 | train | 30,019 |
inveniosoftware/invenio-records | invenio_records/api.py | Record.create | def create(cls, data, id_=None, **kwargs):
r"""Create a new record instance and store it in the database.
#. Send a signal :data:`invenio_records.signals.before_record_insert`
with the new record as parameter.
#. Validate the new record data.
#. Add the new record in the da... | python | def create(cls, data, id_=None, **kwargs):
r"""Create a new record instance and store it in the database.
#. Send a signal :data:`invenio_records.signals.before_record_insert`
with the new record as parameter.
#. Validate the new record data.
#. Add the new record in the da... | [
"def",
"create",
"(",
"cls",
",",
"data",
",",
"id_",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
".",
"models",
"import",
"RecordMetadata",
"with",
"db",
".",
"session",
".",
"begin_nested",
"(",
")",
":",
"record",
"=",
"cls",
"(",
"d... | r"""Create a new record instance and store it in the database.
#. Send a signal :data:`invenio_records.signals.before_record_insert`
with the new record as parameter.
#. Validate the new record data.
#. Add the new record in the database.
#. Send a signal :data:`invenio_re... | [
"r",
"Create",
"a",
"new",
"record",
"instance",
"and",
"store",
"it",
"in",
"the",
"database",
"."
] | b0b1481d04012e45cb71b5ae4019e91dde88d1e2 | https://github.com/inveniosoftware/invenio-records/blob/b0b1481d04012e45cb71b5ae4019e91dde88d1e2/invenio_records/api.py#L141-L189 | train | 30,020 |
inveniosoftware/invenio-records | invenio_records/api.py | Record.get_record | def get_record(cls, id_, with_deleted=False):
"""Retrieve the record by id.
Raise a database exception if the record does not exist.
:param id_: record ID.
:param with_deleted: If `True` then it includes deleted records.
:returns: The :class:`Record` instance.
"""
... | python | def get_record(cls, id_, with_deleted=False):
"""Retrieve the record by id.
Raise a database exception if the record does not exist.
:param id_: record ID.
:param with_deleted: If `True` then it includes deleted records.
:returns: The :class:`Record` instance.
"""
... | [
"def",
"get_record",
"(",
"cls",
",",
"id_",
",",
"with_deleted",
"=",
"False",
")",
":",
"with",
"db",
".",
"session",
".",
"no_autoflush",
":",
"query",
"=",
"RecordMetadata",
".",
"query",
".",
"filter_by",
"(",
"id",
"=",
"id_",
")",
"if",
"not",
... | Retrieve the record by id.
Raise a database exception if the record does not exist.
:param id_: record ID.
:param with_deleted: If `True` then it includes deleted records.
:returns: The :class:`Record` instance. | [
"Retrieve",
"the",
"record",
"by",
"id",
"."
] | b0b1481d04012e45cb71b5ae4019e91dde88d1e2 | https://github.com/inveniosoftware/invenio-records/blob/b0b1481d04012e45cb71b5ae4019e91dde88d1e2/invenio_records/api.py#L192-L206 | train | 30,021 |
inveniosoftware/invenio-records | invenio_records/api.py | Record.get_records | def get_records(cls, ids, with_deleted=False):
"""Retrieve multiple records by id.
:param ids: List of record IDs.
:param with_deleted: If `True` then it includes deleted records.
:returns: A list of :class:`Record` instances.
"""
with db.session.no_autoflush:
... | python | def get_records(cls, ids, with_deleted=False):
"""Retrieve multiple records by id.
:param ids: List of record IDs.
:param with_deleted: If `True` then it includes deleted records.
:returns: A list of :class:`Record` instances.
"""
with db.session.no_autoflush:
... | [
"def",
"get_records",
"(",
"cls",
",",
"ids",
",",
"with_deleted",
"=",
"False",
")",
":",
"with",
"db",
".",
"session",
".",
"no_autoflush",
":",
"query",
"=",
"RecordMetadata",
".",
"query",
".",
"filter",
"(",
"RecordMetadata",
".",
"id",
".",
"in_",
... | Retrieve multiple records by id.
:param ids: List of record IDs.
:param with_deleted: If `True` then it includes deleted records.
:returns: A list of :class:`Record` instances. | [
"Retrieve",
"multiple",
"records",
"by",
"id",
"."
] | b0b1481d04012e45cb71b5ae4019e91dde88d1e2 | https://github.com/inveniosoftware/invenio-records/blob/b0b1481d04012e45cb71b5ae4019e91dde88d1e2/invenio_records/api.py#L209-L221 | train | 30,022 |
inveniosoftware/invenio-records | invenio_records/api.py | Record.patch | def patch(self, patch):
"""Patch record metadata.
:params patch: Dictionary of record metadata.
:returns: A new :class:`Record` instance.
"""
data = apply_patch(dict(self), patch)
return self.__class__(data, model=self.model) | python | def patch(self, patch):
"""Patch record metadata.
:params patch: Dictionary of record metadata.
:returns: A new :class:`Record` instance.
"""
data = apply_patch(dict(self), patch)
return self.__class__(data, model=self.model) | [
"def",
"patch",
"(",
"self",
",",
"patch",
")",
":",
"data",
"=",
"apply_patch",
"(",
"dict",
"(",
"self",
")",
",",
"patch",
")",
"return",
"self",
".",
"__class__",
"(",
"data",
",",
"model",
"=",
"self",
".",
"model",
")"
] | Patch record metadata.
:params patch: Dictionary of record metadata.
:returns: A new :class:`Record` instance. | [
"Patch",
"record",
"metadata",
"."
] | b0b1481d04012e45cb71b5ae4019e91dde88d1e2 | https://github.com/inveniosoftware/invenio-records/blob/b0b1481d04012e45cb71b5ae4019e91dde88d1e2/invenio_records/api.py#L223-L230 | train | 30,023 |
inveniosoftware/invenio-records | invenio_records/api.py | Record.commit | def commit(self, **kwargs):
r"""Store changes of the current record instance in the database.
#. Send a signal :data:`invenio_records.signals.before_record_update`
with the current record to be committed as parameter.
#. Validate the current record data.
#. Commit the curre... | python | def commit(self, **kwargs):
r"""Store changes of the current record instance in the database.
#. Send a signal :data:`invenio_records.signals.before_record_update`
with the current record to be committed as parameter.
#. Validate the current record data.
#. Commit the curre... | [
"def",
"commit",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"self",
".",
"model",
"is",
"None",
"or",
"self",
".",
"model",
".",
"json",
"is",
"None",
":",
"raise",
"MissingModelError",
"(",
")",
"with",
"db",
".",
"session",
".",
"begin... | r"""Store changes of the current record instance in the database.
#. Send a signal :data:`invenio_records.signals.before_record_update`
with the current record to be committed as parameter.
#. Validate the current record data.
#. Commit the current record in the database.
... | [
"r",
"Store",
"changes",
"of",
"the",
"current",
"record",
"instance",
"in",
"the",
"database",
"."
] | b0b1481d04012e45cb71b5ae4019e91dde88d1e2 | https://github.com/inveniosoftware/invenio-records/blob/b0b1481d04012e45cb71b5ae4019e91dde88d1e2/invenio_records/api.py#L232-L278 | train | 30,024 |
inveniosoftware/invenio-records | invenio_records/api.py | Record.revert | def revert(self, revision_id):
"""Revert the record to a specific revision.
#. Send a signal :data:`invenio_records.signals.before_record_revert`
with the current record as parameter.
#. Revert the record to the revision id passed as parameter.
#. Send a signal :data:`inven... | python | def revert(self, revision_id):
"""Revert the record to a specific revision.
#. Send a signal :data:`invenio_records.signals.before_record_revert`
with the current record as parameter.
#. Revert the record to the revision id passed as parameter.
#. Send a signal :data:`inven... | [
"def",
"revert",
"(",
"self",
",",
"revision_id",
")",
":",
"if",
"self",
".",
"model",
"is",
"None",
":",
"raise",
"MissingModelError",
"(",
")",
"revision",
"=",
"self",
".",
"revisions",
"[",
"revision_id",
"]",
"with",
"db",
".",
"session",
".",
"b... | Revert the record to a specific revision.
#. Send a signal :data:`invenio_records.signals.before_record_revert`
with the current record as parameter.
#. Revert the record to the revision id passed as parameter.
#. Send a signal :data:`invenio_records.signals.after_record_revert`
... | [
"Revert",
"the",
"record",
"to",
"a",
"specific",
"revision",
"."
] | b0b1481d04012e45cb71b5ae4019e91dde88d1e2 | https://github.com/inveniosoftware/invenio-records/blob/b0b1481d04012e45cb71b5ae4019e91dde88d1e2/invenio_records/api.py#L322-L355 | train | 30,025 |
inveniosoftware/invenio-records | invenio_records/ext.py | _RecordsState.validate | def validate(self, data, schema, **kwargs):
"""Validate data using schema with ``JSONResolver``."""
if not isinstance(schema, dict):
schema = {'$ref': schema}
return validate(
data,
schema,
resolver=self.ref_resolver_cls.from_schema(schema),
... | python | def validate(self, data, schema, **kwargs):
"""Validate data using schema with ``JSONResolver``."""
if not isinstance(schema, dict):
schema = {'$ref': schema}
return validate(
data,
schema,
resolver=self.ref_resolver_cls.from_schema(schema),
... | [
"def",
"validate",
"(",
"self",
",",
"data",
",",
"schema",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"isinstance",
"(",
"schema",
",",
"dict",
")",
":",
"schema",
"=",
"{",
"'$ref'",
":",
"schema",
"}",
"return",
"validate",
"(",
"data",
","... | Validate data using schema with ``JSONResolver``. | [
"Validate",
"data",
"using",
"schema",
"with",
"JSONResolver",
"."
] | b0b1481d04012e45cb71b5ae4019e91dde88d1e2 | https://github.com/inveniosoftware/invenio-records/blob/b0b1481d04012e45cb71b5ae4019e91dde88d1e2/invenio_records/ext.py#L32-L42 | train | 30,026 |
filestack/filestack-python | filestack/models/filestack_audiovisual.py | AudioVisual.to_filelink | def to_filelink(self):
"""
Checks is the status of the conversion is complete and, if so, converts to a Filelink
*returns* [Filestack.Filelink]
```python
filelink = av_convert.to_filelink()
```
"""
if self.status != 'completed':
return 'Audio... | python | def to_filelink(self):
"""
Checks is the status of the conversion is complete and, if so, converts to a Filelink
*returns* [Filestack.Filelink]
```python
filelink = av_convert.to_filelink()
```
"""
if self.status != 'completed':
return 'Audio... | [
"def",
"to_filelink",
"(",
"self",
")",
":",
"if",
"self",
".",
"status",
"!=",
"'completed'",
":",
"return",
"'Audio/video conversion not complete!'",
"response",
"=",
"utils",
".",
"make_call",
"(",
"self",
".",
"url",
",",
"'get'",
")",
"if",
"response",
... | Checks is the status of the conversion is complete and, if so, converts to a Filelink
*returns* [Filestack.Filelink]
```python
filelink = av_convert.to_filelink()
``` | [
"Checks",
"is",
"the",
"status",
"of",
"the",
"conversion",
"is",
"complete",
"and",
"if",
"so",
"converts",
"to",
"a",
"Filelink"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_audiovisual.py#L34-L57 | train | 30,027 |
filestack/filestack-python | filestack/models/filestack_filelink.py | Filelink._return_tag_task | def _return_tag_task(self, task):
"""
Runs both SFW and Tags tasks
"""
if self.security is None:
raise Exception('Tags require security')
tasks = [task]
transform_url = get_transform_url(
tasks, handle=self.handle, security=self.security,
... | python | def _return_tag_task(self, task):
"""
Runs both SFW and Tags tasks
"""
if self.security is None:
raise Exception('Tags require security')
tasks = [task]
transform_url = get_transform_url(
tasks, handle=self.handle, security=self.security,
... | [
"def",
"_return_tag_task",
"(",
"self",
",",
"task",
")",
":",
"if",
"self",
".",
"security",
"is",
"None",
":",
"raise",
"Exception",
"(",
"'Tags require security'",
")",
"tasks",
"=",
"[",
"task",
"]",
"transform_url",
"=",
"get_transform_url",
"(",
"tasks... | Runs both SFW and Tags tasks | [
"Runs",
"both",
"SFW",
"and",
"Tags",
"tasks"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_filelink.py#L52-L67 | train | 30,028 |
filestack/filestack-python | filestack/models/filestack_filelink.py | Filelink.url | def url(self):
"""
Returns the URL for the instance, which can be used
to retrieve, delete, and overwrite the file. If security is enabled, signature and policy parameters will
be included,
*returns* [String]
```python
filelink = client.upload(filepath='/path/to... | python | def url(self):
"""
Returns the URL for the instance, which can be used
to retrieve, delete, and overwrite the file. If security is enabled, signature and policy parameters will
be included,
*returns* [String]
```python
filelink = client.upload(filepath='/path/to... | [
"def",
"url",
"(",
"self",
")",
":",
"return",
"get_url",
"(",
"CDN_URL",
",",
"handle",
"=",
"self",
".",
"handle",
",",
"security",
"=",
"self",
".",
"security",
")"
] | Returns the URL for the instance, which can be used
to retrieve, delete, and overwrite the file. If security is enabled, signature and policy parameters will
be included,
*returns* [String]
```python
filelink = client.upload(filepath='/path/to/file')
filelink.url
... | [
"Returns",
"the",
"URL",
"for",
"the",
"instance",
"which",
"can",
"be",
"used",
"to",
"retrieve",
"delete",
"and",
"overwrite",
"the",
"file",
".",
"If",
"security",
"is",
"enabled",
"signature",
"and",
"policy",
"parameters",
"will",
"be",
"included"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_filelink.py#L84-L98 | train | 30,029 |
filestack/filestack-python | filestack/mixins/filestack_imagetransform_mixin.py | ImageTransformationMixin.zip | def zip(self, store=False, store_params=None):
"""
Returns a zip file of the current transformation. This is different from
the zip function that lives on the Filestack Client
*returns* [Filestack.Transform]
"""
params = locals()
params.pop('store')
param... | python | def zip(self, store=False, store_params=None):
"""
Returns a zip file of the current transformation. This is different from
the zip function that lives on the Filestack Client
*returns* [Filestack.Transform]
"""
params = locals()
params.pop('store')
param... | [
"def",
"zip",
"(",
"self",
",",
"store",
"=",
"False",
",",
"store_params",
"=",
"None",
")",
":",
"params",
"=",
"locals",
"(",
")",
"params",
".",
"pop",
"(",
"'store'",
")",
"params",
".",
"pop",
"(",
"'store_params'",
")",
"new_transform",
"=",
"... | Returns a zip file of the current transformation. This is different from
the zip function that lives on the Filestack Client
*returns* [Filestack.Transform] | [
"Returns",
"a",
"zip",
"file",
"of",
"the",
"current",
"transformation",
".",
"This",
"is",
"different",
"from",
"the",
"zip",
"function",
"that",
"lives",
"on",
"the",
"Filestack",
"Client"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_imagetransform_mixin.py#L119-L135 | train | 30,030 |
filestack/filestack-python | filestack/mixins/filestack_imagetransform_mixin.py | ImageTransformationMixin.av_convert | def av_convert(self, preset=None, force=None, title=None, extname=None, filename=None,
width=None, height=None, upscale=None, aspect_mode=None, two_pass=None,
video_bitrate=None, fps=None, keyframe_interval=None, location=None,
watermark_url=None, watermark_top=N... | python | def av_convert(self, preset=None, force=None, title=None, extname=None, filename=None,
width=None, height=None, upscale=None, aspect_mode=None, two_pass=None,
video_bitrate=None, fps=None, keyframe_interval=None, location=None,
watermark_url=None, watermark_top=N... | [
"def",
"av_convert",
"(",
"self",
",",
"preset",
"=",
"None",
",",
"force",
"=",
"None",
",",
"title",
"=",
"None",
",",
"extname",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"upscale",
"=... | ```python
from filestack import Client
client = Client("<API_KEY>")
filelink = client.upload(filepath='path/to/file/doom.mp4')
av_convert= filelink.av_convert(width=100, height=100)
while av_convert.status != 'completed':
print(av_convert.status)
filelink = ... | [
"python",
"from",
"filestack",
"import",
"Client"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_imagetransform_mixin.py#L137-L177 | train | 30,031 |
filestack/filestack-python | filestack/mixins/filestack_imagetransform_mixin.py | ImageTransformationMixin.add_transform_task | def add_transform_task(self, transformation, params):
"""
Adds a transform task to the current instance and returns it
*returns* Filestack.Transform
"""
if not isinstance(self, filestack.models.Transform):
instance = filestack.models.Transform(apikey=self.apikey, sec... | python | def add_transform_task(self, transformation, params):
"""
Adds a transform task to the current instance and returns it
*returns* Filestack.Transform
"""
if not isinstance(self, filestack.models.Transform):
instance = filestack.models.Transform(apikey=self.apikey, sec... | [
"def",
"add_transform_task",
"(",
"self",
",",
"transformation",
",",
"params",
")",
":",
"if",
"not",
"isinstance",
"(",
"self",
",",
"filestack",
".",
"models",
".",
"Transform",
")",
":",
"instance",
"=",
"filestack",
".",
"models",
".",
"Transform",
"(... | Adds a transform task to the current instance and returns it
*returns* Filestack.Transform | [
"Adds",
"a",
"transform",
"task",
"to",
"the",
"current",
"instance",
"and",
"returns",
"it"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_imagetransform_mixin.py#L180-L197 | train | 30,032 |
filestack/filestack-python | filestack/mixins/filestack_common.py | CommonMixin.download | def download(self, destination_path, params=None):
"""
Downloads a file to the given local path and returns the size of the downloaded file if successful
*returns* [Integer]
```python
from filestack import Client
client = Client('API_KEY', security=sec)
fileli... | python | def download(self, destination_path, params=None):
"""
Downloads a file to the given local path and returns the size of the downloaded file if successful
*returns* [Integer]
```python
from filestack import Client
client = Client('API_KEY', security=sec)
fileli... | [
"def",
"download",
"(",
"self",
",",
"destination_path",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
":",
"CONTENT_DOWNLOAD_SCHEMA",
".",
"check",
"(",
"params",
")",
"with",
"open",
"(",
"destination_path",
",",
"'wb'",
")",
"as",
"new_file",
":... | Downloads a file to the given local path and returns the size of the downloaded file if successful
*returns* [Integer]
```python
from filestack import Client
client = Client('API_KEY', security=sec)
filelink = client.upload(filepath='/path/to/file')
# if successful, r... | [
"Downloads",
"a",
"file",
"to",
"the",
"given",
"local",
"path",
"and",
"returns",
"the",
"size",
"of",
"the",
"downloaded",
"file",
"if",
"successful"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_common.py#L15-L45 | train | 30,033 |
filestack/filestack-python | filestack/mixins/filestack_common.py | CommonMixin.get_content | def get_content(self, params=None):
"""
Returns the raw byte content of a given Filelink
*returns* [Bytes]
```python
from filestack import Client
client = Client('API_KEY')
filelink = client.upload(filepath='/path/to/file/foo.jpg')
byte_content = fileli... | python | def get_content(self, params=None):
"""
Returns the raw byte content of a given Filelink
*returns* [Bytes]
```python
from filestack import Client
client = Client('API_KEY')
filelink = client.upload(filepath='/path/to/file/foo.jpg')
byte_content = fileli... | [
"def",
"get_content",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
":",
"CONTENT_DOWNLOAD_SCHEMA",
".",
"check",
"(",
"params",
")",
"response",
"=",
"utils",
".",
"make_call",
"(",
"CDN_URL",
",",
"'get'",
",",
"handle",
"=",
"self... | Returns the raw byte content of a given Filelink
*returns* [Bytes]
```python
from filestack import Client
client = Client('API_KEY')
filelink = client.upload(filepath='/path/to/file/foo.jpg')
byte_content = filelink.get_content()
``` | [
"Returns",
"the",
"raw",
"byte",
"content",
"of",
"a",
"given",
"Filelink"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_common.py#L47-L68 | train | 30,034 |
filestack/filestack-python | filestack/mixins/filestack_common.py | CommonMixin.get_metadata | def get_metadata(self, params=None):
"""
Metadata provides certain information about a Filehandle, and you can specify which pieces
of information you will receive back by passing in optional parameters.
```python
from filestack import Client
client = Client('API_KEY')... | python | def get_metadata(self, params=None):
"""
Metadata provides certain information about a Filehandle, and you can specify which pieces
of information you will receive back by passing in optional parameters.
```python
from filestack import Client
client = Client('API_KEY')... | [
"def",
"get_metadata",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"metadata_url",
"=",
"\"{CDN_URL}/{handle}/metadata\"",
".",
"format",
"(",
"CDN_URL",
"=",
"CDN_URL",
",",
"handle",
"=",
"self",
".",
"handle",
")",
"response",
"=",
"utils",
".",
... | Metadata provides certain information about a Filehandle, and you can specify which pieces
of information you will receive back by passing in optional parameters.
```python
from filestack import Client
client = Client('API_KEY')
filelink = client.upload(filepath='/path/to/file... | [
"Metadata",
"provides",
"certain",
"information",
"about",
"a",
"Filehandle",
"and",
"you",
"can",
"specify",
"which",
"pieces",
"of",
"information",
"you",
"will",
"receive",
"back",
"by",
"passing",
"in",
"optional",
"parameters",
"."
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_common.py#L70-L91 | train | 30,035 |
filestack/filestack-python | filestack/mixins/filestack_common.py | CommonMixin.delete | def delete(self, params=None):
"""
You may delete any file you have uploaded, either through a Filelink returned from the client or one you have initialized yourself.
This returns a response of success or failure. This action requires security.abs
*returns* [requests.response]
... | python | def delete(self, params=None):
"""
You may delete any file you have uploaded, either through a Filelink returned from the client or one you have initialized yourself.
This returns a response of success or failure. This action requires security.abs
*returns* [requests.response]
... | [
"def",
"delete",
"(",
"self",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
":",
"params",
"[",
"'key'",
"]",
"=",
"self",
".",
"apikey",
"else",
":",
"params",
"=",
"{",
"'key'",
":",
"self",
".",
"apikey",
"}",
"return",
"utils",
".",
"... | You may delete any file you have uploaded, either through a Filelink returned from the client or one you have initialized yourself.
This returns a response of success or failure. This action requires security.abs
*returns* [requests.response]
```python
from filestack import Client, sec... | [
"You",
"may",
"delete",
"any",
"file",
"you",
"have",
"uploaded",
"either",
"through",
"a",
"Filelink",
"returned",
"from",
"the",
"client",
"or",
"one",
"you",
"have",
"initialized",
"yourself",
".",
"This",
"returns",
"a",
"response",
"of",
"success",
"or"... | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_common.py#L93-L121 | train | 30,036 |
filestack/filestack-python | filestack/mixins/filestack_common.py | CommonMixin.overwrite | def overwrite(self, url=None, filepath=None, params=None):
"""
You may overwrite any Filelink by supplying a new file. The Filehandle will remain the same.
*returns* [requests.response]
```python
from filestack import Client, security
# a policy requires at least an ex... | python | def overwrite(self, url=None, filepath=None, params=None):
"""
You may overwrite any Filelink by supplying a new file. The Filehandle will remain the same.
*returns* [requests.response]
```python
from filestack import Client, security
# a policy requires at least an ex... | [
"def",
"overwrite",
"(",
"self",
",",
"url",
"=",
"None",
",",
"filepath",
"=",
"None",
",",
"params",
"=",
"None",
")",
":",
"if",
"params",
":",
"OVERWRITE_SCHEMA",
".",
"check",
"(",
"params",
")",
"data",
",",
"files",
"=",
"None",
",",
"None",
... | You may overwrite any Filelink by supplying a new file. The Filehandle will remain the same.
*returns* [requests.response]
```python
from filestack import Client, security
# a policy requires at least an expiry
policy = {'expiry': 56589012}
sec = security(policy, 'APP_... | [
"You",
"may",
"overwrite",
"any",
"Filelink",
"by",
"supplying",
"a",
"new",
"file",
".",
"The",
"Filehandle",
"will",
"remain",
"the",
"same",
"."
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/mixins/filestack_common.py#L123-L158 | train | 30,037 |
filestack/filestack-python | filestack/models/filestack_security.py | validate | def validate(policy):
"""
Validates a policy and its parameters and raises an error if invalid
"""
for param, value in policy.items():
if param not in ACCEPTED_SECURITY_TYPES.keys():
raise SecurityError('Invalid Security Parameter: {}'.format(param))
if type(value) != ACCEP... | python | def validate(policy):
"""
Validates a policy and its parameters and raises an error if invalid
"""
for param, value in policy.items():
if param not in ACCEPTED_SECURITY_TYPES.keys():
raise SecurityError('Invalid Security Parameter: {}'.format(param))
if type(value) != ACCEP... | [
"def",
"validate",
"(",
"policy",
")",
":",
"for",
"param",
",",
"value",
"in",
"policy",
".",
"items",
"(",
")",
":",
"if",
"param",
"not",
"in",
"ACCEPTED_SECURITY_TYPES",
".",
"keys",
"(",
")",
":",
"raise",
"SecurityError",
"(",
"'Invalid Security Para... | Validates a policy and its parameters and raises an error if invalid | [
"Validates",
"a",
"policy",
"and",
"its",
"parameters",
"and",
"raises",
"an",
"error",
"if",
"invalid"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_security.py#L10-L23 | train | 30,038 |
filestack/filestack-python | filestack/models/filestack_security.py | security | def security(policy, app_secret):
"""
Creates a valid signature and policy based on provided app secret and
parameters
```python
from filestack import Client, security
# a policy requires at least an expiry
policy = {'expiry': 56589012, 'call': ['read', 'store', 'pick']}
sec = security(... | python | def security(policy, app_secret):
"""
Creates a valid signature and policy based on provided app secret and
parameters
```python
from filestack import Client, security
# a policy requires at least an expiry
policy = {'expiry': 56589012, 'call': ['read', 'store', 'pick']}
sec = security(... | [
"def",
"security",
"(",
"policy",
",",
"app_secret",
")",
":",
"validate",
"(",
"policy",
")",
"policy_enc",
"=",
"base64",
".",
"urlsafe_b64encode",
"(",
"json",
".",
"dumps",
"(",
"policy",
")",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"signature",
"="... | Creates a valid signature and policy based on provided app secret and
parameters
```python
from filestack import Client, security
# a policy requires at least an expiry
policy = {'expiry': 56589012, 'call': ['read', 'store', 'pick']}
sec = security(policy, 'APP_SECRET')
client = Client('A... | [
"Creates",
"a",
"valid",
"signature",
"and",
"policy",
"based",
"on",
"provided",
"app",
"secret",
"and",
"parameters",
"python",
"from",
"filestack",
"import",
"Client",
"security"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_security.py#L26-L47 | train | 30,039 |
filestack/filestack-python | filestack/models/filestack_client.py | Client.transform_external | def transform_external(self, external_url):
"""
Turns an external URL into a Filestack Transform object
*returns* [Filestack.Transform]
```python
from filestack import Client, Filelink
client = Client("API_KEY")
transform = client.transform_external('http://www... | python | def transform_external(self, external_url):
"""
Turns an external URL into a Filestack Transform object
*returns* [Filestack.Transform]
```python
from filestack import Client, Filelink
client = Client("API_KEY")
transform = client.transform_external('http://www... | [
"def",
"transform_external",
"(",
"self",
",",
"external_url",
")",
":",
"return",
"filestack",
".",
"models",
".",
"Transform",
"(",
"apikey",
"=",
"self",
".",
"apikey",
",",
"security",
"=",
"self",
".",
"security",
",",
"external_url",
"=",
"external_url... | Turns an external URL into a Filestack Transform object
*returns* [Filestack.Transform]
```python
from filestack import Client, Filelink
client = Client("API_KEY")
transform = client.transform_external('http://www.example.com')
``` | [
"Turns",
"an",
"external",
"URL",
"into",
"a",
"Filestack",
"Transform",
"object"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_client.py#L26-L39 | train | 30,040 |
filestack/filestack-python | filestack/models/filestack_client.py | Client.urlscreenshot | def urlscreenshot(self, external_url, agent=None, mode=None, width=None, height=None, delay=None):
"""
Takes a 'screenshot' of the given URL
*returns* [Filestack.Transform]
```python
from filestack import Client
client = Client("API_KEY")
# returns a Transform ... | python | def urlscreenshot(self, external_url, agent=None, mode=None, width=None, height=None, delay=None):
"""
Takes a 'screenshot' of the given URL
*returns* [Filestack.Transform]
```python
from filestack import Client
client = Client("API_KEY")
# returns a Transform ... | [
"def",
"urlscreenshot",
"(",
"self",
",",
"external_url",
",",
"agent",
"=",
"None",
",",
"mode",
"=",
"None",
",",
"width",
"=",
"None",
",",
"height",
"=",
"None",
",",
"delay",
"=",
"None",
")",
":",
"params",
"=",
"locals",
"(",
")",
"params",
... | Takes a 'screenshot' of the given URL
*returns* [Filestack.Transform]
```python
from filestack import Client
client = Client("API_KEY")
# returns a Transform object
screenshot = client.url_screenshot('https://www.example.com', width=100, height=100, agent="desktop")
... | [
"Takes",
"a",
"screenshot",
"of",
"the",
"given",
"URL"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_client.py#L41-L67 | train | 30,041 |
filestack/filestack-python | filestack/models/filestack_client.py | Client.zip | def zip(self, destination_path, files):
"""
Takes array of files and downloads a compressed ZIP archive
to provided path
*returns* [requests.response]
```python
from filestack import Client
client = Client("<API_KEY>")
client.zip('/path/to/file/destinat... | python | def zip(self, destination_path, files):
"""
Takes array of files and downloads a compressed ZIP archive
to provided path
*returns* [requests.response]
```python
from filestack import Client
client = Client("<API_KEY>")
client.zip('/path/to/file/destinat... | [
"def",
"zip",
"(",
"self",
",",
"destination_path",
",",
"files",
")",
":",
"zip_url",
"=",
"\"{}/{}/zip/[{}]\"",
".",
"format",
"(",
"CDN_URL",
",",
"self",
".",
"apikey",
",",
"','",
".",
"join",
"(",
"files",
")",
")",
"with",
"open",
"(",
"destinat... | Takes array of files and downloads a compressed ZIP archive
to provided path
*returns* [requests.response]
```python
from filestack import Client
client = Client("<API_KEY>")
client.zip('/path/to/file/destination', ['files'])
``` | [
"Takes",
"array",
"of",
"files",
"and",
"downloads",
"a",
"compressed",
"ZIP",
"archive",
"to",
"provided",
"path"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_client.py#L69-L94 | train | 30,042 |
filestack/filestack-python | filestack/models/filestack_transform.py | Transform.url | def url(self):
"""
Returns the URL for the current transformation, which can be used
to retrieve the file. If security is enabled, signature and policy parameters will
be included
*returns* [String]
```python
transform = client.upload(filepath='/path/to/file')
... | python | def url(self):
"""
Returns the URL for the current transformation, which can be used
to retrieve the file. If security is enabled, signature and policy parameters will
be included
*returns* [String]
```python
transform = client.upload(filepath='/path/to/file')
... | [
"def",
"url",
"(",
"self",
")",
":",
"return",
"utils",
".",
"get_transform_url",
"(",
"self",
".",
"_transformation_tasks",
",",
"external_url",
"=",
"self",
".",
"external_url",
",",
"handle",
"=",
"self",
".",
"handle",
",",
"security",
"=",
"self",
"."... | Returns the URL for the current transformation, which can be used
to retrieve the file. If security is enabled, signature and policy parameters will
be included
*returns* [String]
```python
transform = client.upload(filepath='/path/to/file')
transform.url()
# ht... | [
"Returns",
"the",
"URL",
"for",
"the",
"current",
"transformation",
"which",
"can",
"be",
"used",
"to",
"retrieve",
"the",
"file",
".",
"If",
"security",
"is",
"enabled",
"signature",
"and",
"policy",
"parameters",
"will",
"be",
"included"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_transform.py#L96-L113 | train | 30,043 |
filestack/filestack-python | filestack/models/filestack_transform.py | Transform.store | def store(self, filename=None, location=None, path=None, container=None, region=None, access=None, base64decode=None):
"""
Uploads and stores the current transformation as a Fileink
*returns* [Filestack.Filelink]
```python
filelink = transform.store()
```
"""
... | python | def store(self, filename=None, location=None, path=None, container=None, region=None, access=None, base64decode=None):
"""
Uploads and stores the current transformation as a Fileink
*returns* [Filestack.Filelink]
```python
filelink = transform.store()
```
"""
... | [
"def",
"store",
"(",
"self",
",",
"filename",
"=",
"None",
",",
"location",
"=",
"None",
",",
"path",
"=",
"None",
",",
"container",
"=",
"None",
",",
"region",
"=",
"None",
",",
"access",
"=",
"None",
",",
"base64decode",
"=",
"None",
")",
":",
"i... | Uploads and stores the current transformation as a Fileink
*returns* [Filestack.Filelink]
```python
filelink = transform.store()
``` | [
"Uploads",
"and",
"stores",
"the",
"current",
"transformation",
"as",
"a",
"Fileink"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_transform.py#L115-L136 | train | 30,044 |
filestack/filestack-python | filestack/models/filestack_transform.py | Transform.debug | def debug(self):
"""
Returns a JSON object with inforamtion regarding the current transformation
*returns* [Dict]
"""
debug_instance = self.add_transform_task('debug', locals())
response = utils.make_call(debug_instance.url, 'get')
return response.json() | python | def debug(self):
"""
Returns a JSON object with inforamtion regarding the current transformation
*returns* [Dict]
"""
debug_instance = self.add_transform_task('debug', locals())
response = utils.make_call(debug_instance.url, 'get')
return response.json() | [
"def",
"debug",
"(",
"self",
")",
":",
"debug_instance",
"=",
"self",
".",
"add_transform_task",
"(",
"'debug'",
",",
"locals",
"(",
")",
")",
"response",
"=",
"utils",
".",
"make_call",
"(",
"debug_instance",
".",
"url",
",",
"'get'",
")",
"return",
"re... | Returns a JSON object with inforamtion regarding the current transformation
*returns* [Dict] | [
"Returns",
"a",
"JSON",
"object",
"with",
"inforamtion",
"regarding",
"the",
"current",
"transformation"
] | f4d54c48987f3eeaad02d31cc5f6037e914bba0d | https://github.com/filestack/filestack-python/blob/f4d54c48987f3eeaad02d31cc5f6037e914bba0d/filestack/models/filestack_transform.py#L138-L146 | train | 30,045 |
tox-dev/tox-venv | src/tox_venv/hooks.py | real_python3 | def real_python3(python, version_dict):
"""
Determine the path of the real python executable, which is then used for
venv creation. This is necessary, because an active virtualenv environment
will cause venv creation to malfunction. By getting the path of the real
executable, this issue is bypassed.... | python | def real_python3(python, version_dict):
"""
Determine the path of the real python executable, which is then used for
venv creation. This is necessary, because an active virtualenv environment
will cause venv creation to malfunction. By getting the path of the real
executable, this issue is bypassed.... | [
"def",
"real_python3",
"(",
"python",
",",
"version_dict",
")",
":",
"args",
"=",
"[",
"python",
",",
"'-c'",
",",
"'import sys; print(sys.real_prefix)'",
"]",
"# get python prefix",
"try",
":",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"args",
",",... | Determine the path of the real python executable, which is then used for
venv creation. This is necessary, because an active virtualenv environment
will cause venv creation to malfunction. By getting the path of the real
executable, this issue is bypassed.
The provided `python` path may be either:
... | [
"Determine",
"the",
"path",
"of",
"the",
"real",
"python",
"executable",
"which",
"is",
"then",
"used",
"for",
"venv",
"creation",
".",
"This",
"is",
"necessary",
"because",
"an",
"active",
"virtualenv",
"environment",
"will",
"cause",
"venv",
"creation",
"to"... | e740a96c81e076d850065e6a8444ae1cd833468b | https://github.com/tox-dev/tox-venv/blob/e740a96c81e076d850065e6a8444ae1cd833468b/src/tox_venv/hooks.py#L8-L69 | train | 30,046 |
shinux/PyTime | pytime/pytime.py | today | def today(year=None):
"""this day, last year"""
return datetime.date(int(year), _date.month, _date.day) if year else _date | python | def today(year=None):
"""this day, last year"""
return datetime.date(int(year), _date.month, _date.day) if year else _date | [
"def",
"today",
"(",
"year",
"=",
"None",
")",
":",
"return",
"datetime",
".",
"date",
"(",
"int",
"(",
"year",
")",
",",
"_date",
".",
"month",
",",
"_date",
".",
"day",
")",
"if",
"year",
"else",
"_date"
] | this day, last year | [
"this",
"day",
"last",
"year"
] | f2b9f877507e2a1dddf5dd255fdff243a5dbed48 | https://github.com/shinux/PyTime/blob/f2b9f877507e2a1dddf5dd255fdff243a5dbed48/pytime/pytime.py#L50-L52 | train | 30,047 |
shinux/PyTime | pytime/pytime.py | tomorrow | def tomorrow(date=None):
"""tomorrow is another day"""
if not date:
return _date + datetime.timedelta(days=1)
else:
current_date = parse(date)
return current_date + datetime.timedelta(days=1) | python | def tomorrow(date=None):
"""tomorrow is another day"""
if not date:
return _date + datetime.timedelta(days=1)
else:
current_date = parse(date)
return current_date + datetime.timedelta(days=1) | [
"def",
"tomorrow",
"(",
"date",
"=",
"None",
")",
":",
"if",
"not",
"date",
":",
"return",
"_date",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"else",
":",
"current_date",
"=",
"parse",
"(",
"date",
")",
"return",
"current_date",
... | tomorrow is another day | [
"tomorrow",
"is",
"another",
"day"
] | f2b9f877507e2a1dddf5dd255fdff243a5dbed48 | https://github.com/shinux/PyTime/blob/f2b9f877507e2a1dddf5dd255fdff243a5dbed48/pytime/pytime.py#L55-L61 | train | 30,048 |
shinux/PyTime | pytime/pytime.py | yesterday | def yesterday(date=None):
"""yesterday once more"""
if not date:
return _date - datetime.timedelta(days=1)
else:
current_date = parse(date)
return current_date - datetime.timedelta(days=1) | python | def yesterday(date=None):
"""yesterday once more"""
if not date:
return _date - datetime.timedelta(days=1)
else:
current_date = parse(date)
return current_date - datetime.timedelta(days=1) | [
"def",
"yesterday",
"(",
"date",
"=",
"None",
")",
":",
"if",
"not",
"date",
":",
"return",
"_date",
"-",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"else",
":",
"current_date",
"=",
"parse",
"(",
"date",
")",
"return",
"current_date",
... | yesterday once more | [
"yesterday",
"once",
"more"
] | f2b9f877507e2a1dddf5dd255fdff243a5dbed48 | https://github.com/shinux/PyTime/blob/f2b9f877507e2a1dddf5dd255fdff243a5dbed48/pytime/pytime.py#L64-L70 | train | 30,049 |
shinux/PyTime | pytime/pytime.py | days_range | def days_range(first=None, second=None, wipe=False):
"""
get all days between first and second
:param first: datetime, date or string
:param second: datetime, date or string
:param wipe: boolean, excludes first and last date from range when True. Default is False.
:return: list
"""
_fir... | python | def days_range(first=None, second=None, wipe=False):
"""
get all days between first and second
:param first: datetime, date or string
:param second: datetime, date or string
:param wipe: boolean, excludes first and last date from range when True. Default is False.
:return: list
"""
_fir... | [
"def",
"days_range",
"(",
"first",
"=",
"None",
",",
"second",
"=",
"None",
",",
"wipe",
"=",
"False",
")",
":",
"_first",
",",
"_second",
"=",
"parse",
"(",
"first",
")",
",",
"parse",
"(",
"second",
")",
"(",
"_start",
",",
"_end",
")",
"=",
"(... | get all days between first and second
:param first: datetime, date or string
:param second: datetime, date or string
:param wipe: boolean, excludes first and last date from range when True. Default is False.
:return: list | [
"get",
"all",
"days",
"between",
"first",
"and",
"second"
] | f2b9f877507e2a1dddf5dd255fdff243a5dbed48 | https://github.com/shinux/PyTime/blob/f2b9f877507e2a1dddf5dd255fdff243a5dbed48/pytime/pytime.py#L78-L93 | train | 30,050 |
squaresLab/BugZoo | bugzoo/client/bug.py | BugManager.is_installed | def is_installed(self, bug: Bug) -> bool:
"""
Determines whether the Docker image for a given bug has been installed
on the server.
"""
r = self.__api.get('bugs/{}/installed'.format(bug.name))
if r.status_code == 200:
answer = r.json()
assert isin... | python | def is_installed(self, bug: Bug) -> bool:
"""
Determines whether the Docker image for a given bug has been installed
on the server.
"""
r = self.__api.get('bugs/{}/installed'.format(bug.name))
if r.status_code == 200:
answer = r.json()
assert isin... | [
"def",
"is_installed",
"(",
"self",
",",
"bug",
":",
"Bug",
")",
"->",
"bool",
":",
"r",
"=",
"self",
".",
"__api",
".",
"get",
"(",
"'bugs/{}/installed'",
".",
"format",
"(",
"bug",
".",
"name",
")",
")",
"if",
"r",
".",
"status_code",
"==",
"200"... | Determines whether the Docker image for a given bug has been installed
on the server. | [
"Determines",
"whether",
"the",
"Docker",
"image",
"for",
"a",
"given",
"bug",
"has",
"been",
"installed",
"on",
"the",
"server",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/bug.py#L82-L98 | train | 30,051 |
squaresLab/BugZoo | bugzoo/client/bug.py | BugManager.uninstall | def uninstall(self, bug: Bug) -> bool:
"""
Uninstalls the Docker image associated with a given bug.
"""
r = self.__api.post('bugs/{}/uninstall'.format(bug.name))
raise NotImplementedError | python | def uninstall(self, bug: Bug) -> bool:
"""
Uninstalls the Docker image associated with a given bug.
"""
r = self.__api.post('bugs/{}/uninstall'.format(bug.name))
raise NotImplementedError | [
"def",
"uninstall",
"(",
"self",
",",
"bug",
":",
"Bug",
")",
"->",
"bool",
":",
"r",
"=",
"self",
".",
"__api",
".",
"post",
"(",
"'bugs/{}/uninstall'",
".",
"format",
"(",
"bug",
".",
"name",
")",
")",
"raise",
"NotImplementedError"
] | Uninstalls the Docker image associated with a given bug. | [
"Uninstalls",
"the",
"Docker",
"image",
"associated",
"with",
"a",
"given",
"bug",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/bug.py#L130-L135 | train | 30,052 |
squaresLab/BugZoo | bugzoo/client/bug.py | BugManager.build | def build(self, bug: Bug):
"""
Instructs the server to build the Docker image associated with a given
bug.
"""
r = self.__api.post('bugs/{}/build'.format(bug.name))
if r.status_code == 204:
return
if r.status_code == 200:
raise Exception("... | python | def build(self, bug: Bug):
"""
Instructs the server to build the Docker image associated with a given
bug.
"""
r = self.__api.post('bugs/{}/build'.format(bug.name))
if r.status_code == 204:
return
if r.status_code == 200:
raise Exception("... | [
"def",
"build",
"(",
"self",
",",
"bug",
":",
"Bug",
")",
":",
"r",
"=",
"self",
".",
"__api",
".",
"post",
"(",
"'bugs/{}/build'",
".",
"format",
"(",
"bug",
".",
"name",
")",
")",
"if",
"r",
".",
"status_code",
"==",
"204",
":",
"return",
"if",... | Instructs the server to build the Docker image associated with a given
bug. | [
"Instructs",
"the",
"server",
"to",
"build",
"the",
"Docker",
"image",
"associated",
"with",
"a",
"given",
"bug",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/bug.py#L153-L170 | train | 30,053 |
squaresLab/BugZoo | bugzoo/mgr/source.py | SourceManager.refresh | def refresh(self) -> None:
"""
Reloads all sources that are registered with this server.
"""
logger.info('refreshing sources')
for source in list(self):
self.unload(source)
if not os.path.exists(self.__registry_fn):
return
# TODO add vers... | python | def refresh(self) -> None:
"""
Reloads all sources that are registered with this server.
"""
logger.info('refreshing sources')
for source in list(self):
self.unload(source)
if not os.path.exists(self.__registry_fn):
return
# TODO add vers... | [
"def",
"refresh",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'refreshing sources'",
")",
"for",
"source",
"in",
"list",
"(",
"self",
")",
":",
"self",
".",
"unload",
"(",
"source",
")",
"if",
"not",
"os",
".",
"path",
".",
"e... | Reloads all sources that are registered with this server. | [
"Reloads",
"all",
"sources",
"that",
"are",
"registered",
"with",
"this",
"server",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/source.py#L70-L90 | train | 30,054 |
squaresLab/BugZoo | bugzoo/mgr/source.py | SourceManager.update | def update(self) -> None:
"""
Ensures that all remote sources are up-to-date.
"""
for source_old in self:
if isinstance(source_old, RemoteSource):
repo = git.Repo(source_old.location)
origin = repo.remotes.origin
origin.pull()
... | python | def update(self) -> None:
"""
Ensures that all remote sources are up-to-date.
"""
for source_old in self:
if isinstance(source_old, RemoteSource):
repo = git.Repo(source_old.location)
origin = repo.remotes.origin
origin.pull()
... | [
"def",
"update",
"(",
"self",
")",
"->",
"None",
":",
"for",
"source_old",
"in",
"self",
":",
"if",
"isinstance",
"(",
"source_old",
",",
"RemoteSource",
")",
":",
"repo",
"=",
"git",
".",
"Repo",
"(",
"source_old",
".",
"location",
")",
"origin",
"=",... | Ensures that all remote sources are up-to-date. | [
"Ensures",
"that",
"all",
"remote",
"sources",
"are",
"up",
"-",
"to",
"-",
"date",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/source.py#L92-L122 | train | 30,055 |
squaresLab/BugZoo | bugzoo/mgr/source.py | SourceManager.save | def save(self) -> None:
"""
Saves the contents of the source manager to disk.
"""
logger.info('saving registry to: %s', self.__registry_fn)
d = [s.to_dict() for s in self]
os.makedirs(self.__path, exist_ok=True)
with open(self.__registry_fn, 'w') as f:
... | python | def save(self) -> None:
"""
Saves the contents of the source manager to disk.
"""
logger.info('saving registry to: %s', self.__registry_fn)
d = [s.to_dict() for s in self]
os.makedirs(self.__path, exist_ok=True)
with open(self.__registry_fn, 'w') as f:
... | [
"def",
"save",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'saving registry to: %s'",
",",
"self",
".",
"__registry_fn",
")",
"d",
"=",
"[",
"s",
".",
"to_dict",
"(",
")",
"for",
"s",
"in",
"self",
"]",
"os",
".",
"makedirs",
... | Saves the contents of the source manager to disk. | [
"Saves",
"the",
"contents",
"of",
"the",
"source",
"manager",
"to",
"disk",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/source.py#L124-L134 | train | 30,056 |
squaresLab/BugZoo | bugzoo/mgr/source.py | SourceManager.unload | def unload(self, source: Source) -> None:
"""
Unloads a registered source, causing all of its associated bugs, tools,
and blueprints to also be unloaded. If the given source is not loaded,
this function will do nothing.
"""
logger.info('unloading source: %s', source.name)... | python | def unload(self, source: Source) -> None:
"""
Unloads a registered source, causing all of its associated bugs, tools,
and blueprints to also be unloaded. If the given source is not loaded,
this function will do nothing.
"""
logger.info('unloading source: %s', source.name)... | [
"def",
"unload",
"(",
"self",
",",
"source",
":",
"Source",
")",
"->",
"None",
":",
"logger",
".",
"info",
"(",
"'unloading source: %s'",
",",
"source",
".",
"name",
")",
"try",
":",
"contents",
"=",
"self",
".",
"contents",
"(",
"source",
")",
"del",
... | Unloads a registered source, causing all of its associated bugs, tools,
and blueprints to also be unloaded. If the given source is not loaded,
this function will do nothing. | [
"Unloads",
"a",
"registered",
"source",
"causing",
"all",
"of",
"its",
"associated",
"bugs",
"tools",
"and",
"blueprints",
"to",
"also",
"be",
"unloaded",
".",
"If",
"the",
"given",
"source",
"is",
"not",
"loaded",
"this",
"function",
"will",
"do",
"nothing"... | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/source.py#L136-L159 | train | 30,057 |
squaresLab/BugZoo | bugzoo/mgr/source.py | SourceManager.add | def add(self, name: str, path_or_url: str) -> Source:
"""
Attempts to register a source provided by a given URL or local path
under a given name.
Returns:
a description of the registered source.
Raises:
NameInUseError: if an existing source is already re... | python | def add(self, name: str, path_or_url: str) -> Source:
"""
Attempts to register a source provided by a given URL or local path
under a given name.
Returns:
a description of the registered source.
Raises:
NameInUseError: if an existing source is already re... | [
"def",
"add",
"(",
"self",
",",
"name",
":",
"str",
",",
"path_or_url",
":",
"str",
")",
"->",
"Source",
":",
"logger",
".",
"info",
"(",
"\"adding source: %s -> %s\"",
",",
"name",
",",
"path_or_url",
")",
"if",
"name",
"in",
"self",
".",
"__sources",
... | Attempts to register a source provided by a given URL or local path
under a given name.
Returns:
a description of the registered source.
Raises:
NameInUseError: if an existing source is already registered under
the given name.
IOError: if no ... | [
"Attempts",
"to",
"register",
"a",
"source",
"provided",
"by",
"a",
"given",
"URL",
"or",
"local",
"path",
"under",
"a",
"given",
"name",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/source.py#L274-L334 | train | 30,058 |
squaresLab/BugZoo | bugzoo/mgr/source.py | SourceManager.remove | def remove(self, source: Source) -> None:
"""
Unregisters a given source with this server. If the given source is a
remote source, then its local copy will be removed from disk.
Raises:
KeyError: if the given source is not registered with this server.
"""
sel... | python | def remove(self, source: Source) -> None:
"""
Unregisters a given source with this server. If the given source is a
remote source, then its local copy will be removed from disk.
Raises:
KeyError: if the given source is not registered with this server.
"""
sel... | [
"def",
"remove",
"(",
"self",
",",
"source",
":",
"Source",
")",
"->",
"None",
":",
"self",
".",
"unload",
"(",
"source",
")",
"if",
"isinstance",
"(",
"source",
",",
"RemoteSource",
")",
":",
"shutil",
".",
"rmtree",
"(",
"source",
".",
"location",
... | Unregisters a given source with this server. If the given source is a
remote source, then its local copy will be removed from disk.
Raises:
KeyError: if the given source is not registered with this server. | [
"Unregisters",
"a",
"given",
"source",
"with",
"this",
"server",
".",
"If",
"the",
"given",
"source",
"is",
"a",
"remote",
"source",
"then",
"its",
"local",
"copy",
"will",
"be",
"removed",
"from",
"disk",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/source.py#L336-L347 | train | 30,059 |
squaresLab/BugZoo | bugzoo/mgr/bug.py | BugManager.is_installed | def is_installed(self, bug: Bug) -> bool:
"""
Determines whether or not the Docker image for a given bug has been
installed onto this server.
See: `BuildManager.is_installed`
"""
return self.__installation.build.is_installed(bug.image) | python | def is_installed(self, bug: Bug) -> bool:
"""
Determines whether or not the Docker image for a given bug has been
installed onto this server.
See: `BuildManager.is_installed`
"""
return self.__installation.build.is_installed(bug.image) | [
"def",
"is_installed",
"(",
"self",
",",
"bug",
":",
"Bug",
")",
"->",
"bool",
":",
"return",
"self",
".",
"__installation",
".",
"build",
".",
"is_installed",
"(",
"bug",
".",
"image",
")"
] | Determines whether or not the Docker image for a given bug has been
installed onto this server.
See: `BuildManager.is_installed` | [
"Determines",
"whether",
"or",
"not",
"the",
"Docker",
"image",
"for",
"a",
"given",
"bug",
"has",
"been",
"installed",
"onto",
"this",
"server",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/bug.py#L73-L80 | train | 30,060 |
squaresLab/BugZoo | bugzoo/mgr/bug.py | BugManager.build | def build(self,
bug: Bug,
force: bool = True,
quiet: bool = False
) -> None:
"""
Builds the Docker image associated with a given bug.
See: `BuildManager.build`
"""
self.__installation.build.build(bug.image,
... | python | def build(self,
bug: Bug,
force: bool = True,
quiet: bool = False
) -> None:
"""
Builds the Docker image associated with a given bug.
See: `BuildManager.build`
"""
self.__installation.build.build(bug.image,
... | [
"def",
"build",
"(",
"self",
",",
"bug",
":",
"Bug",
",",
"force",
":",
"bool",
"=",
"True",
",",
"quiet",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"self",
".",
"__installation",
".",
"build",
".",
"build",
"(",
"bug",
".",
"image",
","... | Builds the Docker image associated with a given bug.
See: `BuildManager.build` | [
"Builds",
"the",
"Docker",
"image",
"associated",
"with",
"a",
"given",
"bug",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/bug.py#L82-L94 | train | 30,061 |
squaresLab/BugZoo | bugzoo/mgr/bug.py | BugManager.uninstall | def uninstall(self,
bug: Bug,
force: bool = False,
noprune: bool = False
) -> None:
"""
Uninstalls all Docker images associated with this bug.
See: `BuildManager.uninstall`
"""
self.__installation.build.unin... | python | def uninstall(self,
bug: Bug,
force: bool = False,
noprune: bool = False
) -> None:
"""
Uninstalls all Docker images associated with this bug.
See: `BuildManager.uninstall`
"""
self.__installation.build.unin... | [
"def",
"uninstall",
"(",
"self",
",",
"bug",
":",
"Bug",
",",
"force",
":",
"bool",
"=",
"False",
",",
"noprune",
":",
"bool",
"=",
"False",
")",
"->",
"None",
":",
"self",
".",
"__installation",
".",
"build",
".",
"uninstall",
"(",
"bug",
".",
"im... | Uninstalls all Docker images associated with this bug.
See: `BuildManager.uninstall` | [
"Uninstalls",
"all",
"Docker",
"images",
"associated",
"with",
"this",
"bug",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/bug.py#L96-L108 | train | 30,062 |
squaresLab/BugZoo | bugzoo/mgr/bug.py | BugManager.validate | def validate(self, bug: Bug, verbose: bool = True) -> bool:
"""
Checks that a given bug successfully builds, and that it produces an
expected set of test suite outcomes.
Parameters:
verbose: toggles verbosity of output. If set to `True`, the
outcomes of each ... | python | def validate(self, bug: Bug, verbose: bool = True) -> bool:
"""
Checks that a given bug successfully builds, and that it produces an
expected set of test suite outcomes.
Parameters:
verbose: toggles verbosity of output. If set to `True`, the
outcomes of each ... | [
"def",
"validate",
"(",
"self",
",",
"bug",
":",
"Bug",
",",
"verbose",
":",
"bool",
"=",
"True",
")",
"->",
"bool",
":",
"# attempt to rebuild -- don't worry, Docker's layer caching prevents us",
"# from actually having to rebuild everything from scratch :-)",
"try",
":",
... | Checks that a given bug successfully builds, and that it produces an
expected set of test suite outcomes.
Parameters:
verbose: toggles verbosity of output. If set to `True`, the
outcomes of each test will be printed to the standard output.
Returns:
`True... | [
"Checks",
"that",
"a",
"given",
"bug",
"successfully",
"builds",
"and",
"that",
"it",
"produces",
"an",
"expected",
"set",
"of",
"test",
"suite",
"outcomes",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/bug.py#L129-L199 | train | 30,063 |
squaresLab/BugZoo | bugzoo/mgr/bug.py | BugManager.coverage | def coverage(self, bug: Bug) -> TestSuiteCoverage:
"""
Provides coverage information for each test within the test suite
for the program associated with this bug.
Parameters:
bug: the bug for which to compute coverage.
Returns:
a test suite coverage repo... | python | def coverage(self, bug: Bug) -> TestSuiteCoverage:
"""
Provides coverage information for each test within the test suite
for the program associated with this bug.
Parameters:
bug: the bug for which to compute coverage.
Returns:
a test suite coverage repo... | [
"def",
"coverage",
"(",
"self",
",",
"bug",
":",
"Bug",
")",
"->",
"TestSuiteCoverage",
":",
"# determine the location of the coverage map on disk",
"fn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"self",
".",
"__installation",
".",
"coverage_path",
",",
"\"{}.c... | Provides coverage information for each test within the test suite
for the program associated with this bug.
Parameters:
bug: the bug for which to compute coverage.
Returns:
a test suite coverage report for the given bug. | [
"Provides",
"coverage",
"information",
"for",
"each",
"test",
"within",
"the",
"test",
"suite",
"for",
"the",
"program",
"associated",
"with",
"this",
"bug",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/bug.py#L201-L234 | train | 30,064 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.clear | def clear(self) -> None:
"""
Closes all running containers.
"""
logger.debug("clearing all running containers")
all_uids = [uid for uid in self.__containers.keys()]
for uid in all_uids:
try:
del self[uid]
except KeyError:
... | python | def clear(self) -> None:
"""
Closes all running containers.
"""
logger.debug("clearing all running containers")
all_uids = [uid for uid in self.__containers.keys()]
for uid in all_uids:
try:
del self[uid]
except KeyError:
... | [
"def",
"clear",
"(",
"self",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"\"clearing all running containers\"",
")",
"all_uids",
"=",
"[",
"uid",
"for",
"uid",
"in",
"self",
".",
"__containers",
".",
"keys",
"(",
")",
"]",
"for",
"uid",
"in",
... | Closes all running containers. | [
"Closes",
"all",
"running",
"containers",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L51-L63 | train | 30,065 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.bug | def bug(self, container: Container) -> Bug:
"""
Returns a description of the bug inside a given container.
"""
name = container.bug
return self.__installation.bugs[name] | python | def bug(self, container: Container) -> Bug:
"""
Returns a description of the bug inside a given container.
"""
name = container.bug
return self.__installation.bugs[name] | [
"def",
"bug",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"Bug",
":",
"name",
"=",
"container",
".",
"bug",
"return",
"self",
".",
"__installation",
".",
"bugs",
"[",
"name",
"]"
] | Returns a description of the bug inside a given container. | [
"Returns",
"a",
"description",
"of",
"the",
"bug",
"inside",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L113-L118 | train | 30,066 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.mktemp | def mktemp(self, container: Container) -> str:
"""
Creates a named temporary file within a given container.
Returns:
the absolute path to the created temporary file.
"""
logger.debug("creating a temporary file inside container %s",
container.uid)... | python | def mktemp(self, container: Container) -> str:
"""
Creates a named temporary file within a given container.
Returns:
the absolute path to the created temporary file.
"""
logger.debug("creating a temporary file inside container %s",
container.uid)... | [
"def",
"mktemp",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"str",
":",
"logger",
".",
"debug",
"(",
"\"creating a temporary file inside container %s\"",
",",
"container",
".",
"uid",
")",
"response",
"=",
"self",
".",
"command",
"(",
"contain... | Creates a named temporary file within a given container.
Returns:
the absolute path to the created temporary file. | [
"Creates",
"a",
"named",
"temporary",
"file",
"within",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L239-L260 | train | 30,067 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.is_alive | def is_alive(self, container: Container) -> bool:
"""
Determines whether a given container is still alive.
Returns:
`True` if the underlying Docker container for the given BugZoo
container is still alive, otherwise `False`.
"""
uid = container.uid
... | python | def is_alive(self, container: Container) -> bool:
"""
Determines whether a given container is still alive.
Returns:
`True` if the underlying Docker container for the given BugZoo
container is still alive, otherwise `False`.
"""
uid = container.uid
... | [
"def",
"is_alive",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"bool",
":",
"uid",
"=",
"container",
".",
"uid",
"return",
"uid",
"in",
"self",
".",
"__dockerc",
"and",
"self",
".",
"__dockerc",
"[",
"uid",
"]",
".",
"status",
"==",
"... | Determines whether a given container is still alive.
Returns:
`True` if the underlying Docker container for the given BugZoo
container is still alive, otherwise `False`. | [
"Determines",
"whether",
"a",
"given",
"container",
"is",
"still",
"alive",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L262-L272 | train | 30,068 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.coverage_extractor | def coverage_extractor(self, container: Container) -> CoverageExtractor:
"""
Retrieves the coverage extractor for a given container.
"""
return CoverageExtractor.build(self.__installation, container) | python | def coverage_extractor(self, container: Container) -> CoverageExtractor:
"""
Retrieves the coverage extractor for a given container.
"""
return CoverageExtractor.build(self.__installation, container) | [
"def",
"coverage_extractor",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"CoverageExtractor",
":",
"return",
"CoverageExtractor",
".",
"build",
"(",
"self",
".",
"__installation",
",",
"container",
")"
] | Retrieves the coverage extractor for a given container. | [
"Retrieves",
"the",
"coverage",
"extractor",
"for",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L349-L353 | train | 30,069 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.coverage | def coverage(self,
container: Container,
tests: Optional[Iterable[TestCase]] = None,
*,
instrument: bool = True
) -> TestSuiteCoverage:
"""
Computes line coverage information over a provided set of tests for
the... | python | def coverage(self,
container: Container,
tests: Optional[Iterable[TestCase]] = None,
*,
instrument: bool = True
) -> TestSuiteCoverage:
"""
Computes line coverage information over a provided set of tests for
the... | [
"def",
"coverage",
"(",
"self",
",",
"container",
":",
"Container",
",",
"tests",
":",
"Optional",
"[",
"Iterable",
"[",
"TestCase",
"]",
"]",
"=",
"None",
",",
"*",
",",
"instrument",
":",
"bool",
"=",
"True",
")",
"->",
"TestSuiteCoverage",
":",
"ext... | Computes line coverage information over a provided set of tests for
the program inside a given container. | [
"Computes",
"line",
"coverage",
"information",
"over",
"a",
"provided",
"set",
"of",
"tests",
"for",
"the",
"program",
"inside",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L364-L379 | train | 30,070 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.execute | def execute(self,
container: Container,
test: TestCase,
verbose: bool = False
) -> TestOutcome:
"""
Runs a specified test inside a given container.
Returns:
the outcome of the test execution.
"""
bug = s... | python | def execute(self,
container: Container,
test: TestCase,
verbose: bool = False
) -> TestOutcome:
"""
Runs a specified test inside a given container.
Returns:
the outcome of the test execution.
"""
bug = s... | [
"def",
"execute",
"(",
"self",
",",
"container",
":",
"Container",
",",
"test",
":",
"TestCase",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
"->",
"TestOutcome",
":",
"bug",
"=",
"self",
".",
"__installation",
".",
"bugs",
"[",
"container",
".",
"b... | Runs a specified test inside a given container.
Returns:
the outcome of the test execution. | [
"Runs",
"a",
"specified",
"test",
"inside",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L381-L401 | train | 30,071 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.compile_with_instrumentation | def compile_with_instrumentation(self,
container: Container,
verbose: bool = False
) -> CompilationOutcome:
"""
Attempts to compile the program inside a given container with
instrumenta... | python | def compile_with_instrumentation(self,
container: Container,
verbose: bool = False
) -> CompilationOutcome:
"""
Attempts to compile the program inside a given container with
instrumenta... | [
"def",
"compile_with_instrumentation",
"(",
"self",
",",
"container",
":",
"Container",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
"->",
"CompilationOutcome",
":",
"bug",
"=",
"self",
".",
"__installation",
".",
"bugs",
"[",
"container",
".",
"bug",
"]"... | Attempts to compile the program inside a given container with
instrumentation enabled.
See: `Container.compile` | [
"Attempts",
"to",
"compile",
"the",
"program",
"inside",
"a",
"given",
"container",
"with",
"instrumentation",
"enabled",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L428-L442 | train | 30,072 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.copy_to | def copy_to(self,
container: Container,
fn_host: str,
fn_container: str
) -> None:
"""
Copies a file from the host machine to a specified location inside a
container.
Raises:
FileNotFound: if the host file wasn'... | python | def copy_to(self,
container: Container,
fn_host: str,
fn_container: str
) -> None:
"""
Copies a file from the host machine to a specified location inside a
container.
Raises:
FileNotFound: if the host file wasn'... | [
"def",
"copy_to",
"(",
"self",
",",
"container",
":",
"Container",
",",
"fn_host",
":",
"str",
",",
"fn_container",
":",
"str",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"\"Copying file to container, %s: %s -> %s\"",
",",
"container",
".",
"uid",
... | Copies a file from the host machine to a specified location inside a
container.
Raises:
FileNotFound: if the host file wasn't found.
subprocess.CalledProcessError: if the file could not be copied to
the container. | [
"Copies",
"a",
"file",
"from",
"the",
"host",
"machine",
"to",
"a",
"specified",
"location",
"inside",
"a",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L446-L484 | train | 30,073 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.copy_from | def copy_from(self,
container: Container,
fn_container: str,
fn_host: str
) -> None:
"""
Copies a given file from the container to a specified location on the
host machine.
"""
logger.debug("Copying file from... | python | def copy_from(self,
container: Container,
fn_container: str,
fn_host: str
) -> None:
"""
Copies a given file from the container to a specified location on the
host machine.
"""
logger.debug("Copying file from... | [
"def",
"copy_from",
"(",
"self",
",",
"container",
":",
"Container",
",",
"fn_container",
":",
"str",
",",
"fn_host",
":",
"str",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"\"Copying file from container, %s: %s -> %s\"",
",",
"container",
".",
"uid"... | Copies a given file from the container to a specified location on the
host machine. | [
"Copies",
"a",
"given",
"file",
"from",
"the",
"container",
"to",
"a",
"specified",
"location",
"on",
"the",
"host",
"machine",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L486-L506 | train | 30,074 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.command | def command(self,
container: Container,
cmd: str,
context: Optional[str] = None,
stdout: bool = True,
stderr: bool = False,
block: bool = True,
verbose: bool = False,
time_limit: Optional[int]... | python | def command(self,
container: Container,
cmd: str,
context: Optional[str] = None,
stdout: bool = True,
stderr: bool = False,
block: bool = True,
verbose: bool = False,
time_limit: Optional[int]... | [
"def",
"command",
"(",
"self",
",",
"container",
":",
"Container",
",",
"cmd",
":",
"str",
",",
"context",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"stdout",
":",
"bool",
"=",
"True",
",",
"stderr",
":",
"bool",
"=",
"False",
",",
"block... | Executes a provided shell command inside a given container.
Parameters:
time_limit: an optional parameter that is used to specify the
number of seconds that the command should be allowed to run
without completing before it is aborted. Only supported by
... | [
"Executes",
"a",
"provided",
"shell",
"command",
"inside",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L508-L589 | train | 30,075 |
squaresLab/BugZoo | bugzoo/mgr/container.py | ContainerManager.persist | def persist(self, container: Container, image: str) -> None:
"""
Persists the state of a given container to a BugZoo image on this
server.
Parameters:
container: the container to persist.
image: the name of the Docker image that should be created.
Raises... | python | def persist(self, container: Container, image: str) -> None:
"""
Persists the state of a given container to a BugZoo image on this
server.
Parameters:
container: the container to persist.
image: the name of the Docker image that should be created.
Raises... | [
"def",
"persist",
"(",
"self",
",",
"container",
":",
"Container",
",",
"image",
":",
"str",
")",
"->",
"None",
":",
"logger_c",
"=",
"logger",
".",
"getChild",
"(",
"container",
".",
"uid",
")",
"logger_c",
".",
"debug",
"(",
"\"Persisting container as a ... | Persists the state of a given container to a BugZoo image on this
server.
Parameters:
container: the container to persist.
image: the name of the Docker image that should be created.
Raises:
ImageAlreadyExists: if the image name is already in use by another
... | [
"Persists",
"the",
"state",
"of",
"a",
"given",
"container",
"to",
"a",
"BugZoo",
"image",
"on",
"this",
"server",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/container.py#L593-L629 | train | 30,076 |
squaresLab/BugZoo | bugzoo/server/__init__.py | ephemeral | def ephemeral(*,
port: int = 6060,
timeout_connection: int = 30,
verbose: bool = False
) -> Iterator[Client]:
"""
Launches an ephemeral server instance that will be immediately
close when no longer in context.
Parameters:
port: the port th... | python | def ephemeral(*,
port: int = 6060,
timeout_connection: int = 30,
verbose: bool = False
) -> Iterator[Client]:
"""
Launches an ephemeral server instance that will be immediately
close when no longer in context.
Parameters:
port: the port th... | [
"def",
"ephemeral",
"(",
"*",
",",
"port",
":",
"int",
"=",
"6060",
",",
"timeout_connection",
":",
"int",
"=",
"30",
",",
"verbose",
":",
"bool",
"=",
"False",
")",
"->",
"Iterator",
"[",
"Client",
"]",
":",
"url",
"=",
"\"http://127.0.0.1:{}\"",
".",... | Launches an ephemeral server instance that will be immediately
close when no longer in context.
Parameters:
port: the port that the server should run on.
verbose: if set to True, the server will print its output to the
stdout, otherwise it will remain silent.
Returns:
a... | [
"Launches",
"an",
"ephemeral",
"server",
"instance",
"that",
"will",
"be",
"immediately",
"close",
"when",
"no",
"longer",
"in",
"context",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/server/__init__.py#L67-L95 | train | 30,077 |
squaresLab/BugZoo | bugzoo/mgr/coverage/extractor.py | register | def register(name: str):
"""
Registers a coverage extractor class under a given name.
.. code: python
from bugzoo.mgr.coverage import CoverageExtractor, register
@register('mycov')
class MyCoverageExtractor(CoverageExtractor):
...
"""
def decorator(cls: Type['C... | python | def register(name: str):
"""
Registers a coverage extractor class under a given name.
.. code: python
from bugzoo.mgr.coverage import CoverageExtractor, register
@register('mycov')
class MyCoverageExtractor(CoverageExtractor):
...
"""
def decorator(cls: Type['C... | [
"def",
"register",
"(",
"name",
":",
"str",
")",
":",
"def",
"decorator",
"(",
"cls",
":",
"Type",
"[",
"'CoverageExtractor'",
"]",
")",
":",
"cls",
".",
"register",
"(",
"name",
")",
"return",
"cls",
"return",
"decorator"
] | Registers a coverage extractor class under a given name.
.. code: python
from bugzoo.mgr.coverage import CoverageExtractor, register
@register('mycov')
class MyCoverageExtractor(CoverageExtractor):
... | [
"Registers",
"a",
"coverage",
"extractor",
"class",
"under",
"a",
"given",
"name",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/coverage/extractor.py#L23-L38 | train | 30,078 |
squaresLab/BugZoo | bugzoo/mgr/coverage/extractor.py | register_as_default | def register_as_default(language: Language):
"""
Registers a coverage extractor class as the default coverage extractor
for a given language. Requires that the coverage extractor class has
already been registered with a given name.
.. code: python
from bugzoo.core import Language
f... | python | def register_as_default(language: Language):
"""
Registers a coverage extractor class as the default coverage extractor
for a given language. Requires that the coverage extractor class has
already been registered with a given name.
.. code: python
from bugzoo.core import Language
f... | [
"def",
"register_as_default",
"(",
"language",
":",
"Language",
")",
":",
"def",
"decorator",
"(",
"cls",
":",
"Type",
"[",
"'CoverageExtractor'",
"]",
")",
":",
"cls",
".",
"register_as_default",
"(",
"language",
")",
"return",
"cls",
"return",
"decorator"
] | Registers a coverage extractor class as the default coverage extractor
for a given language. Requires that the coverage extractor class has
already been registered with a given name.
.. code: python
from bugzoo.core import Language
from bugzoo.mgr.coverage import CoverageExtractor, registe... | [
"Registers",
"a",
"coverage",
"extractor",
"class",
"as",
"the",
"default",
"coverage",
"extractor",
"for",
"a",
"given",
"language",
".",
"Requires",
"that",
"the",
"coverage",
"extractor",
"class",
"has",
"already",
"been",
"registered",
"with",
"a",
"given",
... | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/coverage/extractor.py#L41-L61 | train | 30,079 |
squaresLab/BugZoo | bugzoo/mgr/coverage/extractor.py | CoverageExtractor.build | def build(installation: 'BugZoo',
container: Container
) -> 'CoverageExtractor':
"""
Constructs a CoverageExtractor for a given container using the coverage
instructions provided by its accompanying bug description.
"""
bug = installation.bugs[containe... | python | def build(installation: 'BugZoo',
container: Container
) -> 'CoverageExtractor':
"""
Constructs a CoverageExtractor for a given container using the coverage
instructions provided by its accompanying bug description.
"""
bug = installation.bugs[containe... | [
"def",
"build",
"(",
"installation",
":",
"'BugZoo'",
",",
"container",
":",
"Container",
")",
"->",
"'CoverageExtractor'",
":",
"bug",
"=",
"installation",
".",
"bugs",
"[",
"container",
".",
"bug",
"]",
"# type: Bug",
"instructions",
"=",
"bug",
".",
"inst... | Constructs a CoverageExtractor for a given container using the coverage
instructions provided by its accompanying bug description. | [
"Constructs",
"a",
"CoverageExtractor",
"for",
"a",
"given",
"container",
"using",
"the",
"coverage",
"instructions",
"provided",
"by",
"its",
"accompanying",
"bug",
"description",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/coverage/extractor.py#L144-L160 | train | 30,080 |
squaresLab/BugZoo | bugzoo/mgr/coverage/extractor.py | CoverageExtractor.run | def run(self,
tests: Iterable[TestCase],
*,
instrument: bool = True
) -> TestSuiteCoverage:
"""
Computes line coverage information for a given set of tests.
Parameters:
tests: the tests for which coverage should be computed.
... | python | def run(self,
tests: Iterable[TestCase],
*,
instrument: bool = True
) -> TestSuiteCoverage:
"""
Computes line coverage information for a given set of tests.
Parameters:
tests: the tests for which coverage should be computed.
... | [
"def",
"run",
"(",
"self",
",",
"tests",
":",
"Iterable",
"[",
"TestCase",
"]",
",",
"*",
",",
"instrument",
":",
"bool",
"=",
"True",
")",
"->",
"TestSuiteCoverage",
":",
"container",
"=",
"self",
".",
"container",
"logger",
".",
"debug",
"(",
"\"comp... | Computes line coverage information for a given set of tests.
Parameters:
tests: the tests for which coverage should be computed.
instrument: if set to True, calls prepare and cleanup before and
after running the tests. If set to False, prepare
and cleanup... | [
"Computes",
"line",
"coverage",
"information",
"for",
"a",
"given",
"set",
"of",
"tests",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/mgr/coverage/extractor.py#L209-L252 | train | 30,081 |
squaresLab/BugZoo | bugzoo/exceptions.py | BugZooException.from_dict | def from_dict(d: Dict[str, Any]) -> 'BugZooException':
"""
Reconstructs a BugZoo exception from a dictionary-based description.
"""
assert 'error' in d
d = d['error']
cls = getattr(sys.modules[__name__], d['kind'])
assert issubclass(cls, BugZooException)
... | python | def from_dict(d: Dict[str, Any]) -> 'BugZooException':
"""
Reconstructs a BugZoo exception from a dictionary-based description.
"""
assert 'error' in d
d = d['error']
cls = getattr(sys.modules[__name__], d['kind'])
assert issubclass(cls, BugZooException)
... | [
"def",
"from_dict",
"(",
"d",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"'BugZooException'",
":",
"assert",
"'error'",
"in",
"d",
"d",
"=",
"d",
"[",
"'error'",
"]",
"cls",
"=",
"getattr",
"(",
"sys",
".",
"modules",
"[",
"__name__",
"]"... | Reconstructs a BugZoo exception from a dictionary-based description. | [
"Reconstructs",
"a",
"BugZoo",
"exception",
"from",
"a",
"dictionary",
"-",
"based",
"description",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/exceptions.py#L42-L52 | train | 30,082 |
squaresLab/BugZoo | bugzoo/exceptions.py | BugZooException.from_message_and_data | def from_message_and_data(cls,
message: str,
data: Dict[str, Any]
) -> 'BugZooException':
"""
Reproduces an exception from the message and data contained in its
dictionary-based description.
"""
... | python | def from_message_and_data(cls,
message: str,
data: Dict[str, Any]
) -> 'BugZooException':
"""
Reproduces an exception from the message and data contained in its
dictionary-based description.
"""
... | [
"def",
"from_message_and_data",
"(",
"cls",
",",
"message",
":",
"str",
",",
"data",
":",
"Dict",
"[",
"str",
",",
"Any",
"]",
")",
"->",
"'BugZooException'",
":",
"return",
"cls",
"(",
"message",
")"
] | Reproduces an exception from the message and data contained in its
dictionary-based description. | [
"Reproduces",
"an",
"exception",
"from",
"the",
"message",
"and",
"data",
"contained",
"in",
"its",
"dictionary",
"-",
"based",
"description",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/exceptions.py#L66-L74 | train | 30,083 |
squaresLab/BugZoo | bugzoo/exceptions.py | BugZooException.to_dict | def to_dict(self) -> Dict[str, Any]:
"""
Creates a dictionary-based description of this exception, ready to be
serialised as JSON or YAML.
"""
jsn = {
'kind': self.__class__.__name__,
'message': self.message
} # type: Dict[str, Any]
data = ... | python | def to_dict(self) -> Dict[str, Any]:
"""
Creates a dictionary-based description of this exception, ready to be
serialised as JSON or YAML.
"""
jsn = {
'kind': self.__class__.__name__,
'message': self.message
} # type: Dict[str, Any]
data = ... | [
"def",
"to_dict",
"(",
"self",
")",
"->",
"Dict",
"[",
"str",
",",
"Any",
"]",
":",
"jsn",
"=",
"{",
"'kind'",
":",
"self",
".",
"__class__",
".",
"__name__",
",",
"'message'",
":",
"self",
".",
"message",
"}",
"# type: Dict[str, Any]",
"data",
"=",
... | Creates a dictionary-based description of this exception, ready to be
serialised as JSON or YAML. | [
"Creates",
"a",
"dictionary",
"-",
"based",
"description",
"of",
"this",
"exception",
"ready",
"to",
"be",
"serialised",
"as",
"JSON",
"or",
"YAML",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/exceptions.py#L80-L93 | train | 30,084 |
squaresLab/BugZoo | bugzoo/core/patch.py | Hunk._read_next | def _read_next(cls, lines: List[str]) -> 'Hunk':
"""
Constructs a hunk from a supplied fragment of a unified format diff.
"""
header = lines[0]
assert header.startswith('@@ -')
# sometimes the first line can occur on the same line as the header.
# in that case, w... | python | def _read_next(cls, lines: List[str]) -> 'Hunk':
"""
Constructs a hunk from a supplied fragment of a unified format diff.
"""
header = lines[0]
assert header.startswith('@@ -')
# sometimes the first line can occur on the same line as the header.
# in that case, w... | [
"def",
"_read_next",
"(",
"cls",
",",
"lines",
":",
"List",
"[",
"str",
"]",
")",
"->",
"'Hunk'",
":",
"header",
"=",
"lines",
"[",
"0",
"]",
"assert",
"header",
".",
"startswith",
"(",
"'@@ -'",
")",
"# sometimes the first line can occur on the same line as t... | Constructs a hunk from a supplied fragment of a unified format diff. | [
"Constructs",
"a",
"hunk",
"from",
"a",
"supplied",
"fragment",
"of",
"a",
"unified",
"format",
"diff",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/core/patch.py#L58-L112 | train | 30,085 |
squaresLab/BugZoo | bugzoo/core/patch.py | FilePatch._read_next | def _read_next(cls, lines: List[str]) -> 'FilePatch':
"""
Destructively extracts the next file patch from the line buffer.
"""
# keep munching lines until we hit one starting with '---'
while True:
if not lines:
raise Exception("illegal file patch form... | python | def _read_next(cls, lines: List[str]) -> 'FilePatch':
"""
Destructively extracts the next file patch from the line buffer.
"""
# keep munching lines until we hit one starting with '---'
while True:
if not lines:
raise Exception("illegal file patch form... | [
"def",
"_read_next",
"(",
"cls",
",",
"lines",
":",
"List",
"[",
"str",
"]",
")",
"->",
"'FilePatch'",
":",
"# keep munching lines until we hit one starting with '---'",
"while",
"True",
":",
"if",
"not",
"lines",
":",
"raise",
"Exception",
"(",
"\"illegal file pa... | Destructively extracts the next file patch from the line buffer. | [
"Destructively",
"extracts",
"the",
"next",
"file",
"patch",
"from",
"the",
"line",
"buffer",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/core/patch.py#L150-L174 | train | 30,086 |
squaresLab/BugZoo | bugzoo/core/patch.py | Patch.from_unidiff | def from_unidiff(cls, diff: str) -> 'Patch':
"""
Constructs a Patch from a provided unified format diff.
"""
lines = diff.split('\n')
file_patches = []
while lines:
if lines[0] == '' or lines[0].isspace():
lines.pop(0)
continue
... | python | def from_unidiff(cls, diff: str) -> 'Patch':
"""
Constructs a Patch from a provided unified format diff.
"""
lines = diff.split('\n')
file_patches = []
while lines:
if lines[0] == '' or lines[0].isspace():
lines.pop(0)
continue
... | [
"def",
"from_unidiff",
"(",
"cls",
",",
"diff",
":",
"str",
")",
"->",
"'Patch'",
":",
"lines",
"=",
"diff",
".",
"split",
"(",
"'\\n'",
")",
"file_patches",
"=",
"[",
"]",
"while",
"lines",
":",
"if",
"lines",
"[",
"0",
"]",
"==",
"''",
"or",
"l... | Constructs a Patch from a provided unified format diff. | [
"Constructs",
"a",
"Patch",
"from",
"a",
"provided",
"unified",
"format",
"diff",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/core/patch.py#L209-L221 | train | 30,087 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.clear | def clear(self) -> None:
"""
Destroys all running containers.
"""
r = self.__api.delete('containers')
if r.status_code != 204:
self.__api.handle_erroneous_response(r) | python | def clear(self) -> None:
"""
Destroys all running containers.
"""
r = self.__api.delete('containers')
if r.status_code != 204:
self.__api.handle_erroneous_response(r) | [
"def",
"clear",
"(",
"self",
")",
"->",
"None",
":",
"r",
"=",
"self",
".",
"__api",
".",
"delete",
"(",
"'containers'",
")",
"if",
"r",
".",
"status_code",
"!=",
"204",
":",
"self",
".",
"__api",
".",
"handle_erroneous_response",
"(",
"r",
")"
] | Destroys all running containers. | [
"Destroys",
"all",
"running",
"containers",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L87-L93 | train | 30,088 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.provision | def provision(self,
bug: Bug,
*,
plugins: Optional[List[Tool]] = None
) -> Container:
"""
Provisions a container for a given bug.
"""
if plugins is None:
plugins = []
logger.info("provisioning co... | python | def provision(self,
bug: Bug,
*,
plugins: Optional[List[Tool]] = None
) -> Container:
"""
Provisions a container for a given bug.
"""
if plugins is None:
plugins = []
logger.info("provisioning co... | [
"def",
"provision",
"(",
"self",
",",
"bug",
":",
"Bug",
",",
"*",
",",
"plugins",
":",
"Optional",
"[",
"List",
"[",
"Tool",
"]",
"]",
"=",
"None",
")",
"->",
"Container",
":",
"if",
"plugins",
"is",
"None",
":",
"plugins",
"=",
"[",
"]",
"logge... | Provisions a container for a given bug. | [
"Provisions",
"a",
"container",
"for",
"a",
"given",
"bug",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L110-L138 | train | 30,089 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.mktemp | def mktemp(self, container: Container) -> str:
"""
Generates a temporary file for a given container.
Returns:
the path to the temporary file inside the given container.
"""
r = self.__api.post('containers/{}/tempfile'.format(container.uid))
if r.status_code =... | python | def mktemp(self, container: Container) -> str:
"""
Generates a temporary file for a given container.
Returns:
the path to the temporary file inside the given container.
"""
r = self.__api.post('containers/{}/tempfile'.format(container.uid))
if r.status_code =... | [
"def",
"mktemp",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"str",
":",
"r",
"=",
"self",
".",
"__api",
".",
"post",
"(",
"'containers/{}/tempfile'",
".",
"format",
"(",
"container",
".",
"uid",
")",
")",
"if",
"r",
".",
"status_code",... | Generates a temporary file for a given container.
Returns:
the path to the temporary file inside the given container. | [
"Generates",
"a",
"temporary",
"file",
"for",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L140-L150 | train | 30,090 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.is_alive | def is_alive(self, container: Container) -> bool:
"""
Determines whether or not a given container is still alive.
"""
uid = container.uid
r = self.__api.get('containers/{}/alive'.format(uid))
if r.status_code == 200:
return r.json()
if r.status_code ... | python | def is_alive(self, container: Container) -> bool:
"""
Determines whether or not a given container is still alive.
"""
uid = container.uid
r = self.__api.get('containers/{}/alive'.format(uid))
if r.status_code == 200:
return r.json()
if r.status_code ... | [
"def",
"is_alive",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"bool",
":",
"uid",
"=",
"container",
".",
"uid",
"r",
"=",
"self",
".",
"__api",
".",
"get",
"(",
"'containers/{}/alive'",
".",
"format",
"(",
"uid",
")",
")",
"if",
"r",... | Determines whether or not a given container is still alive. | [
"Determines",
"whether",
"or",
"not",
"a",
"given",
"container",
"is",
"still",
"alive",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L164-L177 | train | 30,091 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.extract_coverage | def extract_coverage(self, container: Container) -> FileLineSet:
"""
Extracts a report of the lines that have been executed since the last
time that a coverage report was extracted.
"""
uid = container.uid
r = self.__api.post('containers/{}/read-coverage'.format(uid))
... | python | def extract_coverage(self, container: Container) -> FileLineSet:
"""
Extracts a report of the lines that have been executed since the last
time that a coverage report was extracted.
"""
uid = container.uid
r = self.__api.post('containers/{}/read-coverage'.format(uid))
... | [
"def",
"extract_coverage",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"FileLineSet",
":",
"uid",
"=",
"container",
".",
"uid",
"r",
"=",
"self",
".",
"__api",
".",
"post",
"(",
"'containers/{}/read-coverage'",
".",
"format",
"(",
"uid",
")... | Extracts a report of the lines that have been executed since the last
time that a coverage report was extracted. | [
"Extracts",
"a",
"report",
"of",
"the",
"lines",
"that",
"have",
"been",
"executed",
"since",
"the",
"last",
"time",
"that",
"a",
"coverage",
"report",
"was",
"extracted",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L179-L188 | train | 30,092 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.instrument | def instrument(self,
container: Container
) -> None:
"""
Instruments the program inside the container for computing test suite
coverage.
Params:
container: the container that should be instrumented.
"""
path = "containers... | python | def instrument(self,
container: Container
) -> None:
"""
Instruments the program inside the container for computing test suite
coverage.
Params:
container: the container that should be instrumented.
"""
path = "containers... | [
"def",
"instrument",
"(",
"self",
",",
"container",
":",
"Container",
")",
"->",
"None",
":",
"path",
"=",
"\"containers/{}/instrument\"",
".",
"format",
"(",
"container",
".",
"uid",
")",
"r",
"=",
"self",
".",
"__api",
".",
"post",
"(",
"path",
")",
... | Instruments the program inside the container for computing test suite
coverage.
Params:
container: the container that should be instrumented. | [
"Instruments",
"the",
"program",
"inside",
"the",
"container",
"for",
"computing",
"test",
"suite",
"coverage",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L190-L204 | train | 30,093 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.coverage | def coverage(self,
container: Container,
*,
instrument: bool = True
) -> TestSuiteCoverage:
"""
Computes complete test suite coverage for a given container.
Parameters:
container: the container for which coverage sh... | python | def coverage(self,
container: Container,
*,
instrument: bool = True
) -> TestSuiteCoverage:
"""
Computes complete test suite coverage for a given container.
Parameters:
container: the container for which coverage sh... | [
"def",
"coverage",
"(",
"self",
",",
"container",
":",
"Container",
",",
"*",
",",
"instrument",
":",
"bool",
"=",
"True",
")",
"->",
"TestSuiteCoverage",
":",
"uid",
"=",
"container",
".",
"uid",
"logger",
".",
"info",
"(",
"\"Fetching coverage information ... | Computes complete test suite coverage for a given container.
Parameters:
container: the container for which coverage should be computed.
rebuild: if set to True, the program will be rebuilt before
coverage is computed. | [
"Computes",
"complete",
"test",
"suite",
"coverage",
"for",
"a",
"given",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L261-L293 | train | 30,094 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.exec | def exec(self,
container: Container,
command: str,
context: Optional[str] = None,
stdout: bool = True,
stderr: bool = False,
time_limit: Optional[int] = None
) -> ExecResponse:
"""
Executes a given command inside ... | python | def exec(self,
container: Container,
command: str,
context: Optional[str] = None,
stdout: bool = True,
stderr: bool = False,
time_limit: Optional[int] = None
) -> ExecResponse:
"""
Executes a given command inside ... | [
"def",
"exec",
"(",
"self",
",",
"container",
":",
"Container",
",",
"command",
":",
"str",
",",
"context",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
",",
"stdout",
":",
"bool",
"=",
"True",
",",
"stderr",
":",
"bool",
"=",
"False",
",",
"time... | Executes a given command inside a provided container.
Parameters:
container: the container to which the command should be issued.
command: the command that should be executed.
context: the working directory that should be used to perform the
execution. If no ... | [
"Executes",
"a",
"given",
"command",
"inside",
"a",
"provided",
"container",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L295-L342 | train | 30,095 |
squaresLab/BugZoo | bugzoo/client/container.py | ContainerManager.persist | def persist(self, container: Container, image_name: str) -> None:
"""
Persists the state of a given container as a Docker image on the
server.
Parameters:
container: the container that should be persisted.
image_name: the name of the Docker image that should be c... | python | def persist(self, container: Container, image_name: str) -> None:
"""
Persists the state of a given container as a Docker image on the
server.
Parameters:
container: the container that should be persisted.
image_name: the name of the Docker image that should be c... | [
"def",
"persist",
"(",
"self",
",",
"container",
":",
"Container",
",",
"image_name",
":",
"str",
")",
"->",
"None",
":",
"logger",
".",
"debug",
"(",
"\"attempting to persist container (%s) to image (%s).\"",
",",
"container",
".",
"id",
",",
"image_name",
")",... | Persists the state of a given container as a Docker image on the
server.
Parameters:
container: the container that should be persisted.
image_name: the name of the Docker image that should be created.
Raises:
ContainerNotFound: if the given container does no... | [
"Persists",
"the",
"state",
"of",
"a",
"given",
"container",
"as",
"a",
"Docker",
"image",
"on",
"the",
"server",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/container.py#L363-L394 | train | 30,096 |
squaresLab/BugZoo | bugzoo/compiler/__init__.py | SimpleCompiler.from_dict | def from_dict(d: dict) -> 'SimpleCompiler':
"""
Loads a SimpleCompiler from its dictionary-based description.
"""
cmd = d['command']
cmd_with_instrumentation = d.get('command_with_instrumentation', None)
time_limit = d['time-limit']
context = d['context']
... | python | def from_dict(d: dict) -> 'SimpleCompiler':
"""
Loads a SimpleCompiler from its dictionary-based description.
"""
cmd = d['command']
cmd_with_instrumentation = d.get('command_with_instrumentation', None)
time_limit = d['time-limit']
context = d['context']
... | [
"def",
"from_dict",
"(",
"d",
":",
"dict",
")",
"->",
"'SimpleCompiler'",
":",
"cmd",
"=",
"d",
"[",
"'command'",
"]",
"cmd_with_instrumentation",
"=",
"d",
".",
"get",
"(",
"'command_with_instrumentation'",
",",
"None",
")",
"time_limit",
"=",
"d",
"[",
"... | Loads a SimpleCompiler from its dictionary-based description. | [
"Loads",
"a",
"SimpleCompiler",
"from",
"its",
"dictionary",
"-",
"based",
"description",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/compiler/__init__.py#L101-L114 | train | 30,097 |
matiskay/html-similarity | html_similarity/structural_similarity.py | get_tags | def get_tags(doc):
'''
Get tags from a DOM tree
:param doc: lxml parsed object
:return:
'''
tags = list()
for el in doc.getroot().iter():
if isinstance(el, lxml.html.HtmlElement):
tags.append(el.tag)
elif isinstance(el, lxml.html.HtmlComment):
tags.a... | python | def get_tags(doc):
'''
Get tags from a DOM tree
:param doc: lxml parsed object
:return:
'''
tags = list()
for el in doc.getroot().iter():
if isinstance(el, lxml.html.HtmlElement):
tags.append(el.tag)
elif isinstance(el, lxml.html.HtmlComment):
tags.a... | [
"def",
"get_tags",
"(",
"doc",
")",
":",
"tags",
"=",
"list",
"(",
")",
"for",
"el",
"in",
"doc",
".",
"getroot",
"(",
")",
".",
"iter",
"(",
")",
":",
"if",
"isinstance",
"(",
"el",
",",
"lxml",
".",
"html",
".",
"HtmlElement",
")",
":",
"tags... | Get tags from a DOM tree
:param doc: lxml parsed object
:return: | [
"Get",
"tags",
"from",
"a",
"DOM",
"tree"
] | eef5586b1cf30134254690b2150260ef82cbd18f | https://github.com/matiskay/html-similarity/blob/eef5586b1cf30134254690b2150260ef82cbd18f/html_similarity/structural_similarity.py#L7-L24 | train | 30,098 |
squaresLab/BugZoo | bugzoo/client/api.py | APIClient._url | def _url(self, path: str) -> str:
"""
Computes the URL for a resource located at a given path on the server.
"""
url = "{}/{}".format(self.__base_url, path)
logger.debug("transformed path [%s] into url: %s", path, url)
return url | python | def _url(self, path: str) -> str:
"""
Computes the URL for a resource located at a given path on the server.
"""
url = "{}/{}".format(self.__base_url, path)
logger.debug("transformed path [%s] into url: %s", path, url)
return url | [
"def",
"_url",
"(",
"self",
",",
"path",
":",
"str",
")",
"->",
"str",
":",
"url",
"=",
"\"{}/{}\"",
".",
"format",
"(",
"self",
".",
"__base_url",
",",
"path",
")",
"logger",
".",
"debug",
"(",
"\"transformed path [%s] into url: %s\"",
",",
"path",
",",... | Computes the URL for a resource located at a given path on the server. | [
"Computes",
"the",
"URL",
"for",
"a",
"resource",
"located",
"at",
"a",
"given",
"path",
"on",
"the",
"server",
"."
] | 68664f1977e85b37a78604f7c570382ffae1fa3b | https://github.com/squaresLab/BugZoo/blob/68664f1977e85b37a78604f7c570382ffae1fa3b/bugzoo/client/api.py#L71-L77 | train | 30,099 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.