Search is not available for this dataset
identifier
stringlengths
1
155
parameters
stringlengths
2
6.09k
docstring
stringlengths
11
63.4k
docstring_summary
stringlengths
0
63.4k
function
stringlengths
29
99.8k
function_tokens
list
start_point
list
end_point
list
language
stringclasses
1 value
docstring_language
stringlengths
2
7
docstring_language_predictions
stringlengths
18
23
is_langid_reliable
stringclasses
2 values
MbedTlsTest.align_32bit
(data_bytes)
4 byte aligns input byte array. :return:
4 byte aligns input byte array.
def align_32bit(data_bytes): """ 4 byte aligns input byte array. :return: """ data_bytes += bytearray((4 - (len(data_bytes))) % 4)
[ "def", "align_32bit", "(", "data_bytes", ")", ":", "data_bytes", "+=", "bytearray", "(", "(", "4", "-", "(", "len", "(", "data_bytes", ")", ")", ")", "%", "4", ")" ]
[ 210, 4 ]
[ 216, 60 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.hex_str_bytes
(hex_str)
Converts Hex string representation to byte array :param hex_str: Hex in string format. :return: Output Byte array
Converts Hex string representation to byte array
def hex_str_bytes(hex_str): """ Converts Hex string representation to byte array :param hex_str: Hex in string format. :return: Output Byte array """ if hex_str[0] != '"' or hex_str[len(hex_str) - 1] != '"': raise TestDataParserError("HEX test parameter missi...
[ "def", "hex_str_bytes", "(", "hex_str", ")", ":", "if", "hex_str", "[", "0", "]", "!=", "'\"'", "or", "hex_str", "[", "len", "(", "hex_str", ")", "-", "1", "]", "!=", "'\"'", ":", "raise", "TestDataParserError", "(", "\"HEX test parameter missing '\\\"':\"",...
[ 219, 4 ]
[ 235, 25 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.int32_to_big_endian_bytes
(i)
Coverts i to byte array in big endian format. :param i: Input integer :return: Output bytes array in big endian or network order
Coverts i to byte array in big endian format.
def int32_to_big_endian_bytes(i): """ Coverts i to byte array in big endian format. :param i: Input integer :return: Output bytes array in big endian or network order """ data_bytes = bytearray([((i >> x) & 0xff) for x in [24, 16, 8, 0]]) return data_bytes
[ "def", "int32_to_big_endian_bytes", "(", "i", ")", ":", "data_bytes", "=", "bytearray", "(", "[", "(", "(", "i", ">>", "x", ")", "&", "0xff", ")", "for", "x", "in", "[", "24", ",", "16", ",", "8", ",", "0", "]", "]", ")", "return", "data_bytes" ]
[ 238, 4 ]
[ 246, 25 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.test_vector_to_bytes
(self, function_id, dependencies, parameters)
Converts test vector into a byte array that can be sent to the target. :param function_id: Test Function Identifier :param dependencies: Dependency list :param parameters: Test function input parameters :return: Byte array and its length
Converts test vector into a byte array that can be sent to the target.
def test_vector_to_bytes(self, function_id, dependencies, parameters): """ Converts test vector into a byte array that can be sent to the target. :param function_id: Test Function Identifier :param dependencies: Dependency list :param parameters: Test function input parameters ...
[ "def", "test_vector_to_bytes", "(", "self", ",", "function_id", ",", "dependencies", ",", "parameters", ")", ":", "data_bytes", "=", "bytearray", "(", "[", "len", "(", "dependencies", ")", "]", ")", "if", "dependencies", ":", "data_bytes", "+=", "bytearray", ...
[ 248, 4 ]
[ 283, 33 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.run_next_test
(self)
Fetch next test information and execute the test.
Fetch next test information and execute the test.
def run_next_test(self): """ Fetch next test information and execute the test. """ self.test_index += 1 self.dep_index = 0 if self.test_index < len(self.tests): name, function_id, dependencies, args = self.tests[self.test_index] self.run_test(name...
[ "def", "run_next_test", "(", "self", ")", ":", "self", ".", "test_index", "+=", "1", "self", ".", "dep_index", "=", "0", "if", "self", ".", "test_index", "<", "len", "(", "self", ".", "tests", ")", ":", "name", ",", "function_id", ",", "dependencies", ...
[ 285, 4 ]
[ 296, 51 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.run_test
(self, name, function_id, dependencies, args)
Execute the test on target by sending next test information. :param name: Test name :param function_id: function identifier :param dependencies: Dependencies list :param args: test parameters :return:
Execute the test on target by sending next test information.
def run_test(self, name, function_id, dependencies, args): """ Execute the test on target by sending next test information. :param name: Test name :param function_id: function identifier :param dependencies: Dependencies list :param args: test parameters :return:...
[ "def", "run_test", "(", "self", ",", "name", ",", "function_id", ",", "dependencies", ",", "args", ")", ":", "self", ".", "log", "(", "\"Running: %s\"", "%", "name", ")", "param_bytes", ",", "length", "=", "self", ".", "test_vector_to_bytes", "(", "functio...
[ 298, 4 ]
[ 312, 41 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.get_result
(value)
Converts result from string type to integer :param value: Result code in string :return: Integer result code. Value is from the test status constants defined under the MbedTlsTest class.
Converts result from string type to integer :param value: Result code in string :return: Integer result code. Value is from the test status constants defined under the MbedTlsTest class.
def get_result(value): """ Converts result from string type to integer :param value: Result code in string :return: Integer result code. Value is from the test status constants defined under the MbedTlsTest class. """ try: return int(value) ...
[ "def", "get_result", "(", "value", ")", ":", "try", ":", "return", "int", "(", "value", ")", "except", "ValueError", ":", "ValueError", "(", "\"Result should return error number. \"", "\"Instead received %s\"", "%", "value", ")" ]
[ 315, 4 ]
[ 326, 53 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.on_go
(self, _key, _value, _timestamp)
Sent by the target to start first test. :param _key: Event key :param _value: Value. ignored :param _timestamp: Timestamp ignored. :return:
Sent by the target to start first test.
def on_go(self, _key, _value, _timestamp): """ Sent by the target to start first test. :param _key: Event key :param _value: Value. ignored :param _timestamp: Timestamp ignored. :return: """ self.run_next_test()
[ "def", "on_go", "(", "self", ",", "_key", ",", "_value", ",", "_timestamp", ")", ":", "self", ".", "run_next_test", "(", ")" ]
[ 329, 4 ]
[ 338, 28 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.on_result
(self, _key, value, _timestamp)
Handle result. Prints test start, finish required by Greentea to detect test execution. :param _key: Event key :param value: Value. ignored :param _timestamp: Timestamp ignored. :return:
Handle result. Prints test start, finish required by Greentea to detect test execution.
def on_result(self, _key, value, _timestamp): """ Handle result. Prints test start, finish required by Greentea to detect test execution. :param _key: Event key :param value: Value. ignored :param _timestamp: Timestamp ignored. :return: """ int_va...
[ "def", "on_result", "(", "self", ",", "_key", ",", "value", ",", "_timestamp", ")", ":", "int_val", "=", "self", ".", "get_result", "(", "value", ")", "name", ",", "_", ",", "_", ",", "_", "=", "self", ".", "tests", "[", "self", ".", "test_index", ...
[ 341, 4 ]
[ 358, 28 ]
python
en
['en', 'error', 'th']
False
MbedTlsTest.on_failure
(self, _key, value, _timestamp)
Handles test execution failure. That means dependency not supported or Test function not supported. Hence marking test as skipped. :param _key: Event key :param value: Value. ignored :param _timestamp: Timestamp ignored. :return:
Handles test execution failure. That means dependency not supported or Test function not supported. Hence marking test as skipped.
def on_failure(self, _key, value, _timestamp): """ Handles test execution failure. That means dependency not supported or Test function not supported. Hence marking test as skipped. :param _key: Event key :param value: Value. ignored :param _timestamp: Timestamp ignored....
[ "def", "on_failure", "(", "self", ",", "_key", ",", "value", ",", "_timestamp", ")", ":", "int_val", "=", "self", ".", "get_result", "(", "value", ")", "if", "int_val", "in", "self", ".", "error_str", ":", "err", "=", "self", ".", "error_str", "[", "...
[ 361, 4 ]
[ 378, 28 ]
python
en
['en', 'error', 'th']
False
predict_bam_batch
(batch, reads, model, threshold, batch_size, squiggle_size)
Make a prediction for a batch of signals
Make a prediction for a batch of signals
def predict_bam_batch(batch, reads, model, threshold, batch_size, squiggle_size): ''' Make a prediction for a batch of signals ''' read_ids, sig_len, batch = zip(*batch) sig_len = np.array(sig_len) batch = np.array(batch).reshape(batch_size, squiggle_...
[ "def", "predict_bam_batch", "(", "batch", ",", "reads", ",", "model", ",", "threshold", ",", "batch_size", ",", "squiggle_size", ")", ":", "read_ids", ",", "sig_len", ",", "batch", "=", "zip", "(", "*", "batch", ")", "sig_len", "=", "np", ".", "array", ...
[ 20, 0 ]
[ 36, 37 ]
python
en
['en', 'error', 'th']
False
predict_fq_batch
(batch, reads, model, trimmer, threshold, batch_size, squiggle_size)
Make a prediction for a batch of signals
Make a prediction for a batch of signals
def predict_fq_batch(batch, reads, model, trimmer, threshold, batch_size, squiggle_size): ''' Make a prediction for a batch of signals ''' read_ids, _, batch = zip(*batch) batch = np.array(batch).reshape(batch_size, squiggle_size, 1) preds = model.predi...
[ "def", "predict_fq_batch", "(", "batch", ",", "reads", ",", "model", ",", "trimmer", ",", "threshold", ",", "batch_size", ",", "squiggle_size", ")", ":", "read_ids", ",", "_", ",", "batch", "=", "zip", "(", "*", "batch", ")", "batch", "=", "np", ".", ...
[ 39, 0 ]
[ 52, 37 ]
python
en
['en', 'error', 'th']
False
bam_filter
(bam_fn, read_id_fast5_filemap, model, pass_output_bam_fn, fail_output_bam_fn, threshold=0.5, batch_size=5000, squiggle_size=2000, keep_unmapped=False, processes=8)
Filter a bam file using a model trained to detect adapters in signal from 5' end. Parameters: ---------- bam_fn: str, required Path to input bam file read_id_fast5_filemap: dict, required Dict of read_id: fast5 filepath key value pairs model: kera...
Filter a bam file using a model trained to detect adapters in signal from 5' end. Parameters: ---------- bam_fn: str, required Path to input bam file
def bam_filter(bam_fn, read_id_fast5_filemap, model, pass_output_bam_fn, fail_output_bam_fn, threshold=0.5, batch_size=5000, squiggle_size=2000, keep_unmapped=False, processes=8): ''' Filter a bam file using a model trained to detect adapters in signal from 5' en...
[ "def", "bam_filter", "(", "bam_fn", ",", "read_id_fast5_filemap", ",", "model", ",", "pass_output_bam_fn", ",", "fail_output_bam_fn", ",", "threshold", "=", "0.5", ",", "batch_size", "=", "5000", ",", "squiggle_size", "=", "2000", ",", "keep_unmapped", "=", "Fal...
[ 100, 0 ]
[ 183, 19 ]
python
en
['en', 'error', 'th']
False
fastq_filter
(fastq_fn, read_id_fast5_filemap, model, pass_output_fq_fn, fail_output_fq_fn, threshold=0.5, batch_size=5000, squiggle_size=2000, trim=False, processes=8)
Filter a bam file using a model trained to detect adapters in signal from 5' end. Parameters: ---------- fastq_fn: str, required Path to input fastq file read_id_fast5_filemap: dict, required Dict of read_id: fast5 filepath key value pairs model: ...
Filter a bam file using a model trained to detect adapters in signal from 5' end. Parameters: ---------- fastq_fn: str, required Path to input fastq file
def fastq_filter(fastq_fn, read_id_fast5_filemap, model, pass_output_fq_fn, fail_output_fq_fn, threshold=0.5, batch_size=5000, squiggle_size=2000, trim=False, processes=8): ''' Filter a bam file using a model trained to detect adapters in signal from 5' end...
[ "def", "fastq_filter", "(", "fastq_fn", ",", "read_id_fast5_filemap", ",", "model", ",", "pass_output_fq_fn", ",", "fail_output_fq_fn", ",", "threshold", "=", "0.5", ",", "batch_size", "=", "5000", ",", "squiggle_size", "=", "2000", ",", "trim", "=", "False", ...
[ 186, 0 ]
[ 270, 18 ]
python
en
['en', 'error', 'th']
False
prune_internal_data
(events: List[Dict[str, Any]])
Prunes the internal_data data structures, which are not intended to be exposed to API clients.
Prunes the internal_data data structures, which are not intended to be exposed to API clients.
def prune_internal_data(events: List[Dict[str, Any]]) -> List[Dict[str, Any]]: """Prunes the internal_data data structures, which are not intended to be exposed to API clients. """ events = copy.deepcopy(events) for event in events: if event["type"] == "message" and "internal_data" in event:...
[ "def", "prune_internal_data", "(", "events", ":", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "events", "=", "copy", ".", "deepcopy", "(", "events", ")", "for", "ev...
[ 383, 0 ]
[ 391, 17 ]
python
en
['en', 'en', 'en']
True
missedmessage_hook
( user_profile_id: int, client: ClientDescriptor, last_for_client: bool )
The receiver_is_off_zulip logic used to determine whether a user has no active client suffers from a somewhat fundamental race condition. If the client is no longer on the Internet, receiver_is_off_zulip will still return False for DEFAULT_EVENT_QUEUE_TIMEOUT_SECS, until the queue is garbage-collec...
The receiver_is_off_zulip logic used to determine whether a user has no active client suffers from a somewhat fundamental race condition. If the client is no longer on the Internet, receiver_is_off_zulip will still return False for DEFAULT_EVENT_QUEUE_TIMEOUT_SECS, until the queue is garbage-collec...
def missedmessage_hook( user_profile_id: int, client: ClientDescriptor, last_for_client: bool ) -> None: """The receiver_is_off_zulip logic used to determine whether a user has no active client suffers from a somewhat fundamental race condition. If the client is no longer on the Internet, receiver_...
[ "def", "missedmessage_hook", "(", "user_profile_id", ":", "int", ",", "client", ":", "ClientDescriptor", ",", "last_for_client", ":", "bool", ")", "->", "None", ":", "# Only process missedmessage hook when the last queue for a", "# client has been garbage collected", "if", ...
[ 704, 0 ]
[ 777, 9 ]
python
en
['en', 'en', 'en']
True
maybe_enqueue_notifications
( user_profile_id: int, message_id: int, private_message: bool, mentioned: bool, wildcard_mention_notify: bool, stream_push_notify: bool, stream_email_notify: bool, stream_name: Optional[str], online_push_enabled: bool, idle: bool, already_notified: Dict[str, bool], )
This function has a complete unit test suite in `test_enqueue_notifications` that should be expanded as we add more features here. See https://zulip.readthedocs.io/en/latest/subsystems/notifications.html for high-level design documentation.
This function has a complete unit test suite in `test_enqueue_notifications` that should be expanded as we add more features here.
def maybe_enqueue_notifications( user_profile_id: int, message_id: int, private_message: bool, mentioned: bool, wildcard_mention_notify: bool, stream_push_notify: bool, stream_email_notify: bool, stream_name: Optional[str], online_push_enabled: bool, idle: bool, already_notif...
[ "def", "maybe_enqueue_notifications", "(", "user_profile_id", ":", "int", ",", "message_id", ":", "int", ",", "private_message", ":", "bool", ",", "mentioned", ":", "bool", ",", "wildcard_mention_notify", ":", "bool", ",", "stream_push_notify", ":", "bool", ",", ...
[ 791, 0 ]
[ 853, 19 ]
python
en
['en', 'en', 'en']
True
get_client_info_for_message_event
( event_template: Mapping[str, Any], users: Iterable[Mapping[str, Any]] )
Return client info for all the clients interested in a message. This basically includes clients for users who are recipients of the message, with some nuances for bots that auto-subscribe to all streams, plus users who may be mentioned, etc.
Return client info for all the clients interested in a message. This basically includes clients for users who are recipients of the message, with some nuances for bots that auto-subscribe to all streams, plus users who may be mentioned, etc.
def get_client_info_for_message_event( event_template: Mapping[str, Any], users: Iterable[Mapping[str, Any]] ) -> Dict[str, ClientInfo]: """ Return client info for all the clients interested in a message. This basically includes clients for users who are recipients of the message, with some nuances ...
[ "def", "get_client_info_for_message_event", "(", "event_template", ":", "Mapping", "[", "str", ",", "Any", "]", ",", "users", ":", "Iterable", "[", "Mapping", "[", "str", ",", "Any", "]", "]", ")", "->", "Dict", "[", "str", ",", "ClientInfo", "]", ":", ...
[ 862, 0 ]
[ 901, 26 ]
python
en
['en', 'error', 'th']
False
process_message_event
( event_template: Mapping[str, Any], users: Collection[Mapping[str, Any]] )
See https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html for high-level documentation on this subsystem.
See https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html for high-level documentation on this subsystem.
def process_message_event( event_template: Mapping[str, Any], users: Collection[Mapping[str, Any]] ) -> None: """See https://zulip.readthedocs.io/en/latest/subsystems/sending-messages.html for high-level documentation on this subsystem. """ send_to_clients = get_client_info_for_message_event(eve...
[ "def", "process_message_event", "(", "event_template", ":", "Mapping", "[", "str", ",", "Any", "]", ",", "users", ":", "Collection", "[", "Mapping", "[", "str", ",", "Any", "]", "]", ")", "->", "None", ":", "send_to_clients", "=", "get_client_info_for_messag...
[ 904, 0 ]
[ 1044, 36 ]
python
en
['en', 'en', 'ur']
False
get_old_and_new_values
(change_type: str, message: Mapping[str, Any])
Parses the payload and finds previous and current value of change_type.
Parses the payload and finds previous and current value of change_type.
def get_old_and_new_values(change_type: str, message: Mapping[str, Any]) -> return_type: """Parses the payload and finds previous and current value of change_type.""" old = message["change"]["diff"][change_type].get("from") new = message["change"]["diff"][change_type].get("to") return old, new
[ "def", "get_old_and_new_values", "(", "change_type", ":", "str", ",", "message", ":", "Mapping", "[", "str", ",", "Any", "]", ")", "->", "return_type", ":", "old", "=", "message", "[", "\"change\"", "]", "[", "\"diff\"", "]", "[", "change_type", "]", "."...
[ 158, 0 ]
[ 162, 19 ]
python
en
['en', 'en', 'en']
True
parse_comment
(message: Mapping[str, Any])
Parses the comment to issue, task or US.
Parses the comment to issue, task or US.
def parse_comment(message: Mapping[str, Any]) -> Dict[str, Any]: """Parses the comment to issue, task or US.""" return { "event": "commented", "type": message["type"], "values": { "user": get_owner_name(message), "user_link": get_owner_link(message), "...
[ "def", "parse_comment", "(", "message", ":", "Mapping", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "return", "{", "\"event\"", ":", "\"commented\"", ",", "\"type\"", ":", "message", "[", "\"type\"", "]", ",", "\...
[ 165, 0 ]
[ 175, 5 ]
python
en
['en', 'en', 'en']
True
parse_create_or_delete
(message: Mapping[str, Any])
Parses create or delete event.
Parses create or delete event.
def parse_create_or_delete(message: Mapping[str, Any]) -> Dict[str, Any]: """Parses create or delete event.""" if message["type"] == "relateduserstory": return { "type": message["type"], "event": message["action"], "values": { "user": get_owner_name(me...
[ "def", "parse_create_or_delete", "(", "message", ":", "Mapping", "[", "str", ",", "Any", "]", ")", "->", "Dict", "[", "str", ",", "Any", "]", ":", "if", "message", "[", "\"type\"", "]", "==", "\"relateduserstory\"", ":", "return", "{", "\"type\"", ":", ...
[ 178, 0 ]
[ 200, 5 ]
python
en
['es', 'la', 'en']
False
parse_change_event
(change_type: str, message: Mapping[str, Any])
Parses change event.
Parses change event.
def parse_change_event(change_type: str, message: Mapping[str, Any]) -> Optional[Dict[str, Any]]: """Parses change event.""" evt: Dict[str, Any] = {} values: Dict[str, Any] = { "user": get_owner_name(message), "user_link": get_owner_link(message), "subject": get_subject(message), ...
[ "def", "parse_change_event", "(", "change_type", ":", "str", ",", "message", ":", "Mapping", "[", "str", ",", "Any", "]", ")", "->", "Optional", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "evt", ":", "Dict", "[", "str", ",", "Any", "]", ...
[ 203, 0 ]
[ 271, 14 ]
python
en
['es', 'fr', 'en']
False
parse_message
(message: Mapping[str, Any])
Parses the payload by delegating to specialized functions.
Parses the payload by delegating to specialized functions.
def parse_message(message: Mapping[str, Any]) -> List[Dict[str, Any]]: """Parses the payload by delegating to specialized functions.""" events = [] if message["action"] in ["create", "delete"]: events.append(parse_create_or_delete(message)) elif message["action"] == "change": if message[...
[ "def", "parse_message", "(", "message", ":", "Mapping", "[", "str", ",", "Any", "]", ")", "->", "List", "[", "Dict", "[", "str", ",", "Any", "]", "]", ":", "events", "=", "[", "]", "if", "message", "[", "\"action\"", "]", "in", "[", "\"create\"", ...
[ 286, 0 ]
[ 302, 17 ]
python
en
['en', 'en', 'en']
True
generate_content
(data: Mapping[str, Any])
Gets the template string and formats it with parsed data.
Gets the template string and formats it with parsed data.
def generate_content(data: Mapping[str, Any]) -> str: """Gets the template string and formats it with parsed data.""" template = templates[data["type"]][data["event"]] content = template.format(**data["values"]) return content
[ "def", "generate_content", "(", "data", ":", "Mapping", "[", "str", ",", "Any", "]", ")", "->", "str", ":", "template", "=", "templates", "[", "data", "[", "\"type\"", "]", "]", "[", "data", "[", "\"event\"", "]", "]", "content", "=", "template", "."...
[ 305, 0 ]
[ 309, 18 ]
python
en
['en', 'en', 'en']
True
extract_attrs
(attr_string)
helper method to extract tag attributes, as a dict of un-escaped strings
helper method to extract tag attributes, as a dict of un-escaped strings
def extract_attrs(attr_string): """ helper method to extract tag attributes, as a dict of un-escaped strings """ attributes = {} for name, val in FIND_ATTRS.findall(attr_string): val = val.replace('&lt;', '<').replace('&gt;', '>').replace('&quot;', '"').replace('&amp;', '&') attribut...
[ "def", "extract_attrs", "(", "attr_string", ")", ":", "attributes", "=", "{", "}", "for", "name", ",", "val", "in", "FIND_ATTRS", ".", "findall", "(", "attr_string", ")", ":", "val", "=", "val", ".", "replace", "(", "'&lt;'", ",", "'<'", ")", ".", "r...
[ 12, 0 ]
[ 20, 21 ]
python
en
['en', 'error', 'th']
False
Criterion.from_requirement
(cls, provider, requirement, parent)
Build an instance from a requirement.
Build an instance from a requirement.
def from_requirement(cls, provider, requirement, parent): """Build an instance from a requirement.""" cands = build_iter_view(provider.find_matches([requirement])) infos = [RequirementInformation(requirement, parent)] criterion = cls(cands, infos, incompatibilities=[]) if not can...
[ "def", "from_requirement", "(", "cls", ",", "provider", ",", "requirement", ",", "parent", ")", ":", "cands", "=", "build_iter_view", "(", "provider", ".", "find_matches", "(", "[", "requirement", "]", ")", ")", "infos", "=", "[", "RequirementInformation", "...
[ 76, 4 ]
[ 83, 24 ]
python
en
['en', 'en', 'en']
True
Criterion.merged_with
(self, provider, requirement, parent)
Build a new instance from this and a new requirement.
Build a new instance from this and a new requirement.
def merged_with(self, provider, requirement, parent): """Build a new instance from this and a new requirement.""" infos = list(self.information) infos.append(RequirementInformation(requirement, parent)) cands = build_iter_view(provider.find_matches([r for r, _ in infos])) criteri...
[ "def", "merged_with", "(", "self", ",", "provider", ",", "requirement", ",", "parent", ")", ":", "infos", "=", "list", "(", "self", ".", "information", ")", "infos", ".", "append", "(", "RequirementInformation", "(", "requirement", ",", "parent", ")", ")",...
[ 91, 4 ]
[ 99, 24 ]
python
en
['en', 'en', 'en']
True
Criterion.excluded_of
(self, candidates)
Build a new instance from this, but excluding specified candidates. Returns the new instance, or None if we still have no valid candidates.
Build a new instance from this, but excluding specified candidates.
def excluded_of(self, candidates): """Build a new instance from this, but excluding specified candidates. Returns the new instance, or None if we still have no valid candidates. """ cands = self.candidates.excluding(candidates) if not cands: return None incom...
[ "def", "excluded_of", "(", "self", ",", "candidates", ")", ":", "cands", "=", "self", ".", "candidates", ".", "excluding", "(", "candidates", ")", "if", "not", "cands", ":", "return", "None", "incompats", "=", "self", ".", "incompatibilities", "+", "candid...
[ 101, 4 ]
[ 110, 67 ]
python
en
['en', 'en', 'en']
True
Resolution._push_new_state
(self)
Push a new state into history. This new state will be used to hold resolution results of the next coming round.
Push a new state into history.
def _push_new_state(self): """Push a new state into history. This new state will be used to hold resolution results of the next coming round. """ base = self._states[-1] state = State( mapping=base.mapping.copy(), criteria=base.criteria.copy(), ...
[ "def", "_push_new_state", "(", "self", ")", ":", "base", "=", "self", ".", "_states", "[", "-", "1", "]", "state", "=", "State", "(", "mapping", "=", "base", ".", "mapping", ".", "copy", "(", ")", ",", "criteria", "=", "base", ".", "criteria", ".",...
[ 153, 4 ]
[ 164, 34 ]
python
en
['en', 'en', 'en']
True
Resolution._backtrack
(self)
Perform backtracking. When we enter here, the stack is like this:: [ state Z ] [ state Y ] [ state X ] .... earlier states are irrelevant. 1. No pins worked for Z, so it does not have a pin. 2. We want to reset state Y to unpinned, and pin anoth...
Perform backtracking.
def _backtrack(self): """Perform backtracking. When we enter here, the stack is like this:: [ state Z ] [ state Y ] [ state X ] .... earlier states are irrelevant. 1. No pins worked for Z, so it does not have a pin. 2. We want to reset s...
[ "def", "_backtrack", "(", "self", ")", ":", "while", "len", "(", "self", ".", "_states", ")", ">=", "3", ":", "# Remove the state that triggered backtracking.", "del", "self", ".", "_states", "[", "-", "1", "]", "# Retrieve the last candidate pin and known incompati...
[ 235, 4 ]
[ 297, 20 ]
python
en
['en', 'en', 'en']
False
Resolver.resolve
(self, requirements, max_rounds=100)
Take a collection of constraints, spit out the resolution result. The return value is a representation to the final resolution result. It is a tuple subclass with three public members: * `mapping`: A dict of resolved candidates. Each key is an identifier of a requirement (as return...
Take a collection of constraints, spit out the resolution result.
def resolve(self, requirements, max_rounds=100): """Take a collection of constraints, spit out the resolution result. The return value is a representation to the final resolution result. It is a tuple subclass with three public members: * `mapping`: A dict of resolved candidates. Each ...
[ "def", "resolve", "(", "self", ",", "requirements", ",", "max_rounds", "=", "100", ")", ":", "resolution", "=", "Resolution", "(", "self", ".", "provider", ",", "self", ".", "reporter", ")", "state", "=", "resolution", ".", "resolve", "(", "requirements", ...
[ 415, 4 ]
[ 445, 35 ]
python
en
['en', 'en', 'en']
True
truncate_name
(name, length=None, hash_len=4)
Shorten a string to a repeatable mangled version with the given length. If a quote stripped name contains a username, e.g. USERNAME"."TABLE, truncate the table portion only.
Shorten a string to a repeatable mangled version with the given length. If a quote stripped name contains a username, e.g. USERNAME"."TABLE, truncate the table portion only.
def truncate_name(name, length=None, hash_len=4): """ Shorten a string to a repeatable mangled version with the given length. If a quote stripped name contains a username, e.g. USERNAME"."TABLE, truncate the table portion only. """ match = re.match(r'([^"]+)"\."([^"]+)', name) table_name = m...
[ "def", "truncate_name", "(", "name", ",", "length", "=", "None", ",", "hash_len", "=", "4", ")", ":", "match", "=", "re", ".", "match", "(", "r'([^\"]+)\"\\.\"([^\"]+)'", ",", "name", ")", "table_name", "=", "match", ".", "group", "(", "2", ")", "if", ...
[ 182, 0 ]
[ 195, 100 ]
python
en
['en', 'error', 'th']
False
format_number
(value, max_digits, decimal_places)
Formats a number into a string with the requisite number of digits and decimal places.
Formats a number into a string with the requisite number of digits and decimal places.
def format_number(value, max_digits, decimal_places): """ Formats a number into a string with the requisite number of digits and decimal places. """ if value is None: return None if isinstance(value, decimal.Decimal): context = decimal.getcontext().copy() if max_digits is...
[ "def", "format_number", "(", "value", ",", "max_digits", ",", "decimal_places", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "isinstance", "(", "value", ",", "decimal", ".", "Decimal", ")", ":", "context", "=", "decimal", ".", "get...
[ 198, 0 ]
[ 217, 31 ]
python
en
['en', 'error', 'th']
False
strip_quotes
(table_name)
Strip quotes off of quoted table names to make them safe for use in index names, sequence names, etc. For example '"USER"."TABLE"' (an Oracle naming scheme) becomes 'USER"."TABLE'.
Strip quotes off of quoted table names to make them safe for use in index names, sequence names, etc. For example '"USER"."TABLE"' (an Oracle naming scheme) becomes 'USER"."TABLE'.
def strip_quotes(table_name): """ Strip quotes off of quoted table names to make them safe for use in index names, sequence names, etc. For example '"USER"."TABLE"' (an Oracle naming scheme) becomes 'USER"."TABLE'. """ has_quotes = table_name.startswith('"') and table_name.endswith('"') retu...
[ "def", "strip_quotes", "(", "table_name", ")", ":", "has_quotes", "=", "table_name", ".", "startswith", "(", "'\"'", ")", "and", "table_name", ".", "endswith", "(", "'\"'", ")", "return", "table_name", "[", "1", ":", "-", "1", "]", "if", "has_quotes", "e...
[ 220, 0 ]
[ 227, 57 ]
python
en
['en', 'error', 'th']
False
check.initialize_options
(self)
Sets default values for options.
Sets default values for options.
def initialize_options(self): """Sets default values for options.""" self.restructuredtext = 0 self.metadata = 1 self.strict = 0 self._warnings = 0
[ "def", "initialize_options", "(", "self", ")", ":", "self", ".", "restructuredtext", "=", "0", "self", ".", "metadata", "=", "1", "self", ".", "strict", "=", "0", "self", ".", "_warnings", "=", "0" ]
[ 47, 4 ]
[ 52, 26 ]
python
fr
['fr', 'fr', 'en']
True
check.warn
(self, msg)
Counts the number of warnings that occurs.
Counts the number of warnings that occurs.
def warn(self, msg): """Counts the number of warnings that occurs.""" self._warnings += 1 return Command.warn(self, msg)
[ "def", "warn", "(", "self", ",", "msg", ")", ":", "self", ".", "_warnings", "+=", "1", "return", "Command", ".", "warn", "(", "self", ",", "msg", ")" ]
[ 57, 4 ]
[ 60, 38 ]
python
en
['en', 'en', 'en']
True
check.run
(self)
Runs the command.
Runs the command.
def run(self): """Runs the command.""" # perform the various tests if self.metadata: self.check_metadata() if self.restructuredtext: if HAS_DOCUTILS: self.check_restructuredtext() elif self.strict: raise DistutilsSetupEr...
[ "def", "run", "(", "self", ")", ":", "# perform the various tests", "if", "self", ".", "metadata", ":", "self", ".", "check_metadata", "(", ")", "if", "self", ".", "restructuredtext", ":", "if", "HAS_DOCUTILS", ":", "self", ".", "check_restructuredtext", "(", ...
[ 62, 4 ]
[ 76, 69 ]
python
en
['en', 'it', 'en']
True
check.check_metadata
(self)
Ensures that all required elements of meta-data are supplied. Required fields: name, version, URL Recommended fields: (author and author_email) or (maintainer and maintainer_email)) Warns if any are missing.
Ensures that all required elements of meta-data are supplied.
def check_metadata(self): """Ensures that all required elements of meta-data are supplied. Required fields: name, version, URL Recommended fields: (author and author_email) or (maintainer and maintainer_email)) Warns if any are missing. """ meta...
[ "def", "check_metadata", "(", "self", ")", ":", "metadata", "=", "self", ".", "distribution", ".", "metadata", "missing", "=", "[", "]", "for", "attr", "in", "(", "'name'", ",", "'version'", ",", "'url'", ")", ":", "if", "not", "(", "hasattr", "(", "...
[ 78, 4 ]
[ 109, 43 ]
python
en
['en', 'en', 'en']
True
check.check_restructuredtext
(self)
Checks if the long string fields are reST-compliant.
Checks if the long string fields are reST-compliant.
def check_restructuredtext(self): """Checks if the long string fields are reST-compliant.""" data = self.distribution.get_long_description() for warning in self._check_rst_data(data): line = warning[-1].get('line') if line is None: warning = warning[1] ...
[ "def", "check_restructuredtext", "(", "self", ")", ":", "data", "=", "self", ".", "distribution", ".", "get_long_description", "(", ")", "for", "warning", "in", "self", ".", "_check_rst_data", "(", "data", ")", ":", "line", "=", "warning", "[", "-", "1", ...
[ 111, 4 ]
[ 120, 30 ]
python
en
['en', 'en', 'en']
True
check._check_rst_data
(self, data)
Returns warnings when the provided data doesn't compile.
Returns warnings when the provided data doesn't compile.
def _check_rst_data(self, data): """Returns warnings when the provided data doesn't compile.""" # the include and csv_table directives need this to be a path source_path = self.distribution.script_name or 'setup.py' parser = Parser() settings = frontend.OptionParser(components=(P...
[ "def", "_check_rst_data", "(", "self", ",", "data", ")", ":", "# the include and csv_table directives need this to be a path", "source_path", "=", "self", ".", "distribution", ".", "script_name", "or", "'setup.py'", "parser", "=", "Parser", "(", ")", "settings", "=", ...
[ 122, 4 ]
[ 147, 32 ]
python
en
['en', 'en', 'en']
True
EzsApp.build
(self)
This method loads the root.kv file automatically :rtype: none
This method loads the root.kv file automatically
def build(self): '''This method loads the root.kv file automatically :rtype: none ''' # loading the content of root.kv self.root = Builder.load_file('kv/root.kv')
[ "def", "build", "(", "self", ")", ":", "# loading the content of root.kv", "self", ".", "root", "=", "Builder", ".", "load_file", "(", "'kv/root.kv'", ")" ]
[ 30, 4 ]
[ 36, 51 ]
python
en
['en', 'en', 'en']
True
EzsApp.next_screen
(self, screen)
Clear container and load the given screen object from file in kv folder. :param screen: name of the screen object made from the loaded .kv file :type screen: str :rtype: none
Clear container and load the given screen object from file in kv folder.
def next_screen(self, screen): '''Clear container and load the given screen object from file in kv folder. :param screen: name of the screen object made from the loaded .kv file :type screen: str :rtype: none ''' filename = screen + '.kv' # unload the conten...
[ "def", "next_screen", "(", "self", ",", "screen", ")", ":", "filename", "=", "screen", "+", "'.kv'", "# unload the content of the .kv file", "# reason: it could have data from previous calls", "Builder", ".", "unload_file", "(", "'kv/'", "+", "filename", ")", "# clear t...
[ 38, 4 ]
[ 56, 46 ]
python
en
['en', 'en', 'en']
True
normalize_adj
(mx)
Row-normalize sparse matrix
Row-normalize sparse matrix
def normalize_adj(mx): """Row-normalize sparse matrix""" rowsum = np.array(mx.sum(1)) r_inv_sqrt = np.power(rowsum, -0.5).flatten() r_inv_sqrt[np.isinf(r_inv_sqrt)] = 0. r_mat_inv_sqrt = sp.diags(r_inv_sqrt) return mx.dot(r_mat_inv_sqrt).transpose().dot(r_mat_inv_sqrt).tocoo()
[ "def", "normalize_adj", "(", "mx", ")", ":", "rowsum", "=", "np", ".", "array", "(", "mx", ".", "sum", "(", "1", ")", ")", "r_inv_sqrt", "=", "np", ".", "power", "(", "rowsum", ",", "-", "0.5", ")", ".", "flatten", "(", ")", "r_inv_sqrt", "[", ...
[ 17, 0 ]
[ 24, 73 ]
python
en
['en', 'en', 'tr']
True
load_data
(path="data", dataset="cora")
ind.[:dataset].x => the feature vectors of the training instances (scipy.sparse.csr.csr_matrix) ind.[:dataset].y => the one-hot labels of the labeled training instances (numpy.ndarray) ind.[:dataset].allx => the feature vectors of both labeled and unlabeled training instances (csr_matrix) ind....
ind.[:dataset].x => the feature vectors of the training instances (scipy.sparse.csr.csr_matrix) ind.[:dataset].y => the one-hot labels of the labeled training instances (numpy.ndarray) ind.[:dataset].allx => the feature vectors of both labeled and unlabeled training instances (csr_matrix) ind....
def load_data(path="data", dataset="cora"): """ ind.[:dataset].x => the feature vectors of the training instances (scipy.sparse.csr.csr_matrix) ind.[:dataset].y => the one-hot labels of the labeled training instances (numpy.ndarray) ind.[:dataset].allx => the feature vectors of both labeled and...
[ "def", "load_data", "(", "path", "=", "\"data\"", ",", "dataset", "=", "\"cora\"", ")", ":", "names", "=", "[", "'x'", ",", "'y'", ",", "'tx'", ",", "'ty'", ",", "'allx'", ",", "'ally'", ",", "'graph'", "]", "objects", "=", "[", "]", "for", "i", ...
[ 60, 0 ]
[ 139, 68 ]
python
en
['en', 'error', 'th']
False
normalize
(mx)
Row-normalize sparse matrix
Row-normalize sparse matrix
def normalize(mx): """Row-normalize sparse matrix""" rowsum = np.array(mx.sum(1)) r_inv = np.power(rowsum, -1).flatten() r_inv[np.isinf(r_inv)] = 0. r_mat_inv = sp.diags(r_inv) mx = r_mat_inv.dot(mx) # now rowsum is 1 for each row return mx
[ "def", "normalize", "(", "mx", ")", ":", "rowsum", "=", "np", ".", "array", "(", "mx", ".", "sum", "(", "1", ")", ")", "r_inv", "=", "np", ".", "power", "(", "rowsum", ",", "-", "1", ")", ".", "flatten", "(", ")", "r_inv", "[", "np", ".", "...
[ 142, 0 ]
[ 149, 13 ]
python
en
['en', 'en', 'tr']
True
sparse_mx_to_torch_sparse_tensor
(sparse_mx)
Convert a scipy sparse matrix to a torch sparse tensor.
Convert a scipy sparse matrix to a torch sparse tensor.
def sparse_mx_to_torch_sparse_tensor(sparse_mx): """Convert a scipy sparse matrix to a torch sparse tensor.""" sparse_mx = sparse_mx.tocoo().astype(np.float32) indices = torch.from_numpy( np.vstack((sparse_mx.row, sparse_mx.col)).astype(np.int64)) values = torch.from_numpy(sparse_mx.data) sh...
[ "def", "sparse_mx_to_torch_sparse_tensor", "(", "sparse_mx", ")", ":", "sparse_mx", "=", "sparse_mx", ".", "tocoo", "(", ")", ".", "astype", "(", "np", ".", "float32", ")", "indices", "=", "torch", ".", "from_numpy", "(", "np", ".", "vstack", "(", "(", "...
[ 170, 0 ]
[ 177, 59 ]
python
en
['en', 'en', 'it']
True
PostGISOperations.spatial_version
(self)
Determine the version of the PostGIS library.
Determine the version of the PostGIS library.
def spatial_version(self): """Determine the version of the PostGIS library.""" # Trying to get the PostGIS version because the function # signatures will depend on the version used. The cost # here is a database query to determine the version, which # can be mitigated by setting...
[ "def", "spatial_version", "(", "self", ")", ":", "# Trying to get the PostGIS version because the function", "# signatures will depend on the version used. The cost", "# here is a database query to determine the version, which", "# can be mitigated by setting `POSTGIS_VERSION` with a 3-tuple", ...
[ 212, 4 ]
[ 239, 22 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.convert_extent
(self, box, srid)
Returns a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)".
Returns a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)".
def convert_extent(self, box, srid): """ Returns a 4-tuple extent for the `Extent` aggregate by converting the bounding box text returned by PostGIS (`box` argument), for example: "BOX(-90.0 30.0, -85.0 40.0)". """ if box is None: return None ll, ur = ...
[ "def", "convert_extent", "(", "self", ",", "box", ",", "srid", ")", ":", "if", "box", "is", "None", ":", "return", "None", "ll", ",", "ur", "=", "box", "[", "4", ":", "-", "1", "]", ".", "split", "(", "','", ")", "xmin", ",", "ymin", "=", "ma...
[ 241, 4 ]
[ 252, 39 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.convert_extent3d
(self, box3d, srid)
Returns a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)".
Returns a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)".
def convert_extent3d(self, box3d, srid): """ Returns a 6-tuple extent for the `Extent3D` aggregate by converting the 3d bounding-box text returned by PostGIS (`box3d` argument), for example: "BOX3D(-90.0 30.0 1, -85.0 40.0 2)". """ if box3d is None: return Non...
[ "def", "convert_extent3d", "(", "self", ",", "box3d", ",", "srid", ")", ":", "if", "box3d", "is", "None", ":", "return", "None", "ll", ",", "ur", "=", "box3d", "[", "6", ":", "-", "1", "]", ".", "split", "(", "','", ")", "xmin", ",", "ymin", ",...
[ 254, 4 ]
[ 265, 51 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.geo_db_type
(self, f)
Return the database field type for the given spatial field.
Return the database field type for the given spatial field.
def geo_db_type(self, f): """ Return the database field type for the given spatial field. """ if f.geom_type == 'RASTER': return 'raster' # Type-based geometries. # TODO: Support 'M' extension. if f.dim == 3: geom_type = f.geom_type + 'Z' ...
[ "def", "geo_db_type", "(", "self", ",", "f", ")", ":", "if", "f", ".", "geom_type", "==", "'RASTER'", ":", "return", "'raster'", "# Type-based geometries.", "# TODO: Support 'M' extension.", "if", "f", ".", "dim", "==", "3", ":", "geom_type", "=", "f", ".", ...
[ 267, 4 ]
[ 286, 58 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.get_distance
(self, f, dist_val, lookup_type, handle_spheroid=True)
Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type. This is the most complex implementation of the spatial backends due to what is supported on geodetic geometry columns vs. what's available on projected geometry c...
Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type.
def get_distance(self, f, dist_val, lookup_type, handle_spheroid=True): """ Retrieve the distance parameters for the given geometry field, distance lookup value, and the distance lookup type. This is the most complex implementation of the spatial backends due to what is supporte...
[ "def", "get_distance", "(", "self", ",", "f", ",", "dist_val", ",", "lookup_type", ",", "handle_spheroid", "=", "True", ")", ":", "# Getting the distance parameter", "value", "=", "dist_val", "[", "0", "]", "# Shorthand boolean flags.", "geodetic", "=", "f", "."...
[ 288, 4 ]
[ 328, 21 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.get_geom_placeholder
(self, f, value, compiler)
Provide a proper substitution value for Geometries or rasters that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call.
Provide a proper substitution value for Geometries or rasters that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call.
def get_geom_placeholder(self, f, value, compiler): """ Provide a proper substitution value for Geometries or rasters that are not in the SRID of the field. Specifically, this routine will substitute in the ST_Transform() function call. """ # Get the srid for this object ...
[ "def", "get_geom_placeholder", "(", "self", ",", "f", ",", "value", ",", "compiler", ")", ":", "# Get the srid for this object", "if", "value", "is", "None", ":", "value_srid", "=", "None", "elif", "f", ".", "geom_type", "==", "'RASTER'", "and", "isinstance", ...
[ 330, 4 ]
[ 360, 26 ]
python
en
['en', 'error', 'th']
False
PostGISOperations._get_postgis_func
(self, func)
Helper routine for calling PostGIS functions and returning their result.
Helper routine for calling PostGIS functions and returning their result.
def _get_postgis_func(self, func): """ Helper routine for calling PostGIS functions and returning their result. """ # Close out the connection. See #9437. with self.connection.temporary_connection() as cursor: cursor.execute('SELECT %s()' % func) return c...
[ "def", "_get_postgis_func", "(", "self", ",", "func", ")", ":", "# Close out the connection. See #9437.", "with", "self", ".", "connection", ".", "temporary_connection", "(", ")", "as", "cursor", ":", "cursor", ".", "execute", "(", "'SELECT %s()'", "%", "func", ...
[ 362, 4 ]
[ 369, 39 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.postgis_geos_version
(self)
Returns the version of the GEOS library used with PostGIS.
Returns the version of the GEOS library used with PostGIS.
def postgis_geos_version(self): "Returns the version of the GEOS library used with PostGIS." return self._get_postgis_func('postgis_geos_version')
[ "def", "postgis_geos_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_geos_version'", ")" ]
[ 371, 4 ]
[ 373, 61 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_lib_version
(self)
Returns the version number of the PostGIS library used with PostgreSQL.
Returns the version number of the PostGIS library used with PostgreSQL.
def postgis_lib_version(self): "Returns the version number of the PostGIS library used with PostgreSQL." return self._get_postgis_func('postgis_lib_version')
[ "def", "postgis_lib_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_lib_version'", ")" ]
[ 375, 4 ]
[ 377, 60 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_proj_version
(self)
Returns the version of the PROJ.4 library used with PostGIS.
Returns the version of the PROJ.4 library used with PostGIS.
def postgis_proj_version(self): "Returns the version of the PROJ.4 library used with PostGIS." return self._get_postgis_func('postgis_proj_version')
[ "def", "postgis_proj_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_proj_version'", ")" ]
[ 379, 4 ]
[ 381, 61 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_version
(self)
Returns PostGIS version number and compile-time options.
Returns PostGIS version number and compile-time options.
def postgis_version(self): "Returns PostGIS version number and compile-time options." return self._get_postgis_func('postgis_version')
[ "def", "postgis_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_version'", ")" ]
[ 383, 4 ]
[ 385, 56 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_full_version
(self)
Returns PostGIS version number and compile-time options.
Returns PostGIS version number and compile-time options.
def postgis_full_version(self): "Returns PostGIS version number and compile-time options." return self._get_postgis_func('postgis_full_version')
[ "def", "postgis_full_version", "(", "self", ")", ":", "return", "self", ".", "_get_postgis_func", "(", "'postgis_full_version'", ")" ]
[ 387, 4 ]
[ 389, 61 ]
python
en
['en', 'en', 'en']
True
PostGISOperations.postgis_version_tuple
(self)
Returns the PostGIS version as a tuple (version string, major, minor, subminor).
Returns the PostGIS version as a tuple (version string, major, minor, subminor).
def postgis_version_tuple(self): """ Returns the PostGIS version as a tuple (version string, major, minor, subminor). """ # Getting the PostGIS version version = self.postgis_lib_version() m = self.version_regex.match(version) if m: major = in...
[ "def", "postgis_version_tuple", "(", "self", ")", ":", "# Getting the PostGIS version", "version", "=", "self", ".", "postgis_lib_version", "(", ")", "m", "=", "self", ".", "version_regex", ".", "match", "(", "version", ")", "if", "m", ":", "major", "=", "in...
[ 391, 4 ]
[ 407, 47 ]
python
en
['en', 'error', 'th']
False
PostGISOperations.proj_version_tuple
(self)
Return the version of PROJ.4 used by PostGIS as a tuple of the major, minor, and subminor release numbers.
Return the version of PROJ.4 used by PostGIS as a tuple of the major, minor, and subminor release numbers.
def proj_version_tuple(self): """ Return the version of PROJ.4 used by PostGIS as a tuple of the major, minor, and subminor release numbers. """ proj_regex = re.compile(r'(\d+)\.(\d+)\.(\d+)') proj_ver_str = self.postgis_proj_version() m = proj_regex.search(proj_v...
[ "def", "proj_version_tuple", "(", "self", ")", ":", "proj_regex", "=", "re", ".", "compile", "(", "r'(\\d+)\\.(\\d+)\\.(\\d+)'", ")", "proj_ver_str", "=", "self", ".", "postgis_proj_version", "(", ")", "m", "=", "proj_regex", ".", "search", "(", "proj_ver_str", ...
[ 409, 4 ]
[ 420, 79 ]
python
en
['en', 'error', 'th']
False
build_instance
(Model, data, db)
Build a model instance. If the model instance doesn't have a primary key and the model supports natural keys, try to retrieve it from the database.
Build a model instance.
def build_instance(Model, data, db): """ Build a model instance. If the model instance doesn't have a primary key and the model supports natural keys, try to retrieve it from the database. """ obj = Model(**data) if (obj.pk is None and hasattr(Model, 'natural_key') and hasattr(M...
[ "def", "build_instance", "(", "Model", ",", "data", ",", "db", ")", ":", "obj", "=", "Model", "(", "*", "*", "data", ")", "if", "(", "obj", ".", "pk", "is", "None", "and", "hasattr", "(", "Model", ",", "'natural_key'", ")", "and", "hasattr", "(", ...
[ 214, 0 ]
[ 229, 14 ]
python
en
['en', 'error', 'th']
False
DeserializationError.WithData
(cls, original_exc, model, fk, field_value)
Factory method for creating a deserialization error which has a more explanatory message.
Factory method for creating a deserialization error which has a more explanatory message.
def WithData(cls, original_exc, model, fk, field_value): """ Factory method for creating a deserialization error which has a more explanatory message. """ return cls("%s: (%s:pk=%s) field_value was '%s'" % (original_exc, model, fk, field_value))
[ "def", "WithData", "(", "cls", ",", "original_exc", ",", "model", ",", "fk", ",", "field_value", ")", ":", "return", "cls", "(", "\"%s: (%s:pk=%s) field_value was '%s'\"", "%", "(", "original_exc", ",", "model", ",", "fk", ",", "field_value", ")", ")" ]
[ 21, 4 ]
[ 26, 98 ]
python
en
['en', 'error', 'th']
False
Serializer.serialize
(self, queryset, **options)
Serialize a queryset.
Serialize a queryset.
def serialize(self, queryset, **options): """ Serialize a queryset. """ self.options = options self.stream = options.pop("stream", self.stream_class()) self.selected_fields = options.pop("fields", None) self.use_natural_foreign_keys = options.pop('use_natural_for...
[ "def", "serialize", "(", "self", ",", "queryset", ",", "*", "*", "options", ")", ":", "self", ".", "options", "=", "options", "self", ".", "stream", "=", "options", ".", "pop", "(", "\"stream\"", ",", "self", ".", "stream_class", "(", ")", ")", "self...
[ 63, 4 ]
[ 101, 30 ]
python
en
['en', 'error', 'th']
False
Serializer.start_serialization
(self)
Called when serializing of the queryset starts.
Called when serializing of the queryset starts.
def start_serialization(self): """ Called when serializing of the queryset starts. """ raise NotImplementedError('subclasses of Serializer must provide a start_serialization() method')
[ "def", "start_serialization", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide a start_serialization() method'", ")" ]
[ 103, 4 ]
[ 107, 105 ]
python
en
['en', 'error', 'th']
False
Serializer.end_serialization
(self)
Called when serializing of the queryset ends.
Called when serializing of the queryset ends.
def end_serialization(self): """ Called when serializing of the queryset ends. """ pass
[ "def", "end_serialization", "(", "self", ")", ":", "pass" ]
[ 109, 4 ]
[ 113, 12 ]
python
en
['en', 'error', 'th']
False
Serializer.start_object
(self, obj)
Called when serializing of an object starts.
Called when serializing of an object starts.
def start_object(self, obj): """ Called when serializing of an object starts. """ raise NotImplementedError('subclasses of Serializer must provide a start_object() method')
[ "def", "start_object", "(", "self", ",", "obj", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide a start_object() method'", ")" ]
[ 115, 4 ]
[ 119, 98 ]
python
en
['en', 'error', 'th']
False
Serializer.end_object
(self, obj)
Called when serializing of an object ends.
Called when serializing of an object ends.
def end_object(self, obj): """ Called when serializing of an object ends. """ pass
[ "def", "end_object", "(", "self", ",", "obj", ")", ":", "pass" ]
[ 121, 4 ]
[ 125, 12 ]
python
en
['en', 'error', 'th']
False
Serializer.handle_field
(self, obj, field)
Called to handle each individual (non-relational) field on an object.
Called to handle each individual (non-relational) field on an object.
def handle_field(self, obj, field): """ Called to handle each individual (non-relational) field on an object. """ raise NotImplementedError('subclasses of Serializer must provide an handle_field() method')
[ "def", "handle_field", "(", "self", ",", "obj", ",", "field", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide an handle_field() method'", ")" ]
[ 127, 4 ]
[ 131, 99 ]
python
en
['en', 'error', 'th']
False
Serializer.handle_fk_field
(self, obj, field)
Called to handle a ForeignKey field.
Called to handle a ForeignKey field.
def handle_fk_field(self, obj, field): """ Called to handle a ForeignKey field. """ raise NotImplementedError('subclasses of Serializer must provide an handle_fk_field() method')
[ "def", "handle_fk_field", "(", "self", ",", "obj", ",", "field", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide an handle_fk_field() method'", ")" ]
[ 133, 4 ]
[ 137, 102 ]
python
en
['en', 'error', 'th']
False
Serializer.handle_m2m_field
(self, obj, field)
Called to handle a ManyToManyField.
Called to handle a ManyToManyField.
def handle_m2m_field(self, obj, field): """ Called to handle a ManyToManyField. """ raise NotImplementedError('subclasses of Serializer must provide an handle_m2m_field() method')
[ "def", "handle_m2m_field", "(", "self", ",", "obj", ",", "field", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Serializer must provide an handle_m2m_field() method'", ")" ]
[ 139, 4 ]
[ 143, 103 ]
python
en
['en', 'error', 'th']
False
Serializer.getvalue
(self)
Return the fully serialized queryset (or None if the output stream is not seekable).
Return the fully serialized queryset (or None if the output stream is not seekable).
def getvalue(self): """ Return the fully serialized queryset (or None if the output stream is not seekable). """ if callable(getattr(self.stream, 'getvalue', None)): return self.stream.getvalue()
[ "def", "getvalue", "(", "self", ")", ":", "if", "callable", "(", "getattr", "(", "self", ".", "stream", ",", "'getvalue'", ",", "None", ")", ")", ":", "return", "self", ".", "stream", ".", "getvalue", "(", ")" ]
[ 145, 4 ]
[ 151, 41 ]
python
en
['en', 'error', 'th']
False
Deserializer.__init__
(self, stream_or_string, **options)
Init this serializer given a stream or a string
Init this serializer given a stream or a string
def __init__(self, stream_or_string, **options): """ Init this serializer given a stream or a string """ self.options = options if isinstance(stream_or_string, six.string_types): self.stream = six.StringIO(stream_or_string) else: self.stream = stre...
[ "def", "__init__", "(", "self", ",", "stream_or_string", ",", "*", "*", "options", ")", ":", "self", ".", "options", "=", "options", "if", "isinstance", "(", "stream_or_string", ",", "six", ".", "string_types", ")", ":", "self", ".", "stream", "=", "six"...
[ 159, 4 ]
[ 167, 42 ]
python
en
['en', 'error', 'th']
False
Deserializer.__next__
(self)
Iteration iterface -- return the next item in the stream
Iteration iterface -- return the next item in the stream
def __next__(self): """Iteration iterface -- return the next item in the stream""" raise NotImplementedError('subclasses of Deserializer must provide a __next__() method')
[ "def", "__next__", "(", "self", ")", ":", "raise", "NotImplementedError", "(", "'subclasses of Deserializer must provide a __next__() method'", ")" ]
[ 172, 4 ]
[ 174, 96 ]
python
en
['en', 'en', 'en']
True
Attack.__init__
(self, args)
TODO: Write Comment
TODO: Write Comment
def __init__(self, args): """ TODO: Write Comment """ self.args = args self.VERBOSE = self.args.verbose self.FAMILY_DATASET = self.args.family_dataset self.NUM_MODEL = self.args.model self.NUM_SAMPLES = ...
[ "def", "__init__", "(", "self", ",", "args", ")", ":", "self", ".", "args", "=", "args", "self", ".", "VERBOSE", "=", "self", ".", "args", ".", "verbose", "self", ".", "FAMILY_DATASET", "=", "self", ".", "args", ".", "family_dataset", "self", ".", "N...
[ 12, 4 ]
[ 39, 38 ]
python
en
['en', 'error', 'th']
False
Attack.set_model
(self)
TODO: Write Comment
TODO: Write Comment
def set_model(self): """ TODO: Write Comment """ if self.FAMILY_DATASET == 0: from networks import mnist if self.NUM_MODEL == 0: model = mnist.mlp.MLP(self.args) elif self.NUM_MODEL == 1: model = mnist.conv.Conv(self.args) elif...
[ "def", "set_model", "(", "self", ")", ":", "if", "self", ".", "FAMILY_DATASET", "==", "0", ":", "from", "networks", "import", "mnist", "if", "self", ".", "NUM_MODEL", "==", "0", ":", "model", "=", "mnist", ".", "mlp", ".", "MLP", "(", "self", ".", ...
[ 41, 4 ]
[ 93, 20 ]
python
en
['en', 'error', 'th']
False
Attack.start_attack
(self, target_class, limit=0)
TODO: Write Comment
TODO: Write Comment
def start_attack(self, target_class, limit=0): """ TODO: Write Comment """ attack_result = self.attack(target_class, limit) original_image = self.x attacked_image = self.perturb_image(attack_result)[0] prior_probs = self.model.predict(origina...
[ "def", "start_attack", "(", "self", ",", "target_class", ",", "limit", "=", "0", ")", ":", "attack_result", "=", "self", ".", "attack", "(", "target_class", ",", "limit", ")", "original_image", "=", "self", ".", "x", "attacked_image", "=", "self", ".", "...
[ 95, 4 ]
[ 120, 199 ]
python
en
['en', 'error', 'th']
False
Attack.start
(self)
TODO: Write Comment
TODO: Write Comment
def start(self): """ TODO: Write Comment """ # return None import os, pickle, pandas as pd self.dir_path = f"{self.attack_name}/{self.model.dataset_name}/{self.model.name}" if not os.path.exists(f"./logs/results/{self.dir_path}"): os.makedirs(f"...
[ "def", "start", "(", "self", ")", ":", "# return None", "import", "os", ",", "pickle", ",", "pandas", "as", "pd", "self", ".", "dir_path", "=", "f\"{self.attack_name}/{self.model.dataset_name}/{self.model.name}\"", "if", "not", "os", ".", "path", ".", "exists", ...
[ 122, 4 ]
[ 155, 64 ]
python
en
['en', 'error', 'th']
False
format
(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', force_grouping=False)
Gets a number (as a number or string), and returns it as a string, using formats defined as arguments: * decimal_sep: Decimal separator symbol (for example ".") * decimal_pos: Number of decimal positions * grouping: Number of digits in every group limited by thousand separator. For non-uni...
Gets a number (as a number or string), and returns it as a string, using formats defined as arguments:
def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='', force_grouping=False): """ Gets a number (as a number or string), and returns it as a string, using formats defined as arguments: * decimal_sep: Decimal separator symbol (for example ".") * decimal_pos: Number...
[ "def", "format", "(", "number", ",", "decimal_sep", ",", "decimal_pos", "=", "None", ",", "grouping", "=", "0", ",", "thousand_sep", "=", "''", ",", "force_grouping", "=", "False", ")", ":", "use_grouping", "=", "settings", ".", "USE_L10N", "and", "setting...
[ 9, 0 ]
[ 69, 37 ]
python
en
['en', 'error', 'th']
False
user_data_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific data dir for this application.
def user_data_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "user_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 44, 0 ]
[ 96, 15 ]
python
en
['en', 'en', 'en']
True
site_data_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_data_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of ...
[ "def", "site_data_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "...
[ 99, 0 ]
[ 162, 15 ]
python
en
['en', 'en', 'en']
True
user_config_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific config dir for this application.
def user_config_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific config dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name...
[ "def", "user_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
[ 165, 0 ]
[ 202, 15 ]
python
en
['en', 'en', 'en']
True
site_config_dir
(appname=None, appauthor=None, version=None, multipath=False)
r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-shared data dir for this application.
def site_config_dir(appname=None, appauthor=None, version=None, multipath=False): r"""Return full path to the user-shared data dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name o...
[ "def", "site_config_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "multipath", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "site_data_dir"...
[ 205, 0 ]
[ 253, 15 ]
python
en
['en', 'en', 'en']
True
user_cache_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific cache dir for this application.
def user_cache_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific cache dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of...
[ "def", "user_cache_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"win32\"", ":", "if", "appauthor", "is", "None", ":", "appauthor", "=", "ap...
[ 256, 0 ]
[ 310, 15 ]
python
en
['en', 'en', 'en']
True
user_state_dir
(appname=None, appauthor=None, version=None, roaming=False)
r"""Return full path to the user-specific state dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific state dir for this application.
def user_state_dir(appname=None, appauthor=None, version=None, roaming=False): r"""Return full path to the user-specific state dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name o...
[ "def", "user_state_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "roaming", "=", "False", ")", ":", "if", "system", "in", "[", "\"win32\"", ",", "\"darwin\"", "]", ":", "path", "=", "user_data_dir", ...
[ 313, 0 ]
[ 352, 15 ]
python
en
['en', 'en', 'en']
True
user_log_dir
(appname=None, appauthor=None, version=None, opinion=True)
r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the appauthor or distributing body for this application. Typically ...
r"""Return full path to the user-specific log dir for this application.
def user_log_dir(appname=None, appauthor=None, version=None, opinion=True): r"""Return full path to the user-specific log dir for this application. "appname" is the name of application. If None, just the system directory is returned. "appauthor" (only used on Windows) is the name of the...
[ "def", "user_log_dir", "(", "appname", "=", "None", ",", "appauthor", "=", "None", ",", "version", "=", "None", ",", "opinion", "=", "True", ")", ":", "if", "system", "==", "\"darwin\"", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ...
[ 355, 0 ]
[ 403, 15 ]
python
en
['en', 'en', 'en']
True
_get_win_folder_from_registry
(csidl_name)
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names.
def _get_win_folder_from_registry(csidl_name): """This is a fallback technique at best. I'm not sure if using the registry for this guarantees us the correct answer for all CSIDL_* names. """ if PY3: import winreg as _winreg else: import _winreg shell_folder_name = { "CS...
[ "def", "_get_win_folder_from_registry", "(", "csidl_name", ")", ":", "if", "PY3", ":", "import", "winreg", "as", "_winreg", "else", ":", "import", "_winreg", "shell_folder_name", "=", "{", "\"CSIDL_APPDATA\"", ":", "\"AppData\"", ",", "\"CSIDL_COMMON_APPDATA\"", ":"...
[ 454, 0 ]
[ 475, 14 ]
python
en
['en', 'en', 'en']
True
get_base_snippet_action_menu_items
(model)
Retrieve the global list of menu items for the snippet action menu, which may then be customised on a per-request basis
Retrieve the global list of menu items for the snippet action menu, which may then be customised on a per-request basis
def get_base_snippet_action_menu_items(model): """ Retrieve the global list of menu items for the snippet action menu, which may then be customised on a per-request basis """ menu_items = [ SaveMenuItem(order=0), DeleteMenuItem(order=10), ] for hook in hooks.get_hooks('regis...
[ "def", "get_base_snippet_action_menu_items", "(", "model", ")", ":", "menu_items", "=", "[", "SaveMenuItem", "(", "order", "=", "0", ")", ",", "DeleteMenuItem", "(", "order", "=", "10", ")", ",", "]", "for", "hook", "in", "hooks", ".", "get_hooks", "(", ...
[ 91, 0 ]
[ 106, 21 ]
python
en
['en', 'error', 'th']
False
ActionMenuItem.is_shown
(self, request, context)
Whether this action should be shown on this request; permission checks etc should go here. request = the current request object context = dictionary containing at least: 'view' = 'create' or 'edit' 'model' = the model of the snippet being created/edited 'in...
Whether this action should be shown on this request; permission checks etc should go here.
def is_shown(self, request, context): """ Whether this action should be shown on this request; permission checks etc should go here. request = the current request object context = dictionary containing at least: 'view' = 'create' or 'edit' 'model' = the model of...
[ "def", "is_shown", "(", "self", ",", "request", ",", "context", ")", ":", "return", "True" ]
[ 29, 4 ]
[ 40, 19 ]
python
en
['en', 'error', 'th']
False
ActionMenuItem.get_context
(self, request, parent_context)
Defines context for the template, overridable to use more data
Defines context for the template, overridable to use more data
def get_context(self, request, parent_context): """Defines context for the template, overridable to use more data""" context = parent_context.copy() context.update({ 'label': self.label, 'url': self.get_url(request, context), 'name': self.name, 'cl...
[ "def", "get_context", "(", "self", ",", "request", ",", "parent_context", ")", ":", "context", "=", "parent_context", ".", "copy", "(", ")", "context", ".", "update", "(", "{", "'label'", ":", "self", ".", "label", ",", "'url'", ":", "self", ".", "get_...
[ 42, 4 ]
[ 52, 22 ]
python
en
['en', 'en', 'en']
True
SeleniumTestCaseBase.__new__
(cls, name, bases, attrs)
Dynamically create new classes and add them to the test module when multiple browsers specs are provided (e.g. --selenium=firefox,chrome).
Dynamically create new classes and add them to the test module when multiple browsers specs are provided (e.g. --selenium=firefox,chrome).
def __new__(cls, name, bases, attrs): """ Dynamically create new classes and add them to the test module when multiple browsers specs are provided (e.g. --selenium=firefox,chrome). """ test_class = super(SeleniumTestCaseBase, cls).__new__(cls, name, bases, attrs) # If the...
[ "def", "__new__", "(", "cls", ",", "name", ",", "bases", ",", "attrs", ")", ":", "test_class", "=", "super", "(", "SeleniumTestCaseBase", ",", "cls", ")", ".", "__new__", "(", "cls", ",", "name", ",", "bases", ",", "attrs", ")", "# If the test class is e...
[ 18, 4 ]
[ 47, 66 ]
python
en
['en', 'error', 'th']
False
EditView.get_commenting_changes
(self)
Finds comments that have been changed during this request. Returns a tuple of 5 lists: - New comments - Deleted comments - Resolved comments - Edited comments - Replied comments (dict containing the instance and list of replies)
Finds comments that have been changed during this request.
def get_commenting_changes(self): """ Finds comments that have been changed during this request. Returns a tuple of 5 lists: - New comments - Deleted comments - Resolved comments - Edited comments - Replied comments (dict containing the instance and ...
[ "def", "get_commenting_changes", "(", "self", ")", ":", "# Get changes", "comments_formset", "=", "self", ".", "form", ".", "formsets", "[", "'comments'", "]", "new_comments", "=", "comments_formset", ".", "new_objects", "deleted_comments", "=", "comments_formset", ...
[ 61, 4 ]
[ 115, 9 ]
python
en
['en', 'error', 'th']
False
EditView.send_commenting_notifications
(self, changes)
Sends notifications about any changes to comments to anyone who is subscribed.
Sends notifications about any changes to comments to anyone who is subscribed.
def send_commenting_notifications(self, changes): """ Sends notifications about any changes to comments to anyone who is subscribed. """ relevant_comment_ids = [] relevant_comment_ids.extend(comment.pk for comment in changes['resolved_comments']) relevant_comment_ids.exte...
[ "def", "send_commenting_notifications", "(", "self", ",", "changes", ")", ":", "relevant_comment_ids", "=", "[", "]", "relevant_comment_ids", ".", "extend", "(", "comment", ".", "pk", "for", "comment", "in", "changes", "[", "'resolved_comments'", "]", ")", "rele...
[ 117, 4 ]
[ 193, 10 ]
python
en
['en', 'error', 'th']
False
EditView.log_commenting_changes
(self, changes, revision)
Generates log entries for any changes made to comments or replies.
Generates log entries for any changes made to comments or replies.
def log_commenting_changes(self, changes, revision): """ Generates log entries for any changes made to comments or replies. """ for comment in changes['new_comments']: comment.log_create( page_revision=revision, user=self.request.user ...
[ "def", "log_commenting_changes", "(", "self", ",", "changes", ",", "revision", ")", ":", "for", "comment", "in", "changes", "[", "'new_comments'", "]", ":", "comment", ".", "log_create", "(", "page_revision", "=", "revision", ",", "user", "=", "self", ".", ...
[ 195, 4 ]
[ 242, 17 ]
python
en
['en', 'error', 'th']
False
dump_file
(filename, head=None)
Dumps a file content into log.info. If head is not None, will be dumped before the file content.
Dumps a file content into log.info.
def dump_file(filename, head=None): """Dumps a file content into log.info. If head is not None, will be dumped before the file content. """ if head is None: log.info('%s', filename) else: log.info(head) file = open(filename) try: log.info(file.read()) finally: ...
[ "def", "dump_file", "(", "filename", ",", "head", "=", "None", ")", ":", "if", "head", "is", "None", ":", "log", ".", "info", "(", "'%s'", ",", "filename", ")", "else", ":", "log", ".", "info", "(", "head", ")", "file", "=", "open", "(", "filenam...
[ 330, 0 ]
[ 343, 20 ]
python
en
['en', 'fr', 'en']
True
config._check_compiler
(self)
Check that 'self.compiler' really is a CCompiler object; if not, make it one.
Check that 'self.compiler' really is a CCompiler object; if not, make it one.
def _check_compiler(self): """Check that 'self.compiler' really is a CCompiler object; if not, make it one. """ # We do this late, and only on-demand, because this is an expensive # import. from distutils.ccompiler import CCompiler, new_compiler if not isinstance(...
[ "def", "_check_compiler", "(", "self", ")", ":", "# We do this late, and only on-demand, because this is an expensive", "# import.", "from", "distutils", ".", "ccompiler", "import", "CCompiler", ",", "new_compiler", "if", "not", "isinstance", "(", "self", ".", "compiler",...
[ 88, 4 ]
[ 104, 65 ]
python
en
['en', 'en', 'en']
True
config.try_cpp
(self, body=None, headers=None, include_dirs=None, lang="c")
Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) and run it through the preprocessor. Return true if the preprocessor succeeded, false if there were any errors. ('body' probably isn't of much use, but what th...
Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) and run it through the preprocessor. Return true if the preprocessor succeeded, false if there were any errors. ('body' probably isn't of much use, but what th...
def try_cpp(self, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file from 'body' (a string containing lines of C/C++ code) and 'headers' (a list of header files to include) and run it through the preprocessor. Return true if the preprocessor succeeded, fal...
[ "def", "try_cpp", "(", "self", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "include_dirs", "=", "None", ",", "lang", "=", "\"c\"", ")", ":", "from", "distutils", ".", "ccompiler", "import", "CompileError", "self", ".", "_check_compiler", ...
[ 171, 4 ]
[ 187, 17 ]
python
en
['en', 'en', 'en']
True
config.search_cpp
(self, pattern, body=None, headers=None, include_dirs=None, lang="c")
Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex object or a string containing a regex. If both 'body' and 'headers' are None, preprocesses an empty...
Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex object or a string containing a regex. If both 'body' and 'headers' are None, preprocesses an empty...
def search_cpp(self, pattern, body=None, headers=None, include_dirs=None, lang="c"): """Construct a source file (just like 'try_cpp()'), run it through the preprocessor, and return true if any line of the output matches 'pattern'. 'pattern' should either be a compiled regex o...
[ "def", "search_cpp", "(", "self", ",", "pattern", ",", "body", "=", "None", ",", "headers", "=", "None", ",", "include_dirs", "=", "None", ",", "lang", "=", "\"c\"", ")", ":", "self", ".", "_check_compiler", "(", ")", "src", ",", "out", "=", "self", ...
[ 189, 4 ]
[ 215, 20 ]
python
en
['en', 'en', 'en']
True
config.try_compile
(self, body, headers=None, include_dirs=None, lang="c")
Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise.
Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise.
def try_compile(self, body, headers=None, include_dirs=None, lang="c"): """Try to compile a source file built from 'body' and 'headers'. Return true on success, false otherwise. """ from distutils.ccompiler import CompileError self._check_compiler() try: self....
[ "def", "try_compile", "(", "self", ",", "body", ",", "headers", "=", "None", ",", "include_dirs", "=", "None", ",", "lang", "=", "\"c\"", ")", ":", "from", "distutils", ".", "ccompiler", "import", "CompileError", "self", ".", "_check_compiler", "(", ")", ...
[ 217, 4 ]
[ 231, 17 ]
python
en
['en', 'en', 'en']
True
config.try_link
(self, body, headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c")
Try to compile and link a source file, built from 'body' and 'headers', to executable form. Return true on success, false otherwise.
Try to compile and link a source file, built from 'body' and 'headers', to executable form. Return true on success, false otherwise.
def try_link(self, body, headers=None, include_dirs=None, libraries=None, library_dirs=None, lang="c"): """Try to compile and link a source file, built from 'body' and 'headers', to executable form. Return true on success, false otherwise. """ from distutils.cco...
[ "def", "try_link", "(", "self", ",", "body", ",", "headers", "=", "None", ",", "include_dirs", "=", "None", ",", "libraries", "=", "None", ",", "library_dirs", "=", "None", ",", "lang", "=", "\"c\"", ")", ":", "from", "distutils", ".", "ccompiler", "im...
[ 233, 4 ]
[ 250, 17 ]
python
en
['en', 'en', 'en']
True