repository_name
stringlengths 7
54
| func_path_in_repository
stringlengths 5
179
| func_name
stringlengths 1
109
| whole_func_string
stringlengths 100
30.9k
| language
stringclasses 1
value | func_code_string
stringlengths 100
30.9k
| func_code_tokens
sequencelengths 20
3.12k
| func_documentation_string
stringlengths 1
29.9k
| func_documentation_tokens
sequencelengths 1
893
| split_name
stringclasses 1
value | func_code_url
stringlengths 91
272
| formatted_prompt
stringlengths 344
61k
| input_ids
sequencelengths 512
512
| attention_mask
sequencelengths 512
512
| labels
sequencelengths 512
512
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
etingof/pysnmp | pysnmp/smi/mibs/SNMPv2-SMI.py | ManagedMibObject.getNode | def getNode(self, name, **context):
"""Return tree node found by name"""
if name == self.name:
return self
else:
return self.getBranch(name, **context).getNode(name, **context) | python | def getNode(self, name, **context):
"""Return tree node found by name"""
if name == self.name:
return self
else:
return self.getBranch(name, **context).getNode(name, **context) | [
"def",
"getNode",
"(",
"self",
",",
"name",
",",
"*",
"*",
"context",
")",
":",
"if",
"name",
"==",
"self",
".",
"name",
":",
"return",
"self",
"else",
":",
"return",
"self",
".",
"getBranch",
"(",
"name",
",",
"*",
"*",
"context",
")",
".",
"getNode",
"(",
"name",
",",
"*",
"*",
"context",
")"
] | Return tree node found by name | [
"Return",
"tree",
"node",
"found",
"by",
"name"
] | train | https://github.com/etingof/pysnmp/blob/cde062dd42f67dfd2d7686286a322d40e9c3a4b7/pysnmp/smi/mibs/SNMPv2-SMI.py#L478-L483 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return tree node found by name
### Response:
def getNode(self, name, **context):
"""Return tree node found by name"""
if name == self.name:
return self
else:
return self.getBranch(name, **context).getNode(name, **context)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
5021,
2494,
1766,
555,
836,
271,
14711,
6075,
512,
755,
82898,
1214,
11,
836,
11,
3146,
2196,
997,
286,
4304,
5715,
5021,
2494,
1766,
555,
836,
7275,
286,
422,
836,
624,
659,
2710,
512,
310,
471,
659,
198,
286,
775,
512,
310,
471,
659,
673,
18697,
3232,
11,
3146,
2196,
570,
71084,
3232,
11,
3146,
2196,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
5021,
2494,
1766,
555,
836,
271,
14711,
6075,
512,
755,
82898,
1214,
11,
836,
11,
3146,
2196,
997,
286,
4304,
5715,
5021,
2494,
1766,
555,
836,
7275,
286,
422,
836,
624,
659,
2710,
512,
310,
471,
659,
198,
286,
775,
512,
310,
471,
659,
673,
18697,
3232,
11,
3146,
2196,
570,
71084,
3232,
11,
3146,
2196,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
aliyun/aliyun-log-python-sdk | aliyun/log/consumer/shard_worker.py | ShardConsumerWorker.check_and_generate_next_task | def check_and_generate_next_task(self):
"""
check if the previous task is done and proceed to fire another task
:return:
"""
# if self.task_future is None:
# # there's no any ongoing task
# self._update_status(False)
# self.generate_next_task()
# return
if self.task_future is None or self.task_future.done():
task_success = False
task_result = self.get_task_result(self.task_future)
self.task_future = None
if task_result is not None and task_result.get_exception() is None:
task_success = True
if isinstance(task_result, InitTaskResult):
# maintain check points
assert self.consumer_status == ConsumerStatus.INITIALIZING, \
ClientWorkerException("get init task result, but status is: " + str(self.consumer_status))
init_result = task_result
self.next_fetch_cursor = init_result.get_cursor()
self.fetch_end_cursor = init_result.end_cursor
self.checkpoint_tracker.set_memory_check_point(self.next_fetch_cursor)
if init_result.is_cursor_persistent():
self.checkpoint_tracker.set_persistent_check_point(self.next_fetch_cursor)
elif isinstance(task_result, ProcessTaskResult):
# maintain check points
process_task_result = task_result
roll_back_checkpoint = process_task_result.get_rollback_check_point()
if roll_back_checkpoint:
self.last_fetch_log_group = None
self.logger.info("user defined to roll-back check-point, cancel current fetching task")
self.cancel_current_fetch()
self.next_fetch_cursor = roll_back_checkpoint
# log task status
self._sample_log_error(task_result)
# update status basing on task results
self._update_status(task_success)
#
self._generate_next_task() | python | def check_and_generate_next_task(self):
"""
check if the previous task is done and proceed to fire another task
:return:
"""
# if self.task_future is None:
# # there's no any ongoing task
# self._update_status(False)
# self.generate_next_task()
# return
if self.task_future is None or self.task_future.done():
task_success = False
task_result = self.get_task_result(self.task_future)
self.task_future = None
if task_result is not None and task_result.get_exception() is None:
task_success = True
if isinstance(task_result, InitTaskResult):
# maintain check points
assert self.consumer_status == ConsumerStatus.INITIALIZING, \
ClientWorkerException("get init task result, but status is: " + str(self.consumer_status))
init_result = task_result
self.next_fetch_cursor = init_result.get_cursor()
self.fetch_end_cursor = init_result.end_cursor
self.checkpoint_tracker.set_memory_check_point(self.next_fetch_cursor)
if init_result.is_cursor_persistent():
self.checkpoint_tracker.set_persistent_check_point(self.next_fetch_cursor)
elif isinstance(task_result, ProcessTaskResult):
# maintain check points
process_task_result = task_result
roll_back_checkpoint = process_task_result.get_rollback_check_point()
if roll_back_checkpoint:
self.last_fetch_log_group = None
self.logger.info("user defined to roll-back check-point, cancel current fetching task")
self.cancel_current_fetch()
self.next_fetch_cursor = roll_back_checkpoint
# log task status
self._sample_log_error(task_result)
# update status basing on task results
self._update_status(task_success)
#
self._generate_next_task() | [
"def",
"check_and_generate_next_task",
"(",
"self",
")",
":",
"# if self.task_future is None:",
"# # there's no any ongoing task",
"# self._update_status(False)",
"# self.generate_next_task()",
"# return",
"if",
"self",
".",
"task_future",
"is",
"None",
"or",
"self",
".",
"task_future",
".",
"done",
"(",
")",
":",
"task_success",
"=",
"False",
"task_result",
"=",
"self",
".",
"get_task_result",
"(",
"self",
".",
"task_future",
")",
"self",
".",
"task_future",
"=",
"None",
"if",
"task_result",
"is",
"not",
"None",
"and",
"task_result",
".",
"get_exception",
"(",
")",
"is",
"None",
":",
"task_success",
"=",
"True",
"if",
"isinstance",
"(",
"task_result",
",",
"InitTaskResult",
")",
":",
"# maintain check points",
"assert",
"self",
".",
"consumer_status",
"==",
"ConsumerStatus",
".",
"INITIALIZING",
",",
"ClientWorkerException",
"(",
"\"get init task result, but status is: \"",
"+",
"str",
"(",
"self",
".",
"consumer_status",
")",
")",
"init_result",
"=",
"task_result",
"self",
".",
"next_fetch_cursor",
"=",
"init_result",
".",
"get_cursor",
"(",
")",
"self",
".",
"fetch_end_cursor",
"=",
"init_result",
".",
"end_cursor",
"self",
".",
"checkpoint_tracker",
".",
"set_memory_check_point",
"(",
"self",
".",
"next_fetch_cursor",
")",
"if",
"init_result",
".",
"is_cursor_persistent",
"(",
")",
":",
"self",
".",
"checkpoint_tracker",
".",
"set_persistent_check_point",
"(",
"self",
".",
"next_fetch_cursor",
")",
"elif",
"isinstance",
"(",
"task_result",
",",
"ProcessTaskResult",
")",
":",
"# maintain check points",
"process_task_result",
"=",
"task_result",
"roll_back_checkpoint",
"=",
"process_task_result",
".",
"get_rollback_check_point",
"(",
")",
"if",
"roll_back_checkpoint",
":",
"self",
".",
"last_fetch_log_group",
"=",
"None",
"self",
".",
"logger",
".",
"info",
"(",
"\"user defined to roll-back check-point, cancel current fetching task\"",
")",
"self",
".",
"cancel_current_fetch",
"(",
")",
"self",
".",
"next_fetch_cursor",
"=",
"roll_back_checkpoint",
"# log task status",
"self",
".",
"_sample_log_error",
"(",
"task_result",
")",
"# update status basing on task results",
"self",
".",
"_update_status",
"(",
"task_success",
")",
"#",
"self",
".",
"_generate_next_task",
"(",
")"
] | check if the previous task is done and proceed to fire another task
:return: | [
"check",
"if",
"the",
"previous",
"task",
"is",
"done",
"and",
"proceed",
"to",
"fire",
"another",
"task",
":",
"return",
":"
] | train | https://github.com/aliyun/aliyun-log-python-sdk/blob/ac383db0a16abf1e5ef7df36074374184b43516e/aliyun/log/consumer/shard_worker.py#L137-L186 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
check if the previous task is done and proceed to fire another task
:return:
### Response:
def check_and_generate_next_task(self):
"""
check if the previous task is done and proceed to fire another task
:return:
"""
# if self.task_future is None:
# # there's no any ongoing task
# self._update_status(False)
# self.generate_next_task()
# return
if self.task_future is None or self.task_future.done():
task_success = False
task_result = self.get_task_result(self.task_future)
self.task_future = None
if task_result is not None and task_result.get_exception() is None:
task_success = True
if isinstance(task_result, InitTaskResult):
# maintain check points
assert self.consumer_status == ConsumerStatus.INITIALIZING, \
ClientWorkerException("get init task result, but status is: " + str(self.consumer_status))
init_result = task_result
self.next_fetch_cursor = init_result.get_cursor()
self.fetch_end_cursor = init_result.end_cursor
self.checkpoint_tracker.set_memory_check_point(self.next_fetch_cursor)
if init_result.is_cursor_persistent():
self.checkpoint_tracker.set_persistent_check_point(self.next_fetch_cursor)
elif isinstance(task_result, ProcessTaskResult):
# maintain check points
process_task_result = task_result
roll_back_checkpoint = process_task_result.get_rollback_check_point()
if roll_back_checkpoint:
self.last_fetch_log_group = None
self.logger.info("user defined to roll-back check-point, cancel current fetching task")
self.cancel_current_fetch()
self.next_fetch_cursor = roll_back_checkpoint
# log task status
self._sample_log_error(task_result)
# update status basing on task results
self._update_status(task_success)
#
self._generate_next_task()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2071,
422,
279,
3766,
3465,
374,
2884,
323,
10570,
311,
4027,
2500,
3465,
198,
286,
551,
693,
1473,
14711,
6075,
512,
755,
1817,
8543,
49951,
11507,
12461,
1214,
997,
286,
3270,
286,
1817,
422,
279,
3766,
3465,
374,
2884,
323,
10570,
311,
4027,
2500,
3465,
198,
286,
551,
693,
512,
286,
3270,
286,
674,
422,
659,
15384,
60840,
374,
2290,
512,
286,
674,
257,
674,
1070,
596,
912,
904,
14529,
3465,
198,
286,
674,
257,
659,
1462,
2443,
4878,
23852,
340,
286,
674,
257,
659,
22793,
11507,
12461,
746,
286,
674,
257,
471,
271,
286,
422,
659,
15384,
60840,
374,
2290,
477,
659,
15384,
60840,
32902,
4019,
310,
3465,
19147,
284,
3641,
271,
310,
3465,
5400,
284,
659,
673,
12461,
5400,
1214,
15384,
60840,
340,
310,
659,
15384,
60840,
284,
2290,
271,
310,
422,
3465,
5400,
374,
539,
2290,
323,
3465,
5400,
673,
17957,
368,
374,
2290,
1473,
394,
3465,
19147,
284,
3082,
198,
394,
422,
11656,
17941,
5400,
11,
16065,
6396,
2122,
997,
504,
674,
10519,
1817,
3585,
198,
504,
2105,
659,
69866,
4878,
624,
26262,
2583,
14758,
964,
33701,
1753,
11,
3120,
667,
8589,
22701,
1378,
446,
456,
3003,
3465,
1121,
11,
719,
2704,
374,
25,
330,
489,
610,
1214,
69866,
4878,
4489,
504,
3003,
5400,
284,
3465,
5400,
198,
504,
659,
4630,
12066,
29701,
284,
3003,
5400,
673,
29701,
746,
504,
659,
16512,
6345,
29701,
284,
3003,
5400,
5183,
29701,
198,
504,
659,
9271,
2837,
51364,
995,
19745,
7348,
6213,
1214,
4630,
12066,
29701,
340,
504,
422,
3003,
5400,
2124,
29701,
623,
14256,
4019,
667,
659,
9271,
2837,
51364,
995,
623,
14256,
7348,
6213,
1214,
4630,
12066,
29701,
696,
394,
4508,
11656,
17941,
5400,
11,
8773,
6396,
2122,
997,
504,
674,
10519,
1817,
3585,
198,
504,
1920,
12461,
5400,
284,
3465,
5400,
198,
504,
6638,
3982,
56308,
284,
1920,
12461,
5400,
673,
62,
34659,
7348,
6213,
746,
504,
422,
6638,
3982,
56308,
512,
667,
659,
9288,
12066,
5337,
6422,
284,
2290,
198,
667,
659,
16465,
5506,
446,
882,
4613,
311,
6638,
15825,
1817,
16983,
11,
9299,
1510,
45334,
3465,
1158,
667,
659,
23049,
11327,
12066,
746,
667,
659,
4630,
12066,
29701,
284,
6638,
3982,
56308,
271,
310,
674,
1515,
3465,
2704,
198,
310,
659,
1462,
13925,
5337,
4188,
17941,
5400,
696,
310,
674,
2713,
2704,
3122,
287,
389,
3465,
3135,
198,
310,
659,
1462,
2443,
4878,
17941,
19147,
696,
310,
9733,
310,
659,
1462,
19927,
11507,
12461,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2071,
422,
279,
3766,
3465,
374,
2884,
323,
10570,
311,
4027,
2500,
3465,
198,
286,
551,
693,
1473,
14711,
6075,
512,
755,
1817,
8543,
49951,
11507,
12461,
1214,
997,
286,
3270,
286,
1817,
422,
279,
3766,
3465,
374,
2884,
323,
10570,
311,
4027,
2500,
3465,
198,
286,
551,
693,
512,
286,
3270,
286,
674,
422,
659,
15384,
60840,
374,
2290,
512,
286,
674,
257,
674,
1070,
596,
912,
904,
14529,
3465,
198,
286,
674,
257,
659,
1462,
2443,
4878,
23852,
340,
286,
674,
257,
659,
22793,
11507,
12461,
746,
286,
674,
257,
471,
271,
286,
422,
659,
15384,
60840,
374,
2290,
477,
659,
15384,
60840,
32902,
4019,
310,
3465,
19147,
284,
3641,
271,
310,
3465,
5400,
284,
659,
673,
12461,
5400,
1214,
15384,
60840,
340,
310,
659,
15384,
60840,
284,
2290,
271,
310,
422,
3465,
5400,
374,
539,
2290,
323,
3465,
5400,
673,
17957,
368,
374,
2290,
1473,
394,
3465,
19147,
284,
3082,
198,
394,
422,
11656,
17941,
5400,
11,
16065,
6396,
2122,
997,
504,
674,
10519,
1817,
3585,
198,
504,
2105,
659,
69866,
4878,
624,
26262,
2583,
14758,
964,
33701,
1753,
11,
3120,
667,
8589,
22701,
1378,
446,
456,
3003,
3465,
1121,
11,
719,
2704,
374,
25,
330,
489,
610,
1214,
69866,
4878,
4489,
504,
3003,
5400,
284,
3465,
5400,
198,
504,
659,
4630,
12066,
29701,
284,
3003,
5400,
673,
29701,
746,
504,
659,
16512,
6345,
29701,
284,
3003,
5400,
5183,
29701,
198,
504,
659,
9271,
2837,
51364,
995,
19745,
7348,
6213,
1214,
4630,
12066,
29701,
340,
504,
422,
3003,
5400,
2124,
29701,
623,
14256,
4019,
667,
659,
9271,
2837,
51364,
995,
623,
14256,
7348,
6213,
1214,
4630,
12066,
29701,
696,
394,
4508,
11656,
17941,
5400,
11,
8773,
6396,
2122,
997,
504,
674,
10519,
1817,
3585,
198,
504,
1920,
12461,
5400,
284,
3465,
5400,
198,
504,
6638,
3982,
56308,
284,
1920,
12461,
5400,
673,
62,
34659,
7348,
6213,
746,
504,
422,
6638,
3982,
56308,
512,
667,
659,
9288,
12066,
5337,
6422,
284,
2290,
198,
667,
659,
16465,
5506,
446,
882,
4613,
311,
6638,
15825,
1817,
16983,
11,
9299,
1510,
45334,
3465,
1158,
667,
659,
23049,
11327,
12066,
746,
667,
659,
4630,
12066,
29701,
284,
6638,
3982,
56308,
271,
310,
674,
1515,
3465,
2704,
198,
310,
659,
1462,
13925,
5337,
4188,
17941,
5400,
696,
310,
674,
2713,
2704,
3122,
287,
389,
3465,
3135,
198,
310,
659,
1462,
2443,
4878,
17941,
19147,
696,
310,
9733,
310,
659,
1462,
19927,
11507,
12461,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Arkq/flake8-requirements | src/flake8_requirements/checker.py | Flake8Checker.run | def run(self):
"""Run checker."""
def split(module):
"""Split module into submodules."""
return tuple(module.split("."))
def modcmp(lib=(), test=()):
"""Compare import modules."""
if len(lib) > len(test):
return False
return all(a == b for a, b in zip(lib, test))
mods_1st_party = set()
mods_3rd_party = set()
# Get 1st party modules (used for absolute imports).
modules = [project2module(self.setup.keywords.get('name', ""))]
if modules[0] in self.known_modules:
modules = self.known_modules[modules[0]]
mods_1st_party.update(split(x) for x in modules)
requirements = self.requirements
if self.setup.redirected:
# Use requirements from setup if available.
requirements = self.setup.get_requirements(
setup=self.processing_setup_py,
tests=True,
)
# Get 3rd party module names based on requirements.
for requirement in requirements:
modules = [project2module(requirement.project_name)]
if modules[0] in KNOWN_3RD_PARTIES:
modules = KNOWN_3RD_PARTIES[modules[0]]
if modules[0] in self.known_modules:
modules = self.known_modules[modules[0]]
mods_3rd_party.update(split(x) for x in modules)
# When processing setup.py file, forcefully add setuptools to the
# project requirements. Setuptools might be required to build the
# project, even though it is not listed as a requirement - this
# package is required to run setup.py, so listing it as a setup
# requirement would be pointless.
if self.processing_setup_py:
mods_3rd_party.add(split("setuptools"))
for node in ImportVisitor(self.tree).imports:
_mod = split(node.mod)
_alt = split(node.alt)
if any([_mod[0] == x for x in STDLIB]):
continue
if any([modcmp(x, _mod) or modcmp(x, _alt)
for x in mods_1st_party]):
continue
if any([modcmp(x, _mod) or modcmp(x, _alt)
for x in mods_3rd_party]):
continue
yield (
node.line,
node.offset,
ERRORS['I900'].format(pkg=node.mod),
Flake8Checker,
) | python | def run(self):
"""Run checker."""
def split(module):
"""Split module into submodules."""
return tuple(module.split("."))
def modcmp(lib=(), test=()):
"""Compare import modules."""
if len(lib) > len(test):
return False
return all(a == b for a, b in zip(lib, test))
mods_1st_party = set()
mods_3rd_party = set()
# Get 1st party modules (used for absolute imports).
modules = [project2module(self.setup.keywords.get('name', ""))]
if modules[0] in self.known_modules:
modules = self.known_modules[modules[0]]
mods_1st_party.update(split(x) for x in modules)
requirements = self.requirements
if self.setup.redirected:
# Use requirements from setup if available.
requirements = self.setup.get_requirements(
setup=self.processing_setup_py,
tests=True,
)
# Get 3rd party module names based on requirements.
for requirement in requirements:
modules = [project2module(requirement.project_name)]
if modules[0] in KNOWN_3RD_PARTIES:
modules = KNOWN_3RD_PARTIES[modules[0]]
if modules[0] in self.known_modules:
modules = self.known_modules[modules[0]]
mods_3rd_party.update(split(x) for x in modules)
# When processing setup.py file, forcefully add setuptools to the
# project requirements. Setuptools might be required to build the
# project, even though it is not listed as a requirement - this
# package is required to run setup.py, so listing it as a setup
# requirement would be pointless.
if self.processing_setup_py:
mods_3rd_party.add(split("setuptools"))
for node in ImportVisitor(self.tree).imports:
_mod = split(node.mod)
_alt = split(node.alt)
if any([_mod[0] == x for x in STDLIB]):
continue
if any([modcmp(x, _mod) or modcmp(x, _alt)
for x in mods_1st_party]):
continue
if any([modcmp(x, _mod) or modcmp(x, _alt)
for x in mods_3rd_party]):
continue
yield (
node.line,
node.offset,
ERRORS['I900'].format(pkg=node.mod),
Flake8Checker,
) | [
"def",
"run",
"(",
"self",
")",
":",
"def",
"split",
"(",
"module",
")",
":",
"\"\"\"Split module into submodules.\"\"\"",
"return",
"tuple",
"(",
"module",
".",
"split",
"(",
"\".\"",
")",
")",
"def",
"modcmp",
"(",
"lib",
"=",
"(",
")",
",",
"test",
"=",
"(",
")",
")",
":",
"\"\"\"Compare import modules.\"\"\"",
"if",
"len",
"(",
"lib",
")",
">",
"len",
"(",
"test",
")",
":",
"return",
"False",
"return",
"all",
"(",
"a",
"==",
"b",
"for",
"a",
",",
"b",
"in",
"zip",
"(",
"lib",
",",
"test",
")",
")",
"mods_1st_party",
"=",
"set",
"(",
")",
"mods_3rd_party",
"=",
"set",
"(",
")",
"# Get 1st party modules (used for absolute imports).",
"modules",
"=",
"[",
"project2module",
"(",
"self",
".",
"setup",
".",
"keywords",
".",
"get",
"(",
"'name'",
",",
"\"\"",
")",
")",
"]",
"if",
"modules",
"[",
"0",
"]",
"in",
"self",
".",
"known_modules",
":",
"modules",
"=",
"self",
".",
"known_modules",
"[",
"modules",
"[",
"0",
"]",
"]",
"mods_1st_party",
".",
"update",
"(",
"split",
"(",
"x",
")",
"for",
"x",
"in",
"modules",
")",
"requirements",
"=",
"self",
".",
"requirements",
"if",
"self",
".",
"setup",
".",
"redirected",
":",
"# Use requirements from setup if available.",
"requirements",
"=",
"self",
".",
"setup",
".",
"get_requirements",
"(",
"setup",
"=",
"self",
".",
"processing_setup_py",
",",
"tests",
"=",
"True",
",",
")",
"# Get 3rd party module names based on requirements.",
"for",
"requirement",
"in",
"requirements",
":",
"modules",
"=",
"[",
"project2module",
"(",
"requirement",
".",
"project_name",
")",
"]",
"if",
"modules",
"[",
"0",
"]",
"in",
"KNOWN_3RD_PARTIES",
":",
"modules",
"=",
"KNOWN_3RD_PARTIES",
"[",
"modules",
"[",
"0",
"]",
"]",
"if",
"modules",
"[",
"0",
"]",
"in",
"self",
".",
"known_modules",
":",
"modules",
"=",
"self",
".",
"known_modules",
"[",
"modules",
"[",
"0",
"]",
"]",
"mods_3rd_party",
".",
"update",
"(",
"split",
"(",
"x",
")",
"for",
"x",
"in",
"modules",
")",
"# When processing setup.py file, forcefully add setuptools to the",
"# project requirements. Setuptools might be required to build the",
"# project, even though it is not listed as a requirement - this",
"# package is required to run setup.py, so listing it as a setup",
"# requirement would be pointless.",
"if",
"self",
".",
"processing_setup_py",
":",
"mods_3rd_party",
".",
"add",
"(",
"split",
"(",
"\"setuptools\"",
")",
")",
"for",
"node",
"in",
"ImportVisitor",
"(",
"self",
".",
"tree",
")",
".",
"imports",
":",
"_mod",
"=",
"split",
"(",
"node",
".",
"mod",
")",
"_alt",
"=",
"split",
"(",
"node",
".",
"alt",
")",
"if",
"any",
"(",
"[",
"_mod",
"[",
"0",
"]",
"==",
"x",
"for",
"x",
"in",
"STDLIB",
"]",
")",
":",
"continue",
"if",
"any",
"(",
"[",
"modcmp",
"(",
"x",
",",
"_mod",
")",
"or",
"modcmp",
"(",
"x",
",",
"_alt",
")",
"for",
"x",
"in",
"mods_1st_party",
"]",
")",
":",
"continue",
"if",
"any",
"(",
"[",
"modcmp",
"(",
"x",
",",
"_mod",
")",
"or",
"modcmp",
"(",
"x",
",",
"_alt",
")",
"for",
"x",
"in",
"mods_3rd_party",
"]",
")",
":",
"continue",
"yield",
"(",
"node",
".",
"line",
",",
"node",
".",
"offset",
",",
"ERRORS",
"[",
"'I900'",
"]",
".",
"format",
"(",
"pkg",
"=",
"node",
".",
"mod",
")",
",",
"Flake8Checker",
",",
")"
] | Run checker. | [
"Run",
"checker",
"."
] | train | https://github.com/Arkq/flake8-requirements/blob/d7cb84af2429a63635528b531111a5da527bf2d1/src/flake8_requirements/checker.py#L322-L385 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Run checker.
### Response:
def run(self):
"""Run checker."""
def split(module):
"""Split module into submodules."""
return tuple(module.split("."))
def modcmp(lib=(), test=()):
"""Compare import modules."""
if len(lib) > len(test):
return False
return all(a == b for a, b in zip(lib, test))
mods_1st_party = set()
mods_3rd_party = set()
# Get 1st party modules (used for absolute imports).
modules = [project2module(self.setup.keywords.get('name', ""))]
if modules[0] in self.known_modules:
modules = self.known_modules[modules[0]]
mods_1st_party.update(split(x) for x in modules)
requirements = self.requirements
if self.setup.redirected:
# Use requirements from setup if available.
requirements = self.setup.get_requirements(
setup=self.processing_setup_py,
tests=True,
)
# Get 3rd party module names based on requirements.
for requirement in requirements:
modules = [project2module(requirement.project_name)]
if modules[0] in KNOWN_3RD_PARTIES:
modules = KNOWN_3RD_PARTIES[modules[0]]
if modules[0] in self.known_modules:
modules = self.known_modules[modules[0]]
mods_3rd_party.update(split(x) for x in modules)
# When processing setup.py file, forcefully add setuptools to the
# project requirements. Setuptools might be required to build the
# project, even though it is not listed as a requirement - this
# package is required to run setup.py, so listing it as a setup
# requirement would be pointless.
if self.processing_setup_py:
mods_3rd_party.add(split("setuptools"))
for node in ImportVisitor(self.tree).imports:
_mod = split(node.mod)
_alt = split(node.alt)
if any([_mod[0] == x for x in STDLIB]):
continue
if any([modcmp(x, _mod) or modcmp(x, _alt)
for x in mods_1st_party]):
continue
if any([modcmp(x, _mod) or modcmp(x, _alt)
for x in mods_3rd_party]):
continue
yield (
node.line,
node.offset,
ERRORS['I900'].format(pkg=node.mod),
Flake8Checker,
)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
6869,
42015,
382,
14711,
6075,
512,
755,
1629,
1214,
997,
286,
4304,
6869,
42015,
30284,
286,
711,
6859,
19669,
997,
310,
4304,
20805,
4793,
1139,
1207,
11786,
14781,
310,
471,
14743,
19669,
5402,
74233,
4489,
286,
711,
1491,
7441,
45928,
28,
1535,
1296,
28,
34257,
310,
4304,
28474,
1179,
13761,
14781,
310,
422,
2479,
45928,
8,
871,
2479,
8793,
997,
394,
471,
3641,
198,
310,
471,
682,
2948,
624,
293,
369,
264,
11,
293,
304,
10521,
45928,
11,
1296,
4489,
286,
29354,
62,
16,
267,
45121,
284,
743,
746,
286,
29354,
62,
18,
6634,
45121,
284,
743,
2892,
286,
674,
2175,
220,
16,
267,
4717,
13761,
320,
2656,
369,
10973,
15557,
4390,
286,
13761,
284,
510,
5094,
17,
4450,
1214,
26406,
88259,
673,
493,
609,
518,
1621,
23094,
286,
422,
13761,
58,
15,
60,
304,
659,
5314,
4262,
16227,
512,
310,
13761,
284,
659,
5314,
4262,
16227,
58,
11786,
58,
15,
14623,
286,
29354,
62,
16,
267,
45121,
5430,
41055,
2120,
8,
369,
865,
304,
13761,
696,
286,
8670,
284,
659,
24642,
1392,
198,
286,
422,
659,
26406,
25067,
291,
512,
310,
674,
5560,
8670,
505,
6642,
422,
2561,
627,
310,
8670,
284,
659,
26406,
673,
90732,
1021,
394,
6642,
7822,
17421,
287,
22074,
41391,
345,
394,
7177,
3702,
345,
310,
5235,
286,
674,
2175,
220,
18,
6634,
4717,
4793,
5144,
3196,
389,
8670,
627,
286,
369,
16686,
304,
8670,
512,
310,
13761,
284,
510,
5094,
17,
4450,
24382,
479,
14844,
1292,
5680,
310,
422,
13761,
58,
15,
60,
304,
32392,
7736,
62,
18,
37790,
29378,
5482,
512,
394,
13761,
284,
32392,
7736,
62,
18,
37790,
29378,
5482,
58,
11786,
58,
15,
14623,
310,
422,
13761,
58,
15,
60,
304,
659,
5314,
4262,
16227,
512,
394,
13761,
284,
659,
5314,
4262,
16227,
58,
11786,
58,
15,
14623,
310,
29354,
62,
18,
6634,
45121,
5430,
41055,
2120,
8,
369,
865,
304,
13761,
696,
286,
674,
3277,
8863,
6642,
7345,
1052,
11,
87078,
923,
64897,
311,
279,
198,
286,
674,
2447,
8670,
13,
2638,
52381,
2643,
387,
2631,
311,
1977,
279,
198,
286,
674,
2447,
11,
1524,
3582,
433,
374,
539,
10212,
439,
264,
16686,
482,
420,
198,
286,
674,
6462,
374,
2631,
311,
1629,
6642,
7345,
11,
779,
15182,
433,
439,
264,
6642,
198,
286,
674,
16686,
1053,
387,
60791,
627,
286,
422,
659,
17421,
287,
22074,
41391,
512,
310,
29354,
62,
18,
6634,
45121,
1388,
41055,
446,
751,
52381,
29175,
286,
369,
2494,
304,
13516,
17215,
1214,
26812,
570,
63988,
512,
310,
721,
2658,
284,
6859,
7103,
11169,
340,
310,
721,
3223,
284,
6859,
7103,
51484,
340,
310,
422,
904,
2625,
62,
2658,
58,
15,
60,
624,
865,
369,
865,
304,
4015,
16931,
3336,
22953,
394,
3136,
198,
310,
422,
904,
2625,
2658,
7441,
2120,
11,
721,
2658,
8,
477,
1491,
7441,
2120,
11,
721,
3223,
340,
504,
369,
865,
304,
29354,
62
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
6869,
42015,
382,
14711,
6075,
512,
755,
1629,
1214,
997,
286,
4304,
6869,
42015,
30284,
286,
711,
6859,
19669,
997,
310,
4304,
20805,
4793,
1139,
1207,
11786,
14781,
310,
471,
14743,
19669,
5402,
74233,
4489,
286,
711,
1491,
7441,
45928,
28,
1535,
1296,
28,
34257,
310,
4304,
28474,
1179,
13761,
14781,
310,
422,
2479,
45928,
8,
871,
2479,
8793,
997,
394,
471,
3641,
198,
310,
471,
682,
2948,
624,
293,
369,
264,
11,
293,
304,
10521,
45928,
11,
1296,
4489,
286,
29354,
62,
16,
267,
45121,
284,
743,
746,
286,
29354,
62,
18,
6634,
45121,
284,
743,
2892,
286,
674,
2175,
220,
16,
267,
4717,
13761,
320,
2656,
369,
10973,
15557,
4390,
286,
13761,
284,
510,
5094,
17,
4450,
1214,
26406,
88259,
673,
493,
609,
518,
1621,
23094,
286,
422,
13761,
58,
15,
60,
304,
659,
5314,
4262,
16227,
512,
310,
13761,
284,
659,
5314,
4262,
16227,
58,
11786,
58,
15,
14623,
286,
29354,
62,
16,
267,
45121,
5430,
41055,
2120,
8,
369,
865,
304,
13761,
696,
286,
8670,
284,
659,
24642,
1392,
198,
286,
422,
659,
26406,
25067,
291,
512,
310,
674,
5560,
8670,
505,
6642,
422,
2561,
627,
310,
8670,
284,
659,
26406,
673,
90732,
1021,
394,
6642,
7822,
17421,
287,
22074,
41391,
345,
394,
7177,
3702,
345,
310,
5235,
286,
674,
2175,
220,
18,
6634,
4717,
4793,
5144,
3196,
389,
8670,
627,
286,
369,
16686,
304,
8670,
512,
310,
13761,
284,
510,
5094,
17,
4450,
24382,
479,
14844,
1292,
5680,
310,
422,
13761,
58,
15,
60,
304,
32392,
7736,
62,
18,
37790,
29378,
5482,
512,
394,
13761,
284,
32392,
7736,
62,
18,
37790,
29378,
5482,
58,
11786,
58,
15,
14623,
310,
422,
13761,
58,
15,
60,
304,
659,
5314,
4262,
16227,
512,
394,
13761,
284,
659,
5314,
4262,
16227,
58,
11786,
58,
15,
14623,
310,
29354,
62,
18,
6634,
45121,
5430,
41055,
2120,
8,
369,
865,
304,
13761,
696,
286,
674,
3277,
8863,
6642,
7345,
1052,
11,
87078,
923,
64897,
311,
279,
198,
286,
674,
2447,
8670,
13,
2638,
52381,
2643,
387,
2631,
311,
1977,
279,
198,
286,
674,
2447,
11,
1524,
3582,
433,
374,
539,
10212,
439,
264,
16686,
482,
420,
198,
286,
674,
6462,
374,
2631,
311,
1629,
6642,
7345,
11,
779,
15182,
433,
439,
264,
6642,
198,
286,
674,
16686,
1053,
387,
60791,
627,
286,
422,
659,
17421,
287,
22074,
41391,
512,
310,
29354,
62,
18,
6634,
45121,
1388,
41055,
446,
751,
52381,
29175,
286,
369,
2494,
304,
13516,
17215,
1214,
26812,
570,
63988,
512,
310,
721,
2658,
284,
6859,
7103,
11169,
340,
310,
721,
3223,
284,
6859,
7103,
51484,
340,
310,
422,
904,
2625,
62,
2658,
58,
15,
60,
624,
865,
369,
865,
304,
4015,
16931,
3336,
22953,
394,
3136,
198,
310,
422,
904,
2625,
2658,
7441,
2120,
11,
721,
2658,
8,
477,
1491,
7441,
2120,
11,
721,
3223,
340,
504,
369,
865,
304,
29354,
62
] |
fiesta/fiesta-python | fiesta/fiesta.py | FiestaGroup.create | def create(cls, api, default_name=None, description=None):
"""
http://docs.fiesta.cc/list-management-api.html#creating-a-group
200 character max on the description.
"""
path = 'group'
data = {}
if default_name:
data['default_group_name'] = default_name
if description:
data['description'] = description
if api.domain:
data['domain'] = api.domain
response_data = api.request(path, data=data)
id = response_data['group_id']
group = cls(api, id)
group.default_name = response_data['default_group_name']
return group | python | def create(cls, api, default_name=None, description=None):
"""
http://docs.fiesta.cc/list-management-api.html#creating-a-group
200 character max on the description.
"""
path = 'group'
data = {}
if default_name:
data['default_group_name'] = default_name
if description:
data['description'] = description
if api.domain:
data['domain'] = api.domain
response_data = api.request(path, data=data)
id = response_data['group_id']
group = cls(api, id)
group.default_name = response_data['default_group_name']
return group | [
"def",
"create",
"(",
"cls",
",",
"api",
",",
"default_name",
"=",
"None",
",",
"description",
"=",
"None",
")",
":",
"path",
"=",
"'group'",
"data",
"=",
"{",
"}",
"if",
"default_name",
":",
"data",
"[",
"'default_group_name'",
"]",
"=",
"default_name",
"if",
"description",
":",
"data",
"[",
"'description'",
"]",
"=",
"description",
"if",
"api",
".",
"domain",
":",
"data",
"[",
"'domain'",
"]",
"=",
"api",
".",
"domain",
"response_data",
"=",
"api",
".",
"request",
"(",
"path",
",",
"data",
"=",
"data",
")",
"id",
"=",
"response_data",
"[",
"'group_id'",
"]",
"group",
"=",
"cls",
"(",
"api",
",",
"id",
")",
"group",
".",
"default_name",
"=",
"response_data",
"[",
"'default_group_name'",
"]",
"return",
"group"
] | http://docs.fiesta.cc/list-management-api.html#creating-a-group
200 character max on the description. | [
"http",
":",
"//",
"docs",
".",
"fiesta",
".",
"cc",
"/",
"list",
"-",
"management",
"-",
"api",
".",
"html#creating",
"-",
"a",
"-",
"group"
] | train | https://github.com/fiesta/fiesta-python/blob/cfcc11e4ae4c76b1007794604c33dde877f62cfb/fiesta/fiesta.py#L147-L169 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
http://docs.fiesta.cc/list-management-api.html#creating-a-group
200 character max on the description.
### Response:
def create(cls, api, default_name=None, description=None):
"""
http://docs.fiesta.cc/list-management-api.html#creating-a-group
200 character max on the description.
"""
path = 'group'
data = {}
if default_name:
data['default_group_name'] = default_name
if description:
data['description'] = description
if api.domain:
data['domain'] = api.domain
response_data = api.request(path, data=data)
id = response_data['group_id']
group = cls(api, id)
group.default_name = response_data['default_group_name']
return group
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1277,
1129,
14452,
840,
59549,
28912,
21609,
55885,
24851,
2628,
2,
46002,
7561,
4449,
271,
286,
220,
1049,
3752,
1973,
389,
279,
4096,
382,
14711,
6075,
512,
755,
1893,
21024,
11,
6464,
11,
1670,
1292,
5980,
11,
4096,
5980,
997,
286,
3270,
286,
1795,
1129,
14452,
840,
59549,
28912,
21609,
55885,
24851,
2628,
2,
46002,
7561,
4449,
271,
286,
220,
1049,
3752,
1973,
389,
279,
4096,
627,
286,
3270,
286,
1853,
284,
364,
4166,
3961,
286,
828,
284,
5731,
286,
422,
1670,
1292,
512,
310,
828,
681,
2309,
6422,
1292,
663,
284,
1670,
1292,
198,
286,
422,
4096,
512,
310,
828,
681,
4789,
663,
284,
4096,
198,
286,
422,
6464,
11248,
512,
310,
828,
681,
12482,
663,
284,
6464,
11248,
271,
286,
2077,
1807,
284,
6464,
8387,
5698,
11,
828,
23686,
696,
286,
887,
284,
2077,
1807,
681,
4166,
851,
4532,
286,
1912,
284,
13082,
25865,
11,
887,
340,
286,
1912,
8939,
1292,
284,
2077,
1807,
681,
2309,
6422,
1292,
16049,
286,
471,
1912,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1277,
1129,
14452,
840,
59549,
28912,
21609,
55885,
24851,
2628,
2,
46002,
7561,
4449,
271,
286,
220,
1049,
3752,
1973,
389,
279,
4096,
382,
14711,
6075,
512,
755,
1893,
21024,
11,
6464,
11,
1670,
1292,
5980,
11,
4096,
5980,
997,
286,
3270,
286,
1795,
1129,
14452,
840,
59549,
28912,
21609,
55885,
24851,
2628,
2,
46002,
7561,
4449,
271,
286,
220,
1049,
3752,
1973,
389,
279,
4096,
627,
286,
3270,
286,
1853,
284,
364,
4166,
3961,
286,
828,
284,
5731,
286,
422,
1670,
1292,
512,
310,
828,
681,
2309,
6422,
1292,
663,
284,
1670,
1292,
198,
286,
422,
4096,
512,
310,
828,
681,
4789,
663,
284,
4096,
198,
286,
422,
6464,
11248,
512,
310,
828,
681,
12482,
663,
284,
6464,
11248,
271,
286,
2077,
1807,
284,
6464,
8387,
5698,
11,
828,
23686,
696,
286,
887,
284,
2077,
1807,
681,
4166,
851,
4532,
286,
1912,
284,
13082,
25865,
11,
887,
340,
286,
1912,
8939,
1292,
284,
2077,
1807,
681,
2309,
6422,
1292,
16049,
286,
471,
1912,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
totalgood/nlpia | src/nlpia/anki.py | get_anki_phrases | def get_anki_phrases(lang='english', limit=None):
""" Retrieve as many anki paired-statement corpora as you can for the requested language
If `ankis` (requested languages) is more than one, then get the english texts associated with those languages.
TODO: improve modularity: def function that takes a single language and call it recursively if necessary
>>> get_anki_phrases('afr')[:2]
["'n Groen piesang is nie ryp genoeg om te eet nie.",
"'n Hond het agter die kat aan gehardloop."]
"""
lang = lang.strip().lower()[:3]
lang = LANG2ANKI[lang[:2]] if lang not in ANKI_LANGUAGES else lang
if lang[:2] == 'en':
return get_anki_phrases_english(limit=limit)
return sorted(get_data(lang).iloc[:, -1].str.strip().values) | python | def get_anki_phrases(lang='english', limit=None):
""" Retrieve as many anki paired-statement corpora as you can for the requested language
If `ankis` (requested languages) is more than one, then get the english texts associated with those languages.
TODO: improve modularity: def function that takes a single language and call it recursively if necessary
>>> get_anki_phrases('afr')[:2]
["'n Groen piesang is nie ryp genoeg om te eet nie.",
"'n Hond het agter die kat aan gehardloop."]
"""
lang = lang.strip().lower()[:3]
lang = LANG2ANKI[lang[:2]] if lang not in ANKI_LANGUAGES else lang
if lang[:2] == 'en':
return get_anki_phrases_english(limit=limit)
return sorted(get_data(lang).iloc[:, -1].str.strip().values) | [
"def",
"get_anki_phrases",
"(",
"lang",
"=",
"'english'",
",",
"limit",
"=",
"None",
")",
":",
"lang",
"=",
"lang",
".",
"strip",
"(",
")",
".",
"lower",
"(",
")",
"[",
":",
"3",
"]",
"lang",
"=",
"LANG2ANKI",
"[",
"lang",
"[",
":",
"2",
"]",
"]",
"if",
"lang",
"not",
"in",
"ANKI_LANGUAGES",
"else",
"lang",
"if",
"lang",
"[",
":",
"2",
"]",
"==",
"'en'",
":",
"return",
"get_anki_phrases_english",
"(",
"limit",
"=",
"limit",
")",
"return",
"sorted",
"(",
"get_data",
"(",
"lang",
")",
".",
"iloc",
"[",
":",
",",
"-",
"1",
"]",
".",
"str",
".",
"strip",
"(",
")",
".",
"values",
")"
] | Retrieve as many anki paired-statement corpora as you can for the requested language
If `ankis` (requested languages) is more than one, then get the english texts associated with those languages.
TODO: improve modularity: def function that takes a single language and call it recursively if necessary
>>> get_anki_phrases('afr')[:2]
["'n Groen piesang is nie ryp genoeg om te eet nie.",
"'n Hond het agter die kat aan gehardloop."] | [
"Retrieve",
"as",
"many",
"anki",
"paired",
"-",
"statement",
"corpora",
"as",
"you",
"can",
"for",
"the",
"requested",
"language"
] | train | https://github.com/totalgood/nlpia/blob/efa01126275e9cd3c3a5151a644f1c798a9ec53f/src/nlpia/anki.py#L16-L30 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Retrieve as many anki paired-statement corpora as you can for the requested language
If `ankis` (requested languages) is more than one, then get the english texts associated with those languages.
TODO: improve modularity: def function that takes a single language and call it recursively if necessary
>>> get_anki_phrases('afr')[:2]
["'n Groen piesang is nie ryp genoeg om te eet nie.",
"'n Hond het agter die kat aan gehardloop."]
### Response:
def get_anki_phrases(lang='english', limit=None):
""" Retrieve as many anki paired-statement corpora as you can for the requested language
If `ankis` (requested languages) is more than one, then get the english texts associated with those languages.
TODO: improve modularity: def function that takes a single language and call it recursively if necessary
>>> get_anki_phrases('afr')[:2]
["'n Groen piesang is nie ryp genoeg om te eet nie.",
"'n Hond het agter die kat aan gehardloop."]
"""
lang = lang.strip().lower()[:3]
lang = LANG2ANKI[lang[:2]] if lang not in ANKI_LANGUAGES else lang
if lang[:2] == 'en':
return get_anki_phrases_english(limit=limit)
return sorted(get_data(lang).iloc[:, -1].str.strip().values)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
88765,
439,
1690,
459,
6780,
35526,
5594,
5722,
8533,
64,
439,
499,
649,
369,
279,
11472,
4221,
271,
262,
1442,
1595,
1201,
285,
63,
320,
68205,
15823,
8,
374,
810,
1109,
832,
11,
1243,
636,
279,
30063,
22755,
5938,
449,
1884,
15823,
382,
262,
5456,
25,
7417,
1491,
30079,
25,
711,
734,
430,
5097,
264,
3254,
4221,
323,
1650,
433,
53947,
422,
5995,
198,
262,
12382,
636,
62,
116399,
58829,
2315,
493,
64,
1658,
873,
3530,
17,
933,
262,
4482,
6,
77,
18370,
268,
61777,
526,
374,
11568,
436,
1100,
4173,
78,
797,
8019,
1028,
384,
295,
11568,
10560,
257,
7326,
77,
59215,
9194,
945,
466,
2815,
45356,
18962,
30795,
569,
10719,
1210,
2595,
14711,
6075,
512,
755,
636,
62,
116399,
58829,
2315,
50593,
1151,
30220,
518,
4017,
5980,
997,
262,
4304,
32662,
439,
1690,
459,
6780,
35526,
5594,
5722,
8533,
64,
439,
499,
649,
369,
279,
11472,
4221,
271,
262,
1442,
1595,
1201,
285,
63,
320,
68205,
15823,
8,
374,
810,
1109,
832,
11,
1243,
636,
279,
30063,
22755,
5938,
449,
1884,
15823,
382,
262,
5456,
25,
7417,
1491,
30079,
25,
711,
734,
430,
5097,
264,
3254,
4221,
323,
1650,
433,
53947,
422,
5995,
198,
262,
12382,
636,
62,
116399,
58829,
2315,
493,
64,
1658,
873,
3530,
17,
933,
262,
4482,
6,
77,
18370,
268,
61777,
526,
374,
11568,
436,
1100,
4173,
78,
797,
8019,
1028,
384,
295,
11568,
10560,
257,
7326,
77,
59215,
9194,
945,
466,
2815,
45356,
18962,
30795,
569,
10719,
80301,
262,
3270,
262,
8859,
284,
8859,
17624,
1020,
15115,
368,
3530,
18,
933,
262,
8859,
284,
67097,
17,
16395,
40,
58,
5317,
3530,
17,
5163,
422,
8859,
539,
304,
2147,
82071,
40861,
52,
11488,
775,
8859,
198,
262,
422,
8859,
3530,
17,
60,
624,
364,
268,
3730,
286,
471,
636,
62,
116399,
58829,
2315,
62,
30220,
53362,
28,
9696,
340,
262,
471,
10839,
5550,
1807,
50593,
570,
27043,
9821,
482,
16,
948,
496,
17624,
1020,
3745,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
88765,
439,
1690,
459,
6780,
35526,
5594,
5722,
8533,
64,
439,
499,
649,
369,
279,
11472,
4221,
271,
262,
1442,
1595,
1201,
285,
63,
320,
68205,
15823,
8,
374,
810,
1109,
832,
11,
1243,
636,
279,
30063,
22755,
5938,
449,
1884,
15823,
382,
262,
5456,
25,
7417,
1491,
30079,
25,
711,
734,
430,
5097,
264,
3254,
4221,
323,
1650,
433,
53947,
422,
5995,
198,
262,
12382,
636,
62,
116399,
58829,
2315,
493,
64,
1658,
873,
3530,
17,
933,
262,
4482,
6,
77,
18370,
268,
61777,
526,
374,
11568,
436,
1100,
4173,
78,
797,
8019,
1028,
384,
295,
11568,
10560,
257,
7326,
77,
59215,
9194,
945,
466,
2815,
45356,
18962,
30795,
569,
10719,
1210,
2595,
14711,
6075,
512,
755,
636,
62,
116399,
58829,
2315,
50593,
1151,
30220,
518,
4017,
5980,
997,
262,
4304,
32662,
439,
1690,
459,
6780,
35526,
5594,
5722,
8533,
64,
439,
499,
649,
369,
279,
11472,
4221,
271,
262,
1442,
1595,
1201,
285,
63,
320,
68205,
15823,
8,
374,
810,
1109,
832,
11,
1243,
636,
279,
30063,
22755,
5938,
449,
1884,
15823,
382,
262,
5456,
25,
7417,
1491,
30079,
25,
711,
734,
430,
5097,
264,
3254,
4221,
323,
1650,
433,
53947,
422,
5995,
198,
262,
12382,
636,
62,
116399,
58829,
2315,
493,
64,
1658,
873,
3530,
17,
933,
262,
4482,
6,
77,
18370,
268,
61777,
526,
374,
11568,
436,
1100,
4173,
78,
797,
8019,
1028,
384,
295,
11568,
10560,
257,
7326,
77,
59215,
9194,
945,
466,
2815,
45356,
18962,
30795,
569,
10719,
80301,
262,
3270,
262,
8859,
284,
8859,
17624,
1020,
15115,
368,
3530,
18,
933,
262,
8859,
284,
67097,
17,
16395,
40,
58,
5317,
3530,
17,
5163,
422,
8859,
539,
304,
2147,
82071,
40861,
52,
11488,
775,
8859,
198,
262,
422,
8859,
3530,
17,
60,
624,
364,
268,
3730,
286,
471,
636,
62,
116399,
58829,
2315,
62,
30220,
53362,
28,
9696,
340,
262,
471,
10839,
5550,
1807,
50593,
570,
27043,
9821,
482,
16,
948,
496,
17624,
1020,
3745,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
fprimex/zdesk | zdesk/zdesk_api.py | ZendeskAPI.slas_policy_create | def slas_policy_create(self, data, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/sla_policies#create-sla-policy"
api_path = "/api/v2/slas/policies"
return self.call(api_path, method="POST", data=data, **kwargs) | python | def slas_policy_create(self, data, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/sla_policies#create-sla-policy"
api_path = "/api/v2/slas/policies"
return self.call(api_path, method="POST", data=data, **kwargs) | [
"def",
"slas_policy_create",
"(",
"self",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"api_path",
"=",
"\"/api/v2/slas/policies\"",
"return",
"self",
".",
"call",
"(",
"api_path",
",",
"method",
"=",
"\"POST\"",
",",
"data",
"=",
"data",
",",
"*",
"*",
"kwargs",
")"
] | https://developer.zendesk.com/rest_api/docs/core/sla_policies#create-sla-policy | [
"https",
":",
"//",
"developer",
".",
"zendesk",
".",
"com",
"/",
"rest_api",
"/",
"docs",
"/",
"core",
"/",
"sla_policies#create",
"-",
"sla",
"-",
"policy"
] | train | https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L3149-L3152 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
https://developer.zendesk.com/rest_api/docs/core/sla_policies#create-sla-policy
### Response:
def slas_policy_create(self, data, **kwargs):
"https://developer.zendesk.com/rest_api/docs/core/sla_policies#create-sla-policy"
api_path = "/api/v2/slas/policies"
return self.call(api_path, method="POST", data=data, **kwargs)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2485,
1129,
35501,
4025,
408,
67919,
916,
46365,
11959,
27057,
5433,
2754,
4355,
623,
43138,
79137,
1355,
4355,
67520,
271,
14711,
6075,
512,
755,
1776,
300,
23613,
8827,
1214,
11,
828,
11,
3146,
9872,
997,
286,
330,
2485,
1129,
35501,
4025,
408,
67919,
916,
46365,
11959,
27057,
5433,
2754,
4355,
623,
43138,
79137,
1355,
4355,
67520,
702,
286,
6464,
2703,
284,
3605,
2113,
5574,
17,
2754,
14833,
4420,
43138,
702,
286,
471,
659,
8692,
25865,
2703,
11,
1749,
429,
3019,
498,
828,
23686,
11,
3146,
9872,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2485,
1129,
35501,
4025,
408,
67919,
916,
46365,
11959,
27057,
5433,
2754,
4355,
623,
43138,
79137,
1355,
4355,
67520,
271,
14711,
6075,
512,
755,
1776,
300,
23613,
8827,
1214,
11,
828,
11,
3146,
9872,
997,
286,
330,
2485,
1129,
35501,
4025,
408,
67919,
916,
46365,
11959,
27057,
5433,
2754,
4355,
623,
43138,
79137,
1355,
4355,
67520,
702,
286,
6464,
2703,
284,
3605,
2113,
5574,
17,
2754,
14833,
4420,
43138,
702,
286,
471,
659,
8692,
25865,
2703,
11,
1749,
429,
3019,
498,
828,
23686,
11,
3146,
9872,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
ricequant/rqalpha | rqalpha/model/instrument.py | Instrument.status | def status(self):
"""
[str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市,
‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用)
"""
try:
return self.__dict__["status"]
except (KeyError, ValueError):
raise AttributeError(
"Instrument(order_book_id={}) has no attribute 'status' ".format(self.order_book_id)
) | python | def status(self):
"""
[str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市,
‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用)
"""
try:
return self.__dict__["status"]
except (KeyError, ValueError):
raise AttributeError(
"Instrument(order_book_id={}) has no attribute 'status' ".format(self.order_book_id)
) | [
"def",
"status",
"(",
"self",
")",
":",
"try",
":",
"return",
"self",
".",
"__dict__",
"[",
"\"status\"",
"]",
"except",
"(",
"KeyError",
",",
"ValueError",
")",
":",
"raise",
"AttributeError",
"(",
"\"Instrument(order_book_id={}) has no attribute 'status' \"",
".",
"format",
"(",
"self",
".",
"order_book_id",
")",
")"
] | [str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市,
‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用) | [
"[",
"str",
"]",
"合约状态。’Active’",
"-",
"正常上市",
"‘Delisted’",
"-",
"终止上市",
"‘TemporarySuspended’",
"-",
"暂停上市",
"‘PreIPO’",
"-",
"发行配售期间",
"‘FailIPO’",
"-",
"发行失败(股票专用)"
] | train | https://github.com/ricequant/rqalpha/blob/ac40a62d4e7eca9494b4d0a14f46facf5616820c/rqalpha/model/instrument.py#L188-L198 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
[str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市,
‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用)
### Response:
def status(self):
"""
[str] 合约状态。’Active’ - 正常上市, ‘Delisted’ - 终止上市, ‘TemporarySuspended’ - 暂停上市,
‘PreIPO’ - 发行配售期间, ‘FailIPO’ - 发行失败(股票专用)
"""
try:
return self.__dict__["status"]
except (KeyError, ValueError):
raise AttributeError(
"Instrument(order_book_id={}) has no attribute 'status' ".format(self.order_book_id)
)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
17752,
60,
108825,
95337,
45191,
1811,
529,
5847,
529,
482,
108519,
40053,
17905,
23530,
11,
3451,
16939,
13539,
529,
482,
45154,
230,
82533,
17905,
23530,
11,
3451,
60462,
50,
67449,
529,
482,
113204,
224,
95475,
17905,
23530,
345,
286,
3451,
4808,
40,
2089,
529,
482,
70525,
23039,
55487,
104376,
121362,
11,
3451,
20094,
40,
2089,
529,
482,
70525,
23039,
22820,
10110,
125328,
96511,
11883,
28966,
14711,
6075,
512,
755,
2704,
1214,
997,
286,
3270,
286,
510,
496,
60,
108825,
95337,
45191,
1811,
529,
5847,
529,
482,
108519,
40053,
17905,
23530,
11,
3451,
16939,
13539,
529,
482,
45154,
230,
82533,
17905,
23530,
11,
3451,
60462,
50,
67449,
529,
482,
113204,
224,
95475,
17905,
23530,
345,
286,
3451,
4808,
40,
2089,
529,
482,
70525,
23039,
55487,
104376,
121362,
11,
3451,
20094,
40,
2089,
529,
482,
70525,
23039,
22820,
10110,
125328,
96511,
11883,
23954,
286,
3270,
286,
1456,
512,
310,
471,
659,
4952,
8644,
43003,
2899,
7171,
286,
3734,
320,
1622,
1480,
11,
15764,
997,
310,
4933,
54731,
1021,
394,
330,
57424,
19948,
27519,
851,
1185,
5525,
706,
912,
7180,
364,
2899,
6,
6058,
2293,
1214,
14368,
27519,
851,
340,
310,
1763,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
17752,
60,
108825,
95337,
45191,
1811,
529,
5847,
529,
482,
108519,
40053,
17905,
23530,
11,
3451,
16939,
13539,
529,
482,
45154,
230,
82533,
17905,
23530,
11,
3451,
60462,
50,
67449,
529,
482,
113204,
224,
95475,
17905,
23530,
345,
286,
3451,
4808,
40,
2089,
529,
482,
70525,
23039,
55487,
104376,
121362,
11,
3451,
20094,
40,
2089,
529,
482,
70525,
23039,
22820,
10110,
125328,
96511,
11883,
28966,
14711,
6075,
512,
755,
2704,
1214,
997,
286,
3270,
286,
510,
496,
60,
108825,
95337,
45191,
1811,
529,
5847,
529,
482,
108519,
40053,
17905,
23530,
11,
3451,
16939,
13539,
529,
482,
45154,
230,
82533,
17905,
23530,
11,
3451,
60462,
50,
67449,
529,
482,
113204,
224,
95475,
17905,
23530,
345,
286,
3451,
4808,
40,
2089,
529,
482,
70525,
23039,
55487,
104376,
121362,
11,
3451,
20094,
40,
2089,
529,
482,
70525,
23039,
22820,
10110,
125328,
96511,
11883,
23954,
286,
3270,
286,
1456,
512,
310,
471,
659,
4952,
8644,
43003,
2899,
7171,
286,
3734,
320,
1622,
1480,
11,
15764,
997,
310,
4933,
54731,
1021,
394,
330,
57424,
19948,
27519,
851,
1185,
5525,
706,
912,
7180,
364,
2899,
6,
6058,
2293,
1214,
14368,
27519,
851,
340,
310,
1763,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
bopo/mootdx | mootdx/reader.py | StdReader.daily | def daily(self, symbol=None):
'''
获取日线数据
:param symbol:
:return: pd.dataFrame or None
'''
reader = TdxDailyBarReader()
vipdoc = self.find_path(symbol=symbol, subdir='lday', ext='day')
if vipdoc is not None:
return reader.get_df(vipdoc)
return None | python | def daily(self, symbol=None):
'''
获取日线数据
:param symbol:
:return: pd.dataFrame or None
'''
reader = TdxDailyBarReader()
vipdoc = self.find_path(symbol=symbol, subdir='lday', ext='day')
if vipdoc is not None:
return reader.get_df(vipdoc)
return None | [
"def",
"daily",
"(",
"self",
",",
"symbol",
"=",
"None",
")",
":",
"reader",
"=",
"TdxDailyBarReader",
"(",
")",
"vipdoc",
"=",
"self",
".",
"find_path",
"(",
"symbol",
"=",
"symbol",
",",
"subdir",
"=",
"'lday'",
",",
"ext",
"=",
"'day'",
")",
"if",
"vipdoc",
"is",
"not",
"None",
":",
"return",
"reader",
".",
"get_df",
"(",
"vipdoc",
")",
"return",
"None"
] | 获取日线数据
:param symbol:
:return: pd.dataFrame or None | [
"获取日线数据"
] | train | https://github.com/bopo/mootdx/blob/7c4623e9464c75d3c87a06d48fe8734b027374fa/mootdx/reader.py#L48-L61 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
获取日线数据
:param symbol:
:return: pd.dataFrame or None
### Response:
def daily(self, symbol=None):
'''
获取日线数据
:param symbol:
:return: pd.dataFrame or None
'''
reader = TdxDailyBarReader()
vipdoc = self.find_path(symbol=symbol, subdir='lday', ext='day')
if vipdoc is not None:
return reader.get_df(vipdoc)
return None
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47012,
9080,
44368,
20675,
271,
286,
551,
913,
7891,
512,
286,
551,
693,
25,
7900,
2245,
4467,
477,
2290,
271,
14711,
6075,
512,
755,
7446,
1214,
11,
7891,
5980,
997,
286,
11414,
286,
41771,
9080,
44368,
20675,
271,
286,
551,
913,
7891,
512,
286,
551,
693,
25,
7900,
2245,
4467,
477,
2290,
198,
286,
11414,
286,
6742,
284,
350,
13009,
44653,
3511,
5172,
746,
286,
63968,
5349,
284,
659,
2725,
2703,
41823,
14481,
4089,
11,
99121,
1151,
509,
352,
518,
1327,
1151,
1316,
4713,
286,
422,
63968,
5349,
374,
539,
2290,
512,
310,
471,
6742,
673,
11133,
3832,
575,
5349,
696,
286,
471,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47012,
9080,
44368,
20675,
271,
286,
551,
913,
7891,
512,
286,
551,
693,
25,
7900,
2245,
4467,
477,
2290,
271,
14711,
6075,
512,
755,
7446,
1214,
11,
7891,
5980,
997,
286,
11414,
286,
41771,
9080,
44368,
20675,
271,
286,
551,
913,
7891,
512,
286,
551,
693,
25,
7900,
2245,
4467,
477,
2290,
198,
286,
11414,
286,
6742,
284,
350,
13009,
44653,
3511,
5172,
746,
286,
63968,
5349,
284,
659,
2725,
2703,
41823,
14481,
4089,
11,
99121,
1151,
509,
352,
518,
1327,
1151,
1316,
4713,
286,
422,
63968,
5349,
374,
539,
2290,
512,
310,
471,
6742,
673,
11133,
3832,
575,
5349,
696,
286,
471,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
PythonCharmers/python-future | src/past/translation/__init__.py | RTs.setup | def setup():
"""
Call this before using the refactoring tools to create them on demand
if needed.
"""
if None in [RTs._rt, RTs._rtp]:
RTs._rt = RefactoringTool(myfixes)
RTs._rtp = RefactoringTool(myfixes, {'print_function': True}) | python | def setup():
"""
Call this before using the refactoring tools to create them on demand
if needed.
"""
if None in [RTs._rt, RTs._rtp]:
RTs._rt = RefactoringTool(myfixes)
RTs._rtp = RefactoringTool(myfixes, {'print_function': True}) | [
"def",
"setup",
"(",
")",
":",
"if",
"None",
"in",
"[",
"RTs",
".",
"_rt",
",",
"RTs",
".",
"_rtp",
"]",
":",
"RTs",
".",
"_rt",
"=",
"RefactoringTool",
"(",
"myfixes",
")",
"RTs",
".",
"_rtp",
"=",
"RefactoringTool",
"(",
"myfixes",
",",
"{",
"'print_function'",
":",
"True",
"}",
")"
] | Call this before using the refactoring tools to create them on demand
if needed. | [
"Call",
"this",
"before",
"using",
"the",
"refactoring",
"tools",
"to",
"create",
"them",
"on",
"demand",
"if",
"needed",
"."
] | train | https://github.com/PythonCharmers/python-future/blob/c423752879acc05eebc29b0bb9909327bd5c7308/src/past/translation/__init__.py#L132-L139 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Call this before using the refactoring tools to create them on demand
if needed.
### Response:
def setup():
"""
Call this before using the refactoring tools to create them on demand
if needed.
"""
if None in [RTs._rt, RTs._rtp]:
RTs._rt = RefactoringTool(myfixes)
RTs._rtp = RefactoringTool(myfixes, {'print_function': True})
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7368,
420,
1603,
1701,
279,
2098,
76507,
7526,
311,
1893,
1124,
389,
7631,
198,
286,
422,
4460,
382,
14711,
6075,
512,
755,
6642,
4019,
286,
3270,
286,
7290,
420,
1603,
1701,
279,
2098,
76507,
7526,
311,
1893,
1124,
389,
7631,
198,
286,
422,
4460,
627,
286,
3270,
286,
422,
2290,
304,
510,
5463,
82,
1462,
3423,
11,
10860,
82,
1462,
81,
796,
10556,
310,
10860,
82,
1462,
3423,
284,
8718,
76507,
7896,
14267,
5862,
288,
340,
310,
10860,
82,
1462,
81,
796,
284,
8718,
76507,
7896,
14267,
5862,
288,
11,
5473,
1374,
9353,
1232,
3082,
3602,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7368,
420,
1603,
1701,
279,
2098,
76507,
7526,
311,
1893,
1124,
389,
7631,
198,
286,
422,
4460,
382,
14711,
6075,
512,
755,
6642,
4019,
286,
3270,
286,
7290,
420,
1603,
1701,
279,
2098,
76507,
7526,
311,
1893,
1124,
389,
7631,
198,
286,
422,
4460,
627,
286,
3270,
286,
422,
2290,
304,
510,
5463,
82,
1462,
3423,
11,
10860,
82,
1462,
81,
796,
10556,
310,
10860,
82,
1462,
3423,
284,
8718,
76507,
7896,
14267,
5862,
288,
340,
310,
10860,
82,
1462,
81,
796,
284,
8718,
76507,
7896,
14267,
5862,
288,
11,
5473,
1374,
9353,
1232,
3082,
3602,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
tornadoweb/tornado | tornado/tcpclient.py | _Connector.split | def split(
addrinfo: List[Tuple]
) -> Tuple[
List[Tuple[socket.AddressFamily, Tuple]],
List[Tuple[socket.AddressFamily, Tuple]],
]:
"""Partition the ``addrinfo`` list by address family.
Returns two lists. The first list contains the first entry from
``addrinfo`` and all others with the same family, and the
second list contains all other addresses (normally one list will
be AF_INET and the other AF_INET6, although non-standard resolvers
may return additional families).
"""
primary = []
secondary = []
primary_af = addrinfo[0][0]
for af, addr in addrinfo:
if af == primary_af:
primary.append((af, addr))
else:
secondary.append((af, addr))
return primary, secondary | python | def split(
addrinfo: List[Tuple]
) -> Tuple[
List[Tuple[socket.AddressFamily, Tuple]],
List[Tuple[socket.AddressFamily, Tuple]],
]:
"""Partition the ``addrinfo`` list by address family.
Returns two lists. The first list contains the first entry from
``addrinfo`` and all others with the same family, and the
second list contains all other addresses (normally one list will
be AF_INET and the other AF_INET6, although non-standard resolvers
may return additional families).
"""
primary = []
secondary = []
primary_af = addrinfo[0][0]
for af, addr in addrinfo:
if af == primary_af:
primary.append((af, addr))
else:
secondary.append((af, addr))
return primary, secondary | [
"def",
"split",
"(",
"addrinfo",
":",
"List",
"[",
"Tuple",
"]",
")",
"->",
"Tuple",
"[",
"List",
"[",
"Tuple",
"[",
"socket",
".",
"AddressFamily",
",",
"Tuple",
"]",
"]",
",",
"List",
"[",
"Tuple",
"[",
"socket",
".",
"AddressFamily",
",",
"Tuple",
"]",
"]",
",",
"]",
":",
"primary",
"=",
"[",
"]",
"secondary",
"=",
"[",
"]",
"primary_af",
"=",
"addrinfo",
"[",
"0",
"]",
"[",
"0",
"]",
"for",
"af",
",",
"addr",
"in",
"addrinfo",
":",
"if",
"af",
"==",
"primary_af",
":",
"primary",
".",
"append",
"(",
"(",
"af",
",",
"addr",
")",
")",
"else",
":",
"secondary",
".",
"append",
"(",
"(",
"af",
",",
"addr",
")",
")",
"return",
"primary",
",",
"secondary"
] | Partition the ``addrinfo`` list by address family.
Returns two lists. The first list contains the first entry from
``addrinfo`` and all others with the same family, and the
second list contains all other addresses (normally one list will
be AF_INET and the other AF_INET6, although non-standard resolvers
may return additional families). | [
"Partition",
"the",
"addrinfo",
"list",
"by",
"address",
"family",
"."
] | train | https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/tcpclient.py#L81-L103 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Partition the ``addrinfo`` list by address family.
Returns two lists. The first list contains the first entry from
``addrinfo`` and all others with the same family, and the
second list contains all other addresses (normally one list will
be AF_INET and the other AF_INET6, although non-standard resolvers
may return additional families).
### Response:
def split(
addrinfo: List[Tuple]
) -> Tuple[
List[Tuple[socket.AddressFamily, Tuple]],
List[Tuple[socket.AddressFamily, Tuple]],
]:
"""Partition the ``addrinfo`` list by address family.
Returns two lists. The first list contains the first entry from
``addrinfo`` and all others with the same family, and the
second list contains all other addresses (normally one list will
be AF_INET and the other AF_INET6, although non-standard resolvers
may return additional families).
"""
primary = []
secondary = []
primary_af = addrinfo[0][0]
for af, addr in addrinfo:
if af == primary_af:
primary.append((af, addr))
else:
secondary.append((af, addr))
return primary, secondary
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
51078,
279,
10103,
6346,
2801,
14196,
1160,
555,
2686,
3070,
382,
286,
5295,
1403,
11725,
13,
220,
578,
1176,
1160,
5727,
279,
1176,
4441,
505,
198,
286,
10103,
6346,
2801,
14196,
323,
682,
3885,
449,
279,
1890,
3070,
11,
323,
279,
198,
286,
2132,
1160,
5727,
682,
1023,
14564,
320,
86336,
832,
1160,
690,
198,
286,
387,
20479,
27932,
323,
279,
1023,
20479,
27932,
21,
11,
8051,
2536,
54920,
594,
40535,
198,
286,
1253,
471,
5217,
8689,
3677,
14711,
6075,
512,
755,
6859,
1021,
286,
11022,
2801,
25,
1796,
20961,
6189,
933,
262,
883,
1492,
25645,
9837,
286,
1796,
20961,
6189,
58,
9750,
28077,
15547,
11,
25645,
19052,
286,
1796,
20961,
6189,
58,
9750,
28077,
15547,
11,
25645,
19052,
262,
2331,
512,
286,
4304,
51078,
279,
10103,
6346,
2801,
14196,
1160,
555,
2686,
3070,
382,
286,
5295,
1403,
11725,
13,
220,
578,
1176,
1160,
5727,
279,
1176,
4441,
505,
198,
286,
10103,
6346,
2801,
14196,
323,
682,
3885,
449,
279,
1890,
3070,
11,
323,
279,
198,
286,
2132,
1160,
5727,
682,
1023,
14564,
320,
86336,
832,
1160,
690,
198,
286,
387,
20479,
27932,
323,
279,
1023,
20479,
27932,
21,
11,
8051,
2536,
54920,
594,
40535,
198,
286,
1253,
471,
5217,
8689,
4390,
286,
3270,
286,
6156,
284,
4260,
286,
14580,
284,
4260,
286,
6156,
68313,
284,
11022,
2801,
58,
15,
1483,
15,
933,
286,
369,
8136,
11,
11022,
304,
11022,
2801,
512,
310,
422,
8136,
624,
6156,
68313,
512,
394,
6156,
2102,
1209,
2642,
11,
11022,
1192,
310,
775,
512,
394,
14580,
2102,
1209,
2642,
11,
11022,
1192,
286,
471,
6156,
11,
14580,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
51078,
279,
10103,
6346,
2801,
14196,
1160,
555,
2686,
3070,
382,
286,
5295,
1403,
11725,
13,
220,
578,
1176,
1160,
5727,
279,
1176,
4441,
505,
198,
286,
10103,
6346,
2801,
14196,
323,
682,
3885,
449,
279,
1890,
3070,
11,
323,
279,
198,
286,
2132,
1160,
5727,
682,
1023,
14564,
320,
86336,
832,
1160,
690,
198,
286,
387,
20479,
27932,
323,
279,
1023,
20479,
27932,
21,
11,
8051,
2536,
54920,
594,
40535,
198,
286,
1253,
471,
5217,
8689,
3677,
14711,
6075,
512,
755,
6859,
1021,
286,
11022,
2801,
25,
1796,
20961,
6189,
933,
262,
883,
1492,
25645,
9837,
286,
1796,
20961,
6189,
58,
9750,
28077,
15547,
11,
25645,
19052,
286,
1796,
20961,
6189,
58,
9750,
28077,
15547,
11,
25645,
19052,
262,
2331,
512,
286,
4304,
51078,
279,
10103,
6346,
2801,
14196,
1160,
555,
2686,
3070,
382,
286,
5295,
1403,
11725,
13,
220,
578,
1176,
1160,
5727,
279,
1176,
4441,
505,
198,
286,
10103,
6346,
2801,
14196,
323,
682,
3885,
449,
279,
1890,
3070,
11,
323,
279,
198,
286,
2132,
1160,
5727,
682,
1023,
14564,
320,
86336,
832,
1160,
690,
198,
286,
387,
20479,
27932,
323,
279,
1023,
20479,
27932,
21,
11,
8051,
2536,
54920,
594,
40535,
198,
286,
1253,
471,
5217,
8689,
4390,
286,
3270,
286,
6156,
284,
4260,
286,
14580,
284,
4260,
286,
6156,
68313,
284,
11022,
2801,
58,
15,
1483,
15,
933,
286,
369,
8136,
11,
11022,
304,
11022,
2801,
512,
310,
422,
8136,
624,
6156,
68313,
512,
394,
6156,
2102,
1209,
2642,
11,
11022,
1192,
310,
775,
512,
394,
14580,
2102,
1209,
2642,
11,
11022,
1192,
286,
471,
6156,
11,
14580,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
joesecurity/jbxapi | jbxapi.py | JoeSandbox.submission_delete | def submission_delete(self, submission_id):
"""
Delete a submission.
"""
response = self._post(self.apiurl + '/v2/submission/delete', data={'apikey': self.apikey, 'submission_id': submission_id})
return self._raise_or_extract(response) | python | def submission_delete(self, submission_id):
"""
Delete a submission.
"""
response = self._post(self.apiurl + '/v2/submission/delete', data={'apikey': self.apikey, 'submission_id': submission_id})
return self._raise_or_extract(response) | [
"def",
"submission_delete",
"(",
"self",
",",
"submission_id",
")",
":",
"response",
"=",
"self",
".",
"_post",
"(",
"self",
".",
"apiurl",
"+",
"'/v2/submission/delete'",
",",
"data",
"=",
"{",
"'apikey'",
":",
"self",
".",
"apikey",
",",
"'submission_id'",
":",
"submission_id",
"}",
")",
"return",
"self",
".",
"_raise_or_extract",
"(",
"response",
")"
] | Delete a submission. | [
"Delete",
"a",
"submission",
"."
] | train | https://github.com/joesecurity/jbxapi/blob/cea2f5edef9661d53fe3d58435d4e88701331f79/jbxapi.py#L271-L277 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Delete a submission.
### Response:
def submission_delete(self, submission_id):
"""
Delete a submission.
"""
response = self._post(self.apiurl + '/v2/submission/delete', data={'apikey': self.apikey, 'submission_id': submission_id})
return self._raise_or_extract(response)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
6571,
264,
21142,
382,
14711,
6075,
512,
755,
21142,
11607,
1214,
11,
21142,
851,
997,
286,
3270,
286,
10645,
264,
21142,
627,
286,
3270,
286,
2077,
284,
659,
1462,
2252,
1214,
6314,
1103,
489,
3434,
85,
17,
38985,
2796,
33375,
518,
828,
13150,
73274,
1232,
659,
6314,
798,
11,
364,
58208,
851,
1232,
21142,
851,
9000,
286,
471,
659,
1462,
19223,
8908,
40223,
5802,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
6571,
264,
21142,
382,
14711,
6075,
512,
755,
21142,
11607,
1214,
11,
21142,
851,
997,
286,
3270,
286,
10645,
264,
21142,
627,
286,
3270,
286,
2077,
284,
659,
1462,
2252,
1214,
6314,
1103,
489,
3434,
85,
17,
38985,
2796,
33375,
518,
828,
13150,
73274,
1232,
659,
6314,
798,
11,
364,
58208,
851,
1232,
21142,
851,
9000,
286,
471,
659,
1462,
19223,
8908,
40223,
5802,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
spacetelescope/drizzlepac | drizzlepac/util.py | computeRange | def computeRange(corners):
""" Determine the range spanned by an array of pixel positions. """
x = corners[:, 0]
y = corners[:, 1]
_xrange = (np.minimum.reduce(x), np.maximum.reduce(x))
_yrange = (np.minimum.reduce(y), np.maximum.reduce(y))
return _xrange, _yrange | python | def computeRange(corners):
""" Determine the range spanned by an array of pixel positions. """
x = corners[:, 0]
y = corners[:, 1]
_xrange = (np.minimum.reduce(x), np.maximum.reduce(x))
_yrange = (np.minimum.reduce(y), np.maximum.reduce(y))
return _xrange, _yrange | [
"def",
"computeRange",
"(",
"corners",
")",
":",
"x",
"=",
"corners",
"[",
":",
",",
"0",
"]",
"y",
"=",
"corners",
"[",
":",
",",
"1",
"]",
"_xrange",
"=",
"(",
"np",
".",
"minimum",
".",
"reduce",
"(",
"x",
")",
",",
"np",
".",
"maximum",
".",
"reduce",
"(",
"x",
")",
")",
"_yrange",
"=",
"(",
"np",
".",
"minimum",
".",
"reduce",
"(",
"y",
")",
",",
"np",
".",
"maximum",
".",
"reduce",
"(",
"y",
")",
")",
"return",
"_xrange",
",",
"_yrange"
] | Determine the range spanned by an array of pixel positions. | [
"Determine",
"the",
"range",
"spanned",
"by",
"an",
"array",
"of",
"pixel",
"positions",
"."
] | train | https://github.com/spacetelescope/drizzlepac/blob/15bec3c929a6a869d9e71b9398ced43ede0620f1/drizzlepac/util.py#L1012-L1018 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Determine the range spanned by an array of pixel positions.
### Response:
def computeRange(corners):
""" Determine the range spanned by an array of pixel positions. """
x = corners[:, 0]
y = corners[:, 1]
_xrange = (np.minimum.reduce(x), np.maximum.reduce(x))
_yrange = (np.minimum.reduce(y), np.maximum.reduce(y))
return _xrange, _yrange
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
35,
25296,
279,
2134,
9575,
19212,
555,
459,
1358,
315,
13252,
10093,
382,
14711,
6075,
512,
755,
12849,
6174,
1361,
45380,
997,
262,
4304,
31001,
279,
2134,
9575,
19212,
555,
459,
1358,
315,
13252,
10093,
13,
3270,
262,
865,
284,
24359,
9821,
220,
15,
933,
262,
379,
284,
24359,
9821,
220,
16,
933,
262,
721,
87,
9866,
284,
320,
6331,
58890,
24726,
2120,
705,
2660,
59430,
24726,
2120,
1192,
262,
721,
88,
9866,
284,
320,
6331,
58890,
24726,
7166,
705,
2660,
59430,
24726,
7166,
1192,
262,
471,
721,
87,
9866,
11,
721,
88,
9866,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
35,
25296,
279,
2134,
9575,
19212,
555,
459,
1358,
315,
13252,
10093,
382,
14711,
6075,
512,
755,
12849,
6174,
1361,
45380,
997,
262,
4304,
31001,
279,
2134,
9575,
19212,
555,
459,
1358,
315,
13252,
10093,
13,
3270,
262,
865,
284,
24359,
9821,
220,
15,
933,
262,
379,
284,
24359,
9821,
220,
16,
933,
262,
721,
87,
9866,
284,
320,
6331,
58890,
24726,
2120,
705,
2660,
59430,
24726,
2120,
1192,
262,
721,
88,
9866,
284,
320,
6331,
58890,
24726,
7166,
705,
2660,
59430,
24726,
7166,
1192,
262,
471,
721,
87,
9866,
11,
721,
88,
9866,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
RudolfCardinal/pythonlib | cardinal_pythonlib/rnc_db.py | DatabaseSupporter.delete_by_field | def delete_by_field(self, table: str, field: str, value: Any) -> int:
"""Deletes all records where "field" is "value"."""
sql = ("DELETE FROM " + self.delimit(table) +
" WHERE " + self.delimit(field) + "=?")
return self.db_exec(sql, value) | python | def delete_by_field(self, table: str, field: str, value: Any) -> int:
"""Deletes all records where "field" is "value"."""
sql = ("DELETE FROM " + self.delimit(table) +
" WHERE " + self.delimit(field) + "=?")
return self.db_exec(sql, value) | [
"def",
"delete_by_field",
"(",
"self",
",",
"table",
":",
"str",
",",
"field",
":",
"str",
",",
"value",
":",
"Any",
")",
"->",
"int",
":",
"sql",
"=",
"(",
"\"DELETE FROM \"",
"+",
"self",
".",
"delimit",
"(",
"table",
")",
"+",
"\" WHERE \"",
"+",
"self",
".",
"delimit",
"(",
"field",
")",
"+",
"\"=?\"",
")",
"return",
"self",
".",
"db_exec",
"(",
"sql",
",",
"value",
")"
] | Deletes all records where "field" is "value". | [
"Deletes",
"all",
"records",
"where",
"field",
"is",
"value",
"."
] | train | https://github.com/RudolfCardinal/pythonlib/blob/0b84cb35f38bd7d8723958dae51b480a829b7227/cardinal_pythonlib/rnc_db.py#L2368-L2372 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Deletes all records where "field" is "value".
### Response:
def delete_by_field(self, table: str, field: str, value: Any) -> int:
"""Deletes all records where "field" is "value"."""
sql = ("DELETE FROM " + self.delimit(table) +
" WHERE " + self.delimit(field) + "=?")
return self.db_exec(sql, value)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
62417,
682,
7576,
1405,
330,
2630,
1,
374,
330,
970,
11690,
14711,
6075,
512,
755,
3783,
3795,
5121,
1214,
11,
2007,
25,
610,
11,
2115,
25,
610,
11,
907,
25,
5884,
8,
1492,
528,
512,
286,
4304,
62417,
682,
7576,
1405,
330,
2630,
1,
374,
330,
970,
1,
14781,
286,
5822,
284,
3573,
14762,
4393,
330,
489,
659,
34112,
2408,
16138,
8,
3694,
2342,
330,
5401,
330,
489,
659,
34112,
2408,
15944,
8,
489,
330,
20477,
1158,
286,
471,
659,
7221,
18937,
13449,
11,
907,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0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
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
62417,
682,
7576,
1405,
330,
2630,
1,
374,
330,
970,
11690,
14711,
6075,
512,
755,
3783,
3795,
5121,
1214,
11,
2007,
25,
610,
11,
2115,
25,
610,
11,
907,
25,
5884,
8,
1492,
528,
512,
286,
4304,
62417,
682,
7576,
1405,
330,
2630,
1,
374,
330,
970,
1,
14781,
286,
5822,
284,
3573,
14762,
4393,
330,
489,
659,
34112,
2408,
16138,
8,
3694,
2342,
330,
5401,
330,
489,
659,
34112,
2408,
15944,
8,
489,
330,
20477,
1158,
286,
471,
659,
7221,
18937,
13449,
11,
907,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
CyberReboot/vent | vent/menus/main.py | MainForm.system_commands | def system_commands(self, action):
""" Perform system commands """
if action == 'backup':
status = self.api_action.backup()
if status[0]:
notify_confirm('Vent backup successful')
else:
notify_confirm('Vent backup could not be completed')
elif action == 'start':
status = self.api_action.start()
if status[0]:
notify_confirm('System start complete. '
'Press OK.')
else:
notify_confirm(status[1])
elif action == 'stop':
status = self.api_action.stop()
if status[0]:
notify_confirm('System stop complete. '
'Press OK.')
else:
notify_confirm(status[1])
elif action == 'configure':
# TODO
form_args = {'name': 'Change vent configuration',
'get_configure': self.api_action.get_configure,
'save_configure': self.api_action.save_configure,
'restart_tools': self.api_action.restart_tools,
'vent_cfg': True}
add_kargs = {'form': EditorForm,
'form_name': 'CONFIGUREVENT',
'form_args': form_args}
self.add_form(**add_kargs)
elif action == 'reset':
okay = npyscreen.notify_ok_cancel(
"This factory reset will remove ALL of Vent's user data, "
'containers, and images. Are you sure?',
title='Confirm system command')
if okay:
status = self.api_action.reset()
if status[0]:
notify_confirm('Vent reset complete. '
'Press OK to exit Vent Manager console.')
else:
notify_confirm(status[1])
MainForm.exit()
elif action == 'gpu':
gpu = Gpu(pull=True)
if gpu[0]:
notify_confirm('GPU detection successful. '
'Found: ' + gpu[1])
else:
if gpu[1] == 'Unknown':
notify_confirm('Unable to detect GPUs, try `make gpu` '
'from the vent repository directory. '
'Error: ' + str(gpu[2]))
else:
notify_confirm('No GPUs detected.')
elif action == 'restore':
backup_dir_home = os.path.expanduser('~')
backup_dirs = [f for f in os.listdir(backup_dir_home) if
f.startswith('.vent-backup')]
form_args = {'restore': self.api_action.restore,
'dirs': backup_dirs,
'name': 'Pick a version to restore from' + '\t'*8 +
'^T to toggle main',
'color': 'CONTROL'}
add_kargs = {'form': BackupForm,
'form_name': 'CHOOSEBACKUP',
'form_args': form_args}
self.add_form(**add_kargs)
return | python | def system_commands(self, action):
""" Perform system commands """
if action == 'backup':
status = self.api_action.backup()
if status[0]:
notify_confirm('Vent backup successful')
else:
notify_confirm('Vent backup could not be completed')
elif action == 'start':
status = self.api_action.start()
if status[0]:
notify_confirm('System start complete. '
'Press OK.')
else:
notify_confirm(status[1])
elif action == 'stop':
status = self.api_action.stop()
if status[0]:
notify_confirm('System stop complete. '
'Press OK.')
else:
notify_confirm(status[1])
elif action == 'configure':
# TODO
form_args = {'name': 'Change vent configuration',
'get_configure': self.api_action.get_configure,
'save_configure': self.api_action.save_configure,
'restart_tools': self.api_action.restart_tools,
'vent_cfg': True}
add_kargs = {'form': EditorForm,
'form_name': 'CONFIGUREVENT',
'form_args': form_args}
self.add_form(**add_kargs)
elif action == 'reset':
okay = npyscreen.notify_ok_cancel(
"This factory reset will remove ALL of Vent's user data, "
'containers, and images. Are you sure?',
title='Confirm system command')
if okay:
status = self.api_action.reset()
if status[0]:
notify_confirm('Vent reset complete. '
'Press OK to exit Vent Manager console.')
else:
notify_confirm(status[1])
MainForm.exit()
elif action == 'gpu':
gpu = Gpu(pull=True)
if gpu[0]:
notify_confirm('GPU detection successful. '
'Found: ' + gpu[1])
else:
if gpu[1] == 'Unknown':
notify_confirm('Unable to detect GPUs, try `make gpu` '
'from the vent repository directory. '
'Error: ' + str(gpu[2]))
else:
notify_confirm('No GPUs detected.')
elif action == 'restore':
backup_dir_home = os.path.expanduser('~')
backup_dirs = [f for f in os.listdir(backup_dir_home) if
f.startswith('.vent-backup')]
form_args = {'restore': self.api_action.restore,
'dirs': backup_dirs,
'name': 'Pick a version to restore from' + '\t'*8 +
'^T to toggle main',
'color': 'CONTROL'}
add_kargs = {'form': BackupForm,
'form_name': 'CHOOSEBACKUP',
'form_args': form_args}
self.add_form(**add_kargs)
return | [
"def",
"system_commands",
"(",
"self",
",",
"action",
")",
":",
"if",
"action",
"==",
"'backup'",
":",
"status",
"=",
"self",
".",
"api_action",
".",
"backup",
"(",
")",
"if",
"status",
"[",
"0",
"]",
":",
"notify_confirm",
"(",
"'Vent backup successful'",
")",
"else",
":",
"notify_confirm",
"(",
"'Vent backup could not be completed'",
")",
"elif",
"action",
"==",
"'start'",
":",
"status",
"=",
"self",
".",
"api_action",
".",
"start",
"(",
")",
"if",
"status",
"[",
"0",
"]",
":",
"notify_confirm",
"(",
"'System start complete. '",
"'Press OK.'",
")",
"else",
":",
"notify_confirm",
"(",
"status",
"[",
"1",
"]",
")",
"elif",
"action",
"==",
"'stop'",
":",
"status",
"=",
"self",
".",
"api_action",
".",
"stop",
"(",
")",
"if",
"status",
"[",
"0",
"]",
":",
"notify_confirm",
"(",
"'System stop complete. '",
"'Press OK.'",
")",
"else",
":",
"notify_confirm",
"(",
"status",
"[",
"1",
"]",
")",
"elif",
"action",
"==",
"'configure'",
":",
"# TODO",
"form_args",
"=",
"{",
"'name'",
":",
"'Change vent configuration'",
",",
"'get_configure'",
":",
"self",
".",
"api_action",
".",
"get_configure",
",",
"'save_configure'",
":",
"self",
".",
"api_action",
".",
"save_configure",
",",
"'restart_tools'",
":",
"self",
".",
"api_action",
".",
"restart_tools",
",",
"'vent_cfg'",
":",
"True",
"}",
"add_kargs",
"=",
"{",
"'form'",
":",
"EditorForm",
",",
"'form_name'",
":",
"'CONFIGUREVENT'",
",",
"'form_args'",
":",
"form_args",
"}",
"self",
".",
"add_form",
"(",
"*",
"*",
"add_kargs",
")",
"elif",
"action",
"==",
"'reset'",
":",
"okay",
"=",
"npyscreen",
".",
"notify_ok_cancel",
"(",
"\"This factory reset will remove ALL of Vent's user data, \"",
"'containers, and images. Are you sure?'",
",",
"title",
"=",
"'Confirm system command'",
")",
"if",
"okay",
":",
"status",
"=",
"self",
".",
"api_action",
".",
"reset",
"(",
")",
"if",
"status",
"[",
"0",
"]",
":",
"notify_confirm",
"(",
"'Vent reset complete. '",
"'Press OK to exit Vent Manager console.'",
")",
"else",
":",
"notify_confirm",
"(",
"status",
"[",
"1",
"]",
")",
"MainForm",
".",
"exit",
"(",
")",
"elif",
"action",
"==",
"'gpu'",
":",
"gpu",
"=",
"Gpu",
"(",
"pull",
"=",
"True",
")",
"if",
"gpu",
"[",
"0",
"]",
":",
"notify_confirm",
"(",
"'GPU detection successful. '",
"'Found: '",
"+",
"gpu",
"[",
"1",
"]",
")",
"else",
":",
"if",
"gpu",
"[",
"1",
"]",
"==",
"'Unknown'",
":",
"notify_confirm",
"(",
"'Unable to detect GPUs, try `make gpu` '",
"'from the vent repository directory. '",
"'Error: '",
"+",
"str",
"(",
"gpu",
"[",
"2",
"]",
")",
")",
"else",
":",
"notify_confirm",
"(",
"'No GPUs detected.'",
")",
"elif",
"action",
"==",
"'restore'",
":",
"backup_dir_home",
"=",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
"backup_dirs",
"=",
"[",
"f",
"for",
"f",
"in",
"os",
".",
"listdir",
"(",
"backup_dir_home",
")",
"if",
"f",
".",
"startswith",
"(",
"'.vent-backup'",
")",
"]",
"form_args",
"=",
"{",
"'restore'",
":",
"self",
".",
"api_action",
".",
"restore",
",",
"'dirs'",
":",
"backup_dirs",
",",
"'name'",
":",
"'Pick a version to restore from'",
"+",
"'\\t'",
"*",
"8",
"+",
"'^T to toggle main'",
",",
"'color'",
":",
"'CONTROL'",
"}",
"add_kargs",
"=",
"{",
"'form'",
":",
"BackupForm",
",",
"'form_name'",
":",
"'CHOOSEBACKUP'",
",",
"'form_args'",
":",
"form_args",
"}",
"self",
".",
"add_form",
"(",
"*",
"*",
"add_kargs",
")",
"return"
] | Perform system commands | [
"Perform",
"system",
"commands"
] | train | https://github.com/CyberReboot/vent/blob/9956a09146b11a89a0eabab3bc7ce8906d124885/vent/menus/main.py#L180-L251 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Perform system commands
### Response:
def system_commands(self, action):
""" Perform system commands """
if action == 'backup':
status = self.api_action.backup()
if status[0]:
notify_confirm('Vent backup successful')
else:
notify_confirm('Vent backup could not be completed')
elif action == 'start':
status = self.api_action.start()
if status[0]:
notify_confirm('System start complete. '
'Press OK.')
else:
notify_confirm(status[1])
elif action == 'stop':
status = self.api_action.stop()
if status[0]:
notify_confirm('System stop complete. '
'Press OK.')
else:
notify_confirm(status[1])
elif action == 'configure':
# TODO
form_args = {'name': 'Change vent configuration',
'get_configure': self.api_action.get_configure,
'save_configure': self.api_action.save_configure,
'restart_tools': self.api_action.restart_tools,
'vent_cfg': True}
add_kargs = {'form': EditorForm,
'form_name': 'CONFIGUREVENT',
'form_args': form_args}
self.add_form(**add_kargs)
elif action == 'reset':
okay = npyscreen.notify_ok_cancel(
"This factory reset will remove ALL of Vent's user data, "
'containers, and images. Are you sure?',
title='Confirm system command')
if okay:
status = self.api_action.reset()
if status[0]:
notify_confirm('Vent reset complete. '
'Press OK to exit Vent Manager console.')
else:
notify_confirm(status[1])
MainForm.exit()
elif action == 'gpu':
gpu = Gpu(pull=True)
if gpu[0]:
notify_confirm('GPU detection successful. '
'Found: ' + gpu[1])
else:
if gpu[1] == 'Unknown':
notify_confirm('Unable to detect GPUs, try `make gpu` '
'from the vent repository directory. '
'Error: ' + str(gpu[2]))
else:
notify_confirm('No GPUs detected.')
elif action == 'restore':
backup_dir_home = os.path.expanduser('~')
backup_dirs = [f for f in os.listdir(backup_dir_home) if
f.startswith('.vent-backup')]
form_args = {'restore': self.api_action.restore,
'dirs': backup_dirs,
'name': 'Pick a version to restore from' + '\t'*8 +
'^T to toggle main',
'color': 'CONTROL'}
add_kargs = {'form': BackupForm,
'form_name': 'CHOOSEBACKUP',
'form_args': form_args}
self.add_form(**add_kargs)
return
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
48051,
1887,
11545,
271,
14711,
6075,
512,
755,
1887,
45251,
1214,
11,
1957,
997,
286,
4304,
26050,
1887,
11545,
3270,
286,
422,
1957,
624,
364,
32471,
3730,
310,
2704,
284,
659,
6314,
8090,
99655,
746,
310,
422,
2704,
58,
15,
10556,
394,
15820,
24736,
493,
77632,
16101,
6992,
1329,
310,
775,
512,
394,
15820,
24736,
493,
77632,
16101,
1436,
539,
387,
8308,
1329,
286,
4508,
1957,
624,
364,
2527,
3730,
310,
2704,
284,
659,
6314,
8090,
5069,
746,
310,
422,
2704,
58,
15,
10556,
394,
15820,
24736,
493,
2374,
1212,
4686,
13,
8044,
7714,
364,
6010,
10619,
21537,
310,
775,
512,
394,
15820,
24736,
14159,
58,
16,
2608,
286,
4508,
1957,
624,
364,
9684,
3730,
310,
2704,
284,
659,
6314,
8090,
13530,
746,
310,
422,
2704,
58,
15,
10556,
394,
15820,
24736,
493,
2374,
3009,
4686,
13,
8044,
7714,
364,
6010,
10619,
21537,
310,
775,
512,
394,
15820,
24736,
14159,
58,
16,
2608,
286,
4508,
1957,
624,
364,
21678,
3730,
310,
674,
5456,
198,
310,
1376,
8550,
284,
5473,
609,
1232,
364,
4164,
10594,
6683,
756,
5218,
364,
456,
76987,
1232,
659,
6314,
8090,
673,
76987,
345,
5218,
364,
6766,
76987,
1232,
659,
6314,
8090,
5799,
76987,
345,
5218,
364,
51315,
40823,
1232,
659,
6314,
8090,
83855,
40823,
345,
5218,
364,
688,
18849,
1232,
3082,
534,
310,
923,
4803,
2164,
284,
5473,
630,
1232,
12865,
1876,
345,
5218,
364,
630,
1292,
1232,
364,
25677,
4622,
6927,
756,
5218,
364,
630,
8550,
1232,
1376,
8550,
534,
310,
659,
1388,
8074,
22551,
723,
4803,
2164,
340,
286,
4508,
1957,
624,
364,
9915,
3730,
310,
17339,
284,
2660,
1065,
2240,
25708,
20404,
29995,
1021,
394,
330,
2028,
8803,
7738,
690,
4148,
13398,
315,
27505,
596,
1217,
828,
11,
6360,
394,
364,
40499,
11,
323,
5448,
13,
8886,
499,
2771,
43020,
394,
2316,
1151,
17143,
1887,
3290,
1329,
310,
422,
17339,
512,
394,
2704,
284,
659,
6314,
8090,
14178,
746,
394,
422,
2704,
58,
15,
10556,
504,
15820,
24736,
493,
77632,
7738,
4686,
13,
8044,
9898,
364,
6010,
10619,
311,
4974,
27505,
10790,
2393,
21537,
394,
775,
512,
504,
15820,
24736,
14159,
58,
16,
2608,
394,
75777,
13955,
746,
286,
4508,
1957,
624,
364,
43694,
3730,
310,
39534,
284,
480,
5701,
1319,
620,
3702,
340,
310,
422,
39534,
58,
15,
10556,
394,
15820,
24736,
493,
50991,
18468,
6992,
13,
8044,
7714,
364,
6788,
25,
364,
489,
39534,
58,
16,
2608,
310,
775,
512,
394,
422,
39534,
58,
16,
60,
624,
364,
14109,
3730,
504,
15820,
24736,
493,
17512,
311,
11388,
71503,
11,
1456,
1595,
7072,
39534,
63,
8044,
9898,
364,
1527,
279,
10594,
12827,
6352,
13,
8044,
9898,
364,
1480,
25,
364,
489,
610,
3348,
5701,
58,
17,
11147,
394,
775,
512,
504,
15820,
24736,
493,
2822,
71503,
16914,
21537,
286,
4508,
1957,
624,
364,
31904,
3730,
310,
16101,
4432,
22389,
284,
2709,
3960,
28837,
882,
97125
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
48051,
1887,
11545,
271,
14711,
6075,
512,
755,
1887,
45251,
1214,
11,
1957,
997,
286,
4304,
26050,
1887,
11545,
3270,
286,
422,
1957,
624,
364,
32471,
3730,
310,
2704,
284,
659,
6314,
8090,
99655,
746,
310,
422,
2704,
58,
15,
10556,
394,
15820,
24736,
493,
77632,
16101,
6992,
1329,
310,
775,
512,
394,
15820,
24736,
493,
77632,
16101,
1436,
539,
387,
8308,
1329,
286,
4508,
1957,
624,
364,
2527,
3730,
310,
2704,
284,
659,
6314,
8090,
5069,
746,
310,
422,
2704,
58,
15,
10556,
394,
15820,
24736,
493,
2374,
1212,
4686,
13,
8044,
7714,
364,
6010,
10619,
21537,
310,
775,
512,
394,
15820,
24736,
14159,
58,
16,
2608,
286,
4508,
1957,
624,
364,
9684,
3730,
310,
2704,
284,
659,
6314,
8090,
13530,
746,
310,
422,
2704,
58,
15,
10556,
394,
15820,
24736,
493,
2374,
3009,
4686,
13,
8044,
7714,
364,
6010,
10619,
21537,
310,
775,
512,
394,
15820,
24736,
14159,
58,
16,
2608,
286,
4508,
1957,
624,
364,
21678,
3730,
310,
674,
5456,
198,
310,
1376,
8550,
284,
5473,
609,
1232,
364,
4164,
10594,
6683,
756,
5218,
364,
456,
76987,
1232,
659,
6314,
8090,
673,
76987,
345,
5218,
364,
6766,
76987,
1232,
659,
6314,
8090,
5799,
76987,
345,
5218,
364,
51315,
40823,
1232,
659,
6314,
8090,
83855,
40823,
345,
5218,
364,
688,
18849,
1232,
3082,
534,
310,
923,
4803,
2164,
284,
5473,
630,
1232,
12865,
1876,
345,
5218,
364,
630,
1292,
1232,
364,
25677,
4622,
6927,
756,
5218,
364,
630,
8550,
1232,
1376,
8550,
534,
310,
659,
1388,
8074,
22551,
723,
4803,
2164,
340,
286,
4508,
1957,
624,
364,
9915,
3730,
310,
17339,
284,
2660,
1065,
2240,
25708,
20404,
29995,
1021,
394,
330,
2028,
8803,
7738,
690,
4148,
13398,
315,
27505,
596,
1217,
828,
11,
6360,
394,
364,
40499,
11,
323,
5448,
13,
8886,
499,
2771,
43020,
394,
2316,
1151,
17143,
1887,
3290,
1329,
310,
422,
17339,
512,
394,
2704,
284,
659,
6314,
8090,
14178,
746,
394,
422,
2704,
58,
15,
10556,
504,
15820,
24736,
493,
77632,
7738,
4686,
13,
8044,
9898,
364,
6010,
10619,
311,
4974,
27505,
10790,
2393,
21537,
394,
775,
512,
504,
15820,
24736,
14159,
58,
16,
2608,
394,
75777,
13955,
746,
286,
4508,
1957,
624,
364,
43694,
3730,
310,
39534,
284,
480,
5701,
1319,
620,
3702,
340,
310,
422,
39534,
58,
15,
10556,
394,
15820,
24736,
493,
50991,
18468,
6992,
13,
8044,
7714,
364,
6788,
25,
364,
489,
39534,
58,
16,
2608,
310,
775,
512,
394,
422,
39534,
58,
16,
60,
624,
364,
14109,
3730,
504,
15820,
24736,
493,
17512,
311,
11388,
71503,
11,
1456,
1595,
7072,
39534,
63,
8044,
9898,
364,
1527,
279,
10594,
12827,
6352,
13,
8044,
9898,
364,
1480,
25,
364,
489,
610,
3348,
5701,
58,
17,
11147,
394,
775,
512,
504,
15820,
24736,
493,
2822,
71503,
16914,
21537,
286,
4508,
1957,
624,
364,
31904,
3730,
310,
16101,
4432,
22389,
284,
2709,
3960,
28837,
882,
97125
] |
bhmm/bhmm | bhmm/estimators/_tmatrix_disconnected.py | is_reversible | def is_reversible(P):
""" Returns if P is reversible on its weakly connected sets """
import msmtools.analysis as msmana
# treat each weakly connected set separately
sets = connected_sets(P, strong=False)
for s in sets:
Ps = P[s, :][:, s]
if not msmana.is_transition_matrix(Ps):
return False # isn't even a transition matrix!
pi = msmana.stationary_distribution(Ps)
X = pi[:, None] * Ps
if not np.allclose(X, X.T):
return False
# survived.
return True | python | def is_reversible(P):
""" Returns if P is reversible on its weakly connected sets """
import msmtools.analysis as msmana
# treat each weakly connected set separately
sets = connected_sets(P, strong=False)
for s in sets:
Ps = P[s, :][:, s]
if not msmana.is_transition_matrix(Ps):
return False # isn't even a transition matrix!
pi = msmana.stationary_distribution(Ps)
X = pi[:, None] * Ps
if not np.allclose(X, X.T):
return False
# survived.
return True | [
"def",
"is_reversible",
"(",
"P",
")",
":",
"import",
"msmtools",
".",
"analysis",
"as",
"msmana",
"# treat each weakly connected set separately",
"sets",
"=",
"connected_sets",
"(",
"P",
",",
"strong",
"=",
"False",
")",
"for",
"s",
"in",
"sets",
":",
"Ps",
"=",
"P",
"[",
"s",
",",
":",
"]",
"[",
":",
",",
"s",
"]",
"if",
"not",
"msmana",
".",
"is_transition_matrix",
"(",
"Ps",
")",
":",
"return",
"False",
"# isn't even a transition matrix!",
"pi",
"=",
"msmana",
".",
"stationary_distribution",
"(",
"Ps",
")",
"X",
"=",
"pi",
"[",
":",
",",
"None",
"]",
"*",
"Ps",
"if",
"not",
"np",
".",
"allclose",
"(",
"X",
",",
"X",
".",
"T",
")",
":",
"return",
"False",
"# survived.",
"return",
"True"
] | Returns if P is reversible on its weakly connected sets | [
"Returns",
"if",
"P",
"is",
"reversible",
"on",
"its",
"weakly",
"connected",
"sets"
] | train | https://github.com/bhmm/bhmm/blob/9804d18c2ddb684fb4d90b544cc209617a89ca9a/bhmm/estimators/_tmatrix_disconnected.py#L212-L226 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Returns if P is reversible on its weakly connected sets
### Response:
def is_reversible(P):
""" Returns if P is reversible on its weakly connected sets """
import msmtools.analysis as msmana
# treat each weakly connected set separately
sets = connected_sets(P, strong=False)
for s in sets:
Ps = P[s, :][:, s]
if not msmana.is_transition_matrix(Ps):
return False # isn't even a transition matrix!
pi = msmana.stationary_distribution(Ps)
X = pi[:, None] * Ps
if not np.allclose(X, X.T):
return False
# survived.
return True
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
422,
393,
374,
81193,
389,
1202,
7621,
398,
8599,
7437,
271,
14711,
6075,
512,
755,
374,
1311,
65398,
5417,
997,
262,
4304,
5295,
422,
393,
374,
81193,
389,
1202,
7621,
398,
8599,
7437,
3270,
262,
1179,
59688,
16297,
59297,
439,
10030,
48576,
198,
262,
674,
4322,
1855,
7621,
398,
8599,
743,
26214,
198,
262,
7437,
284,
8599,
21992,
5417,
11,
3831,
5725,
340,
262,
369,
274,
304,
7437,
512,
286,
12065,
284,
393,
12144,
11,
551,
26147,
11,
274,
933,
286,
422,
539,
10030,
48576,
2124,
54693,
10403,
5417,
82,
997,
310,
471,
3641,
220,
674,
4536,
956,
1524,
264,
9320,
6303,
4999,
286,
9115,
284,
10030,
48576,
88440,
661,
42565,
5417,
82,
340,
286,
1630,
284,
9115,
9821,
2290,
60,
353,
12065,
198,
286,
422,
539,
2660,
7825,
5669,
7799,
11,
1630,
844,
997,
310,
471,
3641,
198,
262,
674,
26968,
627,
262,
471,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
422,
393,
374,
81193,
389,
1202,
7621,
398,
8599,
7437,
271,
14711,
6075,
512,
755,
374,
1311,
65398,
5417,
997,
262,
4304,
5295,
422,
393,
374,
81193,
389,
1202,
7621,
398,
8599,
7437,
3270,
262,
1179,
59688,
16297,
59297,
439,
10030,
48576,
198,
262,
674,
4322,
1855,
7621,
398,
8599,
743,
26214,
198,
262,
7437,
284,
8599,
21992,
5417,
11,
3831,
5725,
340,
262,
369,
274,
304,
7437,
512,
286,
12065,
284,
393,
12144,
11,
551,
26147,
11,
274,
933,
286,
422,
539,
10030,
48576,
2124,
54693,
10403,
5417,
82,
997,
310,
471,
3641,
220,
674,
4536,
956,
1524,
264,
9320,
6303,
4999,
286,
9115,
284,
10030,
48576,
88440,
661,
42565,
5417,
82,
340,
286,
1630,
284,
9115,
9821,
2290,
60,
353,
12065,
198,
286,
422,
539,
2660,
7825,
5669,
7799,
11,
1630,
844,
997,
310,
471,
3641,
198,
262,
674,
26968,
627,
262,
471,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
proycon/pynlpl | pynlpl/formats/folia.py | PhonContent.finddefaultreference | def finddefaultreference(self):
"""Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually exists is checked later/elsewhere
"""
depth = 0
e = self
while True:
if e.parent:
e = e.parent #pylint: disable=redefined-variable-type
else:
#no parent, breaking
return False
if isinstance(e,AbstractStructureElement) or isinstance(e,AbstractSubtokenAnnotation):
depth += 1
if depth == 2:
return e
return False | python | def finddefaultreference(self):
"""Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually exists is checked later/elsewhere
"""
depth = 0
e = self
while True:
if e.parent:
e = e.parent #pylint: disable=redefined-variable-type
else:
#no parent, breaking
return False
if isinstance(e,AbstractStructureElement) or isinstance(e,AbstractSubtokenAnnotation):
depth += 1
if depth == 2:
return e
return False | [
"def",
"finddefaultreference",
"(",
"self",
")",
":",
"depth",
"=",
"0",
"e",
"=",
"self",
"while",
"True",
":",
"if",
"e",
".",
"parent",
":",
"e",
"=",
"e",
".",
"parent",
"#pylint: disable=redefined-variable-type",
"else",
":",
"#no parent, breaking",
"return",
"False",
"if",
"isinstance",
"(",
"e",
",",
"AbstractStructureElement",
")",
"or",
"isinstance",
"(",
"e",
",",
"AbstractSubtokenAnnotation",
")",
":",
"depth",
"+=",
"1",
"if",
"depth",
"==",
"2",
":",
"return",
"e",
"return",
"False"
] | Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually exists is checked later/elsewhere | [
"Find",
"the",
"default",
"reference",
"for",
"text",
"offsets",
":",
"The",
"parent",
"of",
"the",
"current",
"textcontent",
"s",
"parent",
"(",
"counting",
"only",
"Structure",
"Elements",
"and",
"Subtoken",
"Annotation",
"Elements",
")"
] | train | https://github.com/proycon/pynlpl/blob/7707f69a91caaa6cde037f0d0379f1d42500a68b/pynlpl/formats/folia.py#L3765-L3787 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually exists is checked later/elsewhere
### Response:
def finddefaultreference(self):
"""Find the default reference for text offsets:
The parent of the current textcontent's parent (counting only Structure Elements and Subtoken Annotation Elements)
Note: This returns not a TextContent element, but its parent. Whether the textcontent actually exists is checked later/elsewhere
"""
depth = 0
e = self
while True:
if e.parent:
e = e.parent #pylint: disable=redefined-variable-type
else:
#no parent, breaking
return False
if isinstance(e,AbstractStructureElement) or isinstance(e,AbstractSubtokenAnnotation):
depth += 1
if depth == 2:
return e
return False
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10086,
279,
1670,
5905,
369,
1495,
36146,
512,
692,
578,
2748,
315,
279,
1510,
1495,
1834,
596,
2748,
320,
1868,
287,
1193,
29696,
35257,
323,
3804,
5963,
46923,
35257,
696,
692,
7181,
25,
1115,
4780,
539,
264,
2991,
2831,
2449,
11,
719,
1202,
2748,
13,
13440,
279,
1495,
1834,
3604,
6866,
374,
10273,
3010,
14,
1531,
2940,
271,
14711,
6075,
512,
755,
1505,
2309,
16690,
1214,
997,
286,
4304,
10086,
279,
1670,
5905,
369,
1495,
36146,
512,
692,
578,
2748,
315,
279,
1510,
1495,
1834,
596,
2748,
320,
1868,
287,
1193,
29696,
35257,
323,
3804,
5963,
46923,
35257,
696,
692,
7181,
25,
1115,
4780,
539,
264,
2991,
2831,
2449,
11,
719,
1202,
2748,
13,
13440,
279,
1495,
1834,
3604,
6866,
374,
10273,
3010,
14,
1531,
2940,
198,
286,
12713,
286,
8149,
284,
220,
15,
198,
286,
384,
284,
659,
198,
286,
1418,
3082,
512,
310,
422,
384,
8829,
512,
394,
384,
284,
384,
8829,
674,
3368,
15306,
25,
11404,
50752,
9910,
39889,
10827,
198,
310,
775,
512,
394,
674,
2201,
2748,
11,
15061,
198,
394,
471,
3641,
271,
310,
422,
11656,
2069,
11,
16328,
23807,
1726,
8,
477,
11656,
2069,
11,
16328,
3214,
5963,
20290,
997,
394,
8149,
1447,
220,
16,
198,
394,
422,
8149,
624,
220,
17,
512,
504,
471,
384,
1432,
286,
471,
3641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10086,
279,
1670,
5905,
369,
1495,
36146,
512,
692,
578,
2748,
315,
279,
1510,
1495,
1834,
596,
2748,
320,
1868,
287,
1193,
29696,
35257,
323,
3804,
5963,
46923,
35257,
696,
692,
7181,
25,
1115,
4780,
539,
264,
2991,
2831,
2449,
11,
719,
1202,
2748,
13,
13440,
279,
1495,
1834,
3604,
6866,
374,
10273,
3010,
14,
1531,
2940,
271,
14711,
6075,
512,
755,
1505,
2309,
16690,
1214,
997,
286,
4304,
10086,
279,
1670,
5905,
369,
1495,
36146,
512,
692,
578,
2748,
315,
279,
1510,
1495,
1834,
596,
2748,
320,
1868,
287,
1193,
29696,
35257,
323,
3804,
5963,
46923,
35257,
696,
692,
7181,
25,
1115,
4780,
539,
264,
2991,
2831,
2449,
11,
719,
1202,
2748,
13,
13440,
279,
1495,
1834,
3604,
6866,
374,
10273,
3010,
14,
1531,
2940,
198,
286,
12713,
286,
8149,
284,
220,
15,
198,
286,
384,
284,
659,
198,
286,
1418,
3082,
512,
310,
422,
384,
8829,
512,
394,
384,
284,
384,
8829,
674,
3368,
15306,
25,
11404,
50752,
9910,
39889,
10827,
198,
310,
775,
512,
394,
674,
2201,
2748,
11,
15061,
198,
394,
471,
3641,
271,
310,
422,
11656,
2069,
11,
16328,
23807,
1726,
8,
477,
11656,
2069,
11,
16328,
3214,
5963,
20290,
997,
394,
8149,
1447,
220,
16,
198,
394,
422,
8149,
624,
220,
17,
512,
504,
471,
384,
1432,
286,
471,
3641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
DarkEnergySurvey/ugali | ugali/scratch/simulation/survey_selection_function.py | query_disc | def query_disc(nside, vec, radius, inclusive=False, fact=4, nest=False):
"""
Wrapper around healpy.query_disc to deal with old healpy implementation.
nside : int
The nside of the Healpix map.
vec : float, sequence of 3 elements
The coordinates of unit vector defining the disk center.
radius : float
The radius (in degrees) of the disc
inclusive : bool, optional
If False, return the exact set of pixels whose pixel centers lie
within the disk; if True, return all pixels that overlap with the disk,
and maybe a few more. Default: False
fact : int, optional
Only used when inclusive=True. The overlapping test will be done at
the resolution fact*nside. For NESTED ordering, fact must be a power of 2,
else it can be any positive integer. Default: 4.
nest: bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
"""
try:
# New-style call (healpy 1.6.3)
return hp.query_disc(nside, vec, np.radians(radius), inclusive, fact, nest)
except Exception as e:
print(e)
# Old-style call (healpy 0.10.2)
return hp.query_disc(nside, vec, np.radians(radius), nest, deg=False) | python | def query_disc(nside, vec, radius, inclusive=False, fact=4, nest=False):
"""
Wrapper around healpy.query_disc to deal with old healpy implementation.
nside : int
The nside of the Healpix map.
vec : float, sequence of 3 elements
The coordinates of unit vector defining the disk center.
radius : float
The radius (in degrees) of the disc
inclusive : bool, optional
If False, return the exact set of pixels whose pixel centers lie
within the disk; if True, return all pixels that overlap with the disk,
and maybe a few more. Default: False
fact : int, optional
Only used when inclusive=True. The overlapping test will be done at
the resolution fact*nside. For NESTED ordering, fact must be a power of 2,
else it can be any positive integer. Default: 4.
nest: bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
"""
try:
# New-style call (healpy 1.6.3)
return hp.query_disc(nside, vec, np.radians(radius), inclusive, fact, nest)
except Exception as e:
print(e)
# Old-style call (healpy 0.10.2)
return hp.query_disc(nside, vec, np.radians(radius), nest, deg=False) | [
"def",
"query_disc",
"(",
"nside",
",",
"vec",
",",
"radius",
",",
"inclusive",
"=",
"False",
",",
"fact",
"=",
"4",
",",
"nest",
"=",
"False",
")",
":",
"try",
":",
"# New-style call (healpy 1.6.3)",
"return",
"hp",
".",
"query_disc",
"(",
"nside",
",",
"vec",
",",
"np",
".",
"radians",
"(",
"radius",
")",
",",
"inclusive",
",",
"fact",
",",
"nest",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"(",
"e",
")",
"# Old-style call (healpy 0.10.2)",
"return",
"hp",
".",
"query_disc",
"(",
"nside",
",",
"vec",
",",
"np",
".",
"radians",
"(",
"radius",
")",
",",
"nest",
",",
"deg",
"=",
"False",
")"
] | Wrapper around healpy.query_disc to deal with old healpy implementation.
nside : int
The nside of the Healpix map.
vec : float, sequence of 3 elements
The coordinates of unit vector defining the disk center.
radius : float
The radius (in degrees) of the disc
inclusive : bool, optional
If False, return the exact set of pixels whose pixel centers lie
within the disk; if True, return all pixels that overlap with the disk,
and maybe a few more. Default: False
fact : int, optional
Only used when inclusive=True. The overlapping test will be done at
the resolution fact*nside. For NESTED ordering, fact must be a power of 2,
else it can be any positive integer. Default: 4.
nest: bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering | [
"Wrapper",
"around",
"healpy",
".",
"query_disc",
"to",
"deal",
"with",
"old",
"healpy",
"implementation",
".",
"nside",
":",
"int",
"The",
"nside",
"of",
"the",
"Healpix",
"map",
".",
"vec",
":",
"float",
"sequence",
"of",
"3",
"elements",
"The",
"coordinates",
"of",
"unit",
"vector",
"defining",
"the",
"disk",
"center",
".",
"radius",
":",
"float",
"The",
"radius",
"(",
"in",
"degrees",
")",
"of",
"the",
"disc",
"inclusive",
":",
"bool",
"optional",
"If",
"False",
"return",
"the",
"exact",
"set",
"of",
"pixels",
"whose",
"pixel",
"centers",
"lie",
"within",
"the",
"disk",
";",
"if",
"True",
"return",
"all",
"pixels",
"that",
"overlap",
"with",
"the",
"disk",
"and",
"maybe",
"a",
"few",
"more",
".",
"Default",
":",
"False",
"fact",
":",
"int",
"optional",
"Only",
"used",
"when",
"inclusive",
"=",
"True",
".",
"The",
"overlapping",
"test",
"will",
"be",
"done",
"at",
"the",
"resolution",
"fact",
"*",
"nside",
".",
"For",
"NESTED",
"ordering",
"fact",
"must",
"be",
"a",
"power",
"of",
"2",
"else",
"it",
"can",
"be",
"any",
"positive",
"integer",
".",
"Default",
":",
"4",
".",
"nest",
":",
"bool",
"optional",
"if",
"True",
"assume",
"NESTED",
"pixel",
"ordering",
"otherwise",
"RING",
"pixel",
"ordering"
] | train | https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/scratch/simulation/survey_selection_function.py#L50-L76 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Wrapper around healpy.query_disc to deal with old healpy implementation.
nside : int
The nside of the Healpix map.
vec : float, sequence of 3 elements
The coordinates of unit vector defining the disk center.
radius : float
The radius (in degrees) of the disc
inclusive : bool, optional
If False, return the exact set of pixels whose pixel centers lie
within the disk; if True, return all pixels that overlap with the disk,
and maybe a few more. Default: False
fact : int, optional
Only used when inclusive=True. The overlapping test will be done at
the resolution fact*nside. For NESTED ordering, fact must be a power of 2,
else it can be any positive integer. Default: 4.
nest: bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
### Response:
def query_disc(nside, vec, radius, inclusive=False, fact=4, nest=False):
"""
Wrapper around healpy.query_disc to deal with old healpy implementation.
nside : int
The nside of the Healpix map.
vec : float, sequence of 3 elements
The coordinates of unit vector defining the disk center.
radius : float
The radius (in degrees) of the disc
inclusive : bool, optional
If False, return the exact set of pixels whose pixel centers lie
within the disk; if True, return all pixels that overlap with the disk,
and maybe a few more. Default: False
fact : int, optional
Only used when inclusive=True. The overlapping test will be done at
the resolution fact*nside. For NESTED ordering, fact must be a power of 2,
else it can be any positive integer. Default: 4.
nest: bool, optional
if True, assume NESTED pixel ordering, otherwise, RING pixel ordering
"""
try:
# New-style call (healpy 1.6.3)
return hp.query_disc(nside, vec, np.radians(radius), inclusive, fact, nest)
except Exception as e:
print(e)
# Old-style call (healpy 0.10.2)
return hp.query_disc(nside, vec, np.radians(radius), nest, deg=False)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11803,
2212,
27661,
3368,
4891,
38845,
311,
3568,
449,
2362,
27661,
3368,
8292,
627,
262,
308,
3002,
551,
528,
198,
415,
578,
308,
3002,
315,
279,
82130,
36584,
2472,
627,
262,
7638,
551,
2273,
11,
8668,
315,
220,
18,
5540,
198,
415,
578,
14259,
315,
5089,
4724,
27409,
279,
13668,
4219,
627,
262,
10801,
551,
2273,
198,
415,
578,
10801,
320,
258,
12628,
8,
315,
279,
2624,
198,
262,
29408,
551,
1845,
11,
10309,
198,
415,
1442,
3641,
11,
471,
279,
4839,
743,
315,
16128,
6832,
13252,
19169,
10457,
720,
415,
2949,
279,
13668,
26,
422,
3082,
11,
471,
682,
16128,
430,
28347,
449,
279,
13668,
345,
415,
323,
7344,
264,
2478,
810,
13,
8058,
25,
3641,
198,
262,
2144,
551,
528,
11,
10309,
198,
415,
8442,
1511,
994,
29408,
3702,
13,
578,
50917,
1296,
690,
387,
2884,
520,
198,
415,
279,
11175,
2144,
24942,
3002,
13,
1789,
452,
5288,
1507,
22106,
11,
2144,
2011,
387,
264,
2410,
315,
220,
17,
345,
415,
775,
433,
649,
387,
904,
6928,
7698,
13,
8058,
25,
220,
19,
627,
262,
23634,
25,
1845,
11,
10309,
198,
415,
422,
3082,
11,
9855,
452,
5288,
1507,
13252,
22106,
11,
6062,
11,
432,
1753,
13252,
22106,
271,
14711,
6075,
512,
755,
3319,
38845,
1471,
3002,
11,
7638,
11,
10801,
11,
29408,
5725,
11,
2144,
28,
19,
11,
23634,
5725,
997,
262,
3270,
262,
36588,
2212,
27661,
3368,
4891,
38845,
311,
3568,
449,
2362,
27661,
3368,
8292,
627,
262,
308,
3002,
551,
528,
198,
415,
578,
308,
3002,
315,
279,
82130,
36584,
2472,
627,
262,
7638,
551,
2273,
11,
8668,
315,
220,
18,
5540,
198,
415,
578,
14259,
315,
5089,
4724,
27409,
279,
13668,
4219,
627,
262,
10801,
551,
2273,
198,
415,
578,
10801,
320,
258,
12628,
8,
315,
279,
2624,
198,
262,
29408,
551,
1845,
11,
10309,
198,
415,
1442,
3641,
11,
471,
279,
4839,
743,
315,
16128,
6832,
13252,
19169,
10457,
720,
415,
2949,
279,
13668,
26,
422,
3082,
11,
471,
682,
16128,
430,
28347,
449,
279,
13668,
345,
415,
323,
7344,
264,
2478,
810,
13,
8058,
25,
3641,
198,
262,
2144,
551,
528,
11,
10309,
198,
415,
8442,
1511,
994,
29408,
3702,
13,
578,
50917,
1296,
690,
387,
2884,
520,
198,
415,
279,
11175,
2144,
24942,
3002,
13,
1789,
452,
5288,
1507,
22106,
11,
2144,
2011,
387,
264,
2410,
315,
220,
17,
345,
415,
775,
433,
649,
387,
904,
6928,
7698,
13,
8058,
25,
220,
19,
627,
262,
23634,
25,
1845,
11,
10309,
198,
415,
422,
3082,
11,
9855,
452,
5288,
1507,
13252,
22106,
11,
6062,
11,
432,
1753,
13252,
22106,
198,
262,
3270,
262,
1456,
25,
720,
286,
674,
1561,
11549,
1650,
320,
383,
278,
3368,
220,
16,
13,
21,
13,
18,
340,
286,
471,
21280,
4891,
38845,
1471,
3002,
11,
7638,
11,
2660,
91744,
62122,
705,
29408,
11,
2144,
11,
23634,
340,
262,
3734,
4204
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11803,
2212,
27661,
3368,
4891,
38845,
311,
3568,
449,
2362,
27661,
3368,
8292,
627,
262,
308,
3002,
551,
528,
198,
415,
578,
308,
3002,
315,
279,
82130,
36584,
2472,
627,
262,
7638,
551,
2273,
11,
8668,
315,
220,
18,
5540,
198,
415,
578,
14259,
315,
5089,
4724,
27409,
279,
13668,
4219,
627,
262,
10801,
551,
2273,
198,
415,
578,
10801,
320,
258,
12628,
8,
315,
279,
2624,
198,
262,
29408,
551,
1845,
11,
10309,
198,
415,
1442,
3641,
11,
471,
279,
4839,
743,
315,
16128,
6832,
13252,
19169,
10457,
720,
415,
2949,
279,
13668,
26,
422,
3082,
11,
471,
682,
16128,
430,
28347,
449,
279,
13668,
345,
415,
323,
7344,
264,
2478,
810,
13,
8058,
25,
3641,
198,
262,
2144,
551,
528,
11,
10309,
198,
415,
8442,
1511,
994,
29408,
3702,
13,
578,
50917,
1296,
690,
387,
2884,
520,
198,
415,
279,
11175,
2144,
24942,
3002,
13,
1789,
452,
5288,
1507,
22106,
11,
2144,
2011,
387,
264,
2410,
315,
220,
17,
345,
415,
775,
433,
649,
387,
904,
6928,
7698,
13,
8058,
25,
220,
19,
627,
262,
23634,
25,
1845,
11,
10309,
198,
415,
422,
3082,
11,
9855,
452,
5288,
1507,
13252,
22106,
11,
6062,
11,
432,
1753,
13252,
22106,
271,
14711,
6075,
512,
755,
3319,
38845,
1471,
3002,
11,
7638,
11,
10801,
11,
29408,
5725,
11,
2144,
28,
19,
11,
23634,
5725,
997,
262,
3270,
262,
36588,
2212,
27661,
3368,
4891,
38845,
311,
3568,
449,
2362,
27661,
3368,
8292,
627,
262,
308,
3002,
551,
528,
198,
415,
578,
308,
3002,
315,
279,
82130,
36584,
2472,
627,
262,
7638,
551,
2273,
11,
8668,
315,
220,
18,
5540,
198,
415,
578,
14259,
315,
5089,
4724,
27409,
279,
13668,
4219,
627,
262,
10801,
551,
2273,
198,
415,
578,
10801,
320,
258,
12628,
8,
315,
279,
2624,
198,
262,
29408,
551,
1845,
11,
10309,
198,
415,
1442,
3641,
11,
471,
279,
4839,
743,
315,
16128,
6832,
13252,
19169,
10457,
720,
415,
2949,
279,
13668,
26,
422,
3082,
11,
471,
682,
16128,
430,
28347,
449,
279,
13668,
345,
415,
323,
7344,
264,
2478,
810,
13,
8058,
25,
3641,
198,
262,
2144,
551,
528,
11,
10309,
198,
415,
8442,
1511,
994,
29408,
3702,
13,
578,
50917,
1296,
690,
387,
2884,
520,
198,
415,
279,
11175,
2144,
24942,
3002,
13,
1789,
452,
5288,
1507,
22106,
11,
2144,
2011,
387,
264,
2410,
315,
220,
17,
345,
415,
775,
433,
649,
387,
904,
6928,
7698,
13,
8058,
25,
220,
19,
627,
262,
23634,
25,
1845,
11,
10309,
198,
415,
422,
3082,
11,
9855,
452,
5288,
1507,
13252,
22106,
11,
6062,
11,
432,
1753,
13252,
22106,
198,
262,
3270,
262,
1456,
25,
720,
286,
674,
1561,
11549,
1650,
320,
383,
278,
3368,
220,
16,
13,
21,
13,
18,
340,
286,
471,
21280,
4891,
38845,
1471,
3002,
11,
7638,
11,
2660,
91744,
62122,
705,
29408,
11,
2144,
11,
23634,
340,
262,
3734,
4204
] |
saltstack/salt | salt/modules/postgres.py | language_list | def language_list(
maintenance_db,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
.. versionadded:: 2016.3.0
Return a list of languages in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.language_list dbname
maintenance_db
The database to check
user
database username if different from config or default
password
user password if any password for a specified user
host
Database host if different from config or default
port
Database port if different from config or default
runas
System user all operations should be performed on behalf of
'''
ret = {}
query = 'SELECT lanname AS "Name" FROM pg_language'
rows = psql_query(
query,
runas=runas,
host=host,
user=user,
port=port,
maintenance_db=maintenance_db,
password=password)
for row in rows:
ret[row['Name']] = row['Name']
return ret | python | def language_list(
maintenance_db,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
.. versionadded:: 2016.3.0
Return a list of languages in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.language_list dbname
maintenance_db
The database to check
user
database username if different from config or default
password
user password if any password for a specified user
host
Database host if different from config or default
port
Database port if different from config or default
runas
System user all operations should be performed on behalf of
'''
ret = {}
query = 'SELECT lanname AS "Name" FROM pg_language'
rows = psql_query(
query,
runas=runas,
host=host,
user=user,
port=port,
maintenance_db=maintenance_db,
password=password)
for row in rows:
ret[row['Name']] = row['Name']
return ret | [
"def",
"language_list",
"(",
"maintenance_db",
",",
"user",
"=",
"None",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"password",
"=",
"None",
",",
"runas",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"query",
"=",
"'SELECT lanname AS \"Name\" FROM pg_language'",
"rows",
"=",
"psql_query",
"(",
"query",
",",
"runas",
"=",
"runas",
",",
"host",
"=",
"host",
",",
"user",
"=",
"user",
",",
"port",
"=",
"port",
",",
"maintenance_db",
"=",
"maintenance_db",
",",
"password",
"=",
"password",
")",
"for",
"row",
"in",
"rows",
":",
"ret",
"[",
"row",
"[",
"'Name'",
"]",
"]",
"=",
"row",
"[",
"'Name'",
"]",
"return",
"ret"
] | .. versionadded:: 2016.3.0
Return a list of languages in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.language_list dbname
maintenance_db
The database to check
user
database username if different from config or default
password
user password if any password for a specified user
host
Database host if different from config or default
port
Database port if different from config or default
runas
System user all operations should be performed on behalf of | [
"..",
"versionadded",
"::",
"2016",
".",
"3",
".",
"0"
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/postgres.py#L2201-L2253 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
.. versionadded:: 2016.3.0
Return a list of languages in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.language_list dbname
maintenance_db
The database to check
user
database username if different from config or default
password
user password if any password for a specified user
host
Database host if different from config or default
port
Database port if different from config or default
runas
System user all operations should be performed on behalf of
### Response:
def language_list(
maintenance_db,
user=None,
host=None,
port=None,
password=None,
runas=None):
'''
.. versionadded:: 2016.3.0
Return a list of languages in a database.
CLI Example:
.. code-block:: bash
salt '*' postgres.language_list dbname
maintenance_db
The database to check
user
database username if different from config or default
password
user password if any password for a specified user
host
Database host if different from config or default
port
Database port if different from config or default
runas
System user all operations should be performed on behalf of
'''
ret = {}
query = 'SELECT lanname AS "Name" FROM pg_language'
rows = psql_query(
query,
runas=runas,
host=host,
user=user,
port=port,
maintenance_db=maintenance_db,
password=password)
for row in rows:
ret[row['Name']] = row['Name']
return ret
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
497,
2373,
17249,
487,
220,
679,
21,
13,
18,
13,
15,
271,
262,
3494,
264,
1160,
315,
15823,
304,
264,
4729,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
60926,
32733,
2062,
84592,
271,
262,
13709,
8856,
198,
286,
578,
4729,
311,
1817,
271,
262,
1217,
198,
286,
4729,
6059,
422,
2204,
505,
2242,
477,
1670,
271,
262,
3636,
198,
286,
1217,
3636,
422,
904,
3636,
369,
264,
5300,
1217,
271,
262,
3552,
198,
286,
10199,
3552,
422,
2204,
505,
2242,
477,
1670,
271,
262,
2700,
198,
286,
10199,
2700,
422,
2204,
505,
2242,
477,
1670,
271,
262,
1629,
300,
198,
286,
744,
1217,
682,
7677,
1288,
387,
10887,
389,
17981,
315,
271,
14711,
6075,
512,
755,
4221,
2062,
1021,
286,
13709,
8856,
345,
286,
1217,
5980,
345,
286,
3552,
5980,
345,
286,
2700,
5980,
345,
286,
3636,
5980,
345,
286,
1629,
300,
5980,
997,
262,
11414,
262,
5354,
2373,
17249,
487,
220,
679,
21,
13,
18,
13,
15,
271,
262,
3494,
264,
1160,
315,
15823,
304,
264,
4729,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
60926,
32733,
2062,
84592,
271,
262,
13709,
8856,
198,
286,
578,
4729,
311,
1817,
271,
262,
1217,
198,
286,
4729,
6059,
422,
2204,
505,
2242,
477,
1670,
271,
262,
3636,
198,
286,
1217,
3636,
422,
904,
3636,
369,
264,
5300,
1217,
271,
262,
3552,
198,
286,
10199,
3552,
422,
2204,
505,
2242,
477,
1670,
271,
262,
2700,
198,
286,
10199,
2700,
422,
2204,
505,
2242,
477,
1670,
271,
262,
1629,
300,
198,
286,
744,
1217,
682,
7677,
1288,
387,
10887,
389,
17981,
315,
198,
262,
45832,
262,
2160,
284,
5731,
262,
3319,
284,
364,
4963,
31791,
609,
5871,
330,
678,
1,
4393,
17953,
30121,
3961,
262,
7123,
284,
281,
3628,
5857,
1021,
286,
3319,
345,
286,
1629,
300,
28,
6236,
300,
345,
286,
3552,
28,
3875,
345,
286,
1217,
31264,
345,
286,
2700,
28,
403,
345,
286,
13709,
8856,
28320,
25577,
8856,
345,
286,
3636,
74617,
696,
262,
369,
2872,
304,
7123,
512,
286,
2160,
17396,
681,
678,
31940,
284,
2872,
681,
678,
16049,
262,
471,
2160,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
497,
2373,
17249,
487,
220,
679,
21,
13,
18,
13,
15,
271,
262,
3494,
264,
1160,
315,
15823,
304,
264,
4729,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
60926,
32733,
2062,
84592,
271,
262,
13709,
8856,
198,
286,
578,
4729,
311,
1817,
271,
262,
1217,
198,
286,
4729,
6059,
422,
2204,
505,
2242,
477,
1670,
271,
262,
3636,
198,
286,
1217,
3636,
422,
904,
3636,
369,
264,
5300,
1217,
271,
262,
3552,
198,
286,
10199,
3552,
422,
2204,
505,
2242,
477,
1670,
271,
262,
2700,
198,
286,
10199,
2700,
422,
2204,
505,
2242,
477,
1670,
271,
262,
1629,
300,
198,
286,
744,
1217,
682,
7677,
1288,
387,
10887,
389,
17981,
315,
271,
14711,
6075,
512,
755,
4221,
2062,
1021,
286,
13709,
8856,
345,
286,
1217,
5980,
345,
286,
3552,
5980,
345,
286,
2700,
5980,
345,
286,
3636,
5980,
345,
286,
1629,
300,
5980,
997,
262,
11414,
262,
5354,
2373,
17249,
487,
220,
679,
21,
13,
18,
13,
15,
271,
262,
3494,
264,
1160,
315,
15823,
304,
264,
4729,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
60926,
32733,
2062,
84592,
271,
262,
13709,
8856,
198,
286,
578,
4729,
311,
1817,
271,
262,
1217,
198,
286,
4729,
6059,
422,
2204,
505,
2242,
477,
1670,
271,
262,
3636,
198,
286,
1217,
3636,
422,
904,
3636,
369,
264,
5300,
1217,
271,
262,
3552,
198,
286,
10199,
3552,
422,
2204,
505,
2242,
477,
1670,
271,
262,
2700,
198,
286,
10199,
2700,
422,
2204,
505,
2242,
477,
1670,
271,
262,
1629,
300,
198,
286,
744,
1217,
682,
7677,
1288,
387,
10887,
389,
17981,
315,
198,
262,
45832,
262,
2160,
284,
5731,
262,
3319,
284,
364,
4963,
31791,
609,
5871,
330,
678,
1,
4393,
17953,
30121,
3961,
262,
7123,
284,
281,
3628,
5857,
1021,
286,
3319,
345,
286,
1629,
300,
28,
6236,
300,
345,
286,
3552,
28,
3875,
345,
286,
1217,
31264,
345,
286,
2700,
28,
403,
345,
286,
13709,
8856,
28320,
25577,
8856,
345,
286,
3636,
74617,
696,
262,
369,
2872,
304,
7123,
512,
286,
2160,
17396,
681,
678,
31940,
284,
2872,
681,
678,
16049,
262,
471,
2160,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
praw-dev/prawcore | prawcore/auth.py | BaseAuthenticator.revoke_token | def revoke_token(self, token, token_type=None):
"""Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
either ``access_token`` or ``refresh_token``.
"""
data = {"token": token}
if token_type is not None:
data["token_type_hint"] = token_type
url = self._requestor.reddit_url + const.REVOKE_TOKEN_PATH
self._post(url, success_status=codes["no_content"], **data) | python | def revoke_token(self, token, token_type=None):
"""Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
either ``access_token`` or ``refresh_token``.
"""
data = {"token": token}
if token_type is not None:
data["token_type_hint"] = token_type
url = self._requestor.reddit_url + const.REVOKE_TOKEN_PATH
self._post(url, success_status=codes["no_content"], **data) | [
"def",
"revoke_token",
"(",
"self",
",",
"token",
",",
"token_type",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"token\"",
":",
"token",
"}",
"if",
"token_type",
"is",
"not",
"None",
":",
"data",
"[",
"\"token_type_hint\"",
"]",
"=",
"token_type",
"url",
"=",
"self",
".",
"_requestor",
".",
"reddit_url",
"+",
"const",
".",
"REVOKE_TOKEN_PATH",
"self",
".",
"_post",
"(",
"url",
",",
"success_status",
"=",
"codes",
"[",
"\"no_content\"",
"]",
",",
"*",
"*",
"data",
")"
] | Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
either ``access_token`` or ``refresh_token``. | [
"Ask",
"Reddit",
"to",
"revoke",
"the",
"provided",
"token",
"."
] | train | https://github.com/praw-dev/prawcore/blob/b16ae88a1f2bf98095ed6fe64851cb7add7ed752/prawcore/auth.py#L77-L90 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
either ``access_token`` or ``refresh_token``.
### Response:
def revoke_token(self, token, token_type=None):
"""Ask Reddit to revoke the provided token.
:param token: The access or refresh token to revoke.
:param token_type: (Optional) When provided, hint to Reddit what the
token type is for a possible efficiency gain. The value can be
either ``access_token`` or ``refresh_token``.
"""
data = {"token": token}
if token_type is not None:
data["token_type_hint"] = token_type
url = self._requestor.reddit_url + const.REVOKE_TOKEN_PATH
self._post(url, success_status=codes["no_content"], **data)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
27264,
27728,
311,
73138,
279,
3984,
4037,
382,
286,
551,
913,
4037,
25,
578,
2680,
477,
10625,
4037,
311,
73138,
627,
286,
551,
913,
4037,
1857,
25,
320,
15669,
8,
3277,
3984,
11,
13310,
311,
27728,
1148,
279,
198,
310,
4037,
955,
374,
369,
264,
3284,
15374,
8895,
13,
578,
907,
649,
387,
198,
310,
3060,
10103,
5323,
6594,
14196,
477,
10103,
17611,
6594,
14196,
382,
14711,
6075,
512,
755,
73138,
6594,
1214,
11,
4037,
11,
4037,
1857,
5980,
997,
286,
4304,
27264,
27728,
311,
73138,
279,
3984,
4037,
382,
286,
551,
913,
4037,
25,
578,
2680,
477,
10625,
4037,
311,
73138,
627,
286,
551,
913,
4037,
1857,
25,
320,
15669,
8,
3277,
3984,
11,
13310,
311,
27728,
1148,
279,
198,
310,
4037,
955,
374,
369,
264,
3284,
15374,
8895,
13,
578,
907,
649,
387,
198,
310,
3060,
10103,
5323,
6594,
14196,
477,
10103,
17611,
6594,
14196,
382,
286,
3270,
286,
828,
284,
5324,
5963,
794,
4037,
534,
286,
422,
4037,
1857,
374,
539,
2290,
512,
310,
828,
1204,
5963,
1857,
46925,
1365,
284,
4037,
1857,
198,
286,
2576,
284,
659,
1462,
2079,
269,
56873,
2975,
489,
738,
15056,
59280,
19199,
8103,
198,
286,
659,
1462,
2252,
6659,
11,
2450,
4878,
20105,
2601,
1204,
2201,
7647,
8073,
3146,
695,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
27264,
27728,
311,
73138,
279,
3984,
4037,
382,
286,
551,
913,
4037,
25,
578,
2680,
477,
10625,
4037,
311,
73138,
627,
286,
551,
913,
4037,
1857,
25,
320,
15669,
8,
3277,
3984,
11,
13310,
311,
27728,
1148,
279,
198,
310,
4037,
955,
374,
369,
264,
3284,
15374,
8895,
13,
578,
907,
649,
387,
198,
310,
3060,
10103,
5323,
6594,
14196,
477,
10103,
17611,
6594,
14196,
382,
14711,
6075,
512,
755,
73138,
6594,
1214,
11,
4037,
11,
4037,
1857,
5980,
997,
286,
4304,
27264,
27728,
311,
73138,
279,
3984,
4037,
382,
286,
551,
913,
4037,
25,
578,
2680,
477,
10625,
4037,
311,
73138,
627,
286,
551,
913,
4037,
1857,
25,
320,
15669,
8,
3277,
3984,
11,
13310,
311,
27728,
1148,
279,
198,
310,
4037,
955,
374,
369,
264,
3284,
15374,
8895,
13,
578,
907,
649,
387,
198,
310,
3060,
10103,
5323,
6594,
14196,
477,
10103,
17611,
6594,
14196,
382,
286,
3270,
286,
828,
284,
5324,
5963,
794,
4037,
534,
286,
422,
4037,
1857,
374,
539,
2290,
512,
310,
828,
1204,
5963,
1857,
46925,
1365,
284,
4037,
1857,
198,
286,
2576,
284,
659,
1462,
2079,
269,
56873,
2975,
489,
738,
15056,
59280,
19199,
8103,
198,
286,
659,
1462,
2252,
6659,
11,
2450,
4878,
20105,
2601,
1204,
2201,
7647,
8073,
3146,
695,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
SavinaRoja/OpenAccess_EPUB | src/openaccess_epub/publisher/plos.py | PLoS.make_article_info_footnotes_other | def make_article_info_footnotes_other(self, article_info_div):
"""
This will catch all of the footnotes of type 'other' in the <fn-group>
of the <back> element.
"""
other_fn_expr = "./back/fn-group/fn[@fn-type='other']"
other_fns = self.article.root.xpath(other_fn_expr)
if other_fns:
other_fn_div = etree.SubElement(article_info_div,
'div',
{'class': 'back-fn-other'})
for other_fn in other_fns:
append_all_below(other_fn_div, other_fn) | python | def make_article_info_footnotes_other(self, article_info_div):
"""
This will catch all of the footnotes of type 'other' in the <fn-group>
of the <back> element.
"""
other_fn_expr = "./back/fn-group/fn[@fn-type='other']"
other_fns = self.article.root.xpath(other_fn_expr)
if other_fns:
other_fn_div = etree.SubElement(article_info_div,
'div',
{'class': 'back-fn-other'})
for other_fn in other_fns:
append_all_below(other_fn_div, other_fn) | [
"def",
"make_article_info_footnotes_other",
"(",
"self",
",",
"article_info_div",
")",
":",
"other_fn_expr",
"=",
"\"./back/fn-group/fn[@fn-type='other']\"",
"other_fns",
"=",
"self",
".",
"article",
".",
"root",
".",
"xpath",
"(",
"other_fn_expr",
")",
"if",
"other_fns",
":",
"other_fn_div",
"=",
"etree",
".",
"SubElement",
"(",
"article_info_div",
",",
"'div'",
",",
"{",
"'class'",
":",
"'back-fn-other'",
"}",
")",
"for",
"other_fn",
"in",
"other_fns",
":",
"append_all_below",
"(",
"other_fn_div",
",",
"other_fn",
")"
] | This will catch all of the footnotes of type 'other' in the <fn-group>
of the <back> element. | [
"This",
"will",
"catch",
"all",
"of",
"the",
"footnotes",
"of",
"type",
"other",
"in",
"the",
"<fn",
"-",
"group",
">",
"of",
"the",
"<back",
">",
"element",
"."
] | train | https://github.com/SavinaRoja/OpenAccess_EPUB/blob/6b77ba30b7394fd003920e7a7957bca963a90656/src/openaccess_epub/publisher/plos.py#L627-L639 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
This will catch all of the footnotes of type 'other' in the <fn-group>
of the <back> element.
### Response:
def make_article_info_footnotes_other(self, article_info_div):
"""
This will catch all of the footnotes of type 'other' in the <fn-group>
of the <back> element.
"""
other_fn_expr = "./back/fn-group/fn[@fn-type='other']"
other_fns = self.article.root.xpath(other_fn_expr)
if other_fns:
other_fn_div = etree.SubElement(article_info_div,
'div',
{'class': 'back-fn-other'})
for other_fn in other_fns:
append_all_below(other_fn_div, other_fn)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2028,
690,
2339,
682,
315,
279,
4579,
18790,
315,
955,
364,
1605,
6,
304,
279,
366,
8998,
4449,
397,
286,
315,
279,
366,
1445,
29,
2449,
382,
14711,
6075,
512,
755,
1304,
38421,
3186,
76859,
18790,
31556,
1214,
11,
4652,
3186,
16635,
997,
286,
3270,
286,
1115,
690,
2339,
682,
315,
279,
4579,
18790,
315,
955,
364,
1605,
6,
304,
279,
366,
8998,
4449,
397,
286,
315,
279,
366,
1445,
29,
2449,
627,
286,
3270,
286,
1023,
15604,
22678,
284,
6049,
1445,
6801,
77,
4449,
6801,
77,
12606,
8998,
10827,
1151,
1605,
663,
702,
286,
1023,
766,
4511,
284,
659,
52516,
12861,
23472,
17532,
15604,
22678,
340,
286,
422,
1023,
766,
4511,
512,
310,
1023,
15604,
16635,
284,
67755,
93442,
52048,
3186,
16635,
345,
3425,
364,
614,
756,
3425,
5473,
1058,
1232,
364,
1445,
2269,
77,
73572,
27482,
286,
369,
1023,
15604,
304,
1023,
766,
4511,
512,
310,
8911,
5823,
83850,
17532,
15604,
16635,
11,
1023,
15604,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2028,
690,
2339,
682,
315,
279,
4579,
18790,
315,
955,
364,
1605,
6,
304,
279,
366,
8998,
4449,
397,
286,
315,
279,
366,
1445,
29,
2449,
382,
14711,
6075,
512,
755,
1304,
38421,
3186,
76859,
18790,
31556,
1214,
11,
4652,
3186,
16635,
997,
286,
3270,
286,
1115,
690,
2339,
682,
315,
279,
4579,
18790,
315,
955,
364,
1605,
6,
304,
279,
366,
8998,
4449,
397,
286,
315,
279,
366,
1445,
29,
2449,
627,
286,
3270,
286,
1023,
15604,
22678,
284,
6049,
1445,
6801,
77,
4449,
6801,
77,
12606,
8998,
10827,
1151,
1605,
663,
702,
286,
1023,
766,
4511,
284,
659,
52516,
12861,
23472,
17532,
15604,
22678,
340,
286,
422,
1023,
766,
4511,
512,
310,
1023,
15604,
16635,
284,
67755,
93442,
52048,
3186,
16635,
345,
3425,
364,
614,
756,
3425,
5473,
1058,
1232,
364,
1445,
2269,
77,
73572,
27482,
286,
369,
1023,
15604,
304,
1023,
766,
4511,
512,
310,
8911,
5823,
83850,
17532,
15604,
16635,
11,
1023,
15604,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
cackharot/suds-py3 | suds/client.py | Client.set_options | def set_options(self, **kwargs):
"""
Set options.
@param kwargs: keyword arguments.
@see: L{Options}
"""
p = Unskin(self.options)
p.update(kwargs) | python | def set_options(self, **kwargs):
"""
Set options.
@param kwargs: keyword arguments.
@see: L{Options}
"""
p = Unskin(self.options)
p.update(kwargs) | [
"def",
"set_options",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"p",
"=",
"Unskin",
"(",
"self",
".",
"options",
")",
"p",
".",
"update",
"(",
"kwargs",
")"
] | Set options.
@param kwargs: keyword arguments.
@see: L{Options} | [
"Set",
"options",
"."
] | train | https://github.com/cackharot/suds-py3/blob/7387ec7806e9be29aad0a711bea5cb3c9396469c/suds/client.py#L122-L129 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Set options.
@param kwargs: keyword arguments.
@see: L{Options}
### Response:
def set_options(self, **kwargs):
"""
Set options.
@param kwargs: keyword arguments.
@see: L{Options}
"""
p = Unskin(self.options)
p.update(kwargs)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
2671,
627,
286,
571,
913,
16901,
25,
16570,
6105,
627,
286,
571,
4151,
25,
445,
90,
3883,
633,
14711,
6075,
512,
755,
743,
8917,
1214,
11,
3146,
9872,
997,
286,
3270,
286,
2638,
2671,
627,
286,
571,
913,
16901,
25,
16570,
6105,
627,
286,
571,
4151,
25,
445,
90,
3883,
534,
286,
3270,
286,
281,
284,
1252,
37282,
1214,
11152,
340,
286,
281,
5430,
71706,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0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25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
2671,
627,
286,
571,
913,
16901,
25,
16570,
6105,
627,
286,
571,
4151,
25,
445,
90,
3883,
633,
14711,
6075,
512,
755,
743,
8917,
1214,
11,
3146,
9872,
997,
286,
3270,
286,
2638,
2671,
627,
286,
571,
913,
16901,
25,
16570,
6105,
627,
286,
571,
4151,
25,
445,
90,
3883,
534,
286,
3270,
286,
281,
284,
1252,
37282,
1214,
11152,
340,
286,
281,
5430,
71706,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
scruffy-t/mpls | mpls/mpls.py | collect | def collect(context=None, style=None, palette=None, **kwargs):
"""Returns the merged rcParams dict of the specified context, style, and palette.
Parameters
----------
context: str
style: str
palette: str
kwargs:
-
Returns
-------
rcParams: dict
The merged parameter dicts of the specified context, style, and palette.
Notes
-----
The rcParams dicts are loaded and updated in the order: context, style, palette. That means if
a context parameter is also defined in the style or palette dict, it will be overwritten. There
is currently no checking being done to avoid this.
"""
params = {}
if context:
params.update(get(context, 'context', **kwargs))
if style:
params.update(get(style, 'style', **kwargs))
if palette:
params.update(get(palette, 'palette', **kwargs))
return params | python | def collect(context=None, style=None, palette=None, **kwargs):
"""Returns the merged rcParams dict of the specified context, style, and palette.
Parameters
----------
context: str
style: str
palette: str
kwargs:
-
Returns
-------
rcParams: dict
The merged parameter dicts of the specified context, style, and palette.
Notes
-----
The rcParams dicts are loaded and updated in the order: context, style, palette. That means if
a context parameter is also defined in the style or palette dict, it will be overwritten. There
is currently no checking being done to avoid this.
"""
params = {}
if context:
params.update(get(context, 'context', **kwargs))
if style:
params.update(get(style, 'style', **kwargs))
if palette:
params.update(get(palette, 'palette', **kwargs))
return params | [
"def",
"collect",
"(",
"context",
"=",
"None",
",",
"style",
"=",
"None",
",",
"palette",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"params",
"=",
"{",
"}",
"if",
"context",
":",
"params",
".",
"update",
"(",
"get",
"(",
"context",
",",
"'context'",
",",
"*",
"*",
"kwargs",
")",
")",
"if",
"style",
":",
"params",
".",
"update",
"(",
"get",
"(",
"style",
",",
"'style'",
",",
"*",
"*",
"kwargs",
")",
")",
"if",
"palette",
":",
"params",
".",
"update",
"(",
"get",
"(",
"palette",
",",
"'palette'",
",",
"*",
"*",
"kwargs",
")",
")",
"return",
"params"
] | Returns the merged rcParams dict of the specified context, style, and palette.
Parameters
----------
context: str
style: str
palette: str
kwargs:
-
Returns
-------
rcParams: dict
The merged parameter dicts of the specified context, style, and palette.
Notes
-----
The rcParams dicts are loaded and updated in the order: context, style, palette. That means if
a context parameter is also defined in the style or palette dict, it will be overwritten. There
is currently no checking being done to avoid this. | [
"Returns",
"the",
"merged",
"rcParams",
"dict",
"of",
"the",
"specified",
"context",
"style",
"and",
"palette",
"."
] | train | https://github.com/scruffy-t/mpls/blob/1320d1217cd72404509da49d0ea7b65163a7b40b/mpls/mpls.py#L123-L155 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Returns the merged rcParams dict of the specified context, style, and palette.
Parameters
----------
context: str
style: str
palette: str
kwargs:
-
Returns
-------
rcParams: dict
The merged parameter dicts of the specified context, style, and palette.
Notes
-----
The rcParams dicts are loaded and updated in the order: context, style, palette. That means if
a context parameter is also defined in the style or palette dict, it will be overwritten. There
is currently no checking being done to avoid this.
### Response:
def collect(context=None, style=None, palette=None, **kwargs):
"""Returns the merged rcParams dict of the specified context, style, and palette.
Parameters
----------
context: str
style: str
palette: str
kwargs:
-
Returns
-------
rcParams: dict
The merged parameter dicts of the specified context, style, and palette.
Notes
-----
The rcParams dicts are loaded and updated in the order: context, style, palette. That means if
a context parameter is also defined in the style or palette dict, it will be overwritten. There
is currently no checking being done to avoid this.
"""
params = {}
if context:
params.update(get(context, 'context', **kwargs))
if style:
params.update(get(style, 'style', **kwargs))
if palette:
params.update(get(palette, 'palette', **kwargs))
return params
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
279,
27092,
10402,
4975,
6587,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
13831,
198,
262,
31423,
262,
2317,
25,
610,
271,
262,
1742,
25,
610,
271,
262,
27404,
25,
610,
271,
262,
16901,
512,
262,
22742,
262,
5295,
198,
262,
39707,
262,
10402,
4975,
25,
6587,
198,
286,
578,
27092,
5852,
98699,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
18559,
198,
262,
81049,
262,
578,
10402,
4975,
98699,
527,
6799,
323,
6177,
304,
279,
2015,
25,
2317,
11,
1742,
11,
27404,
13,
3011,
3445,
422,
198,
262,
264,
2317,
5852,
374,
1101,
4613,
304,
279,
1742,
477,
27404,
6587,
11,
433,
690,
387,
60273,
13,
2684,
198,
262,
374,
5131,
912,
13598,
1694,
2884,
311,
5766,
420,
382,
14711,
6075,
512,
755,
6667,
5491,
5980,
11,
1742,
5980,
11,
27404,
5980,
11,
3146,
9872,
997,
262,
4304,
16851,
279,
27092,
10402,
4975,
6587,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
13831,
198,
262,
31423,
262,
2317,
25,
610,
271,
262,
1742,
25,
610,
271,
262,
27404,
25,
610,
271,
262,
16901,
512,
262,
22742,
262,
5295,
198,
262,
39707,
262,
10402,
4975,
25,
6587,
198,
286,
578,
27092,
5852,
98699,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
18559,
198,
262,
81049,
262,
578,
10402,
4975,
98699,
527,
6799,
323,
6177,
304,
279,
2015,
25,
2317,
11,
1742,
11,
27404,
13,
3011,
3445,
422,
198,
262,
264,
2317,
5852,
374,
1101,
4613,
304,
279,
1742,
477,
27404,
6587,
11,
433,
690,
387,
60273,
13,
2684,
198,
262,
374,
5131,
912,
13598,
1694,
2884,
311,
5766,
420,
627,
262,
3270,
262,
3712,
284,
5731,
262,
422,
2317,
512,
286,
3712,
5430,
5550,
5491,
11,
364,
2196,
518,
3146,
9872,
1192,
262,
422,
1742,
512,
286,
3712,
5430,
5550,
38383,
11,
364,
3612,
518,
3146,
9872,
1192,
262,
422,
27404,
512,
286,
3712,
5430,
5550,
1319,
29610,
11,
364,
60774,
518,
3146,
9872,
1192,
262,
471,
3712,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
279,
27092,
10402,
4975,
6587,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
13831,
198,
262,
31423,
262,
2317,
25,
610,
271,
262,
1742,
25,
610,
271,
262,
27404,
25,
610,
271,
262,
16901,
512,
262,
22742,
262,
5295,
198,
262,
39707,
262,
10402,
4975,
25,
6587,
198,
286,
578,
27092,
5852,
98699,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
18559,
198,
262,
81049,
262,
578,
10402,
4975,
98699,
527,
6799,
323,
6177,
304,
279,
2015,
25,
2317,
11,
1742,
11,
27404,
13,
3011,
3445,
422,
198,
262,
264,
2317,
5852,
374,
1101,
4613,
304,
279,
1742,
477,
27404,
6587,
11,
433,
690,
387,
60273,
13,
2684,
198,
262,
374,
5131,
912,
13598,
1694,
2884,
311,
5766,
420,
382,
14711,
6075,
512,
755,
6667,
5491,
5980,
11,
1742,
5980,
11,
27404,
5980,
11,
3146,
9872,
997,
262,
4304,
16851,
279,
27092,
10402,
4975,
6587,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
13831,
198,
262,
31423,
262,
2317,
25,
610,
271,
262,
1742,
25,
610,
271,
262,
27404,
25,
610,
271,
262,
16901,
512,
262,
22742,
262,
5295,
198,
262,
39707,
262,
10402,
4975,
25,
6587,
198,
286,
578,
27092,
5852,
98699,
315,
279,
5300,
2317,
11,
1742,
11,
323,
27404,
382,
262,
18559,
198,
262,
81049,
262,
578,
10402,
4975,
98699,
527,
6799,
323,
6177,
304,
279,
2015,
25,
2317,
11,
1742,
11,
27404,
13,
3011,
3445,
422,
198,
262,
264,
2317,
5852,
374,
1101,
4613,
304,
279,
1742,
477,
27404,
6587,
11,
433,
690,
387,
60273,
13,
2684,
198,
262,
374,
5131,
912,
13598,
1694,
2884,
311,
5766,
420,
627,
262,
3270,
262,
3712,
284,
5731,
262,
422,
2317,
512,
286,
3712,
5430,
5550,
5491,
11,
364,
2196,
518,
3146,
9872,
1192,
262,
422,
1742,
512,
286,
3712,
5430,
5550,
38383,
11,
364,
3612,
518,
3146,
9872,
1192,
262,
422,
27404,
512,
286,
3712,
5430,
5550,
1319,
29610,
11,
364,
60774,
518,
3146,
9872,
1192,
262,
471,
3712,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
sebdah/dynamic-dynamodb | dynamic_dynamodb/core/table.py | __ensure_provisioning_reads | def __ensure_provisioning_reads(table_name, key_name, num_consec_read_checks):
""" Ensure that provisioning is correct
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type num_consec_read_checks: int
:param num_consec_read_checks: How many consecutive checks have we had
:returns: (bool, int, int)
update_needed, updated_read_units, num_consec_read_checks
"""
if not get_table_option(key_name, 'enable_reads_autoscaling'):
logger.info(
'{0} - Autoscaling of reads has been disabled'.format(table_name))
return False, dynamodb.get_provisioned_table_read_units(table_name), 0
update_needed = False
try:
lookback_window_start = get_table_option(
key_name, 'lookback_window_start')
lookback_period = get_table_option(key_name, 'lookback_period')
current_read_units = dynamodb.get_provisioned_table_read_units(
table_name)
consumed_read_units_percent = \
table_stats.get_consumed_read_units_percent(
table_name, lookback_window_start, lookback_period)
throttled_read_count = \
table_stats.get_throttled_read_event_count(
table_name, lookback_window_start, lookback_period)
throttled_by_provisioned_read_percent = \
table_stats.get_throttled_by_provisioned_read_event_percent(
table_name, lookback_window_start, lookback_period)
throttled_by_consumed_read_percent = \
table_stats.get_throttled_by_consumed_read_percent(
table_name, lookback_window_start, lookback_period)
reads_upper_threshold = \
get_table_option(key_name, 'reads_upper_threshold')
reads_lower_threshold = \
get_table_option(key_name, 'reads_lower_threshold')
throttled_reads_upper_threshold = \
get_table_option(key_name, 'throttled_reads_upper_threshold')
increase_reads_with = \
get_table_option(key_name, 'increase_reads_with')
increase_reads_unit = \
get_table_option(key_name, 'increase_reads_unit')
decrease_reads_with = \
get_table_option(key_name, 'decrease_reads_with')
decrease_reads_unit = \
get_table_option(key_name, 'decrease_reads_unit')
min_provisioned_reads = \
get_table_option(key_name, 'min_provisioned_reads')
max_provisioned_reads = \
get_table_option(key_name, 'max_provisioned_reads')
num_read_checks_before_scale_down = \
get_table_option(key_name, 'num_read_checks_before_scale_down')
num_read_checks_reset_percent = \
get_table_option(key_name, 'num_read_checks_reset_percent')
increase_throttled_by_provisioned_reads_unit = \
get_table_option(
key_name, 'increase_throttled_by_provisioned_reads_unit')
increase_throttled_by_provisioned_reads_scale = \
get_table_option(
key_name, 'increase_throttled_by_provisioned_reads_scale')
increase_throttled_by_consumed_reads_unit = \
get_table_option(
key_name, 'increase_throttled_by_consumed_reads_unit')
increase_throttled_by_consumed_reads_scale = \
get_table_option(
key_name, 'increase_throttled_by_consumed_reads_scale')
increase_consumed_reads_unit = \
get_table_option(key_name, 'increase_consumed_reads_unit')
increase_consumed_reads_with = \
get_table_option(key_name, 'increase_consumed_reads_with')
increase_consumed_reads_scale = \
get_table_option(key_name, 'increase_consumed_reads_scale')
decrease_consumed_reads_unit = \
get_table_option(key_name, 'decrease_consumed_reads_unit')
decrease_consumed_reads_with = \
get_table_option(key_name, 'decrease_consumed_reads_with')
decrease_consumed_reads_scale = \
get_table_option(key_name, 'decrease_consumed_reads_scale')
except JSONResponseError:
raise
except BotoServerError:
raise
# Set the updated units to the current read unit value
updated_read_units = current_read_units
# Reset consecutive reads if num_read_checks_reset_percent is reached
if num_read_checks_reset_percent:
if consumed_read_units_percent >= num_read_checks_reset_percent:
logger.info(
'{0} - Resetting the number of consecutive '
'read checks. Reason: Consumed percent {1} is '
'greater than reset percent: {2}'.format(
table_name,
consumed_read_units_percent,
num_read_checks_reset_percent))
num_consec_read_checks = 0
# Exit if up scaling has been disabled
if not get_table_option(key_name, 'enable_reads_up_scaling'):
logger.debug(
'{0} - Up scaling event detected. No action taken as scaling '
'up reads has been disabled in the configuration'.format(
table_name))
else:
# If local/granular values not specified use global values
increase_consumed_reads_unit = \
increase_consumed_reads_unit or increase_reads_unit
increase_throttled_by_provisioned_reads_unit = \
increase_throttled_by_provisioned_reads_unit or increase_reads_unit
increase_throttled_by_consumed_reads_unit = \
increase_throttled_by_consumed_reads_unit or increase_reads_unit
increase_consumed_reads_with = \
increase_consumed_reads_with or increase_reads_with
# Initialise variables to store calculated provisioning
throttled_by_provisioned_calculated_provisioning = scale_reader(
increase_throttled_by_provisioned_reads_scale,
throttled_by_provisioned_read_percent)
throttled_by_consumed_calculated_provisioning = scale_reader(
increase_throttled_by_consumed_reads_scale,
throttled_by_consumed_read_percent)
consumed_calculated_provisioning = scale_reader(
increase_consumed_reads_scale,
consumed_read_units_percent)
throttled_count_calculated_provisioning = 0
calculated_provisioning = 0
# Increase needed due to high throttled to provisioned ratio
if throttled_by_provisioned_calculated_provisioning:
if increase_throttled_by_provisioned_reads_unit == 'percent':
throttled_by_provisioned_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
throttled_by_provisioned_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_by_provisioned_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
throttled_by_provisioned_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high throttled to consumed ratio
if throttled_by_consumed_calculated_provisioning:
if increase_throttled_by_consumed_reads_unit == 'percent':
throttled_by_consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
throttled_by_consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_by_consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
throttled_by_consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high CU consumption
if consumed_calculated_provisioning:
if increase_consumed_reads_unit == 'percent':
consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
elif (reads_upper_threshold
and consumed_read_units_percent > reads_upper_threshold
and not increase_consumed_reads_scale):
if increase_consumed_reads_unit == 'percent':
consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high throttling
if (throttled_reads_upper_threshold
and throttled_read_count > throttled_reads_upper_threshold):
if increase_reads_unit == 'percent':
throttled_count_calculated_provisioning = \
calculators.increase_reads_in_percent(
updated_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_count_calculated_provisioning = \
calculators.increase_reads_in_units(
updated_read_units,
increase_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Determine which metric requires the most scaling
if (throttled_by_provisioned_calculated_provisioning
> calculated_provisioning):
calculated_provisioning = \
throttled_by_provisioned_calculated_provisioning
scale_reason = (
"due to throttled events by provisioned "
"units threshold being exceeded")
if (throttled_by_consumed_calculated_provisioning
> calculated_provisioning):
calculated_provisioning = \
throttled_by_consumed_calculated_provisioning
scale_reason = (
"due to throttled events by consumed "
"units threshold being exceeded")
if consumed_calculated_provisioning > calculated_provisioning:
calculated_provisioning = consumed_calculated_provisioning
scale_reason = "due to consumed threshold being exceeded"
if throttled_count_calculated_provisioning > calculated_provisioning:
calculated_provisioning = throttled_count_calculated_provisioning
scale_reason = "due to throttled events threshold being exceeded"
if calculated_provisioning > current_read_units:
logger.info(
'{0} - Resetting the number of consecutive '
'read checks. Reason: scale up {1}'.format(
table_name, scale_reason))
num_consec_read_checks = 0
update_needed = True
updated_read_units = calculated_provisioning
# Decrease needed due to low CU consumption
if not update_needed:
# If local/granular values not specified use global values
decrease_consumed_reads_unit = \
decrease_consumed_reads_unit or decrease_reads_unit
decrease_consumed_reads_with = \
decrease_consumed_reads_with or decrease_reads_with
# Initialise variables to store calculated provisioning
consumed_calculated_provisioning = scale_reader_decrease(
decrease_consumed_reads_scale,
consumed_read_units_percent)
calculated_provisioning = None
# Exit if down scaling has been disabled
if not get_table_option(key_name, 'enable_reads_down_scaling'):
logger.debug(
'{0} - Down scaling event detected. No action taken as scaling'
' down reads has been disabled in the configuration'.format(
table_name))
# Exit if reads == 0% and downscaling has been disabled at 0%
elif (consumed_read_units_percent == 0 and not
get_table_option(
key_name, 'allow_scaling_down_reads_on_0_percent')):
logger.info(
'{0} - Down scaling event detected. No action taken as scaling'
' down reads is not done when usage is at 0%'.format(
table_name))
else:
if consumed_calculated_provisioning:
if decrease_consumed_reads_unit == 'percent':
calculated_provisioning = \
calculators.decrease_reads_in_percent(
updated_read_units,
consumed_calculated_provisioning,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
else:
calculated_provisioning = \
calculators.decrease_reads_in_units(
updated_read_units,
consumed_calculated_provisioning,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
elif (reads_lower_threshold
and consumed_read_units_percent < reads_lower_threshold
and not decrease_consumed_reads_scale):
if decrease_consumed_reads_unit == 'percent':
calculated_provisioning = \
calculators.decrease_reads_in_percent(
updated_read_units,
decrease_consumed_reads_with,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
else:
calculated_provisioning = \
calculators.decrease_reads_in_units(
updated_read_units,
decrease_consumed_reads_with,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
if (calculated_provisioning
and current_read_units != calculated_provisioning):
num_consec_read_checks += 1
if num_consec_read_checks >= num_read_checks_before_scale_down:
update_needed = True
updated_read_units = calculated_provisioning
# Never go over the configured max provisioning
if max_provisioned_reads:
if int(updated_read_units) > int(max_provisioned_reads):
update_needed = True
updated_read_units = int(max_provisioned_reads)
logger.info(
'Will not increase writes over max-provisioned-reads '
'limit ({0} writes)'.format(updated_read_units))
# Ensure that we have met the min-provisioning
if min_provisioned_reads:
if int(min_provisioned_reads) > int(updated_read_units):
update_needed = True
updated_read_units = int(min_provisioned_reads)
logger.info(
'{0} - Increasing reads to meet min-provisioned-reads '
'limit ({1} reads)'.format(table_name, updated_read_units))
if calculators.is_consumed_over_proposed(
current_read_units,
updated_read_units,
consumed_read_units_percent):
update_needed = False
updated_read_units = current_read_units
logger.info(
'{0} - Consumed is over proposed read units. Will leave table at '
'current setting.'.format(table_name))
logger.info('{0} - Consecutive read checks {1}/{2}'.format(
table_name,
num_consec_read_checks,
num_read_checks_before_scale_down))
return update_needed, updated_read_units, num_consec_read_checks | python | def __ensure_provisioning_reads(table_name, key_name, num_consec_read_checks):
""" Ensure that provisioning is correct
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type num_consec_read_checks: int
:param num_consec_read_checks: How many consecutive checks have we had
:returns: (bool, int, int)
update_needed, updated_read_units, num_consec_read_checks
"""
if not get_table_option(key_name, 'enable_reads_autoscaling'):
logger.info(
'{0} - Autoscaling of reads has been disabled'.format(table_name))
return False, dynamodb.get_provisioned_table_read_units(table_name), 0
update_needed = False
try:
lookback_window_start = get_table_option(
key_name, 'lookback_window_start')
lookback_period = get_table_option(key_name, 'lookback_period')
current_read_units = dynamodb.get_provisioned_table_read_units(
table_name)
consumed_read_units_percent = \
table_stats.get_consumed_read_units_percent(
table_name, lookback_window_start, lookback_period)
throttled_read_count = \
table_stats.get_throttled_read_event_count(
table_name, lookback_window_start, lookback_period)
throttled_by_provisioned_read_percent = \
table_stats.get_throttled_by_provisioned_read_event_percent(
table_name, lookback_window_start, lookback_period)
throttled_by_consumed_read_percent = \
table_stats.get_throttled_by_consumed_read_percent(
table_name, lookback_window_start, lookback_period)
reads_upper_threshold = \
get_table_option(key_name, 'reads_upper_threshold')
reads_lower_threshold = \
get_table_option(key_name, 'reads_lower_threshold')
throttled_reads_upper_threshold = \
get_table_option(key_name, 'throttled_reads_upper_threshold')
increase_reads_with = \
get_table_option(key_name, 'increase_reads_with')
increase_reads_unit = \
get_table_option(key_name, 'increase_reads_unit')
decrease_reads_with = \
get_table_option(key_name, 'decrease_reads_with')
decrease_reads_unit = \
get_table_option(key_name, 'decrease_reads_unit')
min_provisioned_reads = \
get_table_option(key_name, 'min_provisioned_reads')
max_provisioned_reads = \
get_table_option(key_name, 'max_provisioned_reads')
num_read_checks_before_scale_down = \
get_table_option(key_name, 'num_read_checks_before_scale_down')
num_read_checks_reset_percent = \
get_table_option(key_name, 'num_read_checks_reset_percent')
increase_throttled_by_provisioned_reads_unit = \
get_table_option(
key_name, 'increase_throttled_by_provisioned_reads_unit')
increase_throttled_by_provisioned_reads_scale = \
get_table_option(
key_name, 'increase_throttled_by_provisioned_reads_scale')
increase_throttled_by_consumed_reads_unit = \
get_table_option(
key_name, 'increase_throttled_by_consumed_reads_unit')
increase_throttled_by_consumed_reads_scale = \
get_table_option(
key_name, 'increase_throttled_by_consumed_reads_scale')
increase_consumed_reads_unit = \
get_table_option(key_name, 'increase_consumed_reads_unit')
increase_consumed_reads_with = \
get_table_option(key_name, 'increase_consumed_reads_with')
increase_consumed_reads_scale = \
get_table_option(key_name, 'increase_consumed_reads_scale')
decrease_consumed_reads_unit = \
get_table_option(key_name, 'decrease_consumed_reads_unit')
decrease_consumed_reads_with = \
get_table_option(key_name, 'decrease_consumed_reads_with')
decrease_consumed_reads_scale = \
get_table_option(key_name, 'decrease_consumed_reads_scale')
except JSONResponseError:
raise
except BotoServerError:
raise
# Set the updated units to the current read unit value
updated_read_units = current_read_units
# Reset consecutive reads if num_read_checks_reset_percent is reached
if num_read_checks_reset_percent:
if consumed_read_units_percent >= num_read_checks_reset_percent:
logger.info(
'{0} - Resetting the number of consecutive '
'read checks. Reason: Consumed percent {1} is '
'greater than reset percent: {2}'.format(
table_name,
consumed_read_units_percent,
num_read_checks_reset_percent))
num_consec_read_checks = 0
# Exit if up scaling has been disabled
if not get_table_option(key_name, 'enable_reads_up_scaling'):
logger.debug(
'{0} - Up scaling event detected. No action taken as scaling '
'up reads has been disabled in the configuration'.format(
table_name))
else:
# If local/granular values not specified use global values
increase_consumed_reads_unit = \
increase_consumed_reads_unit or increase_reads_unit
increase_throttled_by_provisioned_reads_unit = \
increase_throttled_by_provisioned_reads_unit or increase_reads_unit
increase_throttled_by_consumed_reads_unit = \
increase_throttled_by_consumed_reads_unit or increase_reads_unit
increase_consumed_reads_with = \
increase_consumed_reads_with or increase_reads_with
# Initialise variables to store calculated provisioning
throttled_by_provisioned_calculated_provisioning = scale_reader(
increase_throttled_by_provisioned_reads_scale,
throttled_by_provisioned_read_percent)
throttled_by_consumed_calculated_provisioning = scale_reader(
increase_throttled_by_consumed_reads_scale,
throttled_by_consumed_read_percent)
consumed_calculated_provisioning = scale_reader(
increase_consumed_reads_scale,
consumed_read_units_percent)
throttled_count_calculated_provisioning = 0
calculated_provisioning = 0
# Increase needed due to high throttled to provisioned ratio
if throttled_by_provisioned_calculated_provisioning:
if increase_throttled_by_provisioned_reads_unit == 'percent':
throttled_by_provisioned_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
throttled_by_provisioned_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_by_provisioned_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
throttled_by_provisioned_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high throttled to consumed ratio
if throttled_by_consumed_calculated_provisioning:
if increase_throttled_by_consumed_reads_unit == 'percent':
throttled_by_consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
throttled_by_consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_by_consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
throttled_by_consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high CU consumption
if consumed_calculated_provisioning:
if increase_consumed_reads_unit == 'percent':
consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
elif (reads_upper_threshold
and consumed_read_units_percent > reads_upper_threshold
and not increase_consumed_reads_scale):
if increase_consumed_reads_unit == 'percent':
consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high throttling
if (throttled_reads_upper_threshold
and throttled_read_count > throttled_reads_upper_threshold):
if increase_reads_unit == 'percent':
throttled_count_calculated_provisioning = \
calculators.increase_reads_in_percent(
updated_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_count_calculated_provisioning = \
calculators.increase_reads_in_units(
updated_read_units,
increase_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Determine which metric requires the most scaling
if (throttled_by_provisioned_calculated_provisioning
> calculated_provisioning):
calculated_provisioning = \
throttled_by_provisioned_calculated_provisioning
scale_reason = (
"due to throttled events by provisioned "
"units threshold being exceeded")
if (throttled_by_consumed_calculated_provisioning
> calculated_provisioning):
calculated_provisioning = \
throttled_by_consumed_calculated_provisioning
scale_reason = (
"due to throttled events by consumed "
"units threshold being exceeded")
if consumed_calculated_provisioning > calculated_provisioning:
calculated_provisioning = consumed_calculated_provisioning
scale_reason = "due to consumed threshold being exceeded"
if throttled_count_calculated_provisioning > calculated_provisioning:
calculated_provisioning = throttled_count_calculated_provisioning
scale_reason = "due to throttled events threshold being exceeded"
if calculated_provisioning > current_read_units:
logger.info(
'{0} - Resetting the number of consecutive '
'read checks. Reason: scale up {1}'.format(
table_name, scale_reason))
num_consec_read_checks = 0
update_needed = True
updated_read_units = calculated_provisioning
# Decrease needed due to low CU consumption
if not update_needed:
# If local/granular values not specified use global values
decrease_consumed_reads_unit = \
decrease_consumed_reads_unit or decrease_reads_unit
decrease_consumed_reads_with = \
decrease_consumed_reads_with or decrease_reads_with
# Initialise variables to store calculated provisioning
consumed_calculated_provisioning = scale_reader_decrease(
decrease_consumed_reads_scale,
consumed_read_units_percent)
calculated_provisioning = None
# Exit if down scaling has been disabled
if not get_table_option(key_name, 'enable_reads_down_scaling'):
logger.debug(
'{0} - Down scaling event detected. No action taken as scaling'
' down reads has been disabled in the configuration'.format(
table_name))
# Exit if reads == 0% and downscaling has been disabled at 0%
elif (consumed_read_units_percent == 0 and not
get_table_option(
key_name, 'allow_scaling_down_reads_on_0_percent')):
logger.info(
'{0} - Down scaling event detected. No action taken as scaling'
' down reads is not done when usage is at 0%'.format(
table_name))
else:
if consumed_calculated_provisioning:
if decrease_consumed_reads_unit == 'percent':
calculated_provisioning = \
calculators.decrease_reads_in_percent(
updated_read_units,
consumed_calculated_provisioning,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
else:
calculated_provisioning = \
calculators.decrease_reads_in_units(
updated_read_units,
consumed_calculated_provisioning,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
elif (reads_lower_threshold
and consumed_read_units_percent < reads_lower_threshold
and not decrease_consumed_reads_scale):
if decrease_consumed_reads_unit == 'percent':
calculated_provisioning = \
calculators.decrease_reads_in_percent(
updated_read_units,
decrease_consumed_reads_with,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
else:
calculated_provisioning = \
calculators.decrease_reads_in_units(
updated_read_units,
decrease_consumed_reads_with,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
if (calculated_provisioning
and current_read_units != calculated_provisioning):
num_consec_read_checks += 1
if num_consec_read_checks >= num_read_checks_before_scale_down:
update_needed = True
updated_read_units = calculated_provisioning
# Never go over the configured max provisioning
if max_provisioned_reads:
if int(updated_read_units) > int(max_provisioned_reads):
update_needed = True
updated_read_units = int(max_provisioned_reads)
logger.info(
'Will not increase writes over max-provisioned-reads '
'limit ({0} writes)'.format(updated_read_units))
# Ensure that we have met the min-provisioning
if min_provisioned_reads:
if int(min_provisioned_reads) > int(updated_read_units):
update_needed = True
updated_read_units = int(min_provisioned_reads)
logger.info(
'{0} - Increasing reads to meet min-provisioned-reads '
'limit ({1} reads)'.format(table_name, updated_read_units))
if calculators.is_consumed_over_proposed(
current_read_units,
updated_read_units,
consumed_read_units_percent):
update_needed = False
updated_read_units = current_read_units
logger.info(
'{0} - Consumed is over proposed read units. Will leave table at '
'current setting.'.format(table_name))
logger.info('{0} - Consecutive read checks {1}/{2}'.format(
table_name,
num_consec_read_checks,
num_read_checks_before_scale_down))
return update_needed, updated_read_units, num_consec_read_checks | [
"def",
"__ensure_provisioning_reads",
"(",
"table_name",
",",
"key_name",
",",
"num_consec_read_checks",
")",
":",
"if",
"not",
"get_table_option",
"(",
"key_name",
",",
"'enable_reads_autoscaling'",
")",
":",
"logger",
".",
"info",
"(",
"'{0} - Autoscaling of reads has been disabled'",
".",
"format",
"(",
"table_name",
")",
")",
"return",
"False",
",",
"dynamodb",
".",
"get_provisioned_table_read_units",
"(",
"table_name",
")",
",",
"0",
"update_needed",
"=",
"False",
"try",
":",
"lookback_window_start",
"=",
"get_table_option",
"(",
"key_name",
",",
"'lookback_window_start'",
")",
"lookback_period",
"=",
"get_table_option",
"(",
"key_name",
",",
"'lookback_period'",
")",
"current_read_units",
"=",
"dynamodb",
".",
"get_provisioned_table_read_units",
"(",
"table_name",
")",
"consumed_read_units_percent",
"=",
"table_stats",
".",
"get_consumed_read_units_percent",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_period",
")",
"throttled_read_count",
"=",
"table_stats",
".",
"get_throttled_read_event_count",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_period",
")",
"throttled_by_provisioned_read_percent",
"=",
"table_stats",
".",
"get_throttled_by_provisioned_read_event_percent",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_period",
")",
"throttled_by_consumed_read_percent",
"=",
"table_stats",
".",
"get_throttled_by_consumed_read_percent",
"(",
"table_name",
",",
"lookback_window_start",
",",
"lookback_period",
")",
"reads_upper_threshold",
"=",
"get_table_option",
"(",
"key_name",
",",
"'reads_upper_threshold'",
")",
"reads_lower_threshold",
"=",
"get_table_option",
"(",
"key_name",
",",
"'reads_lower_threshold'",
")",
"throttled_reads_upper_threshold",
"=",
"get_table_option",
"(",
"key_name",
",",
"'throttled_reads_upper_threshold'",
")",
"increase_reads_with",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_reads_with'",
")",
"increase_reads_unit",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_reads_unit'",
")",
"decrease_reads_with",
"=",
"get_table_option",
"(",
"key_name",
",",
"'decrease_reads_with'",
")",
"decrease_reads_unit",
"=",
"get_table_option",
"(",
"key_name",
",",
"'decrease_reads_unit'",
")",
"min_provisioned_reads",
"=",
"get_table_option",
"(",
"key_name",
",",
"'min_provisioned_reads'",
")",
"max_provisioned_reads",
"=",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
"num_read_checks_before_scale_down",
"=",
"get_table_option",
"(",
"key_name",
",",
"'num_read_checks_before_scale_down'",
")",
"num_read_checks_reset_percent",
"=",
"get_table_option",
"(",
"key_name",
",",
"'num_read_checks_reset_percent'",
")",
"increase_throttled_by_provisioned_reads_unit",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_throttled_by_provisioned_reads_unit'",
")",
"increase_throttled_by_provisioned_reads_scale",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_throttled_by_provisioned_reads_scale'",
")",
"increase_throttled_by_consumed_reads_unit",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_throttled_by_consumed_reads_unit'",
")",
"increase_throttled_by_consumed_reads_scale",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_throttled_by_consumed_reads_scale'",
")",
"increase_consumed_reads_unit",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_consumed_reads_unit'",
")",
"increase_consumed_reads_with",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_consumed_reads_with'",
")",
"increase_consumed_reads_scale",
"=",
"get_table_option",
"(",
"key_name",
",",
"'increase_consumed_reads_scale'",
")",
"decrease_consumed_reads_unit",
"=",
"get_table_option",
"(",
"key_name",
",",
"'decrease_consumed_reads_unit'",
")",
"decrease_consumed_reads_with",
"=",
"get_table_option",
"(",
"key_name",
",",
"'decrease_consumed_reads_with'",
")",
"decrease_consumed_reads_scale",
"=",
"get_table_option",
"(",
"key_name",
",",
"'decrease_consumed_reads_scale'",
")",
"except",
"JSONResponseError",
":",
"raise",
"except",
"BotoServerError",
":",
"raise",
"# Set the updated units to the current read unit value",
"updated_read_units",
"=",
"current_read_units",
"# Reset consecutive reads if num_read_checks_reset_percent is reached",
"if",
"num_read_checks_reset_percent",
":",
"if",
"consumed_read_units_percent",
">=",
"num_read_checks_reset_percent",
":",
"logger",
".",
"info",
"(",
"'{0} - Resetting the number of consecutive '",
"'read checks. Reason: Consumed percent {1} is '",
"'greater than reset percent: {2}'",
".",
"format",
"(",
"table_name",
",",
"consumed_read_units_percent",
",",
"num_read_checks_reset_percent",
")",
")",
"num_consec_read_checks",
"=",
"0",
"# Exit if up scaling has been disabled",
"if",
"not",
"get_table_option",
"(",
"key_name",
",",
"'enable_reads_up_scaling'",
")",
":",
"logger",
".",
"debug",
"(",
"'{0} - Up scaling event detected. No action taken as scaling '",
"'up reads has been disabled in the configuration'",
".",
"format",
"(",
"table_name",
")",
")",
"else",
":",
"# If local/granular values not specified use global values",
"increase_consumed_reads_unit",
"=",
"increase_consumed_reads_unit",
"or",
"increase_reads_unit",
"increase_throttled_by_provisioned_reads_unit",
"=",
"increase_throttled_by_provisioned_reads_unit",
"or",
"increase_reads_unit",
"increase_throttled_by_consumed_reads_unit",
"=",
"increase_throttled_by_consumed_reads_unit",
"or",
"increase_reads_unit",
"increase_consumed_reads_with",
"=",
"increase_consumed_reads_with",
"or",
"increase_reads_with",
"# Initialise variables to store calculated provisioning",
"throttled_by_provisioned_calculated_provisioning",
"=",
"scale_reader",
"(",
"increase_throttled_by_provisioned_reads_scale",
",",
"throttled_by_provisioned_read_percent",
")",
"throttled_by_consumed_calculated_provisioning",
"=",
"scale_reader",
"(",
"increase_throttled_by_consumed_reads_scale",
",",
"throttled_by_consumed_read_percent",
")",
"consumed_calculated_provisioning",
"=",
"scale_reader",
"(",
"increase_consumed_reads_scale",
",",
"consumed_read_units_percent",
")",
"throttled_count_calculated_provisioning",
"=",
"0",
"calculated_provisioning",
"=",
"0",
"# Increase needed due to high throttled to provisioned ratio",
"if",
"throttled_by_provisioned_calculated_provisioning",
":",
"if",
"increase_throttled_by_provisioned_reads_unit",
"==",
"'percent'",
":",
"throttled_by_provisioned_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_percent",
"(",
"current_read_units",
",",
"throttled_by_provisioned_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"else",
":",
"throttled_by_provisioned_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_units",
"(",
"current_read_units",
",",
"throttled_by_provisioned_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"# Increase needed due to high throttled to consumed ratio",
"if",
"throttled_by_consumed_calculated_provisioning",
":",
"if",
"increase_throttled_by_consumed_reads_unit",
"==",
"'percent'",
":",
"throttled_by_consumed_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_percent",
"(",
"current_read_units",
",",
"throttled_by_consumed_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"else",
":",
"throttled_by_consumed_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_units",
"(",
"current_read_units",
",",
"throttled_by_consumed_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"# Increase needed due to high CU consumption",
"if",
"consumed_calculated_provisioning",
":",
"if",
"increase_consumed_reads_unit",
"==",
"'percent'",
":",
"consumed_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_percent",
"(",
"current_read_units",
",",
"consumed_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"else",
":",
"consumed_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_units",
"(",
"current_read_units",
",",
"consumed_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"elif",
"(",
"reads_upper_threshold",
"and",
"consumed_read_units_percent",
">",
"reads_upper_threshold",
"and",
"not",
"increase_consumed_reads_scale",
")",
":",
"if",
"increase_consumed_reads_unit",
"==",
"'percent'",
":",
"consumed_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_percent",
"(",
"current_read_units",
",",
"increase_consumed_reads_with",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"else",
":",
"consumed_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_units",
"(",
"current_read_units",
",",
"increase_consumed_reads_with",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"# Increase needed due to high throttling",
"if",
"(",
"throttled_reads_upper_threshold",
"and",
"throttled_read_count",
">",
"throttled_reads_upper_threshold",
")",
":",
"if",
"increase_reads_unit",
"==",
"'percent'",
":",
"throttled_count_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_percent",
"(",
"updated_read_units",
",",
"increase_consumed_reads_with",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"else",
":",
"throttled_count_calculated_provisioning",
"=",
"calculators",
".",
"increase_reads_in_units",
"(",
"updated_read_units",
",",
"increase_reads_with",
",",
"get_table_option",
"(",
"key_name",
",",
"'max_provisioned_reads'",
")",
",",
"consumed_read_units_percent",
",",
"table_name",
")",
"# Determine which metric requires the most scaling",
"if",
"(",
"throttled_by_provisioned_calculated_provisioning",
">",
"calculated_provisioning",
")",
":",
"calculated_provisioning",
"=",
"throttled_by_provisioned_calculated_provisioning",
"scale_reason",
"=",
"(",
"\"due to throttled events by provisioned \"",
"\"units threshold being exceeded\"",
")",
"if",
"(",
"throttled_by_consumed_calculated_provisioning",
">",
"calculated_provisioning",
")",
":",
"calculated_provisioning",
"=",
"throttled_by_consumed_calculated_provisioning",
"scale_reason",
"=",
"(",
"\"due to throttled events by consumed \"",
"\"units threshold being exceeded\"",
")",
"if",
"consumed_calculated_provisioning",
">",
"calculated_provisioning",
":",
"calculated_provisioning",
"=",
"consumed_calculated_provisioning",
"scale_reason",
"=",
"\"due to consumed threshold being exceeded\"",
"if",
"throttled_count_calculated_provisioning",
">",
"calculated_provisioning",
":",
"calculated_provisioning",
"=",
"throttled_count_calculated_provisioning",
"scale_reason",
"=",
"\"due to throttled events threshold being exceeded\"",
"if",
"calculated_provisioning",
">",
"current_read_units",
":",
"logger",
".",
"info",
"(",
"'{0} - Resetting the number of consecutive '",
"'read checks. Reason: scale up {1}'",
".",
"format",
"(",
"table_name",
",",
"scale_reason",
")",
")",
"num_consec_read_checks",
"=",
"0",
"update_needed",
"=",
"True",
"updated_read_units",
"=",
"calculated_provisioning",
"# Decrease needed due to low CU consumption",
"if",
"not",
"update_needed",
":",
"# If local/granular values not specified use global values",
"decrease_consumed_reads_unit",
"=",
"decrease_consumed_reads_unit",
"or",
"decrease_reads_unit",
"decrease_consumed_reads_with",
"=",
"decrease_consumed_reads_with",
"or",
"decrease_reads_with",
"# Initialise variables to store calculated provisioning",
"consumed_calculated_provisioning",
"=",
"scale_reader_decrease",
"(",
"decrease_consumed_reads_scale",
",",
"consumed_read_units_percent",
")",
"calculated_provisioning",
"=",
"None",
"# Exit if down scaling has been disabled",
"if",
"not",
"get_table_option",
"(",
"key_name",
",",
"'enable_reads_down_scaling'",
")",
":",
"logger",
".",
"debug",
"(",
"'{0} - Down scaling event detected. No action taken as scaling'",
"' down reads has been disabled in the configuration'",
".",
"format",
"(",
"table_name",
")",
")",
"# Exit if reads == 0% and downscaling has been disabled at 0%",
"elif",
"(",
"consumed_read_units_percent",
"==",
"0",
"and",
"not",
"get_table_option",
"(",
"key_name",
",",
"'allow_scaling_down_reads_on_0_percent'",
")",
")",
":",
"logger",
".",
"info",
"(",
"'{0} - Down scaling event detected. No action taken as scaling'",
"' down reads is not done when usage is at 0%'",
".",
"format",
"(",
"table_name",
")",
")",
"else",
":",
"if",
"consumed_calculated_provisioning",
":",
"if",
"decrease_consumed_reads_unit",
"==",
"'percent'",
":",
"calculated_provisioning",
"=",
"calculators",
".",
"decrease_reads_in_percent",
"(",
"updated_read_units",
",",
"consumed_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'min_provisioned_reads'",
")",
",",
"table_name",
")",
"else",
":",
"calculated_provisioning",
"=",
"calculators",
".",
"decrease_reads_in_units",
"(",
"updated_read_units",
",",
"consumed_calculated_provisioning",
",",
"get_table_option",
"(",
"key_name",
",",
"'min_provisioned_reads'",
")",
",",
"table_name",
")",
"elif",
"(",
"reads_lower_threshold",
"and",
"consumed_read_units_percent",
"<",
"reads_lower_threshold",
"and",
"not",
"decrease_consumed_reads_scale",
")",
":",
"if",
"decrease_consumed_reads_unit",
"==",
"'percent'",
":",
"calculated_provisioning",
"=",
"calculators",
".",
"decrease_reads_in_percent",
"(",
"updated_read_units",
",",
"decrease_consumed_reads_with",
",",
"get_table_option",
"(",
"key_name",
",",
"'min_provisioned_reads'",
")",
",",
"table_name",
")",
"else",
":",
"calculated_provisioning",
"=",
"calculators",
".",
"decrease_reads_in_units",
"(",
"updated_read_units",
",",
"decrease_consumed_reads_with",
",",
"get_table_option",
"(",
"key_name",
",",
"'min_provisioned_reads'",
")",
",",
"table_name",
")",
"if",
"(",
"calculated_provisioning",
"and",
"current_read_units",
"!=",
"calculated_provisioning",
")",
":",
"num_consec_read_checks",
"+=",
"1",
"if",
"num_consec_read_checks",
">=",
"num_read_checks_before_scale_down",
":",
"update_needed",
"=",
"True",
"updated_read_units",
"=",
"calculated_provisioning",
"# Never go over the configured max provisioning",
"if",
"max_provisioned_reads",
":",
"if",
"int",
"(",
"updated_read_units",
")",
">",
"int",
"(",
"max_provisioned_reads",
")",
":",
"update_needed",
"=",
"True",
"updated_read_units",
"=",
"int",
"(",
"max_provisioned_reads",
")",
"logger",
".",
"info",
"(",
"'Will not increase writes over max-provisioned-reads '",
"'limit ({0} writes)'",
".",
"format",
"(",
"updated_read_units",
")",
")",
"# Ensure that we have met the min-provisioning",
"if",
"min_provisioned_reads",
":",
"if",
"int",
"(",
"min_provisioned_reads",
")",
">",
"int",
"(",
"updated_read_units",
")",
":",
"update_needed",
"=",
"True",
"updated_read_units",
"=",
"int",
"(",
"min_provisioned_reads",
")",
"logger",
".",
"info",
"(",
"'{0} - Increasing reads to meet min-provisioned-reads '",
"'limit ({1} reads)'",
".",
"format",
"(",
"table_name",
",",
"updated_read_units",
")",
")",
"if",
"calculators",
".",
"is_consumed_over_proposed",
"(",
"current_read_units",
",",
"updated_read_units",
",",
"consumed_read_units_percent",
")",
":",
"update_needed",
"=",
"False",
"updated_read_units",
"=",
"current_read_units",
"logger",
".",
"info",
"(",
"'{0} - Consumed is over proposed read units. Will leave table at '",
"'current setting.'",
".",
"format",
"(",
"table_name",
")",
")",
"logger",
".",
"info",
"(",
"'{0} - Consecutive read checks {1}/{2}'",
".",
"format",
"(",
"table_name",
",",
"num_consec_read_checks",
",",
"num_read_checks_before_scale_down",
")",
")",
"return",
"update_needed",
",",
"updated_read_units",
",",
"num_consec_read_checks"
] | Ensure that provisioning is correct
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type num_consec_read_checks: int
:param num_consec_read_checks: How many consecutive checks have we had
:returns: (bool, int, int)
update_needed, updated_read_units, num_consec_read_checks | [
"Ensure",
"that",
"provisioning",
"is",
"correct"
] | train | https://github.com/sebdah/dynamic-dynamodb/blob/bfd0ca806b1c3301e724696de90ef0f973410493/dynamic_dynamodb/core/table.py#L124-L503 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Ensure that provisioning is correct
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type num_consec_read_checks: int
:param num_consec_read_checks: How many consecutive checks have we had
:returns: (bool, int, int)
update_needed, updated_read_units, num_consec_read_checks
### Response:
def __ensure_provisioning_reads(table_name, key_name, num_consec_read_checks):
""" Ensure that provisioning is correct
:type table_name: str
:param table_name: Name of the DynamoDB table
:type key_name: str
:param key_name: Configuration option key name
:type num_consec_read_checks: int
:param num_consec_read_checks: How many consecutive checks have we had
:returns: (bool, int, int)
update_needed, updated_read_units, num_consec_read_checks
"""
if not get_table_option(key_name, 'enable_reads_autoscaling'):
logger.info(
'{0} - Autoscaling of reads has been disabled'.format(table_name))
return False, dynamodb.get_provisioned_table_read_units(table_name), 0
update_needed = False
try:
lookback_window_start = get_table_option(
key_name, 'lookback_window_start')
lookback_period = get_table_option(key_name, 'lookback_period')
current_read_units = dynamodb.get_provisioned_table_read_units(
table_name)
consumed_read_units_percent = \
table_stats.get_consumed_read_units_percent(
table_name, lookback_window_start, lookback_period)
throttled_read_count = \
table_stats.get_throttled_read_event_count(
table_name, lookback_window_start, lookback_period)
throttled_by_provisioned_read_percent = \
table_stats.get_throttled_by_provisioned_read_event_percent(
table_name, lookback_window_start, lookback_period)
throttled_by_consumed_read_percent = \
table_stats.get_throttled_by_consumed_read_percent(
table_name, lookback_window_start, lookback_period)
reads_upper_threshold = \
get_table_option(key_name, 'reads_upper_threshold')
reads_lower_threshold = \
get_table_option(key_name, 'reads_lower_threshold')
throttled_reads_upper_threshold = \
get_table_option(key_name, 'throttled_reads_upper_threshold')
increase_reads_with = \
get_table_option(key_name, 'increase_reads_with')
increase_reads_unit = \
get_table_option(key_name, 'increase_reads_unit')
decrease_reads_with = \
get_table_option(key_name, 'decrease_reads_with')
decrease_reads_unit = \
get_table_option(key_name, 'decrease_reads_unit')
min_provisioned_reads = \
get_table_option(key_name, 'min_provisioned_reads')
max_provisioned_reads = \
get_table_option(key_name, 'max_provisioned_reads')
num_read_checks_before_scale_down = \
get_table_option(key_name, 'num_read_checks_before_scale_down')
num_read_checks_reset_percent = \
get_table_option(key_name, 'num_read_checks_reset_percent')
increase_throttled_by_provisioned_reads_unit = \
get_table_option(
key_name, 'increase_throttled_by_provisioned_reads_unit')
increase_throttled_by_provisioned_reads_scale = \
get_table_option(
key_name, 'increase_throttled_by_provisioned_reads_scale')
increase_throttled_by_consumed_reads_unit = \
get_table_option(
key_name, 'increase_throttled_by_consumed_reads_unit')
increase_throttled_by_consumed_reads_scale = \
get_table_option(
key_name, 'increase_throttled_by_consumed_reads_scale')
increase_consumed_reads_unit = \
get_table_option(key_name, 'increase_consumed_reads_unit')
increase_consumed_reads_with = \
get_table_option(key_name, 'increase_consumed_reads_with')
increase_consumed_reads_scale = \
get_table_option(key_name, 'increase_consumed_reads_scale')
decrease_consumed_reads_unit = \
get_table_option(key_name, 'decrease_consumed_reads_unit')
decrease_consumed_reads_with = \
get_table_option(key_name, 'decrease_consumed_reads_with')
decrease_consumed_reads_scale = \
get_table_option(key_name, 'decrease_consumed_reads_scale')
except JSONResponseError:
raise
except BotoServerError:
raise
# Set the updated units to the current read unit value
updated_read_units = current_read_units
# Reset consecutive reads if num_read_checks_reset_percent is reached
if num_read_checks_reset_percent:
if consumed_read_units_percent >= num_read_checks_reset_percent:
logger.info(
'{0} - Resetting the number of consecutive '
'read checks. Reason: Consumed percent {1} is '
'greater than reset percent: {2}'.format(
table_name,
consumed_read_units_percent,
num_read_checks_reset_percent))
num_consec_read_checks = 0
# Exit if up scaling has been disabled
if not get_table_option(key_name, 'enable_reads_up_scaling'):
logger.debug(
'{0} - Up scaling event detected. No action taken as scaling '
'up reads has been disabled in the configuration'.format(
table_name))
else:
# If local/granular values not specified use global values
increase_consumed_reads_unit = \
increase_consumed_reads_unit or increase_reads_unit
increase_throttled_by_provisioned_reads_unit = \
increase_throttled_by_provisioned_reads_unit or increase_reads_unit
increase_throttled_by_consumed_reads_unit = \
increase_throttled_by_consumed_reads_unit or increase_reads_unit
increase_consumed_reads_with = \
increase_consumed_reads_with or increase_reads_with
# Initialise variables to store calculated provisioning
throttled_by_provisioned_calculated_provisioning = scale_reader(
increase_throttled_by_provisioned_reads_scale,
throttled_by_provisioned_read_percent)
throttled_by_consumed_calculated_provisioning = scale_reader(
increase_throttled_by_consumed_reads_scale,
throttled_by_consumed_read_percent)
consumed_calculated_provisioning = scale_reader(
increase_consumed_reads_scale,
consumed_read_units_percent)
throttled_count_calculated_provisioning = 0
calculated_provisioning = 0
# Increase needed due to high throttled to provisioned ratio
if throttled_by_provisioned_calculated_provisioning:
if increase_throttled_by_provisioned_reads_unit == 'percent':
throttled_by_provisioned_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
throttled_by_provisioned_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_by_provisioned_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
throttled_by_provisioned_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high throttled to consumed ratio
if throttled_by_consumed_calculated_provisioning:
if increase_throttled_by_consumed_reads_unit == 'percent':
throttled_by_consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
throttled_by_consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_by_consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
throttled_by_consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high CU consumption
if consumed_calculated_provisioning:
if increase_consumed_reads_unit == 'percent':
consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
consumed_calculated_provisioning,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
elif (reads_upper_threshold
and consumed_read_units_percent > reads_upper_threshold
and not increase_consumed_reads_scale):
if increase_consumed_reads_unit == 'percent':
consumed_calculated_provisioning = \
calculators.increase_reads_in_percent(
current_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
consumed_calculated_provisioning = \
calculators.increase_reads_in_units(
current_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Increase needed due to high throttling
if (throttled_reads_upper_threshold
and throttled_read_count > throttled_reads_upper_threshold):
if increase_reads_unit == 'percent':
throttled_count_calculated_provisioning = \
calculators.increase_reads_in_percent(
updated_read_units,
increase_consumed_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
else:
throttled_count_calculated_provisioning = \
calculators.increase_reads_in_units(
updated_read_units,
increase_reads_with,
get_table_option(key_name, 'max_provisioned_reads'),
consumed_read_units_percent,
table_name)
# Determine which metric requires the most scaling
if (throttled_by_provisioned_calculated_provisioning
> calculated_provisioning):
calculated_provisioning = \
throttled_by_provisioned_calculated_provisioning
scale_reason = (
"due to throttled events by provisioned "
"units threshold being exceeded")
if (throttled_by_consumed_calculated_provisioning
> calculated_provisioning):
calculated_provisioning = \
throttled_by_consumed_calculated_provisioning
scale_reason = (
"due to throttled events by consumed "
"units threshold being exceeded")
if consumed_calculated_provisioning > calculated_provisioning:
calculated_provisioning = consumed_calculated_provisioning
scale_reason = "due to consumed threshold being exceeded"
if throttled_count_calculated_provisioning > calculated_provisioning:
calculated_provisioning = throttled_count_calculated_provisioning
scale_reason = "due to throttled events threshold being exceeded"
if calculated_provisioning > current_read_units:
logger.info(
'{0} - Resetting the number of consecutive '
'read checks. Reason: scale up {1}'.format(
table_name, scale_reason))
num_consec_read_checks = 0
update_needed = True
updated_read_units = calculated_provisioning
# Decrease needed due to low CU consumption
if not update_needed:
# If local/granular values not specified use global values
decrease_consumed_reads_unit = \
decrease_consumed_reads_unit or decrease_reads_unit
decrease_consumed_reads_with = \
decrease_consumed_reads_with or decrease_reads_with
# Initialise variables to store calculated provisioning
consumed_calculated_provisioning = scale_reader_decrease(
decrease_consumed_reads_scale,
consumed_read_units_percent)
calculated_provisioning = None
# Exit if down scaling has been disabled
if not get_table_option(key_name, 'enable_reads_down_scaling'):
logger.debug(
'{0} - Down scaling event detected. No action taken as scaling'
' down reads has been disabled in the configuration'.format(
table_name))
# Exit if reads == 0% and downscaling has been disabled at 0%
elif (consumed_read_units_percent == 0 and not
get_table_option(
key_name, 'allow_scaling_down_reads_on_0_percent')):
logger.info(
'{0} - Down scaling event detected. No action taken as scaling'
' down reads is not done when usage is at 0%'.format(
table_name))
else:
if consumed_calculated_provisioning:
if decrease_consumed_reads_unit == 'percent':
calculated_provisioning = \
calculators.decrease_reads_in_percent(
updated_read_units,
consumed_calculated_provisioning,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
else:
calculated_provisioning = \
calculators.decrease_reads_in_units(
updated_read_units,
consumed_calculated_provisioning,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
elif (reads_lower_threshold
and consumed_read_units_percent < reads_lower_threshold
and not decrease_consumed_reads_scale):
if decrease_consumed_reads_unit == 'percent':
calculated_provisioning = \
calculators.decrease_reads_in_percent(
updated_read_units,
decrease_consumed_reads_with,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
else:
calculated_provisioning = \
calculators.decrease_reads_in_units(
updated_read_units,
decrease_consumed_reads_with,
get_table_option(
key_name, 'min_provisioned_reads'),
table_name)
if (calculated_provisioning
and current_read_units != calculated_provisioning):
num_consec_read_checks += 1
if num_consec_read_checks >= num_read_checks_before_scale_down:
update_needed = True
updated_read_units = calculated_provisioning
# Never go over the configured max provisioning
if max_provisioned_reads:
if int(updated_read_units) > int(max_provisioned_reads):
update_needed = True
updated_read_units = int(max_provisioned_reads)
logger.info(
'Will not increase writes over max-provisioned-reads '
'limit ({0} writes)'.format(updated_read_units))
# Ensure that we have met the min-provisioning
if min_provisioned_reads:
if int(min_provisioned_reads) > int(updated_read_units):
update_needed = True
updated_read_units = int(min_provisioned_reads)
logger.info(
'{0} - Increasing reads to meet min-provisioned-reads '
'limit ({1} reads)'.format(table_name, updated_read_units))
if calculators.is_consumed_over_proposed(
current_read_units,
updated_read_units,
consumed_read_units_percent):
update_needed = False
updated_read_units = current_read_units
logger.info(
'{0} - Consumed is over proposed read units. Will leave table at '
'current setting.'.format(table_name))
logger.info('{0} - Consecutive read checks {1}/{2}'.format(
table_name,
num_consec_read_checks,
num_read_checks_before_scale_down))
return update_needed, updated_read_units, num_consec_read_checks
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
65539,
430,
98156,
374,
4495,
271,
262,
551,
1337,
2007,
1292,
25,
610,
198,
262,
551,
913,
2007,
1292,
25,
4076,
315,
279,
72913,
3590,
2007,
198,
262,
551,
1337,
1401,
1292,
25,
610,
198,
262,
551,
913,
1401,
1292,
25,
12499,
3072,
1401,
836,
198,
262,
551,
1337,
1661,
3464,
5132,
6579,
76897,
25,
528,
198,
262,
551,
913,
1661,
3464,
5132,
6579,
76897,
25,
2650,
1690,
24871,
12621,
617,
584,
1047,
198,
262,
551,
4310,
25,
320,
2707,
11,
528,
11,
528,
340,
286,
2713,
58526,
11,
6177,
6579,
29445,
11,
1661,
3464,
5132,
6579,
76897,
271,
14711,
6075,
512,
755,
1328,
28389,
2602,
13311,
287,
67728,
16138,
1292,
11,
1401,
1292,
11,
1661,
3464,
5132,
6579,
76897,
997,
262,
4304,
30379,
430,
98156,
374,
4495,
271,
262,
551,
1337,
2007,
1292,
25,
610,
198,
262,
551,
913,
2007,
1292,
25,
4076,
315,
279,
72913,
3590,
2007,
198,
262,
551,
1337,
1401,
1292,
25,
610,
198,
262,
551,
913,
1401,
1292,
25,
12499,
3072,
1401,
836,
198,
262,
551,
1337,
1661,
3464,
5132,
6579,
76897,
25,
528,
198,
262,
551,
913,
1661,
3464,
5132,
6579,
76897,
25,
2650,
1690,
24871,
12621,
617,
584,
1047,
198,
262,
551,
4310,
25,
320,
2707,
11,
528,
11,
528,
340,
286,
2713,
58526,
11,
6177,
6579,
29445,
11,
1661,
3464,
5132,
6579,
76897,
198,
262,
3270,
262,
422,
539,
636,
5350,
9869,
4962,
1292,
11,
364,
12837,
67728,
33908,
437,
82652,
11290,
286,
6050,
5506,
1021,
310,
11834,
15,
92,
482,
92652,
82652,
315,
16181,
706,
1027,
8552,
4527,
2293,
16138,
1292,
1192,
286,
471,
3641,
11,
18003,
17278,
673,
2602,
13311,
291,
5350,
6579,
29445,
16138,
1292,
705,
220,
15,
271,
262,
2713,
58526,
284,
3641,
198,
262,
1456,
512,
286,
1427,
1445,
12856,
5011,
284,
636,
5350,
9869,
1021,
310,
1401,
1292,
11,
364,
7349,
1445,
12856,
5011,
1329,
286,
1427,
1445,
21485,
284,
636,
5350,
9869,
4962,
1292,
11,
364,
7349,
1445,
21485,
1329,
286,
1510,
6579,
29445,
284,
18003,
17278,
673,
2602,
13311,
291,
5350,
6579,
29445,
1021,
310,
2007,
1292,
340,
286,
27073,
6579,
29445,
30983,
284,
3120,
310,
2007,
15743,
673,
70970,
291,
6579,
29445,
30983,
1021,
394,
2007,
1292,
11,
1427,
1445,
12856,
5011,
11,
1427,
1445,
21485,
340,
286,
81072,
839,
6579,
3259,
284,
3120,
310,
2007,
15743,
673,
5978,
47789,
839,
6579,
6891,
3259,
1021,
394,
2007,
1292,
11,
1427,
1445,
12856,
5011,
11,
1427,
1445,
21485,
340,
286,
81072,
839,
3795,
2602,
13311,
291,
6579,
30983,
284,
3120,
310,
2007,
15743,
673,
5978,
47789,
839,
3795,
2602,
13311,
291,
6579,
6891,
30983,
1021,
394,
2007,
1292,
11,
1427,
1445,
12856,
5011,
11,
1427,
1445,
21485,
340,
286,
81072,
839,
3795,
70970,
291,
6579,
30983,
284,
3120,
310,
2007,
15743,
673,
5978,
47789,
839,
3795,
70970,
291,
6579,
30983,
1021,
394,
2007,
1292,
11,
1427,
1445
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
6498,
382,
14711,
5546,
512,
65539,
430,
98156,
374,
4495,
271,
262,
551,
1337,
2007,
1292,
25,
610,
198,
262,
551,
913,
2007,
1292,
25,
4076,
315,
279,
72913,
3590,
2007,
198,
262,
551,
1337,
1401,
1292,
25,
610,
198,
262,
551,
913,
1401,
1292,
25,
12499,
3072,
1401,
836,
198,
262,
551,
1337,
1661,
3464,
5132,
6579,
76897,
25,
528,
198,
262,
551,
913,
1661,
3464,
5132,
6579,
76897,
25,
2650,
1690,
24871,
12621,
617,
584,
1047,
198,
262,
551,
4310,
25,
320,
2707,
11,
528,
11,
528,
340,
286,
2713,
58526,
11,
6177,
6579,
29445,
11,
1661,
3464,
5132,
6579,
76897,
271,
14711,
6075,
512,
755,
1328,
28389,
2602,
13311,
287,
67728,
16138,
1292,
11,
1401,
1292,
11,
1661,
3464,
5132,
6579,
76897,
997,
262,
4304,
30379,
430,
98156,
374,
4495,
271,
262,
551,
1337,
2007,
1292,
25,
610,
198,
262,
551,
913,
2007,
1292,
25,
4076,
315,
279,
72913,
3590,
2007,
198,
262,
551,
1337,
1401,
1292,
25,
610,
198,
262,
551,
913,
1401,
1292,
25,
12499,
3072,
1401,
836,
198,
262,
551,
1337,
1661,
3464,
5132,
6579,
76897,
25,
528,
198,
262,
551,
913,
1661,
3464,
5132,
6579,
76897,
25,
2650,
1690,
24871,
12621,
617,
584,
1047,
198,
262,
551,
4310,
25,
320,
2707,
11,
528,
11,
528,
340,
286,
2713,
58526,
11,
6177,
6579,
29445,
11,
1661,
3464,
5132,
6579,
76897,
198,
262,
3270,
262,
422,
539,
636,
5350,
9869,
4962,
1292,
11,
364,
12837,
67728,
33908,
437,
82652,
11290,
286,
6050,
5506,
1021,
310,
11834,
15,
92,
482,
92652,
82652,
315,
16181,
706,
1027,
8552,
4527,
2293,
16138,
1292,
1192,
286,
471,
3641,
11,
18003,
17278,
673,
2602,
13311,
291,
5350,
6579,
29445,
16138,
1292,
705,
220,
15,
271,
262,
2713,
58526,
284,
3641,
198,
262,
1456,
512,
286,
1427,
1445,
12856,
5011,
284,
636,
5350,
9869,
1021,
310,
1401,
1292,
11,
364,
7349,
1445,
12856,
5011,
1329,
286,
1427,
1445,
21485,
284,
636,
5350,
9869,
4962,
1292,
11,
364,
7349,
1445,
21485,
1329,
286,
1510,
6579,
29445,
284,
18003,
17278,
673,
2602,
13311,
291,
5350,
6579,
29445,
1021,
310,
2007,
1292,
340,
286,
27073,
6579,
29445,
30983,
284,
3120,
310,
2007,
15743,
673,
70970,
291,
6579,
29445,
30983,
1021,
394,
2007,
1292,
11,
1427,
1445,
12856,
5011,
11,
1427,
1445,
21485,
340,
286,
81072,
839,
6579,
3259,
284,
3120,
310,
2007,
15743,
673,
5978,
47789,
839,
6579,
6891,
3259,
1021,
394,
2007,
1292,
11,
1427,
1445,
12856,
5011,
11,
1427,
1445,
21485,
340,
286,
81072,
839,
3795,
2602,
13311,
291,
6579,
30983,
284,
3120,
310,
2007,
15743,
673,
5978,
47789,
839,
3795,
2602,
13311,
291,
6579,
6891,
30983,
1021,
394,
2007,
1292,
11,
1427,
1445,
12856,
5011,
11,
1427,
1445,
21485,
340,
286,
81072,
839,
3795,
70970,
291,
6579,
30983,
284,
3120,
310,
2007,
15743,
673,
5978,
47789,
839,
3795,
70970,
291,
6579,
30983,
1021,
394,
2007,
1292,
11,
1427,
1445
] |
saltstack/salt | salt/modules/dpkg_lowpkg.py | _get_pkg_install_time | def _get_pkg_install_time(pkg, arch=None):
'''
Return package install time, based on the /var/lib/dpkg/info/<package>.list
:return:
'''
iso_time = iso_time_t = None
loc_root = '/var/lib/dpkg/info'
if pkg is not None:
locations = []
if arch is not None and arch != 'all':
locations.append(os.path.join(loc_root, '{0}:{1}.list'.format(pkg, arch)))
locations.append(os.path.join(loc_root, '{0}.list'.format(pkg)))
for location in locations:
try:
iso_time_t = int(os.path.getmtime(location))
iso_time = datetime.datetime.utcfromtimestamp(iso_time_t).isoformat() + 'Z'
break
except OSError:
pass
if iso_time is None:
log.debug('Unable to get package installation time for package "%s".', pkg)
return iso_time, iso_time_t | python | def _get_pkg_install_time(pkg, arch=None):
'''
Return package install time, based on the /var/lib/dpkg/info/<package>.list
:return:
'''
iso_time = iso_time_t = None
loc_root = '/var/lib/dpkg/info'
if pkg is not None:
locations = []
if arch is not None and arch != 'all':
locations.append(os.path.join(loc_root, '{0}:{1}.list'.format(pkg, arch)))
locations.append(os.path.join(loc_root, '{0}.list'.format(pkg)))
for location in locations:
try:
iso_time_t = int(os.path.getmtime(location))
iso_time = datetime.datetime.utcfromtimestamp(iso_time_t).isoformat() + 'Z'
break
except OSError:
pass
if iso_time is None:
log.debug('Unable to get package installation time for package "%s".', pkg)
return iso_time, iso_time_t | [
"def",
"_get_pkg_install_time",
"(",
"pkg",
",",
"arch",
"=",
"None",
")",
":",
"iso_time",
"=",
"iso_time_t",
"=",
"None",
"loc_root",
"=",
"'/var/lib/dpkg/info'",
"if",
"pkg",
"is",
"not",
"None",
":",
"locations",
"=",
"[",
"]",
"if",
"arch",
"is",
"not",
"None",
"and",
"arch",
"!=",
"'all'",
":",
"locations",
".",
"append",
"(",
"os",
".",
"path",
".",
"join",
"(",
"loc_root",
",",
"'{0}:{1}.list'",
".",
"format",
"(",
"pkg",
",",
"arch",
")",
")",
")",
"locations",
".",
"append",
"(",
"os",
".",
"path",
".",
"join",
"(",
"loc_root",
",",
"'{0}.list'",
".",
"format",
"(",
"pkg",
")",
")",
")",
"for",
"location",
"in",
"locations",
":",
"try",
":",
"iso_time_t",
"=",
"int",
"(",
"os",
".",
"path",
".",
"getmtime",
"(",
"location",
")",
")",
"iso_time",
"=",
"datetime",
".",
"datetime",
".",
"utcfromtimestamp",
"(",
"iso_time_t",
")",
".",
"isoformat",
"(",
")",
"+",
"'Z'",
"break",
"except",
"OSError",
":",
"pass",
"if",
"iso_time",
"is",
"None",
":",
"log",
".",
"debug",
"(",
"'Unable to get package installation time for package \"%s\".'",
",",
"pkg",
")",
"return",
"iso_time",
",",
"iso_time_t"
] | Return package install time, based on the /var/lib/dpkg/info/<package>.list
:return: | [
"Return",
"package",
"install",
"time",
"based",
"on",
"the",
"/",
"var",
"/",
"lib",
"/",
"dpkg",
"/",
"info",
"/",
"<package",
">",
".",
"list"
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dpkg_lowpkg.py#L376-L401 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return package install time, based on the /var/lib/dpkg/info/<package>.list
:return:
### Response:
def _get_pkg_install_time(pkg, arch=None):
'''
Return package install time, based on the /var/lib/dpkg/info/<package>.list
:return:
'''
iso_time = iso_time_t = None
loc_root = '/var/lib/dpkg/info'
if pkg is not None:
locations = []
if arch is not None and arch != 'all':
locations.append(os.path.join(loc_root, '{0}:{1}.list'.format(pkg, arch)))
locations.append(os.path.join(loc_root, '{0}.list'.format(pkg)))
for location in locations:
try:
iso_time_t = int(os.path.getmtime(location))
iso_time = datetime.datetime.utcfromtimestamp(iso_time_t).isoformat() + 'Z'
break
except OSError:
pass
if iso_time is None:
log.debug('Unable to get package installation time for package "%s".', pkg)
return iso_time, iso_time_t
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
6462,
4685,
892,
11,
3196,
389,
279,
611,
959,
8357,
3529,
31169,
56076,
23875,
1757,
14611,
1638,
271,
262,
551,
693,
1473,
14711,
6075,
512,
755,
721,
456,
65839,
35345,
3084,
69880,
11,
5438,
5980,
997,
262,
11414,
262,
3494,
6462,
4685,
892,
11,
3196,
389,
279,
611,
959,
8357,
3529,
31169,
56076,
23875,
1757,
14611,
1638,
271,
262,
551,
693,
512,
262,
11414,
262,
34556,
3084,
284,
34556,
3084,
530,
284,
2290,
198,
262,
1353,
13290,
284,
3434,
959,
8357,
3529,
31169,
56076,
1270,
262,
422,
25830,
374,
539,
2290,
512,
286,
10687,
284,
4260,
286,
422,
5438,
374,
539,
2290,
323,
5438,
976,
364,
543,
3730,
310,
10687,
2102,
9835,
3960,
5563,
23476,
13290,
11,
11834,
15,
59246,
16,
7966,
1638,
4527,
2293,
69880,
11,
5438,
19789,
286,
10687,
2102,
9835,
3960,
5563,
23476,
13290,
11,
11834,
15,
7966,
1638,
4527,
2293,
69880,
6054,
286,
369,
3813,
304,
10687,
512,
310,
1456,
512,
394,
34556,
3084,
530,
284,
528,
9835,
3960,
673,
62076,
23509,
1192,
394,
34556,
3084,
284,
9050,
20296,
46497,
1527,
13333,
9820,
78,
3084,
530,
570,
15782,
2293,
368,
489,
364,
57,
1270,
394,
1464,
198,
310,
3734,
75342,
512,
394,
1522,
271,
286,
422,
34556,
3084,
374,
2290,
512,
310,
1515,
8042,
493,
17512,
311,
636,
6462,
14028,
892,
369,
6462,
6090,
82,
3343,
518,
25830,
696,
262,
471,
34556,
3084,
11,
34556,
3084,
530,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
6462,
4685,
892,
11,
3196,
389,
279,
611,
959,
8357,
3529,
31169,
56076,
23875,
1757,
14611,
1638,
271,
262,
551,
693,
1473,
14711,
6075,
512,
755,
721,
456,
65839,
35345,
3084,
69880,
11,
5438,
5980,
997,
262,
11414,
262,
3494,
6462,
4685,
892,
11,
3196,
389,
279,
611,
959,
8357,
3529,
31169,
56076,
23875,
1757,
14611,
1638,
271,
262,
551,
693,
512,
262,
11414,
262,
34556,
3084,
284,
34556,
3084,
530,
284,
2290,
198,
262,
1353,
13290,
284,
3434,
959,
8357,
3529,
31169,
56076,
1270,
262,
422,
25830,
374,
539,
2290,
512,
286,
10687,
284,
4260,
286,
422,
5438,
374,
539,
2290,
323,
5438,
976,
364,
543,
3730,
310,
10687,
2102,
9835,
3960,
5563,
23476,
13290,
11,
11834,
15,
59246,
16,
7966,
1638,
4527,
2293,
69880,
11,
5438,
19789,
286,
10687,
2102,
9835,
3960,
5563,
23476,
13290,
11,
11834,
15,
7966,
1638,
4527,
2293,
69880,
6054,
286,
369,
3813,
304,
10687,
512,
310,
1456,
512,
394,
34556,
3084,
530,
284,
528,
9835,
3960,
673,
62076,
23509,
1192,
394,
34556,
3084,
284,
9050,
20296,
46497,
1527,
13333,
9820,
78,
3084,
530,
570,
15782,
2293,
368,
489,
364,
57,
1270,
394,
1464,
198,
310,
3734,
75342,
512,
394,
1522,
271,
286,
422,
34556,
3084,
374,
2290,
512,
310,
1515,
8042,
493,
17512,
311,
636,
6462,
14028,
892,
369,
6462,
6090,
82,
3343,
518,
25830,
696,
262,
471,
34556,
3084,
11,
34556,
3084,
530,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
numenta/htmresearch | projects/nik/nik_analysis.py | NIKAnalysis.compute | def compute(self, xt1, yt1, xt, yt, theta1t1, theta2t1, theta1, theta2):
"""
Accumulate the various inputs.
"""
dx = xt - xt1
dy = yt - yt1
if self.numPoints < self.maxPoints:
self.dxValues[self.numPoints,0] = dx
self.dxValues[self.numPoints,1] = dy
self.thetaValues[self.numPoints,0] = theta1
self.thetaValues[self.numPoints,1] = theta2
self.numPoints += 1
# print >>sys.stderr, "Xt's: ", xt1, yt1, xt, yt, "Delta's: ", dx, dy
# print >>sys.stderr, "Theta t-1: ", theta1t1, theta2t1, "t:",theta1, theta2
elif self.numPoints == self.maxPoints:
print >> sys.stderr,"Max points exceeded, analyzing ",self.maxPoints,"points only"
self.numPoints += 1 | python | def compute(self, xt1, yt1, xt, yt, theta1t1, theta2t1, theta1, theta2):
"""
Accumulate the various inputs.
"""
dx = xt - xt1
dy = yt - yt1
if self.numPoints < self.maxPoints:
self.dxValues[self.numPoints,0] = dx
self.dxValues[self.numPoints,1] = dy
self.thetaValues[self.numPoints,0] = theta1
self.thetaValues[self.numPoints,1] = theta2
self.numPoints += 1
# print >>sys.stderr, "Xt's: ", xt1, yt1, xt, yt, "Delta's: ", dx, dy
# print >>sys.stderr, "Theta t-1: ", theta1t1, theta2t1, "t:",theta1, theta2
elif self.numPoints == self.maxPoints:
print >> sys.stderr,"Max points exceeded, analyzing ",self.maxPoints,"points only"
self.numPoints += 1 | [
"def",
"compute",
"(",
"self",
",",
"xt1",
",",
"yt1",
",",
"xt",
",",
"yt",
",",
"theta1t1",
",",
"theta2t1",
",",
"theta1",
",",
"theta2",
")",
":",
"dx",
"=",
"xt",
"-",
"xt1",
"dy",
"=",
"yt",
"-",
"yt1",
"if",
"self",
".",
"numPoints",
"<",
"self",
".",
"maxPoints",
":",
"self",
".",
"dxValues",
"[",
"self",
".",
"numPoints",
",",
"0",
"]",
"=",
"dx",
"self",
".",
"dxValues",
"[",
"self",
".",
"numPoints",
",",
"1",
"]",
"=",
"dy",
"self",
".",
"thetaValues",
"[",
"self",
".",
"numPoints",
",",
"0",
"]",
"=",
"theta1",
"self",
".",
"thetaValues",
"[",
"self",
".",
"numPoints",
",",
"1",
"]",
"=",
"theta2",
"self",
".",
"numPoints",
"+=",
"1",
"# print >>sys.stderr, \"Xt's: \", xt1, yt1, xt, yt, \"Delta's: \", dx, dy",
"# print >>sys.stderr, \"Theta t-1: \", theta1t1, theta2t1, \"t:\",theta1, theta2",
"elif",
"self",
".",
"numPoints",
"==",
"self",
".",
"maxPoints",
":",
"print",
">>",
"sys",
".",
"stderr",
",",
"\"Max points exceeded, analyzing \"",
",",
"self",
".",
"maxPoints",
",",
"\"points only\"",
"self",
".",
"numPoints",
"+=",
"1"
] | Accumulate the various inputs. | [
"Accumulate",
"the",
"various",
"inputs",
"."
] | train | https://github.com/numenta/htmresearch/blob/70c096b09a577ea0432c3f3bfff4442d4871b7aa/projects/nik/nik_analysis.py#L41-L62 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Accumulate the various inputs.
### Response:
def compute(self, xt1, yt1, xt, yt, theta1t1, theta2t1, theta1, theta2):
"""
Accumulate the various inputs.
"""
dx = xt - xt1
dy = yt - yt1
if self.numPoints < self.maxPoints:
self.dxValues[self.numPoints,0] = dx
self.dxValues[self.numPoints,1] = dy
self.thetaValues[self.numPoints,0] = theta1
self.thetaValues[self.numPoints,1] = theta2
self.numPoints += 1
# print >>sys.stderr, "Xt's: ", xt1, yt1, xt, yt, "Delta's: ", dx, dy
# print >>sys.stderr, "Theta t-1: ", theta1t1, theta2t1, "t:",theta1, theta2
elif self.numPoints == self.maxPoints:
print >> sys.stderr,"Max points exceeded, analyzing ",self.maxPoints,"points only"
self.numPoints += 1
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14945,
372,
6468,
279,
5370,
11374,
382,
14711,
6075,
512,
755,
12849,
1214,
11,
63490,
16,
11,
69853,
16,
11,
63490,
11,
69853,
11,
19034,
16,
83,
16,
11,
19034,
17,
83,
16,
11,
19034,
16,
11,
19034,
17,
997,
262,
3270,
262,
80625,
6468,
279,
5370,
11374,
627,
262,
3270,
262,
14142,
284,
63490,
482,
63490,
16,
198,
262,
14282,
284,
69853,
482,
69853,
16,
271,
262,
422,
659,
10744,
11665,
366,
659,
6817,
11665,
512,
415,
659,
53091,
6359,
14664,
10744,
11665,
11,
15,
60,
284,
14142,
198,
415,
659,
53091,
6359,
14664,
10744,
11665,
11,
16,
60,
284,
14282,
271,
415,
659,
70601,
6359,
14664,
10744,
11665,
11,
15,
60,
284,
19034,
16,
198,
415,
659,
70601,
6359,
14664,
10744,
11665,
11,
16,
60,
284,
19034,
17,
271,
415,
659,
10744,
11665,
1447,
220,
16,
271,
415,
674,
1194,
3662,
7947,
35842,
11,
330,
55,
83,
596,
25,
3755,
63490,
16,
11,
69853,
16,
11,
63490,
11,
69853,
11,
330,
20892,
596,
25,
3755,
14142,
11,
14282,
198,
415,
674,
1194,
3662,
7947,
35842,
11,
330,
45414,
259,
12,
16,
25,
3755,
19034,
16,
83,
16,
11,
19034,
17,
83,
16,
11,
330,
83,
12421,
16356,
16,
11,
19034,
17,
271,
262,
4508,
659,
10744,
11665,
624,
659,
6817,
11665,
512,
415,
1194,
3662,
5826,
35842,
1359,
6102,
3585,
34908,
11,
42118,
3755,
726,
6817,
11665,
1359,
7862,
1193,
702,
415,
659,
10744,
11665,
1447,
220,
16,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14945,
372,
6468,
279,
5370,
11374,
382,
14711,
6075,
512,
755,
12849,
1214,
11,
63490,
16,
11,
69853,
16,
11,
63490,
11,
69853,
11,
19034,
16,
83,
16,
11,
19034,
17,
83,
16,
11,
19034,
16,
11,
19034,
17,
997,
262,
3270,
262,
80625,
6468,
279,
5370,
11374,
627,
262,
3270,
262,
14142,
284,
63490,
482,
63490,
16,
198,
262,
14282,
284,
69853,
482,
69853,
16,
271,
262,
422,
659,
10744,
11665,
366,
659,
6817,
11665,
512,
415,
659,
53091,
6359,
14664,
10744,
11665,
11,
15,
60,
284,
14142,
198,
415,
659,
53091,
6359,
14664,
10744,
11665,
11,
16,
60,
284,
14282,
271,
415,
659,
70601,
6359,
14664,
10744,
11665,
11,
15,
60,
284,
19034,
16,
198,
415,
659,
70601,
6359,
14664,
10744,
11665,
11,
16,
60,
284,
19034,
17,
271,
415,
659,
10744,
11665,
1447,
220,
16,
271,
415,
674,
1194,
3662,
7947,
35842,
11,
330,
55,
83,
596,
25,
3755,
63490,
16,
11,
69853,
16,
11,
63490,
11,
69853,
11,
330,
20892,
596,
25,
3755,
14142,
11,
14282,
198,
415,
674,
1194,
3662,
7947,
35842,
11,
330,
45414,
259,
12,
16,
25,
3755,
19034,
16,
83,
16,
11,
19034,
17,
83,
16,
11,
330,
83,
12421,
16356,
16,
11,
19034,
17,
271,
262,
4508,
659,
10744,
11665,
624,
659,
6817,
11665,
512,
415,
1194,
3662,
5826,
35842,
1359,
6102,
3585,
34908,
11,
42118,
3755,
726,
6817,
11665,
1359,
7862,
1193,
702,
415,
659,
10744,
11665,
1447,
220,
16,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
SecurityInnovation/PGPy | pgpy/pgp.py | PGPKey.is_public | def is_public(self):
"""``True`` if this is a public key, otherwise ``False``"""
return isinstance(self._key, Public) and not isinstance(self._key, Private) | python | def is_public(self):
"""``True`` if this is a public key, otherwise ``False``"""
return isinstance(self._key, Public) and not isinstance(self._key, Private) | [
"def",
"is_public",
"(",
"self",
")",
":",
"return",
"isinstance",
"(",
"self",
".",
"_key",
",",
"Public",
")",
"and",
"not",
"isinstance",
"(",
"self",
".",
"_key",
",",
"Private",
")"
] | ``True`` if this is a public key, otherwise ``False`` | [
"True",
"if",
"this",
"is",
"a",
"public",
"key",
"otherwise",
"False"
] | train | https://github.com/SecurityInnovation/PGPy/blob/f1c3d68e32c334f5aa14c34580925e97f17f4fde/pgpy/pgp.py#L1282-L1284 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
``True`` if this is a public key, otherwise ``False``
### Response:
def is_public(self):
"""``True`` if this is a public key, otherwise ``False``"""
return isinstance(self._key, Public) and not isinstance(self._key, Private)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14196,
2575,
14196,
422,
420,
374,
264,
586,
1401,
11,
6062,
10103,
4139,
14196,
271,
14711,
6075,
512,
755,
374,
28173,
1214,
997,
286,
4304,
14196,
2575,
14196,
422,
420,
374,
264,
586,
1401,
11,
6062,
10103,
4139,
14196,
7275,
286,
471,
11656,
1214,
1462,
798,
11,
3142,
8,
323,
539,
11656,
1214,
1462,
798,
11,
9877,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14196,
2575,
14196,
422,
420,
374,
264,
586,
1401,
11,
6062,
10103,
4139,
14196,
271,
14711,
6075,
512,
755,
374,
28173,
1214,
997,
286,
4304,
14196,
2575,
14196,
422,
420,
374,
264,
586,
1401,
11,
6062,
10103,
4139,
14196,
7275,
286,
471,
11656,
1214,
1462,
798,
11,
3142,
8,
323,
539,
11656,
1214,
1462,
798,
11,
9877,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
lipoja/URLExtract | urlextract/urlextract_core.py | _urlextract_cli | def _urlextract_cli():
"""
urlextract - command line program that will print all URLs to stdout
Usage: urlextract [input_file] [-u] [-v]
input_file - text file with URLs to extract
"""
import argparse
def get_args():
"""
Parse programs arguments
"""
parser = argparse.ArgumentParser(
description='urlextract - prints out all URLs that were '
'found in input file or stdin based on locating '
'their TLDs')
ver = URLExtract.get_version()
parser.add_argument("-v", "--version", action="version",
version='%(prog)s - version {}'.format(ver))
parser.add_argument(
"-u", "--unique", dest='unique', action='store_true',
help='print out only unique URLs found in file.')
parser.add_argument(
'input_file', nargs='?', metavar='<input_file>',
type=argparse.FileType(encoding="UTF-8"), default=sys.stdin,
help='input text file with URLs to extract. [UTF-8]')
parsed_args = parser.parse_args()
return parsed_args
args = get_args()
logging.basicConfig(
level=logging.INFO, stream=sys.stderr,
format='%(asctime)s - %(levelname)s (%(name)s): %(message)s')
logger = logging.getLogger('urlextract')
try:
urlextract = URLExtract()
urlextract.update_when_older(30)
content = args.input_file.read()
for url in urlextract.find_urls(content, args.unique):
print(url)
except CacheFileError as e:
logger.error(str(e))
sys.exit(-1)
finally:
args.input_file.close() | python | def _urlextract_cli():
"""
urlextract - command line program that will print all URLs to stdout
Usage: urlextract [input_file] [-u] [-v]
input_file - text file with URLs to extract
"""
import argparse
def get_args():
"""
Parse programs arguments
"""
parser = argparse.ArgumentParser(
description='urlextract - prints out all URLs that were '
'found in input file or stdin based on locating '
'their TLDs')
ver = URLExtract.get_version()
parser.add_argument("-v", "--version", action="version",
version='%(prog)s - version {}'.format(ver))
parser.add_argument(
"-u", "--unique", dest='unique', action='store_true',
help='print out only unique URLs found in file.')
parser.add_argument(
'input_file', nargs='?', metavar='<input_file>',
type=argparse.FileType(encoding="UTF-8"), default=sys.stdin,
help='input text file with URLs to extract. [UTF-8]')
parsed_args = parser.parse_args()
return parsed_args
args = get_args()
logging.basicConfig(
level=logging.INFO, stream=sys.stderr,
format='%(asctime)s - %(levelname)s (%(name)s): %(message)s')
logger = logging.getLogger('urlextract')
try:
urlextract = URLExtract()
urlextract.update_when_older(30)
content = args.input_file.read()
for url in urlextract.find_urls(content, args.unique):
print(url)
except CacheFileError as e:
logger.error(str(e))
sys.exit(-1)
finally:
args.input_file.close() | [
"def",
"_urlextract_cli",
"(",
")",
":",
"import",
"argparse",
"def",
"get_args",
"(",
")",
":",
"\"\"\"\n Parse programs arguments\n \"\"\"",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'urlextract - prints out all URLs that were '",
"'found in input file or stdin based on locating '",
"'their TLDs'",
")",
"ver",
"=",
"URLExtract",
".",
"get_version",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"-v\"",
",",
"\"--version\"",
",",
"action",
"=",
"\"version\"",
",",
"version",
"=",
"'%(prog)s - version {}'",
".",
"format",
"(",
"ver",
")",
")",
"parser",
".",
"add_argument",
"(",
"\"-u\"",
",",
"\"--unique\"",
",",
"dest",
"=",
"'unique'",
",",
"action",
"=",
"'store_true'",
",",
"help",
"=",
"'print out only unique URLs found in file.'",
")",
"parser",
".",
"add_argument",
"(",
"'input_file'",
",",
"nargs",
"=",
"'?'",
",",
"metavar",
"=",
"'<input_file>'",
",",
"type",
"=",
"argparse",
".",
"FileType",
"(",
"encoding",
"=",
"\"UTF-8\"",
")",
",",
"default",
"=",
"sys",
".",
"stdin",
",",
"help",
"=",
"'input text file with URLs to extract. [UTF-8]'",
")",
"parsed_args",
"=",
"parser",
".",
"parse_args",
"(",
")",
"return",
"parsed_args",
"args",
"=",
"get_args",
"(",
")",
"logging",
".",
"basicConfig",
"(",
"level",
"=",
"logging",
".",
"INFO",
",",
"stream",
"=",
"sys",
".",
"stderr",
",",
"format",
"=",
"'%(asctime)s - %(levelname)s (%(name)s): %(message)s'",
")",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'urlextract'",
")",
"try",
":",
"urlextract",
"=",
"URLExtract",
"(",
")",
"urlextract",
".",
"update_when_older",
"(",
"30",
")",
"content",
"=",
"args",
".",
"input_file",
".",
"read",
"(",
")",
"for",
"url",
"in",
"urlextract",
".",
"find_urls",
"(",
"content",
",",
"args",
".",
"unique",
")",
":",
"print",
"(",
"url",
")",
"except",
"CacheFileError",
"as",
"e",
":",
"logger",
".",
"error",
"(",
"str",
"(",
"e",
")",
")",
"sys",
".",
"exit",
"(",
"-",
"1",
")",
"finally",
":",
"args",
".",
"input_file",
".",
"close",
"(",
")"
] | urlextract - command line program that will print all URLs to stdout
Usage: urlextract [input_file] [-u] [-v]
input_file - text file with URLs to extract | [
"urlextract",
"-",
"command",
"line",
"program",
"that",
"will",
"print",
"all",
"URLs",
"to",
"stdout",
"Usage",
":",
"urlextract",
"[",
"input_file",
"]",
"[",
"-",
"u",
"]",
"[",
"-",
"v",
"]"
] | train | https://github.com/lipoja/URLExtract/blob/b53fd2adfaed3cd23a811aed4d277b0ade7b4640/urlextract/urlextract_core.py#L590-L640 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
urlextract - command line program that will print all URLs to stdout
Usage: urlextract [input_file] [-u] [-v]
input_file - text file with URLs to extract
### Response:
def _urlextract_cli():
"""
urlextract - command line program that will print all URLs to stdout
Usage: urlextract [input_file] [-u] [-v]
input_file - text file with URLs to extract
"""
import argparse
def get_args():
"""
Parse programs arguments
"""
parser = argparse.ArgumentParser(
description='urlextract - prints out all URLs that were '
'found in input file or stdin based on locating '
'their TLDs')
ver = URLExtract.get_version()
parser.add_argument("-v", "--version", action="version",
version='%(prog)s - version {}'.format(ver))
parser.add_argument(
"-u", "--unique", dest='unique', action='store_true',
help='print out only unique URLs found in file.')
parser.add_argument(
'input_file', nargs='?', metavar='<input_file>',
type=argparse.FileType(encoding="UTF-8"), default=sys.stdin,
help='input text file with URLs to extract. [UTF-8]')
parsed_args = parser.parse_args()
return parsed_args
args = get_args()
logging.basicConfig(
level=logging.INFO, stream=sys.stderr,
format='%(asctime)s - %(levelname)s (%(name)s): %(message)s')
logger = logging.getLogger('urlextract')
try:
urlextract = URLExtract()
urlextract.update_when_older(30)
content = args.input_file.read()
for url in urlextract.find_urls(content, args.unique):
print(url)
except CacheFileError as e:
logger.error(str(e))
sys.exit(-1)
finally:
args.input_file.close()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
324,
2635,
2193,
482,
3290,
1584,
2068,
430,
690,
1194,
682,
36106,
311,
20676,
198,
262,
25585,
25,
4433,
2635,
2193,
510,
1379,
2517,
60,
10261,
84,
60,
10261,
85,
2595,
262,
1988,
2517,
482,
1495,
1052,
449,
36106,
311,
8819,
271,
14711,
6075,
512,
755,
721,
324,
2635,
2193,
48247,
4019,
262,
3270,
262,
4433,
2635,
2193,
482,
3290,
1584,
2068,
430,
690,
1194,
682,
36106,
311,
20676,
198,
262,
25585,
25,
4433,
2635,
2193,
510,
1379,
2517,
60,
10261,
84,
60,
10261,
85,
2595,
262,
1988,
2517,
482,
1495,
1052,
449,
36106,
311,
8819,
198,
262,
3270,
262,
1179,
23122,
271,
262,
711,
636,
8550,
4019,
286,
3270,
286,
15118,
7620,
6105,
198,
286,
3270,
286,
6871,
284,
23122,
39066,
1021,
310,
4096,
1151,
324,
2635,
2193,
482,
24370,
704,
682,
36106,
430,
1051,
8044,
667,
364,
15456,
304,
1988,
1052,
477,
32469,
3196,
389,
72991,
8044,
667,
364,
50828,
350,
12615,
82,
4713,
286,
2807,
284,
5665,
30059,
673,
9625,
746,
286,
6871,
1388,
9202,
13959,
85,
498,
14822,
4464,
498,
1957,
429,
4464,
761,
1014,
2373,
1151,
20939,
34092,
16871,
482,
2373,
26307,
2293,
92737,
4489,
286,
6871,
1388,
9202,
1021,
310,
6660,
84,
498,
14822,
9782,
498,
3281,
1151,
9782,
518,
1957,
1151,
4412,
16469,
756,
310,
1520,
1151,
1374,
704,
1193,
5016,
36106,
1766,
304,
1052,
49420,
286,
6871,
1388,
9202,
1021,
310,
364,
1379,
2517,
518,
52716,
1151,
50734,
52318,
36795,
1379,
2517,
24049,
310,
955,
28,
867,
6534,
8744,
941,
86963,
429,
8729,
12,
23,
4063,
1670,
59970,
44284,
345,
310,
1520,
1151,
1379,
1495,
1052,
449,
36106,
311,
8819,
13,
510,
8729,
12,
23,
60,
4713,
286,
16051,
8550,
284,
6871,
4736,
8550,
746,
286,
471,
16051,
8550,
271,
262,
2897,
284,
636,
8550,
746,
262,
8558,
69897,
1021,
286,
2237,
71328,
39417,
11,
4365,
59970,
35842,
345,
286,
3645,
1151,
20939,
78177,
16871,
482,
21921,
76741,
16871,
13764,
7,
609,
16871,
1680,
21921,
2037,
16871,
1329,
262,
6050,
284,
8558,
13993,
493,
324,
2635,
2193,
4713,
262,
1456,
512,
286,
4433,
2635,
2193,
284,
5665,
30059,
746,
286,
4433,
2635,
2193,
5430,
48736,
62,
2061,
7,
966,
340,
286,
2262,
284,
2897,
10252,
2517,
4217,
746,
286,
369,
2576,
304,
4433,
2635,
2193,
2725,
33922,
15413,
11,
2897,
36618,
997,
310,
1194,
6659,
340,
262,
3734,
20044,
1738,
1480,
439,
384,
512,
286,
6050,
4517,
4293,
2069,
1192,
286,
5826,
13955,
4172,
16,
340,
262,
5616,
512,
286,
2897,
10252,
2517,
4757,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
324,
2635,
2193,
482,
3290,
1584,
2068,
430,
690,
1194,
682,
36106,
311,
20676,
198,
262,
25585,
25,
4433,
2635,
2193,
510,
1379,
2517,
60,
10261,
84,
60,
10261,
85,
2595,
262,
1988,
2517,
482,
1495,
1052,
449,
36106,
311,
8819,
271,
14711,
6075,
512,
755,
721,
324,
2635,
2193,
48247,
4019,
262,
3270,
262,
4433,
2635,
2193,
482,
3290,
1584,
2068,
430,
690,
1194,
682,
36106,
311,
20676,
198,
262,
25585,
25,
4433,
2635,
2193,
510,
1379,
2517,
60,
10261,
84,
60,
10261,
85,
2595,
262,
1988,
2517,
482,
1495,
1052,
449,
36106,
311,
8819,
198,
262,
3270,
262,
1179,
23122,
271,
262,
711,
636,
8550,
4019,
286,
3270,
286,
15118,
7620,
6105,
198,
286,
3270,
286,
6871,
284,
23122,
39066,
1021,
310,
4096,
1151,
324,
2635,
2193,
482,
24370,
704,
682,
36106,
430,
1051,
8044,
667,
364,
15456,
304,
1988,
1052,
477,
32469,
3196,
389,
72991,
8044,
667,
364,
50828,
350,
12615,
82,
4713,
286,
2807,
284,
5665,
30059,
673,
9625,
746,
286,
6871,
1388,
9202,
13959,
85,
498,
14822,
4464,
498,
1957,
429,
4464,
761,
1014,
2373,
1151,
20939,
34092,
16871,
482,
2373,
26307,
2293,
92737,
4489,
286,
6871,
1388,
9202,
1021,
310,
6660,
84,
498,
14822,
9782,
498,
3281,
1151,
9782,
518,
1957,
1151,
4412,
16469,
756,
310,
1520,
1151,
1374,
704,
1193,
5016,
36106,
1766,
304,
1052,
49420,
286,
6871,
1388,
9202,
1021,
310,
364,
1379,
2517,
518,
52716,
1151,
50734,
52318,
36795,
1379,
2517,
24049,
310,
955,
28,
867,
6534,
8744,
941,
86963,
429,
8729,
12,
23,
4063,
1670,
59970,
44284,
345,
310,
1520,
1151,
1379,
1495,
1052,
449,
36106,
311,
8819,
13,
510,
8729,
12,
23,
60,
4713,
286,
16051,
8550,
284,
6871,
4736,
8550,
746,
286,
471,
16051,
8550,
271,
262,
2897,
284,
636,
8550,
746,
262,
8558,
69897,
1021,
286,
2237,
71328,
39417,
11,
4365,
59970,
35842,
345,
286,
3645,
1151,
20939,
78177,
16871,
482,
21921,
76741,
16871,
13764,
7,
609,
16871,
1680,
21921,
2037,
16871,
1329,
262,
6050,
284,
8558,
13993,
493,
324,
2635,
2193,
4713,
262,
1456,
512,
286,
4433,
2635,
2193,
284,
5665,
30059,
746,
286,
4433,
2635,
2193,
5430,
48736,
62,
2061,
7,
966,
340,
286,
2262,
284,
2897,
10252,
2517,
4217,
746,
286,
369,
2576,
304,
4433,
2635,
2193,
2725,
33922,
15413,
11,
2897,
36618,
997,
310,
1194,
6659,
340,
262,
3734,
20044,
1738,
1480,
439,
384,
512,
286,
6050,
4517,
4293,
2069,
1192,
286,
5826,
13955,
4172,
16,
340,
262,
5616,
512,
286,
2897,
10252,
2517,
4757,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
materialsproject/pymatgen | pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py | Plane.distances_indices_sorted | def distances_indices_sorted(self, points, sign=False):
"""
Computes the distances from the plane to each of the points. Positive distances are on the side of the
normal of the plane while negative distances are on the other side. Indices sorting the points from closest
to furthest is also computed.
:param points: Points for which distances are computed
:param sign: Whether to add sign information in the indices sorting the points distances
:return: Distances from the plane to the points (positive values on the side of the normal to the plane,
negative values on the other side), as well as indices of the points from closest to furthest. For
the latter, when the sign parameter is True, items of the sorting list are given as tuples of
(index, sign).
"""
distances = [np.dot(self.normal_vector, pp) + self.d for pp in points]
indices = sorted(range(len(distances)), key=lambda k: np.abs(distances[k]))
if sign:
indices = [(ii, int(np.sign(distances[ii]))) for ii in indices]
return distances, indices | python | def distances_indices_sorted(self, points, sign=False):
"""
Computes the distances from the plane to each of the points. Positive distances are on the side of the
normal of the plane while negative distances are on the other side. Indices sorting the points from closest
to furthest is also computed.
:param points: Points for which distances are computed
:param sign: Whether to add sign information in the indices sorting the points distances
:return: Distances from the plane to the points (positive values on the side of the normal to the plane,
negative values on the other side), as well as indices of the points from closest to furthest. For
the latter, when the sign parameter is True, items of the sorting list are given as tuples of
(index, sign).
"""
distances = [np.dot(self.normal_vector, pp) + self.d for pp in points]
indices = sorted(range(len(distances)), key=lambda k: np.abs(distances[k]))
if sign:
indices = [(ii, int(np.sign(distances[ii]))) for ii in indices]
return distances, indices | [
"def",
"distances_indices_sorted",
"(",
"self",
",",
"points",
",",
"sign",
"=",
"False",
")",
":",
"distances",
"=",
"[",
"np",
".",
"dot",
"(",
"self",
".",
"normal_vector",
",",
"pp",
")",
"+",
"self",
".",
"d",
"for",
"pp",
"in",
"points",
"]",
"indices",
"=",
"sorted",
"(",
"range",
"(",
"len",
"(",
"distances",
")",
")",
",",
"key",
"=",
"lambda",
"k",
":",
"np",
".",
"abs",
"(",
"distances",
"[",
"k",
"]",
")",
")",
"if",
"sign",
":",
"indices",
"=",
"[",
"(",
"ii",
",",
"int",
"(",
"np",
".",
"sign",
"(",
"distances",
"[",
"ii",
"]",
")",
")",
")",
"for",
"ii",
"in",
"indices",
"]",
"return",
"distances",
",",
"indices"
] | Computes the distances from the plane to each of the points. Positive distances are on the side of the
normal of the plane while negative distances are on the other side. Indices sorting the points from closest
to furthest is also computed.
:param points: Points for which distances are computed
:param sign: Whether to add sign information in the indices sorting the points distances
:return: Distances from the plane to the points (positive values on the side of the normal to the plane,
negative values on the other side), as well as indices of the points from closest to furthest. For
the latter, when the sign parameter is True, items of the sorting list are given as tuples of
(index, sign). | [
"Computes",
"the",
"distances",
"from",
"the",
"plane",
"to",
"each",
"of",
"the",
"points",
".",
"Positive",
"distances",
"are",
"on",
"the",
"side",
"of",
"the",
"normal",
"of",
"the",
"plane",
"while",
"negative",
"distances",
"are",
"on",
"the",
"other",
"side",
".",
"Indices",
"sorting",
"the",
"points",
"from",
"closest",
"to",
"furthest",
"is",
"also",
"computed",
".",
":",
"param",
"points",
":",
"Points",
"for",
"which",
"distances",
"are",
"computed",
":",
"param",
"sign",
":",
"Whether",
"to",
"add",
"sign",
"information",
"in",
"the",
"indices",
"sorting",
"the",
"points",
"distances",
":",
"return",
":",
"Distances",
"from",
"the",
"plane",
"to",
"the",
"points",
"(",
"positive",
"values",
"on",
"the",
"side",
"of",
"the",
"normal",
"to",
"the",
"plane",
"negative",
"values",
"on",
"the",
"other",
"side",
")",
"as",
"well",
"as",
"indices",
"of",
"the",
"points",
"from",
"closest",
"to",
"furthest",
".",
"For",
"the",
"latter",
"when",
"the",
"sign",
"parameter",
"is",
"True",
"items",
"of",
"the",
"sorting",
"list",
"are",
"given",
"as",
"tuples",
"of",
"(",
"index",
"sign",
")",
"."
] | train | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/analysis/chemenv/utils/coordination_geometry_utils.py#L704-L720 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Computes the distances from the plane to each of the points. Positive distances are on the side of the
normal of the plane while negative distances are on the other side. Indices sorting the points from closest
to furthest is also computed.
:param points: Points for which distances are computed
:param sign: Whether to add sign information in the indices sorting the points distances
:return: Distances from the plane to the points (positive values on the side of the normal to the plane,
negative values on the other side), as well as indices of the points from closest to furthest. For
the latter, when the sign parameter is True, items of the sorting list are given as tuples of
(index, sign).
### Response:
def distances_indices_sorted(self, points, sign=False):
"""
Computes the distances from the plane to each of the points. Positive distances are on the side of the
normal of the plane while negative distances are on the other side. Indices sorting the points from closest
to furthest is also computed.
:param points: Points for which distances are computed
:param sign: Whether to add sign information in the indices sorting the points distances
:return: Distances from the plane to the points (positive values on the side of the normal to the plane,
negative values on the other side), as well as indices of the points from closest to furthest. For
the latter, when the sign parameter is True, items of the sorting list are given as tuples of
(index, sign).
"""
distances = [np.dot(self.normal_vector, pp) + self.d for pp in points]
indices = sorted(range(len(distances)), key=lambda k: np.abs(distances[k]))
if sign:
indices = [(ii, int(np.sign(distances[ii]))) for ii in indices]
return distances, indices
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
59122,
288,
279,
27650,
505,
279,
11277,
311,
1855,
315,
279,
3585,
13,
45003,
27650,
527,
389,
279,
3185,
315,
279,
198,
286,
4725,
315,
279,
11277,
1418,
8389,
27650,
527,
389,
279,
1023,
3185,
13,
86869,
29373,
279,
3585,
505,
18585,
198,
286,
311,
18742,
61943,
374,
1101,
25157,
627,
286,
551,
913,
3585,
25,
21387,
369,
902,
27650,
527,
25157,
198,
286,
551,
913,
1879,
25,
13440,
311,
923,
1879,
2038,
304,
279,
15285,
29373,
279,
3585,
27650,
198,
286,
551,
693,
25,
28704,
3095,
505,
279,
11277,
311,
279,
3585,
320,
31587,
2819,
389,
279,
3185,
315,
279,
4725,
311,
279,
11277,
345,
338,
8389,
2819,
389,
279,
1023,
3185,
705,
439,
1664,
439,
15285,
315,
279,
3585,
505,
18585,
311,
18742,
61943,
13,
1789,
198,
338,
279,
15629,
11,
994,
279,
1879,
5852,
374,
3082,
11,
3673,
315,
279,
29373,
1160,
527,
2728,
439,
46325,
315,
198,
338,
320,
1275,
11,
1879,
3677,
14711,
6075,
512,
755,
27650,
18839,
42377,
1214,
11,
3585,
11,
1879,
5725,
997,
286,
3270,
286,
66075,
279,
27650,
505,
279,
11277,
311,
1855,
315,
279,
3585,
13,
45003,
27650,
527,
389,
279,
3185,
315,
279,
198,
286,
4725,
315,
279,
11277,
1418,
8389,
27650,
527,
389,
279,
1023,
3185,
13,
86869,
29373,
279,
3585,
505,
18585,
198,
286,
311,
18742,
61943,
374,
1101,
25157,
627,
286,
551,
913,
3585,
25,
21387,
369,
902,
27650,
527,
25157,
198,
286,
551,
913,
1879,
25,
13440,
311,
923,
1879,
2038,
304,
279,
15285,
29373,
279,
3585,
27650,
198,
286,
551,
693,
25,
28704,
3095,
505,
279,
11277,
311,
279,
3585,
320,
31587,
2819,
389,
279,
3185,
315,
279,
4725,
311,
279,
11277,
345,
338,
8389,
2819,
389,
279,
1023,
3185,
705,
439,
1664,
439,
15285,
315,
279,
3585,
505,
18585,
311,
18742,
61943,
13,
1789,
198,
338,
279,
15629,
11,
994,
279,
1879,
5852,
374,
3082,
11,
3673,
315,
279,
29373,
1160,
527,
2728,
439,
46325,
315,
198,
338,
320,
1275,
11,
1879,
4390,
286,
3270,
286,
27650,
284,
510,
6331,
23633,
1214,
20738,
12526,
11,
12086,
8,
489,
659,
962,
369,
12086,
304,
3585,
933,
286,
15285,
284,
10839,
23147,
7046,
37268,
3095,
5850,
1401,
28604,
597,
25,
2660,
14914,
37268,
3095,
6874,
11147,
286,
422,
1879,
512,
310,
15285,
284,
18305,
3893,
11,
528,
10101,
15867,
37268,
3095,
31924,
81503,
369,
14799,
304,
15285,
933,
286,
471,
27650,
11,
15285,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
59122,
288,
279,
27650,
505,
279,
11277,
311,
1855,
315,
279,
3585,
13,
45003,
27650,
527,
389,
279,
3185,
315,
279,
198,
286,
4725,
315,
279,
11277,
1418,
8389,
27650,
527,
389,
279,
1023,
3185,
13,
86869,
29373,
279,
3585,
505,
18585,
198,
286,
311,
18742,
61943,
374,
1101,
25157,
627,
286,
551,
913,
3585,
25,
21387,
369,
902,
27650,
527,
25157,
198,
286,
551,
913,
1879,
25,
13440,
311,
923,
1879,
2038,
304,
279,
15285,
29373,
279,
3585,
27650,
198,
286,
551,
693,
25,
28704,
3095,
505,
279,
11277,
311,
279,
3585,
320,
31587,
2819,
389,
279,
3185,
315,
279,
4725,
311,
279,
11277,
345,
338,
8389,
2819,
389,
279,
1023,
3185,
705,
439,
1664,
439,
15285,
315,
279,
3585,
505,
18585,
311,
18742,
61943,
13,
1789,
198,
338,
279,
15629,
11,
994,
279,
1879,
5852,
374,
3082,
11,
3673,
315,
279,
29373,
1160,
527,
2728,
439,
46325,
315,
198,
338,
320,
1275,
11,
1879,
3677,
14711,
6075,
512,
755,
27650,
18839,
42377,
1214,
11,
3585,
11,
1879,
5725,
997,
286,
3270,
286,
66075,
279,
27650,
505,
279,
11277,
311,
1855,
315,
279,
3585,
13,
45003,
27650,
527,
389,
279,
3185,
315,
279,
198,
286,
4725,
315,
279,
11277,
1418,
8389,
27650,
527,
389,
279,
1023,
3185,
13,
86869,
29373,
279,
3585,
505,
18585,
198,
286,
311,
18742,
61943,
374,
1101,
25157,
627,
286,
551,
913,
3585,
25,
21387,
369,
902,
27650,
527,
25157,
198,
286,
551,
913,
1879,
25,
13440,
311,
923,
1879,
2038,
304,
279,
15285,
29373,
279,
3585,
27650,
198,
286,
551,
693,
25,
28704,
3095,
505,
279,
11277,
311,
279,
3585,
320,
31587,
2819,
389,
279,
3185,
315,
279,
4725,
311,
279,
11277,
345,
338,
8389,
2819,
389,
279,
1023,
3185,
705,
439,
1664,
439,
15285,
315,
279,
3585,
505,
18585,
311,
18742,
61943,
13,
1789,
198,
338,
279,
15629,
11,
994,
279,
1879,
5852,
374,
3082,
11,
3673,
315,
279,
29373,
1160,
527,
2728,
439,
46325,
315,
198,
338,
320,
1275,
11,
1879,
4390,
286,
3270,
286,
27650,
284,
510,
6331,
23633,
1214,
20738,
12526,
11,
12086,
8,
489,
659,
962,
369,
12086,
304,
3585,
933,
286,
15285,
284,
10839,
23147,
7046,
37268,
3095,
5850,
1401,
28604,
597,
25,
2660,
14914,
37268,
3095,
6874,
11147,
286,
422,
1879,
512,
310,
15285,
284,
18305,
3893,
11,
528,
10101,
15867,
37268,
3095,
31924,
81503,
369,
14799,
304,
15285,
933,
286,
471,
27650,
11,
15285,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
google/grr | grr/server/grr_response_server/databases/mem_paths.py | InMemoryDBPathMixin.MultiWritePathHistory | def MultiWritePathHistory(self, client_path_histories):
"""Writes a collection of hash and stat entries observed for given paths."""
for client_path, client_path_history in iteritems(client_path_histories):
if client_path.client_id not in self.metadatas:
raise db.UnknownClientError(client_path.client_id)
path_info = rdf_objects.PathInfo(
path_type=client_path.path_type, components=client_path.components)
for timestamp, stat_entry in iteritems(client_path_history.stat_entries):
path_record = self._GetPathRecord(
client_path.client_id, path_info, set_default=False)
if path_record is None:
# TODO(hanuszczak): Provide more details about paths that caused that.
raise db.AtLeastOneUnknownPathError([])
path_record.AddStatEntry(stat_entry, timestamp)
for timestamp, hash_entry in iteritems(client_path_history.hash_entries):
path_record = self._GetPathRecord(
client_path.client_id, path_info, set_default=False)
if path_record is None:
# TODO(hanuszczak): Provide more details about paths that caused that.
raise db.AtLeastOneUnknownPathError([])
path_record.AddHashEntry(hash_entry, timestamp) | python | def MultiWritePathHistory(self, client_path_histories):
"""Writes a collection of hash and stat entries observed for given paths."""
for client_path, client_path_history in iteritems(client_path_histories):
if client_path.client_id not in self.metadatas:
raise db.UnknownClientError(client_path.client_id)
path_info = rdf_objects.PathInfo(
path_type=client_path.path_type, components=client_path.components)
for timestamp, stat_entry in iteritems(client_path_history.stat_entries):
path_record = self._GetPathRecord(
client_path.client_id, path_info, set_default=False)
if path_record is None:
# TODO(hanuszczak): Provide more details about paths that caused that.
raise db.AtLeastOneUnknownPathError([])
path_record.AddStatEntry(stat_entry, timestamp)
for timestamp, hash_entry in iteritems(client_path_history.hash_entries):
path_record = self._GetPathRecord(
client_path.client_id, path_info, set_default=False)
if path_record is None:
# TODO(hanuszczak): Provide more details about paths that caused that.
raise db.AtLeastOneUnknownPathError([])
path_record.AddHashEntry(hash_entry, timestamp) | [
"def",
"MultiWritePathHistory",
"(",
"self",
",",
"client_path_histories",
")",
":",
"for",
"client_path",
",",
"client_path_history",
"in",
"iteritems",
"(",
"client_path_histories",
")",
":",
"if",
"client_path",
".",
"client_id",
"not",
"in",
"self",
".",
"metadatas",
":",
"raise",
"db",
".",
"UnknownClientError",
"(",
"client_path",
".",
"client_id",
")",
"path_info",
"=",
"rdf_objects",
".",
"PathInfo",
"(",
"path_type",
"=",
"client_path",
".",
"path_type",
",",
"components",
"=",
"client_path",
".",
"components",
")",
"for",
"timestamp",
",",
"stat_entry",
"in",
"iteritems",
"(",
"client_path_history",
".",
"stat_entries",
")",
":",
"path_record",
"=",
"self",
".",
"_GetPathRecord",
"(",
"client_path",
".",
"client_id",
",",
"path_info",
",",
"set_default",
"=",
"False",
")",
"if",
"path_record",
"is",
"None",
":",
"# TODO(hanuszczak): Provide more details about paths that caused that.",
"raise",
"db",
".",
"AtLeastOneUnknownPathError",
"(",
"[",
"]",
")",
"path_record",
".",
"AddStatEntry",
"(",
"stat_entry",
",",
"timestamp",
")",
"for",
"timestamp",
",",
"hash_entry",
"in",
"iteritems",
"(",
"client_path_history",
".",
"hash_entries",
")",
":",
"path_record",
"=",
"self",
".",
"_GetPathRecord",
"(",
"client_path",
".",
"client_id",
",",
"path_info",
",",
"set_default",
"=",
"False",
")",
"if",
"path_record",
"is",
"None",
":",
"# TODO(hanuszczak): Provide more details about paths that caused that.",
"raise",
"db",
".",
"AtLeastOneUnknownPathError",
"(",
"[",
"]",
")",
"path_record",
".",
"AddHashEntry",
"(",
"hash_entry",
",",
"timestamp",
")"
] | Writes a collection of hash and stat entries observed for given paths. | [
"Writes",
"a",
"collection",
"of",
"hash",
"and",
"stat",
"entries",
"observed",
"for",
"given",
"paths",
"."
] | train | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/server/grr_response_server/databases/mem_paths.py#L329-L354 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Writes a collection of hash and stat entries observed for given paths.
### Response:
def MultiWritePathHistory(self, client_path_histories):
"""Writes a collection of hash and stat entries observed for given paths."""
for client_path, client_path_history in iteritems(client_path_histories):
if client_path.client_id not in self.metadatas:
raise db.UnknownClientError(client_path.client_id)
path_info = rdf_objects.PathInfo(
path_type=client_path.path_type, components=client_path.components)
for timestamp, stat_entry in iteritems(client_path_history.stat_entries):
path_record = self._GetPathRecord(
client_path.client_id, path_info, set_default=False)
if path_record is None:
# TODO(hanuszczak): Provide more details about paths that caused that.
raise db.AtLeastOneUnknownPathError([])
path_record.AddStatEntry(stat_entry, timestamp)
for timestamp, hash_entry in iteritems(client_path_history.hash_entries):
path_record = self._GetPathRecord(
client_path.client_id, path_info, set_default=False)
if path_record is None:
# TODO(hanuszczak): Provide more details about paths that caused that.
raise db.AtLeastOneUnknownPathError([])
path_record.AddHashEntry(hash_entry, timestamp)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
94738,
264,
4526,
315,
5286,
323,
2863,
10925,
13468,
369,
2728,
13006,
382,
14711,
6075,
512,
755,
17896,
8144,
1858,
13730,
1214,
11,
3016,
2703,
37499,
2490,
997,
262,
4304,
94738,
264,
4526,
315,
5286,
323,
2863,
10925,
13468,
369,
2728,
13006,
14781,
262,
369,
3016,
2703,
11,
3016,
2703,
20389,
304,
5480,
3699,
13097,
2703,
37499,
2490,
997,
415,
422,
3016,
2703,
6718,
851,
539,
304,
659,
41748,
329,
19907,
512,
286,
4933,
3000,
71071,
3032,
1480,
13097,
2703,
6718,
851,
696,
415,
1853,
3186,
284,
67165,
25915,
17932,
1767,
1021,
692,
1853,
1857,
28,
3045,
2703,
3960,
1857,
11,
6956,
28,
3045,
2703,
20641,
696,
415,
369,
11695,
11,
2863,
9255,
304,
5480,
3699,
13097,
2703,
20389,
31187,
27184,
997,
286,
1853,
14526,
284,
659,
1462,
1991,
1858,
6607,
1021,
310,
3016,
2703,
6718,
851,
11,
1853,
3186,
11,
743,
10198,
5725,
340,
286,
422,
1853,
14526,
374,
2290,
512,
692,
674,
5456,
3283,
59063,
89,
14088,
587,
1680,
40665,
810,
3649,
922,
13006,
430,
9057,
430,
627,
692,
4933,
3000,
15913,
82916,
4054,
14109,
1858,
1480,
10779,
696,
286,
1853,
14526,
1943,
16257,
5998,
42885,
9255,
11,
11695,
696,
415,
369,
11695,
11,
5286,
9255,
304,
5480,
3699,
13097,
2703,
20389,
15452,
27184,
997,
286,
1853,
14526,
284,
659,
1462,
1991,
1858,
6607,
1021,
310,
3016,
2703,
6718,
851,
11,
1853,
3186,
11,
743,
10198,
5725,
340,
286,
422,
1853,
14526,
374,
2290,
512,
692,
674,
5456,
3283,
59063,
89,
14088,
587,
1680,
40665,
810,
3649,
922,
13006,
430,
9057,
430,
627,
692,
4933,
3000,
15913,
82916,
4054,
14109,
1858,
1480,
10779,
696,
286,
1853,
14526,
1943,
6504,
5998,
28680,
9255,
11,
11695,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
94738,
264,
4526,
315,
5286,
323,
2863,
10925,
13468,
369,
2728,
13006,
382,
14711,
6075,
512,
755,
17896,
8144,
1858,
13730,
1214,
11,
3016,
2703,
37499,
2490,
997,
262,
4304,
94738,
264,
4526,
315,
5286,
323,
2863,
10925,
13468,
369,
2728,
13006,
14781,
262,
369,
3016,
2703,
11,
3016,
2703,
20389,
304,
5480,
3699,
13097,
2703,
37499,
2490,
997,
415,
422,
3016,
2703,
6718,
851,
539,
304,
659,
41748,
329,
19907,
512,
286,
4933,
3000,
71071,
3032,
1480,
13097,
2703,
6718,
851,
696,
415,
1853,
3186,
284,
67165,
25915,
17932,
1767,
1021,
692,
1853,
1857,
28,
3045,
2703,
3960,
1857,
11,
6956,
28,
3045,
2703,
20641,
696,
415,
369,
11695,
11,
2863,
9255,
304,
5480,
3699,
13097,
2703,
20389,
31187,
27184,
997,
286,
1853,
14526,
284,
659,
1462,
1991,
1858,
6607,
1021,
310,
3016,
2703,
6718,
851,
11,
1853,
3186,
11,
743,
10198,
5725,
340,
286,
422,
1853,
14526,
374,
2290,
512,
692,
674,
5456,
3283,
59063,
89,
14088,
587,
1680,
40665,
810,
3649,
922,
13006,
430,
9057,
430,
627,
692,
4933,
3000,
15913,
82916,
4054,
14109,
1858,
1480,
10779,
696,
286,
1853,
14526,
1943,
16257,
5998,
42885,
9255,
11,
11695,
696,
415,
369,
11695,
11,
5286,
9255,
304,
5480,
3699,
13097,
2703,
20389,
15452,
27184,
997,
286,
1853,
14526,
284,
659,
1462,
1991,
1858,
6607,
1021,
310,
3016,
2703,
6718,
851,
11,
1853,
3186,
11,
743,
10198,
5725,
340,
286,
422,
1853,
14526,
374,
2290,
512,
692,
674,
5456,
3283,
59063,
89,
14088,
587,
1680,
40665,
810,
3649,
922,
13006,
430,
9057,
430,
627,
692,
4933,
3000,
15913,
82916,
4054,
14109,
1858,
1480,
10779,
696,
286,
1853,
14526,
1943,
6504,
5998,
28680,
9255,
11,
11695,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
petl-developers/petl | petl/transform/selects.py | selectisinstance | def selectisinstance(table, field, value, complement=False):
"""Select rows where the given field is an instance of the given type."""
return selectop(table, field, value, isinstance, complement=complement) | python | def selectisinstance(table, field, value, complement=False):
"""Select rows where the given field is an instance of the given type."""
return selectop(table, field, value, isinstance, complement=complement) | [
"def",
"selectisinstance",
"(",
"table",
",",
"field",
",",
"value",
",",
"complement",
"=",
"False",
")",
":",
"return",
"selectop",
"(",
"table",
",",
"field",
",",
"value",
",",
"isinstance",
",",
"complement",
"=",
"complement",
")"
] | Select rows where the given field is an instance of the given type. | [
"Select",
"rows",
"where",
"the",
"given",
"field",
"is",
"an",
"instance",
"of",
"the",
"given",
"type",
"."
] | train | https://github.com/petl-developers/petl/blob/1d33ca055f7e04e0d28a772041c9fd30c8d415d6/petl/transform/selects.py#L274-L277 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Select rows where the given field is an instance of the given type.
### Response:
def selectisinstance(table, field, value, complement=False):
"""Select rows where the given field is an instance of the given type."""
return selectop(table, field, value, isinstance, complement=complement)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
3461,
7123,
1405,
279,
2728,
2115,
374,
459,
2937,
315,
279,
2728,
955,
382,
14711,
6075,
512,
755,
3373,
285,
4956,
16138,
11,
2115,
11,
907,
11,
23606,
5725,
997,
262,
4304,
3461,
7123,
1405,
279,
2728,
2115,
374,
459,
2937,
315,
279,
2728,
955,
30284,
262,
471,
3373,
454,
16138,
11,
2115,
11,
907,
11,
11656,
11,
23606,
59946,
2833,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
3461,
7123,
1405,
279,
2728,
2115,
374,
459,
2937,
315,
279,
2728,
955,
382,
14711,
6075,
512,
755,
3373,
285,
4956,
16138,
11,
2115,
11,
907,
11,
23606,
5725,
997,
262,
4304,
3461,
7123,
1405,
279,
2728,
2115,
374,
459,
2937,
315,
279,
2728,
955,
30284,
262,
471,
3373,
454,
16138,
11,
2115,
11,
907,
11,
11656,
11,
23606,
59946,
2833,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pytroll/pyorbital | pyorbital/astronomy.py | sun_ecliptic_longitude | def sun_ecliptic_longitude(utc_time):
"""Ecliptic longitude of the sun at *utc_time*.
"""
jdate = jdays2000(utc_time) / 36525.0
# mean anomaly, rad
m_a = np.deg2rad(357.52910 +
35999.05030 * jdate -
0.0001559 * jdate * jdate -
0.00000048 * jdate * jdate * jdate)
# mean longitude, deg
l_0 = 280.46645 + 36000.76983 * jdate + 0.0003032 * jdate * jdate
d_l = ((1.914600 - 0.004817 * jdate - 0.000014 * jdate * jdate) * np.sin(m_a) +
(0.019993 - 0.000101 * jdate) * np.sin(2 * m_a) + 0.000290 * np.sin(3 * m_a))
# true longitude, deg
l__ = l_0 + d_l
return np.deg2rad(l__) | python | def sun_ecliptic_longitude(utc_time):
"""Ecliptic longitude of the sun at *utc_time*.
"""
jdate = jdays2000(utc_time) / 36525.0
# mean anomaly, rad
m_a = np.deg2rad(357.52910 +
35999.05030 * jdate -
0.0001559 * jdate * jdate -
0.00000048 * jdate * jdate * jdate)
# mean longitude, deg
l_0 = 280.46645 + 36000.76983 * jdate + 0.0003032 * jdate * jdate
d_l = ((1.914600 - 0.004817 * jdate - 0.000014 * jdate * jdate) * np.sin(m_a) +
(0.019993 - 0.000101 * jdate) * np.sin(2 * m_a) + 0.000290 * np.sin(3 * m_a))
# true longitude, deg
l__ = l_0 + d_l
return np.deg2rad(l__) | [
"def",
"sun_ecliptic_longitude",
"(",
"utc_time",
")",
":",
"jdate",
"=",
"jdays2000",
"(",
"utc_time",
")",
"/",
"36525.0",
"# mean anomaly, rad",
"m_a",
"=",
"np",
".",
"deg2rad",
"(",
"357.52910",
"+",
"35999.05030",
"*",
"jdate",
"-",
"0.0001559",
"*",
"jdate",
"*",
"jdate",
"-",
"0.00000048",
"*",
"jdate",
"*",
"jdate",
"*",
"jdate",
")",
"# mean longitude, deg",
"l_0",
"=",
"280.46645",
"+",
"36000.76983",
"*",
"jdate",
"+",
"0.0003032",
"*",
"jdate",
"*",
"jdate",
"d_l",
"=",
"(",
"(",
"1.914600",
"-",
"0.004817",
"*",
"jdate",
"-",
"0.000014",
"*",
"jdate",
"*",
"jdate",
")",
"*",
"np",
".",
"sin",
"(",
"m_a",
")",
"+",
"(",
"0.019993",
"-",
"0.000101",
"*",
"jdate",
")",
"*",
"np",
".",
"sin",
"(",
"2",
"*",
"m_a",
")",
"+",
"0.000290",
"*",
"np",
".",
"sin",
"(",
"3",
"*",
"m_a",
")",
")",
"# true longitude, deg",
"l__",
"=",
"l_0",
"+",
"d_l",
"return",
"np",
".",
"deg2rad",
"(",
"l__",
")"
] | Ecliptic longitude of the sun at *utc_time*. | [
"Ecliptic",
"longitude",
"of",
"the",
"sun",
"at",
"*",
"utc_time",
"*",
"."
] | train | https://github.com/pytroll/pyorbital/blob/647007934dc827a4c698629cf32a84a5167844b2/pyorbital/astronomy.py#L73-L88 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Ecliptic longitude of the sun at *utc_time*.
### Response:
def sun_ecliptic_longitude(utc_time):
"""Ecliptic longitude of the sun at *utc_time*.
"""
jdate = jdays2000(utc_time) / 36525.0
# mean anomaly, rad
m_a = np.deg2rad(357.52910 +
35999.05030 * jdate -
0.0001559 * jdate * jdate -
0.00000048 * jdate * jdate * jdate)
# mean longitude, deg
l_0 = 280.46645 + 36000.76983 * jdate + 0.0003032 * jdate * jdate
d_l = ((1.914600 - 0.004817 * jdate - 0.000014 * jdate * jdate) * np.sin(m_a) +
(0.019993 - 0.000101 * jdate) * np.sin(2 * m_a) + 0.000290 * np.sin(3 * m_a))
# true longitude, deg
l__ = l_0 + d_l
return np.deg2rad(l__)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36,
566,
11696,
292,
21155,
315,
279,
7160,
520,
353,
29455,
3084,
9,
382,
14711,
6075,
512,
755,
7160,
2253,
566,
11696,
292,
80834,
7,
29455,
3084,
997,
262,
4304,
36,
566,
11696,
292,
21155,
315,
279,
7160,
520,
353,
29455,
3084,
9,
627,
262,
3270,
262,
503,
1045,
284,
503,
14097,
1049,
15,
7,
29455,
3084,
8,
611,
220,
12676,
914,
13,
15,
198,
262,
674,
3152,
64048,
11,
9038,
198,
262,
296,
4404,
284,
2660,
71517,
17,
13584,
7,
18520,
13,
21618,
605,
3694,
3909,
220,
19192,
1484,
13,
16193,
966,
353,
503,
1045,
18722,
3909,
220,
15,
13,
931,
9992,
24,
353,
503,
1045,
353,
503,
1045,
18722,
3909,
220,
15,
13,
931,
931,
2166,
353,
503,
1045,
353,
503,
1045,
353,
503,
1045,
340,
262,
674,
3152,
21155,
11,
5367,
198,
262,
326,
62,
15,
284,
220,
11209,
13,
21404,
1774,
489,
220,
6843,
410,
13,
24619,
6069,
353,
503,
1045,
489,
220,
15,
13,
931,
13236,
17,
353,
503,
1045,
353,
503,
1045,
198,
262,
294,
918,
284,
1819,
16,
13,
24579,
5067,
482,
220,
15,
13,
8759,
25528,
353,
503,
1045,
482,
220,
15,
13,
931,
15901,
353,
503,
1045,
353,
503,
1045,
8,
353,
2660,
16719,
1278,
4404,
8,
3694,
1881,
320,
15,
13,
18089,
24242,
482,
220,
15,
13,
931,
4645,
353,
503,
1045,
8,
353,
2660,
16719,
7,
17,
353,
296,
4404,
8,
489,
220,
15,
13,
931,
13754,
353,
2660,
16719,
7,
18,
353,
296,
4404,
1192,
262,
674,
837,
21155,
11,
5367,
198,
262,
326,
565,
284,
326,
62,
15,
489,
294,
918,
198,
262,
471,
2660,
71517,
17,
13584,
2387,
24010,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36,
566,
11696,
292,
21155,
315,
279,
7160,
520,
353,
29455,
3084,
9,
382,
14711,
6075,
512,
755,
7160,
2253,
566,
11696,
292,
80834,
7,
29455,
3084,
997,
262,
4304,
36,
566,
11696,
292,
21155,
315,
279,
7160,
520,
353,
29455,
3084,
9,
627,
262,
3270,
262,
503,
1045,
284,
503,
14097,
1049,
15,
7,
29455,
3084,
8,
611,
220,
12676,
914,
13,
15,
198,
262,
674,
3152,
64048,
11,
9038,
198,
262,
296,
4404,
284,
2660,
71517,
17,
13584,
7,
18520,
13,
21618,
605,
3694,
3909,
220,
19192,
1484,
13,
16193,
966,
353,
503,
1045,
18722,
3909,
220,
15,
13,
931,
9992,
24,
353,
503,
1045,
353,
503,
1045,
18722,
3909,
220,
15,
13,
931,
931,
2166,
353,
503,
1045,
353,
503,
1045,
353,
503,
1045,
340,
262,
674,
3152,
21155,
11,
5367,
198,
262,
326,
62,
15,
284,
220,
11209,
13,
21404,
1774,
489,
220,
6843,
410,
13,
24619,
6069,
353,
503,
1045,
489,
220,
15,
13,
931,
13236,
17,
353,
503,
1045,
353,
503,
1045,
198,
262,
294,
918,
284,
1819,
16,
13,
24579,
5067,
482,
220,
15,
13,
8759,
25528,
353,
503,
1045,
482,
220,
15,
13,
931,
15901,
353,
503,
1045,
353,
503,
1045,
8,
353,
2660,
16719,
1278,
4404,
8,
3694,
1881,
320,
15,
13,
18089,
24242,
482,
220,
15,
13,
931,
4645,
353,
503,
1045,
8,
353,
2660,
16719,
7,
17,
353,
296,
4404,
8,
489,
220,
15,
13,
931,
13754,
353,
2660,
16719,
7,
18,
353,
296,
4404,
1192,
262,
674,
837,
21155,
11,
5367,
198,
262,
326,
565,
284,
326,
62,
15,
489,
294,
918,
198,
262,
471,
2660,
71517,
17,
13584,
2387,
24010,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
auth0/auth0-python | auth0/v3/authentication/get_token.py | GetToken.refresh_token | def refresh_token(self, client_id, client_secret, refresh_token, grant_type='refresh_token'):
"""Calls oauth/token endpoint with refresh token grant type
Use this endpoint to refresh an access token, using the refresh token you got during authorization.
Args:
grant_type (str): Denotes the flow you're using. For refresh token
use refresh_token
client_id (str): your application's client Id
client_secret (str): your application's client Secret
refresh_token (str): The refresh token returned from the initial token request.
Returns:
access_token, id_token
"""
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'client_secret': client_secret,
'refresh_token': refresh_token,
'grant_type': grant_type
},
headers={'Content-Type': 'application/json'}
) | python | def refresh_token(self, client_id, client_secret, refresh_token, grant_type='refresh_token'):
"""Calls oauth/token endpoint with refresh token grant type
Use this endpoint to refresh an access token, using the refresh token you got during authorization.
Args:
grant_type (str): Denotes the flow you're using. For refresh token
use refresh_token
client_id (str): your application's client Id
client_secret (str): your application's client Secret
refresh_token (str): The refresh token returned from the initial token request.
Returns:
access_token, id_token
"""
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'client_secret': client_secret,
'refresh_token': refresh_token,
'grant_type': grant_type
},
headers={'Content-Type': 'application/json'}
) | [
"def",
"refresh_token",
"(",
"self",
",",
"client_id",
",",
"client_secret",
",",
"refresh_token",
",",
"grant_type",
"=",
"'refresh_token'",
")",
":",
"return",
"self",
".",
"post",
"(",
"'https://{}/oauth/token'",
".",
"format",
"(",
"self",
".",
"domain",
")",
",",
"data",
"=",
"{",
"'client_id'",
":",
"client_id",
",",
"'client_secret'",
":",
"client_secret",
",",
"'refresh_token'",
":",
"refresh_token",
",",
"'grant_type'",
":",
"grant_type",
"}",
",",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
"}",
")"
] | Calls oauth/token endpoint with refresh token grant type
Use this endpoint to refresh an access token, using the refresh token you got during authorization.
Args:
grant_type (str): Denotes the flow you're using. For refresh token
use refresh_token
client_id (str): your application's client Id
client_secret (str): your application's client Secret
refresh_token (str): The refresh token returned from the initial token request.
Returns:
access_token, id_token | [
"Calls",
"oauth",
"/",
"token",
"endpoint",
"with",
"refresh",
"token",
"grant",
"type"
] | train | https://github.com/auth0/auth0-python/blob/34adad3f342226aaaa6071387fa405ab840e5c02/auth0/v3/authentication/get_token.py#L171-L199 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Calls oauth/token endpoint with refresh token grant type
Use this endpoint to refresh an access token, using the refresh token you got during authorization.
Args:
grant_type (str): Denotes the flow you're using. For refresh token
use refresh_token
client_id (str): your application's client Id
client_secret (str): your application's client Secret
refresh_token (str): The refresh token returned from the initial token request.
Returns:
access_token, id_token
### Response:
def refresh_token(self, client_id, client_secret, refresh_token, grant_type='refresh_token'):
"""Calls oauth/token endpoint with refresh token grant type
Use this endpoint to refresh an access token, using the refresh token you got during authorization.
Args:
grant_type (str): Denotes the flow you're using. For refresh token
use refresh_token
client_id (str): your application's client Id
client_secret (str): your application's client Secret
refresh_token (str): The refresh token returned from the initial token request.
Returns:
access_token, id_token
"""
return self.post(
'https://{}/oauth/token'.format(self.domain),
data={
'client_id': client_id,
'client_secret': client_secret,
'refresh_token': refresh_token,
'grant_type': grant_type
},
headers={'Content-Type': 'application/json'}
)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
56392,
47515,
55486,
15233,
449,
10625,
4037,
13500,
955,
271,
286,
5560,
420,
15233,
311,
10625,
459,
2680,
4037,
11,
1701,
279,
10625,
4037,
499,
2751,
2391,
24645,
382,
286,
18161,
512,
310,
13500,
1857,
320,
496,
1680,
9973,
6429,
279,
6530,
499,
2351,
1701,
13,
1789,
10625,
4037,
198,
310,
1005,
10625,
6594,
271,
310,
3016,
851,
320,
496,
1680,
701,
3851,
596,
3016,
5336,
271,
310,
3016,
22729,
320,
496,
1680,
701,
3851,
596,
3016,
8769,
271,
310,
10625,
6594,
320,
496,
1680,
578,
10625,
4037,
6052,
505,
279,
2926,
4037,
1715,
382,
286,
5295,
512,
310,
2680,
6594,
11,
887,
6594,
271,
14711,
6075,
512,
755,
10625,
6594,
1214,
11,
3016,
851,
11,
3016,
22729,
11,
10625,
6594,
11,
13500,
1857,
1151,
17611,
6594,
11290,
286,
4304,
56392,
47515,
55486,
15233,
449,
10625,
4037,
13500,
955,
271,
286,
5560,
420,
15233,
311,
10625,
459,
2680,
4037,
11,
1701,
279,
10625,
4037,
499,
2751,
2391,
24645,
382,
286,
18161,
512,
310,
13500,
1857,
320,
496,
1680,
9973,
6429,
279,
6530,
499,
2351,
1701,
13,
1789,
10625,
4037,
198,
310,
1005,
10625,
6594,
271,
310,
3016,
851,
320,
496,
1680,
701,
3851,
596,
3016,
5336,
271,
310,
3016,
22729,
320,
496,
1680,
701,
3851,
596,
3016,
8769,
271,
310,
10625,
6594,
320,
496,
1680,
578,
10625,
4037,
6052,
505,
279,
2926,
4037,
1715,
382,
286,
5295,
512,
310,
2680,
6594,
11,
887,
6594,
198,
286,
12713,
286,
471,
659,
6679,
1021,
310,
364,
2485,
82876,
4572,
35463,
55486,
4527,
2293,
1214,
11248,
1350,
310,
828,
18013,
394,
364,
3045,
851,
1232,
3016,
851,
345,
394,
364,
3045,
22729,
1232,
3016,
22729,
345,
394,
364,
17611,
6594,
1232,
10625,
6594,
345,
394,
364,
52727,
1857,
1232,
13500,
1857,
198,
310,
1173,
310,
7247,
13150,
2831,
11038,
1232,
364,
5242,
9108,
16823,
286,
1763,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
56392,
47515,
55486,
15233,
449,
10625,
4037,
13500,
955,
271,
286,
5560,
420,
15233,
311,
10625,
459,
2680,
4037,
11,
1701,
279,
10625,
4037,
499,
2751,
2391,
24645,
382,
286,
18161,
512,
310,
13500,
1857,
320,
496,
1680,
9973,
6429,
279,
6530,
499,
2351,
1701,
13,
1789,
10625,
4037,
198,
310,
1005,
10625,
6594,
271,
310,
3016,
851,
320,
496,
1680,
701,
3851,
596,
3016,
5336,
271,
310,
3016,
22729,
320,
496,
1680,
701,
3851,
596,
3016,
8769,
271,
310,
10625,
6594,
320,
496,
1680,
578,
10625,
4037,
6052,
505,
279,
2926,
4037,
1715,
382,
286,
5295,
512,
310,
2680,
6594,
11,
887,
6594,
271,
14711,
6075,
512,
755,
10625,
6594,
1214,
11,
3016,
851,
11,
3016,
22729,
11,
10625,
6594,
11,
13500,
1857,
1151,
17611,
6594,
11290,
286,
4304,
56392,
47515,
55486,
15233,
449,
10625,
4037,
13500,
955,
271,
286,
5560,
420,
15233,
311,
10625,
459,
2680,
4037,
11,
1701,
279,
10625,
4037,
499,
2751,
2391,
24645,
382,
286,
18161,
512,
310,
13500,
1857,
320,
496,
1680,
9973,
6429,
279,
6530,
499,
2351,
1701,
13,
1789,
10625,
4037,
198,
310,
1005,
10625,
6594,
271,
310,
3016,
851,
320,
496,
1680,
701,
3851,
596,
3016,
5336,
271,
310,
3016,
22729,
320,
496,
1680,
701,
3851,
596,
3016,
8769,
271,
310,
10625,
6594,
320,
496,
1680,
578,
10625,
4037,
6052,
505,
279,
2926,
4037,
1715,
382,
286,
5295,
512,
310,
2680,
6594,
11,
887,
6594,
198,
286,
12713,
286,
471,
659,
6679,
1021,
310,
364,
2485,
82876,
4572,
35463,
55486,
4527,
2293,
1214,
11248,
1350,
310,
828,
18013,
394,
364,
3045,
851,
1232,
3016,
851,
345,
394,
364,
3045,
22729,
1232,
3016,
22729,
345,
394,
364,
17611,
6594,
1232,
10625,
6594,
345,
394,
364,
52727,
1857,
1232,
13500,
1857,
198,
310,
1173,
310,
7247,
13150,
2831,
11038,
1232,
364,
5242,
9108,
16823,
286,
1763,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
bambinos/bambi | bambi/diagnostics.py | effective_n | def effective_n(mcmc):
"""
Args:
mcmc (MCMCResults): Pre-sliced MCMC samples to compute diagnostics for.
"""
if mcmc.n_chains < 2:
raise ValueError(
'Calculation of effective sample size requires multiple chains '
'of the same length.')
def get_neff(x):
"""Compute the effective sample size for a 2D array."""
trace_value = x.T
nchain, n_samples = trace_value.shape
acov = np.asarray([autocov(trace_value[chain]) for chain in range(nchain)])
chain_mean = trace_value.mean(axis=1)
chain_var = acov[:, 0] * n_samples / (n_samples - 1.)
acov_t = acov[:, 1] * n_samples / (n_samples - 1.)
mean_var = np.mean(chain_var)
var_plus = mean_var * (n_samples - 1.) / n_samples
var_plus += np.var(chain_mean, ddof=1)
rho_hat_t = np.zeros(n_samples)
rho_hat_even = 1.
rho_hat_t[0] = rho_hat_even
rho_hat_odd = 1. - (mean_var - np.mean(acov_t)) / var_plus
rho_hat_t[1] = rho_hat_odd
# Geyer's initial positive sequence
max_t = 1
t = 1
while t < (n_samples - 2) and (rho_hat_even + rho_hat_odd) >= 0.:
rho_hat_even = 1. - (mean_var - np.mean(acov[:, t + 1])) / var_plus
rho_hat_odd = 1. - (mean_var - np.mean(acov[:, t + 2])) / var_plus
if (rho_hat_even + rho_hat_odd) >= 0:
rho_hat_t[t + 1] = rho_hat_even
rho_hat_t[t + 2] = rho_hat_odd
max_t = t + 2
t += 2
# Geyer's initial monotone sequence
t = 3
while t <= max_t - 2:
if (rho_hat_t[t + 1] + rho_hat_t[t + 2]) > (rho_hat_t[t - 1] + rho_hat_t[t]):
rho_hat_t[t + 1] = (rho_hat_t[t - 1] + rho_hat_t[t]) / 2.
rho_hat_t[t + 2] = rho_hat_t[t + 1]
t += 2
ess = nchain * n_samples
ess = ess / (-1. + 2. * np.sum(rho_hat_t))
return ess
nvar = mcmc.data.shape[-1]
n_eff = [get_neff(mcmc.data[:, :, i]) for i in range(nvar)]
return pd.DataFrame({'effective_n': n_eff}, index=mcmc.levels) | python | def effective_n(mcmc):
"""
Args:
mcmc (MCMCResults): Pre-sliced MCMC samples to compute diagnostics for.
"""
if mcmc.n_chains < 2:
raise ValueError(
'Calculation of effective sample size requires multiple chains '
'of the same length.')
def get_neff(x):
"""Compute the effective sample size for a 2D array."""
trace_value = x.T
nchain, n_samples = trace_value.shape
acov = np.asarray([autocov(trace_value[chain]) for chain in range(nchain)])
chain_mean = trace_value.mean(axis=1)
chain_var = acov[:, 0] * n_samples / (n_samples - 1.)
acov_t = acov[:, 1] * n_samples / (n_samples - 1.)
mean_var = np.mean(chain_var)
var_plus = mean_var * (n_samples - 1.) / n_samples
var_plus += np.var(chain_mean, ddof=1)
rho_hat_t = np.zeros(n_samples)
rho_hat_even = 1.
rho_hat_t[0] = rho_hat_even
rho_hat_odd = 1. - (mean_var - np.mean(acov_t)) / var_plus
rho_hat_t[1] = rho_hat_odd
# Geyer's initial positive sequence
max_t = 1
t = 1
while t < (n_samples - 2) and (rho_hat_even + rho_hat_odd) >= 0.:
rho_hat_even = 1. - (mean_var - np.mean(acov[:, t + 1])) / var_plus
rho_hat_odd = 1. - (mean_var - np.mean(acov[:, t + 2])) / var_plus
if (rho_hat_even + rho_hat_odd) >= 0:
rho_hat_t[t + 1] = rho_hat_even
rho_hat_t[t + 2] = rho_hat_odd
max_t = t + 2
t += 2
# Geyer's initial monotone sequence
t = 3
while t <= max_t - 2:
if (rho_hat_t[t + 1] + rho_hat_t[t + 2]) > (rho_hat_t[t - 1] + rho_hat_t[t]):
rho_hat_t[t + 1] = (rho_hat_t[t - 1] + rho_hat_t[t]) / 2.
rho_hat_t[t + 2] = rho_hat_t[t + 1]
t += 2
ess = nchain * n_samples
ess = ess / (-1. + 2. * np.sum(rho_hat_t))
return ess
nvar = mcmc.data.shape[-1]
n_eff = [get_neff(mcmc.data[:, :, i]) for i in range(nvar)]
return pd.DataFrame({'effective_n': n_eff}, index=mcmc.levels) | [
"def",
"effective_n",
"(",
"mcmc",
")",
":",
"if",
"mcmc",
".",
"n_chains",
"<",
"2",
":",
"raise",
"ValueError",
"(",
"'Calculation of effective sample size requires multiple chains '",
"'of the same length.'",
")",
"def",
"get_neff",
"(",
"x",
")",
":",
"\"\"\"Compute the effective sample size for a 2D array.\"\"\"",
"trace_value",
"=",
"x",
".",
"T",
"nchain",
",",
"n_samples",
"=",
"trace_value",
".",
"shape",
"acov",
"=",
"np",
".",
"asarray",
"(",
"[",
"autocov",
"(",
"trace_value",
"[",
"chain",
"]",
")",
"for",
"chain",
"in",
"range",
"(",
"nchain",
")",
"]",
")",
"chain_mean",
"=",
"trace_value",
".",
"mean",
"(",
"axis",
"=",
"1",
")",
"chain_var",
"=",
"acov",
"[",
":",
",",
"0",
"]",
"*",
"n_samples",
"/",
"(",
"n_samples",
"-",
"1.",
")",
"acov_t",
"=",
"acov",
"[",
":",
",",
"1",
"]",
"*",
"n_samples",
"/",
"(",
"n_samples",
"-",
"1.",
")",
"mean_var",
"=",
"np",
".",
"mean",
"(",
"chain_var",
")",
"var_plus",
"=",
"mean_var",
"*",
"(",
"n_samples",
"-",
"1.",
")",
"/",
"n_samples",
"var_plus",
"+=",
"np",
".",
"var",
"(",
"chain_mean",
",",
"ddof",
"=",
"1",
")",
"rho_hat_t",
"=",
"np",
".",
"zeros",
"(",
"n_samples",
")",
"rho_hat_even",
"=",
"1.",
"rho_hat_t",
"[",
"0",
"]",
"=",
"rho_hat_even",
"rho_hat_odd",
"=",
"1.",
"-",
"(",
"mean_var",
"-",
"np",
".",
"mean",
"(",
"acov_t",
")",
")",
"/",
"var_plus",
"rho_hat_t",
"[",
"1",
"]",
"=",
"rho_hat_odd",
"# Geyer's initial positive sequence",
"max_t",
"=",
"1",
"t",
"=",
"1",
"while",
"t",
"<",
"(",
"n_samples",
"-",
"2",
")",
"and",
"(",
"rho_hat_even",
"+",
"rho_hat_odd",
")",
">=",
"0.",
":",
"rho_hat_even",
"=",
"1.",
"-",
"(",
"mean_var",
"-",
"np",
".",
"mean",
"(",
"acov",
"[",
":",
",",
"t",
"+",
"1",
"]",
")",
")",
"/",
"var_plus",
"rho_hat_odd",
"=",
"1.",
"-",
"(",
"mean_var",
"-",
"np",
".",
"mean",
"(",
"acov",
"[",
":",
",",
"t",
"+",
"2",
"]",
")",
")",
"/",
"var_plus",
"if",
"(",
"rho_hat_even",
"+",
"rho_hat_odd",
")",
">=",
"0",
":",
"rho_hat_t",
"[",
"t",
"+",
"1",
"]",
"=",
"rho_hat_even",
"rho_hat_t",
"[",
"t",
"+",
"2",
"]",
"=",
"rho_hat_odd",
"max_t",
"=",
"t",
"+",
"2",
"t",
"+=",
"2",
"# Geyer's initial monotone sequence",
"t",
"=",
"3",
"while",
"t",
"<=",
"max_t",
"-",
"2",
":",
"if",
"(",
"rho_hat_t",
"[",
"t",
"+",
"1",
"]",
"+",
"rho_hat_t",
"[",
"t",
"+",
"2",
"]",
")",
">",
"(",
"rho_hat_t",
"[",
"t",
"-",
"1",
"]",
"+",
"rho_hat_t",
"[",
"t",
"]",
")",
":",
"rho_hat_t",
"[",
"t",
"+",
"1",
"]",
"=",
"(",
"rho_hat_t",
"[",
"t",
"-",
"1",
"]",
"+",
"rho_hat_t",
"[",
"t",
"]",
")",
"/",
"2.",
"rho_hat_t",
"[",
"t",
"+",
"2",
"]",
"=",
"rho_hat_t",
"[",
"t",
"+",
"1",
"]",
"t",
"+=",
"2",
"ess",
"=",
"nchain",
"*",
"n_samples",
"ess",
"=",
"ess",
"/",
"(",
"-",
"1.",
"+",
"2.",
"*",
"np",
".",
"sum",
"(",
"rho_hat_t",
")",
")",
"return",
"ess",
"nvar",
"=",
"mcmc",
".",
"data",
".",
"shape",
"[",
"-",
"1",
"]",
"n_eff",
"=",
"[",
"get_neff",
"(",
"mcmc",
".",
"data",
"[",
":",
",",
":",
",",
"i",
"]",
")",
"for",
"i",
"in",
"range",
"(",
"nvar",
")",
"]",
"return",
"pd",
".",
"DataFrame",
"(",
"{",
"'effective_n'",
":",
"n_eff",
"}",
",",
"index",
"=",
"mcmc",
".",
"levels",
")"
] | Args:
mcmc (MCMCResults): Pre-sliced MCMC samples to compute diagnostics for. | [
"Args",
":",
"mcmc",
"(",
"MCMCResults",
")",
":",
"Pre",
"-",
"sliced",
"MCMC",
"samples",
"to",
"compute",
"diagnostics",
"for",
"."
] | train | https://github.com/bambinos/bambi/blob/b4a0ced917968bb99ca20915317417d708387946/bambi/diagnostics.py#L78-L134 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Args:
mcmc (MCMCResults): Pre-sliced MCMC samples to compute diagnostics for.
### Response:
def effective_n(mcmc):
"""
Args:
mcmc (MCMCResults): Pre-sliced MCMC samples to compute diagnostics for.
"""
if mcmc.n_chains < 2:
raise ValueError(
'Calculation of effective sample size requires multiple chains '
'of the same length.')
def get_neff(x):
"""Compute the effective sample size for a 2D array."""
trace_value = x.T
nchain, n_samples = trace_value.shape
acov = np.asarray([autocov(trace_value[chain]) for chain in range(nchain)])
chain_mean = trace_value.mean(axis=1)
chain_var = acov[:, 0] * n_samples / (n_samples - 1.)
acov_t = acov[:, 1] * n_samples / (n_samples - 1.)
mean_var = np.mean(chain_var)
var_plus = mean_var * (n_samples - 1.) / n_samples
var_plus += np.var(chain_mean, ddof=1)
rho_hat_t = np.zeros(n_samples)
rho_hat_even = 1.
rho_hat_t[0] = rho_hat_even
rho_hat_odd = 1. - (mean_var - np.mean(acov_t)) / var_plus
rho_hat_t[1] = rho_hat_odd
# Geyer's initial positive sequence
max_t = 1
t = 1
while t < (n_samples - 2) and (rho_hat_even + rho_hat_odd) >= 0.:
rho_hat_even = 1. - (mean_var - np.mean(acov[:, t + 1])) / var_plus
rho_hat_odd = 1. - (mean_var - np.mean(acov[:, t + 2])) / var_plus
if (rho_hat_even + rho_hat_odd) >= 0:
rho_hat_t[t + 1] = rho_hat_even
rho_hat_t[t + 2] = rho_hat_odd
max_t = t + 2
t += 2
# Geyer's initial monotone sequence
t = 3
while t <= max_t - 2:
if (rho_hat_t[t + 1] + rho_hat_t[t + 2]) > (rho_hat_t[t - 1] + rho_hat_t[t]):
rho_hat_t[t + 1] = (rho_hat_t[t - 1] + rho_hat_t[t]) / 2.
rho_hat_t[t + 2] = rho_hat_t[t + 1]
t += 2
ess = nchain * n_samples
ess = ess / (-1. + 2. * np.sum(rho_hat_t))
return ess
nvar = mcmc.data.shape[-1]
n_eff = [get_neff(mcmc.data[:, :, i]) for i in range(nvar)]
return pd.DataFrame({'effective_n': n_eff}, index=mcmc.levels)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4209,
512,
286,
296,
95966,
320,
44,
10190,
34,
10001,
1680,
5075,
1355,
75730,
386,
10190,
34,
10688,
311,
12849,
50518,
369,
382,
14711,
6075,
512,
755,
7524,
1107,
1278,
95966,
997,
262,
3270,
262,
18161,
512,
286,
296,
95966,
320,
44,
10190,
34,
10001,
1680,
5075,
1355,
75730,
386,
10190,
34,
10688,
311,
12849,
50518,
369,
627,
262,
12713,
262,
422,
296,
95966,
1276,
4231,
1771,
366,
220,
17,
512,
286,
4933,
15764,
1021,
310,
364,
48268,
2987,
315,
7524,
6205,
1404,
7612,
5361,
27271,
8044,
310,
364,
1073,
279,
1890,
3160,
49420,
262,
711,
636,
14250,
544,
2120,
997,
286,
4304,
47354,
279,
7524,
6205,
1404,
369,
264,
220,
17,
35,
1358,
14781,
286,
11917,
3220,
284,
865,
844,
198,
286,
308,
8995,
11,
308,
18801,
284,
11917,
3220,
7201,
271,
286,
1645,
869,
284,
2660,
39178,
2625,
2784,
511,
869,
56558,
3220,
58,
8995,
2526,
369,
8957,
304,
2134,
1471,
8995,
68964,
286,
8957,
17363,
284,
11917,
3220,
19231,
32984,
28,
16,
340,
286,
8957,
4715,
284,
1645,
869,
9821,
220,
15,
60,
353,
308,
18801,
611,
320,
77,
18801,
482,
220,
16,
29275,
286,
1645,
869,
530,
284,
1645,
869,
9821,
220,
16,
60,
353,
308,
18801,
611,
320,
77,
18801,
482,
220,
16,
29275,
286,
3152,
4715,
284,
2660,
19231,
63691,
4715,
340,
286,
767,
29143,
284,
3152,
4715,
353,
320,
77,
18801,
482,
220,
16,
6266,
611,
308,
18801,
198,
286,
767,
29143,
1447,
2660,
20096,
63691,
17363,
11,
20221,
1073,
28,
16,
696,
286,
32481,
40873,
530,
284,
2660,
13064,
1471,
18801,
340,
286,
32481,
40873,
69447,
284,
220,
16,
627,
286,
32481,
40873,
530,
58,
15,
60,
284,
32481,
40873,
69447,
198,
286,
32481,
40873,
75768,
284,
220,
16,
13,
482,
320,
14622,
4715,
482,
2660,
19231,
49496,
869,
530,
595,
611,
767,
29143,
198,
286,
32481,
40873,
530,
58,
16,
60,
284,
32481,
40873,
75768,
198,
286,
674,
480,
35472,
596,
2926,
6928,
8668,
198,
286,
1973,
530,
284,
220,
16,
198,
286,
259,
284,
220,
16,
198,
286,
1418,
259,
366,
320,
77,
18801,
482,
220,
17,
8,
323,
320,
41422,
40873,
69447,
489,
32481,
40873,
75768,
8,
2669,
220,
15,
13,
512,
310,
32481,
40873,
69447,
284,
220,
16,
13,
482,
320,
14622,
4715,
482,
2660,
19231,
49496,
869,
9821,
259,
489,
220,
16,
9549,
611,
767,
29143,
198,
310,
32481,
40873,
75768,
284,
220,
16,
13,
482,
320,
14622,
4715,
482,
2660,
19231,
49496,
869,
9821,
259,
489,
220,
17,
9549,
611,
767,
29143,
198,
310,
422,
320,
41422,
40873,
69447,
489,
32481,
40873,
75768,
8,
2669,
220,
15,
512,
394,
32481,
40873,
530,
14527,
489,
220,
16,
60,
284,
32481,
40873,
69447,
198,
394,
32481,
40873,
530,
14527,
489,
220,
17,
60,
284,
32481,
40873,
75768,
198,
310,
1973,
530,
284,
259,
489,
220,
17,
198,
310,
259,
1447,
220
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4209,
512,
286,
296,
95966,
320,
44,
10190,
34,
10001,
1680,
5075,
1355,
75730,
386,
10190,
34,
10688,
311,
12849,
50518,
369,
382,
14711,
6075,
512,
755,
7524,
1107,
1278,
95966,
997,
262,
3270,
262,
18161,
512,
286,
296,
95966,
320,
44,
10190,
34,
10001,
1680,
5075,
1355,
75730,
386,
10190,
34,
10688,
311,
12849,
50518,
369,
627,
262,
12713,
262,
422,
296,
95966,
1276,
4231,
1771,
366,
220,
17,
512,
286,
4933,
15764,
1021,
310,
364,
48268,
2987,
315,
7524,
6205,
1404,
7612,
5361,
27271,
8044,
310,
364,
1073,
279,
1890,
3160,
49420,
262,
711,
636,
14250,
544,
2120,
997,
286,
4304,
47354,
279,
7524,
6205,
1404,
369,
264,
220,
17,
35,
1358,
14781,
286,
11917,
3220,
284,
865,
844,
198,
286,
308,
8995,
11,
308,
18801,
284,
11917,
3220,
7201,
271,
286,
1645,
869,
284,
2660,
39178,
2625,
2784,
511,
869,
56558,
3220,
58,
8995,
2526,
369,
8957,
304,
2134,
1471,
8995,
68964,
286,
8957,
17363,
284,
11917,
3220,
19231,
32984,
28,
16,
340,
286,
8957,
4715,
284,
1645,
869,
9821,
220,
15,
60,
353,
308,
18801,
611,
320,
77,
18801,
482,
220,
16,
29275,
286,
1645,
869,
530,
284,
1645,
869,
9821,
220,
16,
60,
353,
308,
18801,
611,
320,
77,
18801,
482,
220,
16,
29275,
286,
3152,
4715,
284,
2660,
19231,
63691,
4715,
340,
286,
767,
29143,
284,
3152,
4715,
353,
320,
77,
18801,
482,
220,
16,
6266,
611,
308,
18801,
198,
286,
767,
29143,
1447,
2660,
20096,
63691,
17363,
11,
20221,
1073,
28,
16,
696,
286,
32481,
40873,
530,
284,
2660,
13064,
1471,
18801,
340,
286,
32481,
40873,
69447,
284,
220,
16,
627,
286,
32481,
40873,
530,
58,
15,
60,
284,
32481,
40873,
69447,
198,
286,
32481,
40873,
75768,
284,
220,
16,
13,
482,
320,
14622,
4715,
482,
2660,
19231,
49496,
869,
530,
595,
611,
767,
29143,
198,
286,
32481,
40873,
530,
58,
16,
60,
284,
32481,
40873,
75768,
198,
286,
674,
480,
35472,
596,
2926,
6928,
8668,
198,
286,
1973,
530,
284,
220,
16,
198,
286,
259,
284,
220,
16,
198,
286,
1418,
259,
366,
320,
77,
18801,
482,
220,
17,
8,
323,
320,
41422,
40873,
69447,
489,
32481,
40873,
75768,
8,
2669,
220,
15,
13,
512,
310,
32481,
40873,
69447,
284,
220,
16,
13,
482,
320,
14622,
4715,
482,
2660,
19231,
49496,
869,
9821,
259,
489,
220,
16,
9549,
611,
767,
29143,
198,
310,
32481,
40873,
75768,
284,
220,
16,
13,
482,
320,
14622,
4715,
482,
2660,
19231,
49496,
869,
9821,
259,
489,
220,
17,
9549,
611,
767,
29143,
198,
310,
422,
320,
41422,
40873,
69447,
489,
32481,
40873,
75768,
8,
2669,
220,
15,
512,
394,
32481,
40873,
530,
14527,
489,
220,
16,
60,
284,
32481,
40873,
69447,
198,
394,
32481,
40873,
530,
14527,
489,
220,
17,
60,
284,
32481,
40873,
75768,
198,
310,
1973,
530,
284,
259,
489,
220,
17,
198,
310,
259,
1447,
220
] |
signalfx/signalfx-python | signalfx/signalflow/ws.py | WebSocketTransport.closed | def closed(self, code, reason=None):
"""Handler called when the WebSocket is closed. Status code 1000
denotes a normal close; all others are errors."""
if code != 1000:
self._error = errors.SignalFlowException(code, reason)
_logger.info('Lost WebSocket connection with %s (%s: %s).',
self, code, reason)
for c in self._channels.values():
c.offer(WebSocketComputationChannel.END_SENTINEL)
self._channels.clear()
with self._connection_cv:
self._connected = False
self._connection_cv.notify() | python | def closed(self, code, reason=None):
"""Handler called when the WebSocket is closed. Status code 1000
denotes a normal close; all others are errors."""
if code != 1000:
self._error = errors.SignalFlowException(code, reason)
_logger.info('Lost WebSocket connection with %s (%s: %s).',
self, code, reason)
for c in self._channels.values():
c.offer(WebSocketComputationChannel.END_SENTINEL)
self._channels.clear()
with self._connection_cv:
self._connected = False
self._connection_cv.notify() | [
"def",
"closed",
"(",
"self",
",",
"code",
",",
"reason",
"=",
"None",
")",
":",
"if",
"code",
"!=",
"1000",
":",
"self",
".",
"_error",
"=",
"errors",
".",
"SignalFlowException",
"(",
"code",
",",
"reason",
")",
"_logger",
".",
"info",
"(",
"'Lost WebSocket connection with %s (%s: %s).'",
",",
"self",
",",
"code",
",",
"reason",
")",
"for",
"c",
"in",
"self",
".",
"_channels",
".",
"values",
"(",
")",
":",
"c",
".",
"offer",
"(",
"WebSocketComputationChannel",
".",
"END_SENTINEL",
")",
"self",
".",
"_channels",
".",
"clear",
"(",
")",
"with",
"self",
".",
"_connection_cv",
":",
"self",
".",
"_connected",
"=",
"False",
"self",
".",
"_connection_cv",
".",
"notify",
"(",
")"
] | Handler called when the WebSocket is closed. Status code 1000
denotes a normal close; all others are errors. | [
"Handler",
"called",
"when",
"the",
"WebSocket",
"is",
"closed",
".",
"Status",
"code",
"1000",
"denotes",
"a",
"normal",
"close",
";",
"all",
"others",
"are",
"errors",
"."
] | train | https://github.com/signalfx/signalfx-python/blob/650eb9a2b301bcc795e4e3a8c031574ade69849d/signalfx/signalflow/ws.py#L276-L288 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Handler called when the WebSocket is closed. Status code 1000
denotes a normal close; all others are errors.
### Response:
def closed(self, code, reason=None):
"""Handler called when the WebSocket is closed. Status code 1000
denotes a normal close; all others are errors."""
if code != 1000:
self._error = errors.SignalFlowException(code, reason)
_logger.info('Lost WebSocket connection with %s (%s: %s).',
self, code, reason)
for c in self._channels.values():
c.offer(WebSocketComputationChannel.END_SENTINEL)
self._channels.clear()
with self._connection_cv:
self._connected = False
self._connection_cv.notify()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
3126,
2663,
994,
279,
48142,
374,
8036,
13,
8266,
2082,
220,
1041,
15,
198,
286,
72214,
264,
4725,
3345,
26,
682,
3885,
527,
6103,
382,
14711,
6075,
512,
755,
8036,
1214,
11,
2082,
11,
2944,
5980,
997,
286,
4304,
3126,
2663,
994,
279,
48142,
374,
8036,
13,
8266,
2082,
220,
1041,
15,
198,
286,
72214,
264,
4725,
3345,
26,
682,
3885,
527,
6103,
14781,
286,
422,
2082,
976,
220,
1041,
15,
512,
310,
659,
1462,
850,
284,
6103,
76769,
19410,
1378,
16221,
11,
2944,
340,
310,
721,
9985,
5506,
493,
48353,
48142,
3717,
449,
1034,
82,
13764,
82,
25,
1034,
82,
570,
756,
5218,
659,
11,
2082,
11,
2944,
340,
310,
369,
272,
304,
659,
1462,
33525,
10883,
4019,
394,
272,
62741,
7,
62338,
1110,
13623,
9826,
56598,
73763,
691,
2818,
340,
286,
659,
1462,
33525,
7578,
746,
286,
449,
659,
1462,
7898,
44333,
512,
310,
659,
1462,
15647,
284,
3641,
198,
310,
659,
1462,
7898,
44333,
25708,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
3126,
2663,
994,
279,
48142,
374,
8036,
13,
8266,
2082,
220,
1041,
15,
198,
286,
72214,
264,
4725,
3345,
26,
682,
3885,
527,
6103,
382,
14711,
6075,
512,
755,
8036,
1214,
11,
2082,
11,
2944,
5980,
997,
286,
4304,
3126,
2663,
994,
279,
48142,
374,
8036,
13,
8266,
2082,
220,
1041,
15,
198,
286,
72214,
264,
4725,
3345,
26,
682,
3885,
527,
6103,
14781,
286,
422,
2082,
976,
220,
1041,
15,
512,
310,
659,
1462,
850,
284,
6103,
76769,
19410,
1378,
16221,
11,
2944,
340,
310,
721,
9985,
5506,
493,
48353,
48142,
3717,
449,
1034,
82,
13764,
82,
25,
1034,
82,
570,
756,
5218,
659,
11,
2082,
11,
2944,
340,
310,
369,
272,
304,
659,
1462,
33525,
10883,
4019,
394,
272,
62741,
7,
62338,
1110,
13623,
9826,
56598,
73763,
691,
2818,
340,
286,
659,
1462,
33525,
7578,
746,
286,
449,
659,
1462,
7898,
44333,
512,
310,
659,
1462,
15647,
284,
3641,
198,
310,
659,
1462,
7898,
44333,
25708,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
SwissDataScienceCenter/renku-python | renku/models/_tabulate.py | tabulate | def tabulate(collection, headers, datetime_fmt='%Y-%m-%d %H:%M:%S', **kwargs):
"""Pretty-print a collection."""
if isinstance(headers, dict):
attrs = headers.keys()
# if mapping is not specified keep original
names = [
key if value is None else value for key, value in headers.items()
]
else:
attrs = names = headers
table = [(
format_cell(cell, datetime_fmt=datetime_fmt)
for cell in attrgetter(*attrs)(c)
) for c in collection]
return tblte(table, headers=[h.upper() for h in names], **kwargs) | python | def tabulate(collection, headers, datetime_fmt='%Y-%m-%d %H:%M:%S', **kwargs):
"""Pretty-print a collection."""
if isinstance(headers, dict):
attrs = headers.keys()
# if mapping is not specified keep original
names = [
key if value is None else value for key, value in headers.items()
]
else:
attrs = names = headers
table = [(
format_cell(cell, datetime_fmt=datetime_fmt)
for cell in attrgetter(*attrs)(c)
) for c in collection]
return tblte(table, headers=[h.upper() for h in names], **kwargs) | [
"def",
"tabulate",
"(",
"collection",
",",
"headers",
",",
"datetime_fmt",
"=",
"'%Y-%m-%d %H:%M:%S'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"headers",
",",
"dict",
")",
":",
"attrs",
"=",
"headers",
".",
"keys",
"(",
")",
"# if mapping is not specified keep original",
"names",
"=",
"[",
"key",
"if",
"value",
"is",
"None",
"else",
"value",
"for",
"key",
",",
"value",
"in",
"headers",
".",
"items",
"(",
")",
"]",
"else",
":",
"attrs",
"=",
"names",
"=",
"headers",
"table",
"=",
"[",
"(",
"format_cell",
"(",
"cell",
",",
"datetime_fmt",
"=",
"datetime_fmt",
")",
"for",
"cell",
"in",
"attrgetter",
"(",
"*",
"attrs",
")",
"(",
"c",
")",
")",
"for",
"c",
"in",
"collection",
"]",
"return",
"tblte",
"(",
"table",
",",
"headers",
"=",
"[",
"h",
".",
"upper",
"(",
")",
"for",
"h",
"in",
"names",
"]",
",",
"*",
"*",
"kwargs",
")"
] | Pretty-print a collection. | [
"Pretty",
"-",
"print",
"a",
"collection",
"."
] | train | https://github.com/SwissDataScienceCenter/renku-python/blob/691644d695b055a01e0ca22b2620e55bbd928c0d/renku/models/_tabulate.py#L33-L47 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Pretty-print a collection.
### Response:
def tabulate(collection, headers, datetime_fmt='%Y-%m-%d %H:%M:%S', **kwargs):
"""Pretty-print a collection."""
if isinstance(headers, dict):
attrs = headers.keys()
# if mapping is not specified keep original
names = [
key if value is None else value for key, value in headers.items()
]
else:
attrs = names = headers
table = [(
format_cell(cell, datetime_fmt=datetime_fmt)
for cell in attrgetter(*attrs)(c)
) for c in collection]
return tblte(table, headers=[h.upper() for h in names], **kwargs)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
53040,
43245,
264,
4526,
382,
14711,
6075,
512,
755,
5769,
6468,
36966,
11,
7247,
11,
9050,
39228,
42882,
56,
11316,
76,
11316,
67,
1034,
39,
7685,
44,
7685,
50,
518,
3146,
9872,
997,
262,
4304,
53040,
43245,
264,
4526,
14781,
262,
422,
11656,
55127,
11,
6587,
997,
286,
16602,
284,
7247,
9301,
746,
286,
674,
422,
13021,
374,
539,
5300,
2567,
4113,
198,
286,
5144,
284,
2330,
310,
1401,
422,
907,
374,
2290,
775,
907,
369,
1401,
11,
907,
304,
7247,
9812,
746,
286,
5243,
262,
775,
512,
286,
16602,
284,
5144,
284,
7247,
198,
262,
2007,
284,
510,
1021,
286,
3645,
17061,
23521,
11,
9050,
39228,
57849,
39228,
340,
286,
369,
2849,
304,
6510,
53991,
4163,
21101,
2432,
66,
340,
262,
883,
369,
272,
304,
4526,
933,
262,
471,
21862,
668,
16138,
11,
7247,
5941,
71,
34764,
368,
369,
305,
304,
5144,
1145,
3146,
9872,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0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
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
53040,
43245,
264,
4526,
382,
14711,
6075,
512,
755,
5769,
6468,
36966,
11,
7247,
11,
9050,
39228,
42882,
56,
11316,
76,
11316,
67,
1034,
39,
7685,
44,
7685,
50,
518,
3146,
9872,
997,
262,
4304,
53040,
43245,
264,
4526,
14781,
262,
422,
11656,
55127,
11,
6587,
997,
286,
16602,
284,
7247,
9301,
746,
286,
674,
422,
13021,
374,
539,
5300,
2567,
4113,
198,
286,
5144,
284,
2330,
310,
1401,
422,
907,
374,
2290,
775,
907,
369,
1401,
11,
907,
304,
7247,
9812,
746,
286,
5243,
262,
775,
512,
286,
16602,
284,
5144,
284,
7247,
198,
262,
2007,
284,
510,
1021,
286,
3645,
17061,
23521,
11,
9050,
39228,
57849,
39228,
340,
286,
369,
2849,
304,
6510,
53991,
4163,
21101,
2432,
66,
340,
262,
883,
369,
272,
304,
4526,
933,
262,
471,
21862,
668,
16138,
11,
7247,
5941,
71,
34764,
368,
369,
305,
304,
5144,
1145,
3146,
9872,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
robhowley/nhlscrapi | nhlscrapi/games/events.py | EventFactory.Create | def Create(event_type):
"""
Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`.
:param event_type: number for type of event
:returns: constructed event corresponding to ``event_type``
:rtype: :py:class:`.Event`
"""
if event_type in EventType.Name:
# unknown event type gets base class
if EventType.Name[event_type] == Event.__name__:
return Event()
else:
# instantiate Event subclass with same name as EventType name
return [t for t in EventFactory.event_list if t.__name__ == EventType.Name[event_type]][0]()
else:
raise TypeError("EventFactory.Create: Invalid EventType") | python | def Create(event_type):
"""
Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`.
:param event_type: number for type of event
:returns: constructed event corresponding to ``event_type``
:rtype: :py:class:`.Event`
"""
if event_type in EventType.Name:
# unknown event type gets base class
if EventType.Name[event_type] == Event.__name__:
return Event()
else:
# instantiate Event subclass with same name as EventType name
return [t for t in EventFactory.event_list if t.__name__ == EventType.Name[event_type]][0]()
else:
raise TypeError("EventFactory.Create: Invalid EventType") | [
"def",
"Create",
"(",
"event_type",
")",
":",
"if",
"event_type",
"in",
"EventType",
".",
"Name",
":",
"# unknown event type gets base class",
"if",
"EventType",
".",
"Name",
"[",
"event_type",
"]",
"==",
"Event",
".",
"__name__",
":",
"return",
"Event",
"(",
")",
"else",
":",
"# instantiate Event subclass with same name as EventType name",
"return",
"[",
"t",
"for",
"t",
"in",
"EventFactory",
".",
"event_list",
"if",
"t",
".",
"__name__",
"==",
"EventType",
".",
"Name",
"[",
"event_type",
"]",
"]",
"[",
"0",
"]",
"(",
")",
"else",
":",
"raise",
"TypeError",
"(",
"\"EventFactory.Create: Invalid EventType\"",
")"
] | Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`.
:param event_type: number for type of event
:returns: constructed event corresponding to ``event_type``
:rtype: :py:class:`.Event` | [
"Factory",
"method",
"creates",
"objects",
"derived",
"from",
":",
"py",
":",
"class",
".",
"Event",
"with",
"class",
"name",
"matching",
"the",
":",
"py",
":",
"class",
".",
"EventType",
".",
":",
"param",
"event_type",
":",
"number",
"for",
"type",
"of",
"event",
":",
"returns",
":",
"constructed",
"event",
"corresponding",
"to",
"event_type",
":",
"rtype",
":",
":",
"py",
":",
"class",
":",
".",
"Event"
] | train | https://github.com/robhowley/nhlscrapi/blob/2273683497ff27b0e92c8d1557ff0ce962dbf43b/nhlscrapi/games/events.py#L167-L183 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`.
:param event_type: number for type of event
:returns: constructed event corresponding to ``event_type``
:rtype: :py:class:`.Event`
### Response:
def Create(event_type):
"""
Factory method creates objects derived from :py:class`.Event` with class name matching the :py:class`.EventType`.
:param event_type: number for type of event
:returns: constructed event corresponding to ``event_type``
:rtype: :py:class:`.Event`
"""
if event_type in EventType.Name:
# unknown event type gets base class
if EventType.Name[event_type] == Event.__name__:
return Event()
else:
# instantiate Event subclass with same name as EventType name
return [t for t in EventFactory.event_list if t.__name__ == EventType.Name[event_type]][0]()
else:
raise TypeError("EventFactory.Create: Invalid EventType")
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4246,
1749,
11705,
6302,
14592,
505,
551,
3368,
93064,
29687,
1585,
63,
449,
538,
836,
12864,
279,
551,
3368,
93064,
29687,
49006,
19154,
1827,
286,
551,
913,
1567,
1857,
25,
1396,
369,
955,
315,
1567,
198,
286,
551,
4310,
25,
20968,
1567,
12435,
311,
10103,
3163,
1857,
85374,
286,
551,
33613,
25,
551,
3368,
93064,
19258,
13,
1585,
19884,
14711,
6075,
512,
755,
4324,
6368,
1857,
997,
286,
3270,
286,
17367,
1749,
11705,
6302,
14592,
505,
551,
3368,
93064,
29687,
1585,
63,
449,
538,
836,
12864,
279,
551,
3368,
93064,
29687,
49006,
19154,
1827,
286,
551,
913,
1567,
1857,
25,
1396,
369,
955,
315,
1567,
198,
286,
551,
4310,
25,
20968,
1567,
12435,
311,
10103,
3163,
1857,
85374,
286,
551,
33613,
25,
551,
3368,
93064,
19258,
13,
1585,
4077,
286,
3270,
286,
422,
1567,
1857,
304,
64228,
3040,
512,
310,
674,
9987,
1567,
955,
5334,
2385,
538,
198,
310,
422,
64228,
3040,
55899,
1857,
60,
624,
3749,
4952,
609,
565,
512,
394,
471,
3749,
746,
310,
775,
512,
394,
674,
42002,
3749,
38290,
449,
1890,
836,
439,
64228,
836,
198,
394,
471,
510,
83,
369,
259,
304,
3749,
4246,
5892,
2062,
422,
259,
4952,
609,
565,
624,
64228,
3040,
55899,
1857,
28819,
15,
37722,
286,
775,
512,
310,
4933,
26082,
446,
1585,
4246,
7399,
25,
14204,
64228,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4246,
1749,
11705,
6302,
14592,
505,
551,
3368,
93064,
29687,
1585,
63,
449,
538,
836,
12864,
279,
551,
3368,
93064,
29687,
49006,
19154,
1827,
286,
551,
913,
1567,
1857,
25,
1396,
369,
955,
315,
1567,
198,
286,
551,
4310,
25,
20968,
1567,
12435,
311,
10103,
3163,
1857,
85374,
286,
551,
33613,
25,
551,
3368,
93064,
19258,
13,
1585,
19884,
14711,
6075,
512,
755,
4324,
6368,
1857,
997,
286,
3270,
286,
17367,
1749,
11705,
6302,
14592,
505,
551,
3368,
93064,
29687,
1585,
63,
449,
538,
836,
12864,
279,
551,
3368,
93064,
29687,
49006,
19154,
1827,
286,
551,
913,
1567,
1857,
25,
1396,
369,
955,
315,
1567,
198,
286,
551,
4310,
25,
20968,
1567,
12435,
311,
10103,
3163,
1857,
85374,
286,
551,
33613,
25,
551,
3368,
93064,
19258,
13,
1585,
4077,
286,
3270,
286,
422,
1567,
1857,
304,
64228,
3040,
512,
310,
674,
9987,
1567,
955,
5334,
2385,
538,
198,
310,
422,
64228,
3040,
55899,
1857,
60,
624,
3749,
4952,
609,
565,
512,
394,
471,
3749,
746,
310,
775,
512,
394,
674,
42002,
3749,
38290,
449,
1890,
836,
439,
64228,
836,
198,
394,
471,
510,
83,
369,
259,
304,
3749,
4246,
5892,
2062,
422,
259,
4952,
609,
565,
624,
64228,
3040,
55899,
1857,
28819,
15,
37722,
286,
775,
512,
310,
4933,
26082,
446,
1585,
4246,
7399,
25,
14204,
64228,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
coopernurse/barrister | barrister/runtime.py | Struct.field | def field(self, name):
"""
Returns the field on this struct with the given name. Will try to find this
name on all ancestors if this struct extends another.
If found, returns a dict with keys: 'name', 'comment', 'type', 'is_array'
If not found, returns None
:Parameters:
name
string name of field to lookup
"""
if self.fields.has_key(name):
return self.fields[name]
elif self.extends:
if not self.parent:
self.parent = self.contract.struct(self.extends)
return self.parent.field(name)
else:
return None | python | def field(self, name):
"""
Returns the field on this struct with the given name. Will try to find this
name on all ancestors if this struct extends another.
If found, returns a dict with keys: 'name', 'comment', 'type', 'is_array'
If not found, returns None
:Parameters:
name
string name of field to lookup
"""
if self.fields.has_key(name):
return self.fields[name]
elif self.extends:
if not self.parent:
self.parent = self.contract.struct(self.extends)
return self.parent.field(name)
else:
return None | [
"def",
"field",
"(",
"self",
",",
"name",
")",
":",
"if",
"self",
".",
"fields",
".",
"has_key",
"(",
"name",
")",
":",
"return",
"self",
".",
"fields",
"[",
"name",
"]",
"elif",
"self",
".",
"extends",
":",
"if",
"not",
"self",
".",
"parent",
":",
"self",
".",
"parent",
"=",
"self",
".",
"contract",
".",
"struct",
"(",
"self",
".",
"extends",
")",
"return",
"self",
".",
"parent",
".",
"field",
"(",
"name",
")",
"else",
":",
"return",
"None"
] | Returns the field on this struct with the given name. Will try to find this
name on all ancestors if this struct extends another.
If found, returns a dict with keys: 'name', 'comment', 'type', 'is_array'
If not found, returns None
:Parameters:
name
string name of field to lookup | [
"Returns",
"the",
"field",
"on",
"this",
"struct",
"with",
"the",
"given",
"name",
".",
"Will",
"try",
"to",
"find",
"this",
"name",
"on",
"all",
"ancestors",
"if",
"this",
"struct",
"extends",
"another",
"."
] | train | https://github.com/coopernurse/barrister/blob/0471b1d98d3327ba381684db496ec94c79c20848/barrister/runtime.py#L1007-L1026 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Returns the field on this struct with the given name. Will try to find this
name on all ancestors if this struct extends another.
If found, returns a dict with keys: 'name', 'comment', 'type', 'is_array'
If not found, returns None
:Parameters:
name
string name of field to lookup
### Response:
def field(self, name):
"""
Returns the field on this struct with the given name. Will try to find this
name on all ancestors if this struct extends another.
If found, returns a dict with keys: 'name', 'comment', 'type', 'is_array'
If not found, returns None
:Parameters:
name
string name of field to lookup
"""
if self.fields.has_key(name):
return self.fields[name]
elif self.extends:
if not self.parent:
self.parent = self.contract.struct(self.extends)
return self.parent.field(name)
else:
return None
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
279,
2115,
389,
420,
2080,
449,
279,
2728,
836,
13,
4946,
1456,
311,
1505,
420,
720,
286,
836,
389,
682,
38618,
422,
420,
2080,
2289,
2500,
382,
286,
1442,
1766,
11,
4780,
264,
6587,
449,
7039,
25,
364,
609,
518,
364,
6313,
518,
364,
1337,
518,
364,
285,
3943,
1270,
286,
1442,
539,
1766,
11,
4780,
2290,
271,
286,
551,
9905,
512,
692,
836,
198,
310,
925,
836,
315,
2115,
311,
19128,
271,
14711,
6075,
512,
755,
2115,
1214,
11,
836,
997,
286,
3270,
286,
5295,
279,
2115,
389,
420,
2080,
449,
279,
2728,
836,
13,
4946,
1456,
311,
1505,
420,
720,
286,
836,
389,
682,
38618,
422,
420,
2080,
2289,
2500,
382,
286,
1442,
1766,
11,
4780,
264,
6587,
449,
7039,
25,
364,
609,
518,
364,
6313,
518,
364,
1337,
518,
364,
285,
3943,
1270,
286,
1442,
539,
1766,
11,
4780,
2290,
271,
286,
551,
9905,
512,
692,
836,
198,
310,
925,
836,
315,
2115,
311,
19128,
198,
286,
3270,
286,
422,
659,
13216,
7001,
3173,
3232,
997,
310,
471,
659,
13216,
11174,
933,
286,
4508,
659,
9402,
1438,
512,
310,
422,
539,
659,
8829,
512,
394,
659,
8829,
284,
659,
52735,
73318,
1214,
9402,
1438,
340,
310,
471,
659,
8829,
16859,
3232,
340,
286,
775,
512,
310,
471,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
279,
2115,
389,
420,
2080,
449,
279,
2728,
836,
13,
4946,
1456,
311,
1505,
420,
720,
286,
836,
389,
682,
38618,
422,
420,
2080,
2289,
2500,
382,
286,
1442,
1766,
11,
4780,
264,
6587,
449,
7039,
25,
364,
609,
518,
364,
6313,
518,
364,
1337,
518,
364,
285,
3943,
1270,
286,
1442,
539,
1766,
11,
4780,
2290,
271,
286,
551,
9905,
512,
692,
836,
198,
310,
925,
836,
315,
2115,
311,
19128,
271,
14711,
6075,
512,
755,
2115,
1214,
11,
836,
997,
286,
3270,
286,
5295,
279,
2115,
389,
420,
2080,
449,
279,
2728,
836,
13,
4946,
1456,
311,
1505,
420,
720,
286,
836,
389,
682,
38618,
422,
420,
2080,
2289,
2500,
382,
286,
1442,
1766,
11,
4780,
264,
6587,
449,
7039,
25,
364,
609,
518,
364,
6313,
518,
364,
1337,
518,
364,
285,
3943,
1270,
286,
1442,
539,
1766,
11,
4780,
2290,
271,
286,
551,
9905,
512,
692,
836,
198,
310,
925,
836,
315,
2115,
311,
19128,
198,
286,
3270,
286,
422,
659,
13216,
7001,
3173,
3232,
997,
310,
471,
659,
13216,
11174,
933,
286,
4508,
659,
9402,
1438,
512,
310,
422,
539,
659,
8829,
512,
394,
659,
8829,
284,
659,
52735,
73318,
1214,
9402,
1438,
340,
310,
471,
659,
8829,
16859,
3232,
340,
286,
775,
512,
310,
471,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
ralphje/imagemounter | imagemounter/unmounter.py | Unmounter._index_loopbacks | def _index_loopbacks(self):
"""Finds all loopbacks and stores them in :attr:`loopbacks`"""
self.loopbacks = {}
try:
result = _util.check_output_(['losetup', '-a'])
for line in result.splitlines():
m = re.match(r'(.+): (.+) \((.+)\).*', line)
if m:
self.loopbacks[m.group(1)] = m.group(3)
except Exception:
pass | python | def _index_loopbacks(self):
"""Finds all loopbacks and stores them in :attr:`loopbacks`"""
self.loopbacks = {}
try:
result = _util.check_output_(['losetup', '-a'])
for line in result.splitlines():
m = re.match(r'(.+): (.+) \((.+)\).*', line)
if m:
self.loopbacks[m.group(1)] = m.group(3)
except Exception:
pass | [
"def",
"_index_loopbacks",
"(",
"self",
")",
":",
"self",
".",
"loopbacks",
"=",
"{",
"}",
"try",
":",
"result",
"=",
"_util",
".",
"check_output_",
"(",
"[",
"'losetup'",
",",
"'-a'",
"]",
")",
"for",
"line",
"in",
"result",
".",
"splitlines",
"(",
")",
":",
"m",
"=",
"re",
".",
"match",
"(",
"r'(.+): (.+) \\((.+)\\).*'",
",",
"line",
")",
"if",
"m",
":",
"self",
".",
"loopbacks",
"[",
"m",
".",
"group",
"(",
"1",
")",
"]",
"=",
"m",
".",
"group",
"(",
"3",
")",
"except",
"Exception",
":",
"pass"
] | Finds all loopbacks and stores them in :attr:`loopbacks` | [
"Finds",
"all",
"loopbacks",
"and",
"stores",
"them",
"in",
":",
"attr",
":",
"loopbacks"
] | train | https://github.com/ralphje/imagemounter/blob/86213781c366cad65096447d91f522f0a3fb4b93/imagemounter/unmounter.py#L103-L114 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Finds all loopbacks and stores them in :attr:`loopbacks`
### Response:
def _index_loopbacks(self):
"""Finds all loopbacks and stores them in :attr:`loopbacks`"""
self.loopbacks = {}
try:
result = _util.check_output_(['losetup', '-a'])
for line in result.splitlines():
m = re.match(r'(.+): (.+) \((.+)\).*', line)
if m:
self.loopbacks[m.group(1)] = m.group(3)
except Exception:
pass
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
37,
8843,
682,
6471,
25082,
323,
10756,
1124,
304,
551,
3064,
19258,
10719,
25082,
19884,
14711,
6075,
512,
755,
721,
1275,
17641,
25082,
1214,
997,
286,
4304,
37,
8843,
682,
6471,
25082,
323,
10756,
1124,
304,
551,
3064,
19258,
10719,
25082,
63,
15425,
286,
659,
45451,
25082,
284,
5731,
286,
1456,
512,
310,
1121,
284,
721,
1338,
9271,
7800,
62,
6561,
385,
15543,
518,
7944,
64,
7519,
310,
369,
1584,
304,
1121,
5402,
8128,
4019,
394,
296,
284,
312,
11319,
2666,
6,
14960,
10,
1680,
30565,
37297,
1144,
1209,
60252,
10929,
46176,
518,
1584,
340,
394,
422,
296,
512,
504,
659,
45451,
25082,
12335,
6306,
7,
16,
7400,
284,
296,
6306,
7,
18,
340,
286,
3734,
4204,
512,
310,
1522,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
37,
8843,
682,
6471,
25082,
323,
10756,
1124,
304,
551,
3064,
19258,
10719,
25082,
19884,
14711,
6075,
512,
755,
721,
1275,
17641,
25082,
1214,
997,
286,
4304,
37,
8843,
682,
6471,
25082,
323,
10756,
1124,
304,
551,
3064,
19258,
10719,
25082,
63,
15425,
286,
659,
45451,
25082,
284,
5731,
286,
1456,
512,
310,
1121,
284,
721,
1338,
9271,
7800,
62,
6561,
385,
15543,
518,
7944,
64,
7519,
310,
369,
1584,
304,
1121,
5402,
8128,
4019,
394,
296,
284,
312,
11319,
2666,
6,
14960,
10,
1680,
30565,
37297,
1144,
1209,
60252,
10929,
46176,
518,
1584,
340,
394,
422,
296,
512,
504,
659,
45451,
25082,
12335,
6306,
7,
16,
7400,
284,
296,
6306,
7,
18,
340,
286,
3734,
4204,
512,
310,
1522,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
log2timeline/dfvfs | dfvfs/helpers/file_system_searcher.py | FileSystemSearcher.GetRelativePath | def GetRelativePath(self, path_spec):
"""Returns the relative path based on a resolved path specification.
The relative path is the location of the upper most path specification.
The the location of the mount point is stripped off if relevant.
Args:
path_spec (PathSpec): path specification.
Returns:
str: corresponding relative path or None if the relative path could not
be determined.
Raises:
PathSpecError: if the path specification is incorrect.
"""
location = getattr(path_spec, 'location', None)
if location is None:
raise errors.PathSpecError('Path specification missing location.')
if path_spec_factory.Factory.IsSystemLevelTypeIndicator(
self._file_system.type_indicator):
if not location.startswith(self._mount_point.location):
raise errors.PathSpecError(
'Path specification does not contain mount point.')
else:
if not hasattr(path_spec, 'parent'):
raise errors.PathSpecError('Path specification missing parent.')
if path_spec.parent != self._mount_point:
raise errors.PathSpecError(
'Path specification does not contain mount point.')
path_segments = self._file_system.SplitPath(location)
if path_spec_factory.Factory.IsSystemLevelTypeIndicator(
self._file_system.type_indicator):
mount_point_path_segments = self._file_system.SplitPath(
self._mount_point.location)
path_segments = path_segments[len(mount_point_path_segments):]
return '{0:s}{1:s}'.format(
self._file_system.PATH_SEPARATOR,
self._file_system.PATH_SEPARATOR.join(path_segments)) | python | def GetRelativePath(self, path_spec):
"""Returns the relative path based on a resolved path specification.
The relative path is the location of the upper most path specification.
The the location of the mount point is stripped off if relevant.
Args:
path_spec (PathSpec): path specification.
Returns:
str: corresponding relative path or None if the relative path could not
be determined.
Raises:
PathSpecError: if the path specification is incorrect.
"""
location = getattr(path_spec, 'location', None)
if location is None:
raise errors.PathSpecError('Path specification missing location.')
if path_spec_factory.Factory.IsSystemLevelTypeIndicator(
self._file_system.type_indicator):
if not location.startswith(self._mount_point.location):
raise errors.PathSpecError(
'Path specification does not contain mount point.')
else:
if not hasattr(path_spec, 'parent'):
raise errors.PathSpecError('Path specification missing parent.')
if path_spec.parent != self._mount_point:
raise errors.PathSpecError(
'Path specification does not contain mount point.')
path_segments = self._file_system.SplitPath(location)
if path_spec_factory.Factory.IsSystemLevelTypeIndicator(
self._file_system.type_indicator):
mount_point_path_segments = self._file_system.SplitPath(
self._mount_point.location)
path_segments = path_segments[len(mount_point_path_segments):]
return '{0:s}{1:s}'.format(
self._file_system.PATH_SEPARATOR,
self._file_system.PATH_SEPARATOR.join(path_segments)) | [
"def",
"GetRelativePath",
"(",
"self",
",",
"path_spec",
")",
":",
"location",
"=",
"getattr",
"(",
"path_spec",
",",
"'location'",
",",
"None",
")",
"if",
"location",
"is",
"None",
":",
"raise",
"errors",
".",
"PathSpecError",
"(",
"'Path specification missing location.'",
")",
"if",
"path_spec_factory",
".",
"Factory",
".",
"IsSystemLevelTypeIndicator",
"(",
"self",
".",
"_file_system",
".",
"type_indicator",
")",
":",
"if",
"not",
"location",
".",
"startswith",
"(",
"self",
".",
"_mount_point",
".",
"location",
")",
":",
"raise",
"errors",
".",
"PathSpecError",
"(",
"'Path specification does not contain mount point.'",
")",
"else",
":",
"if",
"not",
"hasattr",
"(",
"path_spec",
",",
"'parent'",
")",
":",
"raise",
"errors",
".",
"PathSpecError",
"(",
"'Path specification missing parent.'",
")",
"if",
"path_spec",
".",
"parent",
"!=",
"self",
".",
"_mount_point",
":",
"raise",
"errors",
".",
"PathSpecError",
"(",
"'Path specification does not contain mount point.'",
")",
"path_segments",
"=",
"self",
".",
"_file_system",
".",
"SplitPath",
"(",
"location",
")",
"if",
"path_spec_factory",
".",
"Factory",
".",
"IsSystemLevelTypeIndicator",
"(",
"self",
".",
"_file_system",
".",
"type_indicator",
")",
":",
"mount_point_path_segments",
"=",
"self",
".",
"_file_system",
".",
"SplitPath",
"(",
"self",
".",
"_mount_point",
".",
"location",
")",
"path_segments",
"=",
"path_segments",
"[",
"len",
"(",
"mount_point_path_segments",
")",
":",
"]",
"return",
"'{0:s}{1:s}'",
".",
"format",
"(",
"self",
".",
"_file_system",
".",
"PATH_SEPARATOR",
",",
"self",
".",
"_file_system",
".",
"PATH_SEPARATOR",
".",
"join",
"(",
"path_segments",
")",
")"
] | Returns the relative path based on a resolved path specification.
The relative path is the location of the upper most path specification.
The the location of the mount point is stripped off if relevant.
Args:
path_spec (PathSpec): path specification.
Returns:
str: corresponding relative path or None if the relative path could not
be determined.
Raises:
PathSpecError: if the path specification is incorrect. | [
"Returns",
"the",
"relative",
"path",
"based",
"on",
"a",
"resolved",
"path",
"specification",
"."
] | train | https://github.com/log2timeline/dfvfs/blob/2b3ccd115f9901d89f383397d4a1376a873c83c4/dfvfs/helpers/file_system_searcher.py#L484-L527 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Returns the relative path based on a resolved path specification.
The relative path is the location of the upper most path specification.
The the location of the mount point is stripped off if relevant.
Args:
path_spec (PathSpec): path specification.
Returns:
str: corresponding relative path or None if the relative path could not
be determined.
Raises:
PathSpecError: if the path specification is incorrect.
### Response:
def GetRelativePath(self, path_spec):
"""Returns the relative path based on a resolved path specification.
The relative path is the location of the upper most path specification.
The the location of the mount point is stripped off if relevant.
Args:
path_spec (PathSpec): path specification.
Returns:
str: corresponding relative path or None if the relative path could not
be determined.
Raises:
PathSpecError: if the path specification is incorrect.
"""
location = getattr(path_spec, 'location', None)
if location is None:
raise errors.PathSpecError('Path specification missing location.')
if path_spec_factory.Factory.IsSystemLevelTypeIndicator(
self._file_system.type_indicator):
if not location.startswith(self._mount_point.location):
raise errors.PathSpecError(
'Path specification does not contain mount point.')
else:
if not hasattr(path_spec, 'parent'):
raise errors.PathSpecError('Path specification missing parent.')
if path_spec.parent != self._mount_point:
raise errors.PathSpecError(
'Path specification does not contain mount point.')
path_segments = self._file_system.SplitPath(location)
if path_spec_factory.Factory.IsSystemLevelTypeIndicator(
self._file_system.type_indicator):
mount_point_path_segments = self._file_system.SplitPath(
self._mount_point.location)
path_segments = path_segments[len(mount_point_path_segments):]
return '{0:s}{1:s}'.format(
self._file_system.PATH_SEPARATOR,
self._file_system.PATH_SEPARATOR.join(path_segments))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
279,
8844,
1853,
3196,
389,
264,
20250,
1853,
26185,
382,
262,
578,
8844,
1853,
374,
279,
3813,
315,
279,
8582,
1455,
1853,
26185,
627,
262,
578,
279,
3813,
315,
279,
6606,
1486,
374,
37779,
1022,
422,
9959,
382,
262,
18161,
512,
415,
1853,
13908,
320,
1858,
8491,
1680,
1853,
26185,
382,
262,
5295,
512,
415,
610,
25,
12435,
8844,
1853,
477,
2290,
422,
279,
8844,
1853,
1436,
539,
198,
692,
387,
11075,
382,
262,
61411,
512,
415,
8092,
8491,
1480,
25,
422,
279,
1853,
26185,
374,
15465,
382,
14711,
6075,
512,
755,
2175,
29542,
1858,
1214,
11,
1853,
13908,
997,
262,
4304,
16851,
279,
8844,
1853,
3196,
389,
264,
20250,
1853,
26185,
382,
262,
578,
8844,
1853,
374,
279,
3813,
315,
279,
8582,
1455,
1853,
26185,
627,
262,
578,
279,
3813,
315,
279,
6606,
1486,
374,
37779,
1022,
422,
9959,
382,
262,
18161,
512,
415,
1853,
13908,
320,
1858,
8491,
1680,
1853,
26185,
382,
262,
5295,
512,
415,
610,
25,
12435,
8844,
1853,
477,
2290,
422,
279,
8844,
1853,
1436,
539,
198,
692,
387,
11075,
382,
262,
61411,
512,
415,
8092,
8491,
1480,
25,
422,
279,
1853,
26185,
374,
15465,
627,
262,
3270,
262,
3813,
284,
31097,
5698,
13908,
11,
364,
2588,
518,
2290,
340,
262,
422,
3813,
374,
2290,
512,
415,
4933,
6103,
17932,
8491,
1480,
493,
1858,
26185,
7554,
3813,
49420,
262,
422,
1853,
13908,
25255,
52108,
4607,
2374,
4549,
941,
20093,
1021,
286,
659,
1462,
1213,
18155,
4957,
59170,
997,
415,
422,
539,
3813,
27249,
1214,
1462,
16966,
6213,
8383,
997,
286,
4933,
6103,
17932,
8491,
1480,
1021,
310,
364,
1858,
26185,
1587,
539,
6782,
6606,
1486,
21537,
262,
775,
512,
415,
422,
539,
32156,
5698,
13908,
11,
364,
3850,
11290,
286,
4933,
6103,
17932,
8491,
1480,
493,
1858,
26185,
7554,
2748,
49420,
415,
422,
1853,
13908,
8829,
976,
659,
1462,
16966,
6213,
512,
286,
4933,
6103,
17932,
8491,
1480,
1021,
310,
364,
1858,
26185,
1587,
539,
6782,
6606,
1486,
49420,
262,
1853,
56835,
284,
659,
1462,
1213,
18155,
20410,
1858,
23509,
696,
262,
422,
1853,
13908,
25255,
52108,
4607,
2374,
4549,
941,
20093,
1021,
286,
659,
1462,
1213,
18155,
4957,
59170,
997,
415,
6606,
6213,
2703,
56835,
284,
659,
1462,
1213,
18155,
20410,
1858,
1021,
692,
659,
1462,
16966,
6213,
8383,
340,
415,
1853,
56835,
284,
1853,
56835,
25721,
1278,
632,
6213,
2703,
56835,
1680,
2595,
262,
471,
11834,
15,
14835,
15523,
16,
14835,
24398,
2293,
1021,
286,
659,
1462,
1213,
18155,
1087,
4932,
33343,
345,
286,
659,
1462,
1213,
18155,
1087,
4932,
33343,
5563,
5698,
56835,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
3196,
389,
264,
20250,
1853,
26185,
382,
262,
578,
8844,
1853,
374,
279,
3813,
315,
279,
8582,
1455,
1853,
26185,
627,
262,
578,
279,
3813,
315,
279,
6606,
1486,
374,
37779,
1022,
422,
9959,
382,
262,
18161,
512,
415,
1853,
13908,
320,
1858,
8491,
1680,
1853,
26185,
382,
262,
5295,
512,
415,
610,
25,
12435,
8844,
1853,
477,
2290,
422,
279,
8844,
1853,
1436,
539,
198,
692,
387,
11075,
382,
262,
61411,
512,
415,
8092,
8491,
1480,
25,
422,
279,
1853,
26185,
374,
15465,
382,
14711,
6075,
512,
755,
2175,
29542,
1858,
1214,
11,
1853,
13908,
997,
262,
4304,
16851,
279,
8844,
1853,
3196,
389,
264,
20250,
1853,
26185,
382,
262,
578,
8844,
1853,
374,
279,
3813,
315,
279,
8582,
1455,
1853,
26185,
627,
262,
578,
279,
3813,
315,
279,
6606,
1486,
374,
37779,
1022,
422,
9959,
382,
262,
18161,
512,
415,
1853,
13908,
320,
1858,
8491,
1680,
1853,
26185,
382,
262,
5295,
512,
415,
610,
25,
12435,
8844,
1853,
477,
2290,
422,
279,
8844,
1853,
1436,
539,
198,
692,
387,
11075,
382,
262,
61411,
512,
415,
8092,
8491,
1480,
25,
422,
279,
1853,
26185,
374,
15465,
627,
262,
3270,
262,
3813,
284,
31097,
5698,
13908,
11,
364,
2588,
518,
2290,
340,
262,
422,
3813,
374,
2290,
512,
415,
4933,
6103,
17932,
8491,
1480,
493,
1858,
26185,
7554,
3813,
49420,
262,
422,
1853,
13908,
25255,
52108,
4607,
2374,
4549,
941,
20093,
1021,
286,
659,
1462,
1213,
18155,
4957,
59170,
997,
415,
422,
539,
3813,
27249,
1214,
1462,
16966,
6213,
8383,
997,
286,
4933,
6103,
17932,
8491,
1480,
1021,
310,
364,
1858,
26185,
1587,
539,
6782,
6606,
1486,
21537,
262,
775,
512,
415,
422,
539,
32156,
5698,
13908,
11,
364,
3850,
11290,
286,
4933,
6103,
17932,
8491,
1480,
493,
1858,
26185,
7554,
2748,
49420,
415,
422,
1853,
13908,
8829,
976,
659,
1462,
16966,
6213,
512,
286,
4933,
6103,
17932,
8491,
1480,
1021,
310,
364,
1858,
26185,
1587,
539,
6782,
6606,
1486,
49420,
262,
1853,
56835,
284,
659,
1462,
1213,
18155,
20410,
1858,
23509,
696,
262,
422,
1853,
13908,
25255,
52108,
4607,
2374,
4549,
941,
20093,
1021,
286,
659,
1462,
1213,
18155,
4957,
59170,
997,
415,
6606,
6213,
2703,
56835,
284,
659,
1462,
1213,
18155,
20410,
1858,
1021,
692,
659,
1462,
16966,
6213,
8383,
340,
415,
1853,
56835,
284,
1853,
56835,
25721,
1278,
632,
6213,
2703,
56835,
1680,
2595,
262,
471,
11834,
15,
14835,
15523,
16,
14835,
24398,
2293,
1021,
286,
659,
1462,
1213,
18155,
1087,
4932,
33343,
345,
286,
659,
1462,
1213,
18155,
1087,
4932,
33343,
5563,
5698,
56835,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
dustinmm80/healthy | package_utils.py | download_package_to_sandbox | def download_package_to_sandbox(sandbox, package_url):
"""
Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory
"""
response = requests.get(package_url)
package_tar = os.path.join(sandbox, 'package.tar.gz')
with open(package_tar, 'w') as f:
f.write(response.content)
os.chdir(sandbox)
with tarfile.open('package.tar.gz', 'r:gz') as tf:
tf.extractall()
directory = [d for d in os.listdir(sandbox) if os.path.isdir(d)][0]
return os.path.join(sandbox, directory) | python | def download_package_to_sandbox(sandbox, package_url):
"""
Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory
"""
response = requests.get(package_url)
package_tar = os.path.join(sandbox, 'package.tar.gz')
with open(package_tar, 'w') as f:
f.write(response.content)
os.chdir(sandbox)
with tarfile.open('package.tar.gz', 'r:gz') as tf:
tf.extractall()
directory = [d for d in os.listdir(sandbox) if os.path.isdir(d)][0]
return os.path.join(sandbox, directory) | [
"def",
"download_package_to_sandbox",
"(",
"sandbox",
",",
"package_url",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"package_url",
")",
"package_tar",
"=",
"os",
".",
"path",
".",
"join",
"(",
"sandbox",
",",
"'package.tar.gz'",
")",
"with",
"open",
"(",
"package_tar",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"response",
".",
"content",
")",
"os",
".",
"chdir",
"(",
"sandbox",
")",
"with",
"tarfile",
".",
"open",
"(",
"'package.tar.gz'",
",",
"'r:gz'",
")",
"as",
"tf",
":",
"tf",
".",
"extractall",
"(",
")",
"directory",
"=",
"[",
"d",
"for",
"d",
"in",
"os",
".",
"listdir",
"(",
"sandbox",
")",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"d",
")",
"]",
"[",
"0",
"]",
"return",
"os",
".",
"path",
".",
"join",
"(",
"sandbox",
",",
"directory",
")"
] | Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory | [
"Downloads",
"an",
"unzips",
"a",
"package",
"to",
"the",
"sandbox",
":",
"param",
"sandbox",
":",
"temporary",
"directory",
"name",
":",
"param",
"package_url",
":",
"link",
"to",
"package",
"download",
":",
"returns",
":",
"name",
"of",
"unzipped",
"package",
"directory"
] | train | https://github.com/dustinmm80/healthy/blob/b59016c3f578ca45b6ce857a2d5c4584b8542288/package_utils.py#L26-L48 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory
### Response:
def download_package_to_sandbox(sandbox, package_url):
"""
Downloads an unzips a package to the sandbox
:param sandbox: temporary directory name
:param package_url: link to package download
:returns: name of unzipped package directory
"""
response = requests.get(package_url)
package_tar = os.path.join(sandbox, 'package.tar.gz')
with open(package_tar, 'w') as f:
f.write(response.content)
os.chdir(sandbox)
with tarfile.open('package.tar.gz', 'r:gz') as tf:
tf.extractall()
directory = [d for d in os.listdir(sandbox) if os.path.isdir(d)][0]
return os.path.join(sandbox, directory)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50878,
459,
653,
89,
3153,
264,
6462,
311,
279,
43854,
198,
262,
551,
913,
43854,
25,
13643,
6352,
836,
198,
262,
551,
913,
6462,
2975,
25,
2723,
311,
6462,
4232,
198,
262,
551,
4310,
25,
836,
315,
653,
89,
6586,
6462,
6352,
271,
14711,
6075,
512,
755,
4232,
27425,
2401,
646,
32636,
1161,
32636,
11,
6462,
2975,
997,
262,
3270,
262,
50261,
459,
653,
89,
3153,
264,
6462,
311,
279,
43854,
198,
262,
551,
913,
43854,
25,
13643,
6352,
836,
198,
262,
551,
913,
6462,
2975,
25,
2723,
311,
6462,
4232,
198,
262,
551,
4310,
25,
836,
315,
653,
89,
6586,
6462,
6352,
198,
262,
12713,
262,
2077,
284,
7540,
673,
48720,
2975,
696,
262,
6462,
67708,
284,
2709,
3960,
5563,
1161,
32636,
11,
364,
1757,
29148,
21637,
4713,
262,
449,
1825,
48720,
67708,
11,
364,
86,
873,
439,
282,
512,
286,
282,
3921,
5802,
5521,
696,
262,
2709,
52110,
1161,
32636,
696,
262,
449,
12460,
1213,
5949,
493,
1757,
29148,
21637,
518,
364,
81,
25,
47689,
873,
439,
6543,
512,
286,
6543,
38458,
543,
2892,
262,
6352,
284,
510,
67,
369,
294,
304,
2709,
33576,
1161,
32636,
8,
422,
2709,
3960,
49261,
1528,
55368,
15,
2595,
262,
471,
2709,
3960,
5563,
1161,
32636,
11,
6352,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50878,
459,
653,
89,
3153,
264,
6462,
311,
279,
43854,
198,
262,
551,
913,
43854,
25,
13643,
6352,
836,
198,
262,
551,
913,
6462,
2975,
25,
2723,
311,
6462,
4232,
198,
262,
551,
4310,
25,
836,
315,
653,
89,
6586,
6462,
6352,
271,
14711,
6075,
512,
755,
4232,
27425,
2401,
646,
32636,
1161,
32636,
11,
6462,
2975,
997,
262,
3270,
262,
50261,
459,
653,
89,
3153,
264,
6462,
311,
279,
43854,
198,
262,
551,
913,
43854,
25,
13643,
6352,
836,
198,
262,
551,
913,
6462,
2975,
25,
2723,
311,
6462,
4232,
198,
262,
551,
4310,
25,
836,
315,
653,
89,
6586,
6462,
6352,
198,
262,
12713,
262,
2077,
284,
7540,
673,
48720,
2975,
696,
262,
6462,
67708,
284,
2709,
3960,
5563,
1161,
32636,
11,
364,
1757,
29148,
21637,
4713,
262,
449,
1825,
48720,
67708,
11,
364,
86,
873,
439,
282,
512,
286,
282,
3921,
5802,
5521,
696,
262,
2709,
52110,
1161,
32636,
696,
262,
449,
12460,
1213,
5949,
493,
1757,
29148,
21637,
518,
364,
81,
25,
47689,
873,
439,
6543,
512,
286,
6543,
38458,
543,
2892,
262,
6352,
284,
510,
67,
369,
294,
304,
2709,
33576,
1161,
32636,
8,
422,
2709,
3960,
49261,
1528,
55368,
15,
2595,
262,
471,
2709,
3960,
5563,
1161,
32636,
11,
6352,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
volafiled/python-volapi | volapi/handler.py | Handler._handle_key | def _handle_key(self, data):
"""Handle keys"""
self.room.key = data
self.conn.enqueue_data("key", self.room.key) | python | def _handle_key(self, data):
"""Handle keys"""
self.room.key = data
self.conn.enqueue_data("key", self.room.key) | [
"def",
"_handle_key",
"(",
"self",
",",
"data",
")",
":",
"self",
".",
"room",
".",
"key",
"=",
"data",
"self",
".",
"conn",
".",
"enqueue_data",
"(",
"\"key\"",
",",
"self",
".",
"room",
".",
"key",
")"
] | Handle keys | [
"Handle",
"keys"
] | train | https://github.com/volafiled/python-volapi/blob/5f0bc03dbde703264ac6ed494e2050761f688a3e/volapi/handler.py#L139-L143 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Handle keys
### Response:
def _handle_key(self, data):
"""Handle keys"""
self.room.key = data
self.conn.enqueue_data("key", self.room.key)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7144,
7039,
271,
14711,
6075,
512,
755,
721,
8355,
3173,
1214,
11,
828,
997,
286,
4304,
7144,
7039,
15425,
286,
659,
22788,
4840,
284,
828,
198,
286,
659,
23656,
48568,
1807,
446,
798,
498,
659,
22788,
4840,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7144,
7039,
271,
14711,
6075,
512,
755,
721,
8355,
3173,
1214,
11,
828,
997,
286,
4304,
7144,
7039,
15425,
286,
659,
22788,
4840,
284,
828,
198,
286,
659,
23656,
48568,
1807,
446,
798,
498,
659,
22788,
4840,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
miyakogi/wdom | wdom/node.py | Node.ownerDocument | def ownerDocument(self) -> Optional[AbstractNode]:
"""Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: Document or None
"""
if self.nodeType == Node.DOCUMENT_NODE:
return self
elif self.parentNode:
return self.parentNode.ownerDocument
return None | python | def ownerDocument(self) -> Optional[AbstractNode]:
"""Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: Document or None
"""
if self.nodeType == Node.DOCUMENT_NODE:
return self
elif self.parentNode:
return self.parentNode.ownerDocument
return None | [
"def",
"ownerDocument",
"(",
"self",
")",
"->",
"Optional",
"[",
"AbstractNode",
"]",
":",
"if",
"self",
".",
"nodeType",
"==",
"Node",
".",
"DOCUMENT_NODE",
":",
"return",
"self",
"elif",
"self",
".",
"parentNode",
":",
"return",
"self",
".",
"parentNode",
".",
"ownerDocument",
"return",
"None"
] | Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: Document or None | [
"Return",
"the",
"owner",
"document",
"of",
"this",
"node",
"."
] | train | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L140-L153 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: Document or None
### Response:
def ownerDocument(self) -> Optional[AbstractNode]:
"""Return the owner document of this node.
Owner document is an ancestor document node of this node. If this node
(or node tree including this node) is not appended to any document
node, this property returns ``None``.
:rtype: Document or None
"""
if self.nodeType == Node.DOCUMENT_NODE:
return self
elif self.parentNode:
return self.parentNode.ownerDocument
return None
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
6506,
2246,
315,
420,
2494,
382,
286,
26918,
2246,
374,
459,
46831,
2246,
2494,
315,
420,
2494,
13,
1442,
420,
2494,
198,
286,
320,
269,
2494,
5021,
2737,
420,
2494,
8,
374,
539,
52287,
311,
904,
2246,
198,
286,
2494,
11,
420,
3424,
4780,
10103,
4155,
14196,
382,
286,
551,
33613,
25,
12051,
477,
2290,
271,
14711,
6075,
512,
755,
6506,
7676,
1214,
8,
1492,
12536,
58,
16328,
1997,
10556,
286,
4304,
5715,
279,
6506,
2246,
315,
420,
2494,
382,
286,
26918,
2246,
374,
459,
46831,
2246,
2494,
315,
420,
2494,
13,
1442,
420,
2494,
198,
286,
320,
269,
2494,
5021,
2737,
420,
2494,
8,
374,
539,
52287,
311,
904,
2246,
198,
286,
2494,
11,
420,
3424,
4780,
10103,
4155,
14196,
382,
286,
551,
33613,
25,
12051,
477,
2290,
198,
286,
3270,
286,
422,
659,
61472,
624,
6146,
920,
35801,
19769,
512,
310,
471,
659,
198,
286,
4508,
659,
28393,
512,
310,
471,
659,
28393,
26772,
7676,
198,
286,
471,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
6506,
2246,
315,
420,
2494,
382,
286,
26918,
2246,
374,
459,
46831,
2246,
2494,
315,
420,
2494,
13,
1442,
420,
2494,
198,
286,
320,
269,
2494,
5021,
2737,
420,
2494,
8,
374,
539,
52287,
311,
904,
2246,
198,
286,
2494,
11,
420,
3424,
4780,
10103,
4155,
14196,
382,
286,
551,
33613,
25,
12051,
477,
2290,
271,
14711,
6075,
512,
755,
6506,
7676,
1214,
8,
1492,
12536,
58,
16328,
1997,
10556,
286,
4304,
5715,
279,
6506,
2246,
315,
420,
2494,
382,
286,
26918,
2246,
374,
459,
46831,
2246,
2494,
315,
420,
2494,
13,
1442,
420,
2494,
198,
286,
320,
269,
2494,
5021,
2737,
420,
2494,
8,
374,
539,
52287,
311,
904,
2246,
198,
286,
2494,
11,
420,
3424,
4780,
10103,
4155,
14196,
382,
286,
551,
33613,
25,
12051,
477,
2290,
198,
286,
3270,
286,
422,
659,
61472,
624,
6146,
920,
35801,
19769,
512,
310,
471,
659,
198,
286,
4508,
659,
28393,
512,
310,
471,
659,
28393,
26772,
7676,
198,
286,
471,
2290,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
guaix-ucm/numina | numina/user/cli.py | main | def main(args=None):
"""Entry point for the Numina CLI."""
# Configuration args from a text file
config = configparser.SafeConfigParser()
# Building programatically
config.add_section('numina')
config.set('numina', 'format', 'yaml')
# Custom values
config.read([
os.path.join(xdg_config_home, 'numina/numina.cfg'),
'.numina.cfg'
])
parser0 = argparse.ArgumentParser(
description='Command line interface of Numina',
prog='numina',
epilog="For detailed help pass --help to a target",
add_help=False
)
parser0.add_argument('--disable-plugins', action='store_true')
args0, args = parser0.parse_known_args(args)
# Load plugin commands if enabled
subcmd_load = []
if not args0.disable_plugins:
for entry in pkg_resources.iter_entry_points(
group='numina.plugins.1'
):
try:
register = entry.load()
subcmd_load.append(register)
except Exception as error:
print(error, file=sys.stderr)
parser = argparse.ArgumentParser(
description='Command line interface of Numina',
prog='numina',
epilog="For detailed help pass --help to a target"
)
parser.add_argument('--disable-plugins', action='store_true',
help='disable plugin loading')
parser.add_argument(
'-l', action="store", dest="logging", metavar="FILE",
help="FILE with logging configuration"
)
parser.add_argument(
'-d', '--debug',
action="store_true",
dest="debug", default=False,
help="make lots of noise"
)
parser.add_argument(
'--standalone',
action="store_true",
dest="standalone", default=False,
help="do not activate GTC compatibility code"
)
# Due to a problem with argparse
# this command blocks the defaults of the subparsers
# in argparse of Pyhton < 2.7.9
# https://bugs.python.org/issue9351
# parser.set_defaults(command=None)
subparsers = parser.add_subparsers(
title='Targets',
description='These are valid commands you can ask numina to do.'
)
# Init subcommands
cmds = ['clishowins', 'clishowom', 'clishowrecip',
'clirun', 'clirunrec']
for cmd in cmds:
cmd_mod = import_module('.%s' % (cmd, ), 'numina.user')
register = getattr(cmd_mod, 'register', None)
if register is not None:
register(subparsers, config)
# Add commands by plugins
for register in subcmd_load:
try:
register(subparsers, config)
except Exception as error:
print(error, file=sys.stderr)
args, unknowns = parser.parse_known_args(args)
extra_args = process_unknown_arguments(unknowns)
# logger file
if args.standalone:
import numina.ext.gtc
numina.ext.gtc.ignore_gtc_check()
try:
if args.logging is not None:
loggingf = args.logging
else:
loggingf = config.get('numina', 'logging')
with open(loggingf) as logfile:
logconf = yaml.load(logfile)
logging.config.dictConfig(logconf)
except configparser.Error:
logging.config.dictConfig(numina_cli_logconf)
_logger.debug('Numina simple recipe runner version %s', __version__)
command = getattr(args, 'command', None)
if command is not None:
args.command(args, extra_args) | python | def main(args=None):
"""Entry point for the Numina CLI."""
# Configuration args from a text file
config = configparser.SafeConfigParser()
# Building programatically
config.add_section('numina')
config.set('numina', 'format', 'yaml')
# Custom values
config.read([
os.path.join(xdg_config_home, 'numina/numina.cfg'),
'.numina.cfg'
])
parser0 = argparse.ArgumentParser(
description='Command line interface of Numina',
prog='numina',
epilog="For detailed help pass --help to a target",
add_help=False
)
parser0.add_argument('--disable-plugins', action='store_true')
args0, args = parser0.parse_known_args(args)
# Load plugin commands if enabled
subcmd_load = []
if not args0.disable_plugins:
for entry in pkg_resources.iter_entry_points(
group='numina.plugins.1'
):
try:
register = entry.load()
subcmd_load.append(register)
except Exception as error:
print(error, file=sys.stderr)
parser = argparse.ArgumentParser(
description='Command line interface of Numina',
prog='numina',
epilog="For detailed help pass --help to a target"
)
parser.add_argument('--disable-plugins', action='store_true',
help='disable plugin loading')
parser.add_argument(
'-l', action="store", dest="logging", metavar="FILE",
help="FILE with logging configuration"
)
parser.add_argument(
'-d', '--debug',
action="store_true",
dest="debug", default=False,
help="make lots of noise"
)
parser.add_argument(
'--standalone',
action="store_true",
dest="standalone", default=False,
help="do not activate GTC compatibility code"
)
# Due to a problem with argparse
# this command blocks the defaults of the subparsers
# in argparse of Pyhton < 2.7.9
# https://bugs.python.org/issue9351
# parser.set_defaults(command=None)
subparsers = parser.add_subparsers(
title='Targets',
description='These are valid commands you can ask numina to do.'
)
# Init subcommands
cmds = ['clishowins', 'clishowom', 'clishowrecip',
'clirun', 'clirunrec']
for cmd in cmds:
cmd_mod = import_module('.%s' % (cmd, ), 'numina.user')
register = getattr(cmd_mod, 'register', None)
if register is not None:
register(subparsers, config)
# Add commands by plugins
for register in subcmd_load:
try:
register(subparsers, config)
except Exception as error:
print(error, file=sys.stderr)
args, unknowns = parser.parse_known_args(args)
extra_args = process_unknown_arguments(unknowns)
# logger file
if args.standalone:
import numina.ext.gtc
numina.ext.gtc.ignore_gtc_check()
try:
if args.logging is not None:
loggingf = args.logging
else:
loggingf = config.get('numina', 'logging')
with open(loggingf) as logfile:
logconf = yaml.load(logfile)
logging.config.dictConfig(logconf)
except configparser.Error:
logging.config.dictConfig(numina_cli_logconf)
_logger.debug('Numina simple recipe runner version %s', __version__)
command = getattr(args, 'command', None)
if command is not None:
args.command(args, extra_args) | [
"def",
"main",
"(",
"args",
"=",
"None",
")",
":",
"# Configuration args from a text file",
"config",
"=",
"configparser",
".",
"SafeConfigParser",
"(",
")",
"# Building programatically",
"config",
".",
"add_section",
"(",
"'numina'",
")",
"config",
".",
"set",
"(",
"'numina'",
",",
"'format'",
",",
"'yaml'",
")",
"# Custom values",
"config",
".",
"read",
"(",
"[",
"os",
".",
"path",
".",
"join",
"(",
"xdg_config_home",
",",
"'numina/numina.cfg'",
")",
",",
"'.numina.cfg'",
"]",
")",
"parser0",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Command line interface of Numina'",
",",
"prog",
"=",
"'numina'",
",",
"epilog",
"=",
"\"For detailed help pass --help to a target\"",
",",
"add_help",
"=",
"False",
")",
"parser0",
".",
"add_argument",
"(",
"'--disable-plugins'",
",",
"action",
"=",
"'store_true'",
")",
"args0",
",",
"args",
"=",
"parser0",
".",
"parse_known_args",
"(",
"args",
")",
"# Load plugin commands if enabled",
"subcmd_load",
"=",
"[",
"]",
"if",
"not",
"args0",
".",
"disable_plugins",
":",
"for",
"entry",
"in",
"pkg_resources",
".",
"iter_entry_points",
"(",
"group",
"=",
"'numina.plugins.1'",
")",
":",
"try",
":",
"register",
"=",
"entry",
".",
"load",
"(",
")",
"subcmd_load",
".",
"append",
"(",
"register",
")",
"except",
"Exception",
"as",
"error",
":",
"print",
"(",
"error",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'Command line interface of Numina'",
",",
"prog",
"=",
"'numina'",
",",
"epilog",
"=",
"\"For detailed help pass --help to a target\"",
")",
"parser",
".",
"add_argument",
"(",
"'--disable-plugins'",
",",
"action",
"=",
"'store_true'",
",",
"help",
"=",
"'disable plugin loading'",
")",
"parser",
".",
"add_argument",
"(",
"'-l'",
",",
"action",
"=",
"\"store\"",
",",
"dest",
"=",
"\"logging\"",
",",
"metavar",
"=",
"\"FILE\"",
",",
"help",
"=",
"\"FILE with logging configuration\"",
")",
"parser",
".",
"add_argument",
"(",
"'-d'",
",",
"'--debug'",
",",
"action",
"=",
"\"store_true\"",
",",
"dest",
"=",
"\"debug\"",
",",
"default",
"=",
"False",
",",
"help",
"=",
"\"make lots of noise\"",
")",
"parser",
".",
"add_argument",
"(",
"'--standalone'",
",",
"action",
"=",
"\"store_true\"",
",",
"dest",
"=",
"\"standalone\"",
",",
"default",
"=",
"False",
",",
"help",
"=",
"\"do not activate GTC compatibility code\"",
")",
"# Due to a problem with argparse",
"# this command blocks the defaults of the subparsers",
"# in argparse of Pyhton < 2.7.9",
"# https://bugs.python.org/issue9351",
"# parser.set_defaults(command=None)",
"subparsers",
"=",
"parser",
".",
"add_subparsers",
"(",
"title",
"=",
"'Targets'",
",",
"description",
"=",
"'These are valid commands you can ask numina to do.'",
")",
"# Init subcommands",
"cmds",
"=",
"[",
"'clishowins'",
",",
"'clishowom'",
",",
"'clishowrecip'",
",",
"'clirun'",
",",
"'clirunrec'",
"]",
"for",
"cmd",
"in",
"cmds",
":",
"cmd_mod",
"=",
"import_module",
"(",
"'.%s'",
"%",
"(",
"cmd",
",",
")",
",",
"'numina.user'",
")",
"register",
"=",
"getattr",
"(",
"cmd_mod",
",",
"'register'",
",",
"None",
")",
"if",
"register",
"is",
"not",
"None",
":",
"register",
"(",
"subparsers",
",",
"config",
")",
"# Add commands by plugins",
"for",
"register",
"in",
"subcmd_load",
":",
"try",
":",
"register",
"(",
"subparsers",
",",
"config",
")",
"except",
"Exception",
"as",
"error",
":",
"print",
"(",
"error",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"args",
",",
"unknowns",
"=",
"parser",
".",
"parse_known_args",
"(",
"args",
")",
"extra_args",
"=",
"process_unknown_arguments",
"(",
"unknowns",
")",
"# logger file",
"if",
"args",
".",
"standalone",
":",
"import",
"numina",
".",
"ext",
".",
"gtc",
"numina",
".",
"ext",
".",
"gtc",
".",
"ignore_gtc_check",
"(",
")",
"try",
":",
"if",
"args",
".",
"logging",
"is",
"not",
"None",
":",
"loggingf",
"=",
"args",
".",
"logging",
"else",
":",
"loggingf",
"=",
"config",
".",
"get",
"(",
"'numina'",
",",
"'logging'",
")",
"with",
"open",
"(",
"loggingf",
")",
"as",
"logfile",
":",
"logconf",
"=",
"yaml",
".",
"load",
"(",
"logfile",
")",
"logging",
".",
"config",
".",
"dictConfig",
"(",
"logconf",
")",
"except",
"configparser",
".",
"Error",
":",
"logging",
".",
"config",
".",
"dictConfig",
"(",
"numina_cli_logconf",
")",
"_logger",
".",
"debug",
"(",
"'Numina simple recipe runner version %s'",
",",
"__version__",
")",
"command",
"=",
"getattr",
"(",
"args",
",",
"'command'",
",",
"None",
")",
"if",
"command",
"is",
"not",
"None",
":",
"args",
".",
"command",
"(",
"args",
",",
"extra_args",
")"
] | Entry point for the Numina CLI. | [
"Entry",
"point",
"for",
"the",
"Numina",
"CLI",
"."
] | train | https://github.com/guaix-ucm/numina/blob/6c829495df8937f77c2de9383c1038ffb3e713e3/numina/user/cli.py#L33-L149 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Entry point for the Numina CLI.
### Response:
def main(args=None):
"""Entry point for the Numina CLI."""
# Configuration args from a text file
config = configparser.SafeConfigParser()
# Building programatically
config.add_section('numina')
config.set('numina', 'format', 'yaml')
# Custom values
config.read([
os.path.join(xdg_config_home, 'numina/numina.cfg'),
'.numina.cfg'
])
parser0 = argparse.ArgumentParser(
description='Command line interface of Numina',
prog='numina',
epilog="For detailed help pass --help to a target",
add_help=False
)
parser0.add_argument('--disable-plugins', action='store_true')
args0, args = parser0.parse_known_args(args)
# Load plugin commands if enabled
subcmd_load = []
if not args0.disable_plugins:
for entry in pkg_resources.iter_entry_points(
group='numina.plugins.1'
):
try:
register = entry.load()
subcmd_load.append(register)
except Exception as error:
print(error, file=sys.stderr)
parser = argparse.ArgumentParser(
description='Command line interface of Numina',
prog='numina',
epilog="For detailed help pass --help to a target"
)
parser.add_argument('--disable-plugins', action='store_true',
help='disable plugin loading')
parser.add_argument(
'-l', action="store", dest="logging", metavar="FILE",
help="FILE with logging configuration"
)
parser.add_argument(
'-d', '--debug',
action="store_true",
dest="debug", default=False,
help="make lots of noise"
)
parser.add_argument(
'--standalone',
action="store_true",
dest="standalone", default=False,
help="do not activate GTC compatibility code"
)
# Due to a problem with argparse
# this command blocks the defaults of the subparsers
# in argparse of Pyhton < 2.7.9
# https://bugs.python.org/issue9351
# parser.set_defaults(command=None)
subparsers = parser.add_subparsers(
title='Targets',
description='These are valid commands you can ask numina to do.'
)
# Init subcommands
cmds = ['clishowins', 'clishowom', 'clishowrecip',
'clirun', 'clirunrec']
for cmd in cmds:
cmd_mod = import_module('.%s' % (cmd, ), 'numina.user')
register = getattr(cmd_mod, 'register', None)
if register is not None:
register(subparsers, config)
# Add commands by plugins
for register in subcmd_load:
try:
register(subparsers, config)
except Exception as error:
print(error, file=sys.stderr)
args, unknowns = parser.parse_known_args(args)
extra_args = process_unknown_arguments(unknowns)
# logger file
if args.standalone:
import numina.ext.gtc
numina.ext.gtc.ignore_gtc_check()
try:
if args.logging is not None:
loggingf = args.logging
else:
loggingf = config.get('numina', 'logging')
with open(loggingf) as logfile:
logconf = yaml.load(logfile)
logging.config.dictConfig(logconf)
except configparser.Error:
logging.config.dictConfig(numina_cli_logconf)
_logger.debug('Numina simple recipe runner version %s', __version__)
command = getattr(args, 'command', None)
if command is not None:
args.command(args, extra_args)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5998,
1486,
369,
279,
16610,
2259,
40377,
382,
14711,
6075,
512,
755,
1925,
7506,
5980,
997,
262,
4304,
5998,
1486,
369,
279,
16610,
2259,
40377,
30284,
262,
674,
12499,
2897,
505,
264,
1495,
1052,
198,
262,
2242,
284,
98537,
90928,
2714,
6707,
2892,
262,
674,
17283,
2068,
7167,
198,
262,
2242,
1388,
16619,
493,
2470,
2259,
1329,
262,
2242,
995,
493,
2470,
2259,
518,
364,
2293,
518,
364,
42566,
4713,
262,
674,
8572,
2819,
198,
262,
2242,
4217,
9133,
286,
2709,
3960,
5563,
2120,
36238,
5445,
22389,
11,
364,
2470,
2259,
14,
2470,
2259,
31581,
3379,
286,
6389,
2470,
2259,
31581,
1270,
262,
58093,
262,
6871,
15,
284,
23122,
39066,
1021,
286,
4096,
1151,
4153,
1584,
3834,
315,
16610,
2259,
756,
286,
30371,
1151,
2470,
2259,
756,
286,
4248,
51873,
429,
2520,
11944,
1520,
1522,
1198,
8823,
311,
264,
2218,
761,
286,
923,
28024,
5725,
198,
286,
5235,
262,
6871,
15,
1388,
9202,
17052,
18502,
84846,
518,
1957,
1151,
4412,
16469,
4713,
262,
2897,
15,
11,
2897,
284,
6871,
15,
4736,
72790,
8550,
7506,
696,
262,
674,
9069,
9183,
11545,
422,
9147,
198,
262,
1207,
8883,
12693,
284,
14941,
262,
422,
539,
2897,
15,
43728,
46758,
512,
286,
369,
4441,
304,
25830,
36669,
20036,
9255,
13224,
1021,
394,
1912,
1151,
2470,
2259,
30491,
13,
16,
1270,
286,
21711,
310,
1456,
512,
394,
4254,
284,
4441,
5214,
746,
394,
1207,
8883,
12693,
2102,
69266,
340,
310,
3734,
4204,
439,
1493,
512,
394,
1194,
6524,
11,
1052,
59970,
35842,
696,
262,
6871,
284,
23122,
39066,
1021,
286,
4096,
1151,
4153,
1584,
3834,
315,
16610,
2259,
756,
286,
30371,
1151,
2470,
2259,
756,
286,
4248,
51873,
429,
2520,
11944,
1520,
1522,
1198,
8823,
311,
264,
2218,
702,
286,
5235,
262,
6871,
1388,
9202,
17052,
18502,
84846,
518,
1957,
1151,
4412,
16469,
756,
667,
1520,
1151,
18502,
9183,
8441,
1329,
262,
6871,
1388,
9202,
1021,
286,
7944,
75,
518,
1957,
429,
4412,
498,
3281,
429,
26330,
498,
52318,
429,
6169,
761,
286,
1520,
429,
6169,
449,
8558,
6683,
702,
286,
1763,
262,
6871,
1388,
9202,
1021,
286,
7944,
67,
518,
17753,
8514,
756,
286,
1957,
429,
4412,
16469,
761,
286,
3281,
429,
8514,
498,
1670,
5725,
345,
286,
1520,
429,
7072,
10283,
315,
12248,
702,
286,
5235,
262,
6871,
1388,
9202,
1021,
286,
17753,
2752,
32676,
756,
286,
1957,
429,
4412,
16469,
761,
286,
3281,
429,
2752,
32676,
498,
1670,
5725,
345,
286,
1520,
429,
3055,
539,
20891,
480,
7905,
25780,
2082,
702,
286,
5235,
262,
674,
24586,
311,
264,
3575,
449,
23122,
198,
262,
674,
420,
3290,
10215,
279,
17088,
315,
279,
1207,
89664,
198,
262,
674,
304,
23122,
315,
5468,
65812,
366,
220,
17,
13,
22,
13,
24,
198,
262,
674,
3788,
1129,
57276,
44293,
2726,
14,
11407,
26970,
16,
198,
262,
674,
6871,
995,
43390,
15494,
5980,
696,
262,
1207,
89664,
284,
6871,
1388
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5998,
1486,
369,
279,
16610,
2259,
40377,
382,
14711,
6075,
512,
755,
1925,
7506,
5980,
997,
262,
4304,
5998,
1486,
369,
279,
16610,
2259,
40377,
30284,
262,
674,
12499,
2897,
505,
264,
1495,
1052,
198,
262,
2242,
284,
98537,
90928,
2714,
6707,
2892,
262,
674,
17283,
2068,
7167,
198,
262,
2242,
1388,
16619,
493,
2470,
2259,
1329,
262,
2242,
995,
493,
2470,
2259,
518,
364,
2293,
518,
364,
42566,
4713,
262,
674,
8572,
2819,
198,
262,
2242,
4217,
9133,
286,
2709,
3960,
5563,
2120,
36238,
5445,
22389,
11,
364,
2470,
2259,
14,
2470,
2259,
31581,
3379,
286,
6389,
2470,
2259,
31581,
1270,
262,
58093,
262,
6871,
15,
284,
23122,
39066,
1021,
286,
4096,
1151,
4153,
1584,
3834,
315,
16610,
2259,
756,
286,
30371,
1151,
2470,
2259,
756,
286,
4248,
51873,
429,
2520,
11944,
1520,
1522,
1198,
8823,
311,
264,
2218,
761,
286,
923,
28024,
5725,
198,
286,
5235,
262,
6871,
15,
1388,
9202,
17052,
18502,
84846,
518,
1957,
1151,
4412,
16469,
4713,
262,
2897,
15,
11,
2897,
284,
6871,
15,
4736,
72790,
8550,
7506,
696,
262,
674,
9069,
9183,
11545,
422,
9147,
198,
262,
1207,
8883,
12693,
284,
14941,
262,
422,
539,
2897,
15,
43728,
46758,
512,
286,
369,
4441,
304,
25830,
36669,
20036,
9255,
13224,
1021,
394,
1912,
1151,
2470,
2259,
30491,
13,
16,
1270,
286,
21711,
310,
1456,
512,
394,
4254,
284,
4441,
5214,
746,
394,
1207,
8883,
12693,
2102,
69266,
340,
310,
3734,
4204,
439,
1493,
512,
394,
1194,
6524,
11,
1052,
59970,
35842,
696,
262,
6871,
284,
23122,
39066,
1021,
286,
4096,
1151,
4153,
1584,
3834,
315,
16610,
2259,
756,
286,
30371,
1151,
2470,
2259,
756,
286,
4248,
51873,
429,
2520,
11944,
1520,
1522,
1198,
8823,
311,
264,
2218,
702,
286,
5235,
262,
6871,
1388,
9202,
17052,
18502,
84846,
518,
1957,
1151,
4412,
16469,
756,
667,
1520,
1151,
18502,
9183,
8441,
1329,
262,
6871,
1388,
9202,
1021,
286,
7944,
75,
518,
1957,
429,
4412,
498,
3281,
429,
26330,
498,
52318,
429,
6169,
761,
286,
1520,
429,
6169,
449,
8558,
6683,
702,
286,
1763,
262,
6871,
1388,
9202,
1021,
286,
7944,
67,
518,
17753,
8514,
756,
286,
1957,
429,
4412,
16469,
761,
286,
3281,
429,
8514,
498,
1670,
5725,
345,
286,
1520,
429,
7072,
10283,
315,
12248,
702,
286,
5235,
262,
6871,
1388,
9202,
1021,
286,
17753,
2752,
32676,
756,
286,
1957,
429,
4412,
16469,
761,
286,
3281,
429,
2752,
32676,
498,
1670,
5725,
345,
286,
1520,
429,
3055,
539,
20891,
480,
7905,
25780,
2082,
702,
286,
5235,
262,
674,
24586,
311,
264,
3575,
449,
23122,
198,
262,
674,
420,
3290,
10215,
279,
17088,
315,
279,
1207,
89664,
198,
262,
674,
304,
23122,
315,
5468,
65812,
366,
220,
17,
13,
22,
13,
24,
198,
262,
674,
3788,
1129,
57276,
44293,
2726,
14,
11407,
26970,
16,
198,
262,
674,
6871,
995,
43390,
15494,
5980,
696,
262,
1207,
89664,
284,
6871,
1388
] |
lrq3000/pyFileFixity | pyFileFixity/lib/profilers/visual/pympler/classtracker.py | TrackedObject._save_trace | def _save_trace(self):
"""
Save current stack trace as formatted string.
"""
stack_trace = stack()
try:
self.trace = []
for frm in stack_trace[5:]: # eliminate our own overhead
self.trace.insert(0, frm[1:])
finally:
del stack_trace | python | def _save_trace(self):
"""
Save current stack trace as formatted string.
"""
stack_trace = stack()
try:
self.trace = []
for frm in stack_trace[5:]: # eliminate our own overhead
self.trace.insert(0, frm[1:])
finally:
del stack_trace | [
"def",
"_save_trace",
"(",
"self",
")",
":",
"stack_trace",
"=",
"stack",
"(",
")",
"try",
":",
"self",
".",
"trace",
"=",
"[",
"]",
"for",
"frm",
"in",
"stack_trace",
"[",
"5",
":",
"]",
":",
"# eliminate our own overhead",
"self",
".",
"trace",
".",
"insert",
"(",
"0",
",",
"frm",
"[",
"1",
":",
"]",
")",
"finally",
":",
"del",
"stack_trace"
] | Save current stack trace as formatted string. | [
"Save",
"current",
"stack",
"trace",
"as",
"formatted",
"string",
"."
] | train | https://github.com/lrq3000/pyFileFixity/blob/fd5ef23bb13835faf1e3baa773619b86a1cc9bdf/pyFileFixity/lib/profilers/visual/pympler/classtracker.py#L110-L120 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Save current stack trace as formatted string.
### Response:
def _save_trace(self):
"""
Save current stack trace as formatted string.
"""
stack_trace = stack()
try:
self.trace = []
for frm in stack_trace[5:]: # eliminate our own overhead
self.trace.insert(0, frm[1:])
finally:
del stack_trace
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8960,
1510,
5729,
11917,
439,
24001,
925,
382,
14711,
6075,
512,
755,
721,
6766,
24489,
1214,
997,
286,
3270,
286,
10467,
1510,
5729,
11917,
439,
24001,
925,
627,
286,
3270,
286,
5729,
24489,
284,
5729,
746,
286,
1456,
512,
310,
659,
35512,
284,
4260,
310,
369,
29454,
304,
5729,
24489,
58,
20,
25,
5787,
674,
22472,
1057,
1866,
32115,
198,
394,
659,
35512,
7175,
7,
15,
11,
29454,
58,
16,
44157,
286,
5616,
512,
310,
1624,
5729,
24489,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8960,
1510,
5729,
11917,
439,
24001,
925,
382,
14711,
6075,
512,
755,
721,
6766,
24489,
1214,
997,
286,
3270,
286,
10467,
1510,
5729,
11917,
439,
24001,
925,
627,
286,
3270,
286,
5729,
24489,
284,
5729,
746,
286,
1456,
512,
310,
659,
35512,
284,
4260,
310,
369,
29454,
304,
5729,
24489,
58,
20,
25,
5787,
674,
22472,
1057,
1866,
32115,
198,
394,
659,
35512,
7175,
7,
15,
11,
29454,
58,
16,
44157,
286,
5616,
512,
310,
1624,
5729,
24489,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
wakatime/wakatime | wakatime/packages/pygments/console.py | ansiformat | def ansiformat(attr, text):
"""
Format ``text`` with a color and/or some attributes::
color normal color
*color* bold color
_color_ underlined color
+color+ blinking color
"""
result = []
if attr[:1] == attr[-1:] == '+':
result.append(codes['blink'])
attr = attr[1:-1]
if attr[:1] == attr[-1:] == '*':
result.append(codes['bold'])
attr = attr[1:-1]
if attr[:1] == attr[-1:] == '_':
result.append(codes['underline'])
attr = attr[1:-1]
result.append(codes[attr])
result.append(text)
result.append(codes['reset'])
return ''.join(result) | python | def ansiformat(attr, text):
"""
Format ``text`` with a color and/or some attributes::
color normal color
*color* bold color
_color_ underlined color
+color+ blinking color
"""
result = []
if attr[:1] == attr[-1:] == '+':
result.append(codes['blink'])
attr = attr[1:-1]
if attr[:1] == attr[-1:] == '*':
result.append(codes['bold'])
attr = attr[1:-1]
if attr[:1] == attr[-1:] == '_':
result.append(codes['underline'])
attr = attr[1:-1]
result.append(codes[attr])
result.append(text)
result.append(codes['reset'])
return ''.join(result) | [
"def",
"ansiformat",
"(",
"attr",
",",
"text",
")",
":",
"result",
"=",
"[",
"]",
"if",
"attr",
"[",
":",
"1",
"]",
"==",
"attr",
"[",
"-",
"1",
":",
"]",
"==",
"'+'",
":",
"result",
".",
"append",
"(",
"codes",
"[",
"'blink'",
"]",
")",
"attr",
"=",
"attr",
"[",
"1",
":",
"-",
"1",
"]",
"if",
"attr",
"[",
":",
"1",
"]",
"==",
"attr",
"[",
"-",
"1",
":",
"]",
"==",
"'*'",
":",
"result",
".",
"append",
"(",
"codes",
"[",
"'bold'",
"]",
")",
"attr",
"=",
"attr",
"[",
"1",
":",
"-",
"1",
"]",
"if",
"attr",
"[",
":",
"1",
"]",
"==",
"attr",
"[",
"-",
"1",
":",
"]",
"==",
"'_'",
":",
"result",
".",
"append",
"(",
"codes",
"[",
"'underline'",
"]",
")",
"attr",
"=",
"attr",
"[",
"1",
":",
"-",
"1",
"]",
"result",
".",
"append",
"(",
"codes",
"[",
"attr",
"]",
")",
"result",
".",
"append",
"(",
"text",
")",
"result",
".",
"append",
"(",
"codes",
"[",
"'reset'",
"]",
")",
"return",
"''",
".",
"join",
"(",
"result",
")"
] | Format ``text`` with a color and/or some attributes::
color normal color
*color* bold color
_color_ underlined color
+color+ blinking color | [
"Format",
"text",
"with",
"a",
"color",
"and",
"/",
"or",
"some",
"attributes",
"::"
] | train | https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/pygments/console.py#L52-L74 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Format ``text`` with a color and/or some attributes::
color normal color
*color* bold color
_color_ underlined color
+color+ blinking color
### Response:
def ansiformat(attr, text):
"""
Format ``text`` with a color and/or some attributes::
color normal color
*color* bold color
_color_ underlined color
+color+ blinking color
"""
result = []
if attr[:1] == attr[-1:] == '+':
result.append(codes['blink'])
attr = attr[1:-1]
if attr[:1] == attr[-1:] == '*':
result.append(codes['bold'])
attr = attr[1:-1]
if attr[:1] == attr[-1:] == '_':
result.append(codes['underline'])
attr = attr[1:-1]
result.append(codes[attr])
result.append(text)
result.append(codes['reset'])
return ''.join(result)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4152,
10103,
1342,
14196,
449,
264,
1933,
323,
5255,
1063,
8365,
66152,
286,
1933,
996,
4725,
1933,
198,
286,
353,
3506,
9,
257,
14265,
1933,
198,
286,
721,
3506,
62,
257,
1234,
15472,
1933,
198,
286,
489,
3506,
10,
257,
85122,
1933,
271,
14711,
6075,
512,
755,
8261,
7398,
266,
33531,
11,
1495,
997,
262,
3270,
262,
15392,
10103,
1342,
14196,
449,
264,
1933,
323,
5255,
1063,
8365,
66152,
286,
1933,
996,
4725,
1933,
198,
286,
353,
3506,
9,
257,
14265,
1933,
198,
286,
721,
3506,
62,
257,
1234,
15472,
1933,
198,
286,
489,
3506,
10,
257,
85122,
1933,
198,
262,
3270,
262,
1121,
284,
4260,
262,
422,
6510,
3530,
16,
60,
624,
6510,
7764,
16,
29383,
624,
14226,
3730,
286,
1121,
2102,
1361,
2601,
681,
55416,
7519,
286,
6510,
284,
6510,
58,
16,
11184,
16,
933,
262,
422,
6510,
3530,
16,
60,
624,
6510,
7764,
16,
29383,
624,
15224,
3730,
286,
1121,
2102,
1361,
2601,
681,
15168,
7519,
286,
6510,
284,
6510,
58,
16,
11184,
16,
933,
262,
422,
6510,
3530,
16,
60,
624,
6510,
7764,
16,
29383,
624,
9418,
3730,
286,
1121,
2102,
1361,
2601,
681,
46773,
7519,
286,
6510,
284,
6510,
58,
16,
11184,
16,
933,
262,
1121,
2102,
1361,
2601,
67562,
2608,
262,
1121,
2102,
7383,
340,
262,
1121,
2102,
1361,
2601,
681,
9915,
7519,
262,
471,
43963,
6115,
4556,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4152,
10103,
1342,
14196,
449,
264,
1933,
323,
5255,
1063,
8365,
66152,
286,
1933,
996,
4725,
1933,
198,
286,
353,
3506,
9,
257,
14265,
1933,
198,
286,
721,
3506,
62,
257,
1234,
15472,
1933,
198,
286,
489,
3506,
10,
257,
85122,
1933,
271,
14711,
6075,
512,
755,
8261,
7398,
266,
33531,
11,
1495,
997,
262,
3270,
262,
15392,
10103,
1342,
14196,
449,
264,
1933,
323,
5255,
1063,
8365,
66152,
286,
1933,
996,
4725,
1933,
198,
286,
353,
3506,
9,
257,
14265,
1933,
198,
286,
721,
3506,
62,
257,
1234,
15472,
1933,
198,
286,
489,
3506,
10,
257,
85122,
1933,
198,
262,
3270,
262,
1121,
284,
4260,
262,
422,
6510,
3530,
16,
60,
624,
6510,
7764,
16,
29383,
624,
14226,
3730,
286,
1121,
2102,
1361,
2601,
681,
55416,
7519,
286,
6510,
284,
6510,
58,
16,
11184,
16,
933,
262,
422,
6510,
3530,
16,
60,
624,
6510,
7764,
16,
29383,
624,
15224,
3730,
286,
1121,
2102,
1361,
2601,
681,
15168,
7519,
286,
6510,
284,
6510,
58,
16,
11184,
16,
933,
262,
422,
6510,
3530,
16,
60,
624,
6510,
7764,
16,
29383,
624,
9418,
3730,
286,
1121,
2102,
1361,
2601,
681,
46773,
7519,
286,
6510,
284,
6510,
58,
16,
11184,
16,
933,
262,
1121,
2102,
1361,
2601,
67562,
2608,
262,
1121,
2102,
7383,
340,
262,
1121,
2102,
1361,
2601,
681,
9915,
7519,
262,
471,
43963,
6115,
4556,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pywbem/pywbem | attic/cimxml_parse.py | _get_end_event | def _get_end_event(parser, tagName):
"""Check that the next event is the end of a particular XML tag."""
(event, node) = six.next(parser)
if event != pulldom.END_ELEMENT or node.tagName != tagName:
raise ParseError(
'Expecting %s end tag, got %s %s' % (tagName, event, node.tagName)) | python | def _get_end_event(parser, tagName):
"""Check that the next event is the end of a particular XML tag."""
(event, node) = six.next(parser)
if event != pulldom.END_ELEMENT or node.tagName != tagName:
raise ParseError(
'Expecting %s end tag, got %s %s' % (tagName, event, node.tagName)) | [
"def",
"_get_end_event",
"(",
"parser",
",",
"tagName",
")",
":",
"(",
"event",
",",
"node",
")",
"=",
"six",
".",
"next",
"(",
"parser",
")",
"if",
"event",
"!=",
"pulldom",
".",
"END_ELEMENT",
"or",
"node",
".",
"tagName",
"!=",
"tagName",
":",
"raise",
"ParseError",
"(",
"'Expecting %s end tag, got %s %s'",
"%",
"(",
"tagName",
",",
"event",
",",
"node",
".",
"tagName",
")",
")"
] | Check that the next event is the end of a particular XML tag. | [
"Check",
"that",
"the",
"next",
"event",
"is",
"the",
"end",
"of",
"a",
"particular",
"XML",
"tag",
"."
] | train | https://github.com/pywbem/pywbem/blob/e54ecb82c2211e289a268567443d60fdd489f1e4/attic/cimxml_parse.py#L71-L78 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Check that the next event is the end of a particular XML tag.
### Response:
def _get_end_event(parser, tagName):
"""Check that the next event is the end of a particular XML tag."""
(event, node) = six.next(parser)
if event != pulldom.END_ELEMENT or node.tagName != tagName:
raise ParseError(
'Expecting %s end tag, got %s %s' % (tagName, event, node.tagName))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4061,
430,
279,
1828,
1567,
374,
279,
842,
315,
264,
4040,
12138,
4877,
382,
14711,
6075,
512,
755,
721,
456,
6345,
6891,
36435,
11,
63467,
997,
262,
4304,
4061,
430,
279,
1828,
1567,
374,
279,
842,
315,
264,
4040,
12138,
4877,
30284,
262,
320,
3163,
11,
2494,
8,
284,
4848,
4630,
36435,
696,
262,
422,
1567,
976,
7893,
509,
316,
56598,
28255,
477,
2494,
58115,
976,
63467,
512,
286,
4933,
15118,
1480,
1021,
310,
364,
17995,
287,
1034,
82,
842,
4877,
11,
2751,
1034,
82,
1034,
82,
6,
1034,
320,
74373,
11,
1567,
11,
2494,
58115,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4061,
430,
279,
1828,
1567,
374,
279,
842,
315,
264,
4040,
12138,
4877,
382,
14711,
6075,
512,
755,
721,
456,
6345,
6891,
36435,
11,
63467,
997,
262,
4304,
4061,
430,
279,
1828,
1567,
374,
279,
842,
315,
264,
4040,
12138,
4877,
30284,
262,
320,
3163,
11,
2494,
8,
284,
4848,
4630,
36435,
696,
262,
422,
1567,
976,
7893,
509,
316,
56598,
28255,
477,
2494,
58115,
976,
63467,
512,
286,
4933,
15118,
1480,
1021,
310,
364,
17995,
287,
1034,
82,
842,
4877,
11,
2751,
1034,
82,
1034,
82,
6,
1034,
320,
74373,
11,
1567,
11,
2494,
58115,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
saltstack/salt | salt/modules/at_solaris.py | at | def at(*args, **kwargs): # pylint: disable=C0103
'''
Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim
'''
# check args
if len(args) < 2:
return {'jobs': []}
# build job
if 'tag' in kwargs:
stdin = '### SALT: {0}\n{1}'.format(kwargs['tag'], ' '.join(args[1:]))
else:
stdin = ' '.join(args[1:])
cmd_kwargs = {'stdin': stdin, 'python_shell': False}
if 'runas' in kwargs:
cmd_kwargs['runas'] = kwargs['runas']
res = __salt__['cmd.run_all']('at "{timespec}"'.format(
timespec=args[0]
), **cmd_kwargs)
# verify job creation
if res['retcode'] > 0:
if 'bad time specification' in res['stderr']:
return {'jobs': [], 'error': 'invalid timespec'}
return {'jobs': [], 'error': res['stderr']}
else:
jobid = res['stderr'].splitlines()[1]
jobid = six.text_type(jobid.split()[1])
return atq(jobid) | python | def at(*args, **kwargs): # pylint: disable=C0103
'''
Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim
'''
# check args
if len(args) < 2:
return {'jobs': []}
# build job
if 'tag' in kwargs:
stdin = '### SALT: {0}\n{1}'.format(kwargs['tag'], ' '.join(args[1:]))
else:
stdin = ' '.join(args[1:])
cmd_kwargs = {'stdin': stdin, 'python_shell': False}
if 'runas' in kwargs:
cmd_kwargs['runas'] = kwargs['runas']
res = __salt__['cmd.run_all']('at "{timespec}"'.format(
timespec=args[0]
), **cmd_kwargs)
# verify job creation
if res['retcode'] > 0:
if 'bad time specification' in res['stderr']:
return {'jobs': [], 'error': 'invalid timespec'}
return {'jobs': [], 'error': res['stderr']}
else:
jobid = res['stderr'].splitlines()[1]
jobid = six.text_type(jobid.split()[1])
return atq(jobid) | [
"def",
"at",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# pylint: disable=C0103",
"# check args",
"if",
"len",
"(",
"args",
")",
"<",
"2",
":",
"return",
"{",
"'jobs'",
":",
"[",
"]",
"}",
"# build job",
"if",
"'tag'",
"in",
"kwargs",
":",
"stdin",
"=",
"'### SALT: {0}\\n{1}'",
".",
"format",
"(",
"kwargs",
"[",
"'tag'",
"]",
",",
"' '",
".",
"join",
"(",
"args",
"[",
"1",
":",
"]",
")",
")",
"else",
":",
"stdin",
"=",
"' '",
".",
"join",
"(",
"args",
"[",
"1",
":",
"]",
")",
"cmd_kwargs",
"=",
"{",
"'stdin'",
":",
"stdin",
",",
"'python_shell'",
":",
"False",
"}",
"if",
"'runas'",
"in",
"kwargs",
":",
"cmd_kwargs",
"[",
"'runas'",
"]",
"=",
"kwargs",
"[",
"'runas'",
"]",
"res",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"'at \"{timespec}\"'",
".",
"format",
"(",
"timespec",
"=",
"args",
"[",
"0",
"]",
")",
",",
"*",
"*",
"cmd_kwargs",
")",
"# verify job creation",
"if",
"res",
"[",
"'retcode'",
"]",
">",
"0",
":",
"if",
"'bad time specification'",
"in",
"res",
"[",
"'stderr'",
"]",
":",
"return",
"{",
"'jobs'",
":",
"[",
"]",
",",
"'error'",
":",
"'invalid timespec'",
"}",
"return",
"{",
"'jobs'",
":",
"[",
"]",
",",
"'error'",
":",
"res",
"[",
"'stderr'",
"]",
"}",
"else",
":",
"jobid",
"=",
"res",
"[",
"'stderr'",
"]",
".",
"splitlines",
"(",
")",
"[",
"1",
"]",
"jobid",
"=",
"six",
".",
"text_type",
"(",
"jobid",
".",
"split",
"(",
")",
"[",
"1",
"]",
")",
"return",
"atq",
"(",
"jobid",
")"
] | Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim | [
"Add",
"a",
"job",
"to",
"the",
"queue",
"."
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/at_solaris.py#L170-L211 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim
### Response:
def at(*args, **kwargs): # pylint: disable=C0103
'''
Add a job to the queue.
The 'timespec' follows the format documented in the
at(1) manpage.
CLI Example:
.. code-block:: bash
salt '*' at.at <timespec> <cmd> [tag=<tag>] [runas=<user>]
salt '*' at.at 12:05am '/sbin/reboot' tag=reboot
salt '*' at.at '3:05am +3 days' 'bin/myscript' tag=nightly runas=jim
'''
# check args
if len(args) < 2:
return {'jobs': []}
# build job
if 'tag' in kwargs:
stdin = '### SALT: {0}\n{1}'.format(kwargs['tag'], ' '.join(args[1:]))
else:
stdin = ' '.join(args[1:])
cmd_kwargs = {'stdin': stdin, 'python_shell': False}
if 'runas' in kwargs:
cmd_kwargs['runas'] = kwargs['runas']
res = __salt__['cmd.run_all']('at "{timespec}"'.format(
timespec=args[0]
), **cmd_kwargs)
# verify job creation
if res['retcode'] > 0:
if 'bad time specification' in res['stderr']:
return {'jobs': [], 'error': 'invalid timespec'}
return {'jobs': [], 'error': res['stderr']}
else:
jobid = res['stderr'].splitlines()[1]
jobid = six.text_type(jobid.split()[1])
return atq(jobid)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
264,
2683,
311,
279,
7325,
382,
262,
578,
364,
15487,
1007,
6,
11263,
279,
3645,
27470,
304,
279,
198,
262,
520,
7,
16,
8,
893,
2964,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
520,
6990,
366,
15487,
1007,
29,
366,
8883,
29,
510,
4681,
39798,
4681,
54629,
510,
6236,
300,
39798,
882,
29,
933,
286,
12290,
31801,
520,
6990,
220,
717,
25,
2304,
309,
3434,
93363,
10991,
4722,
6,
4877,
50752,
4722,
198,
286,
12290,
31801,
520,
6990,
364,
18,
25,
2304,
309,
489,
18,
2919,
6,
364,
7006,
3262,
1065,
1250,
6,
4877,
28,
9471,
398,
1629,
300,
46712,
318,
271,
14711,
6075,
512,
755,
520,
4163,
2164,
11,
3146,
9872,
1680,
220,
674,
51471,
25,
11404,
42017,
7755,
18,
198,
262,
11414,
262,
2758,
264,
2683,
311,
279,
7325,
382,
262,
578,
364,
15487,
1007,
6,
11263,
279,
3645,
27470,
304,
279,
198,
262,
520,
7,
16,
8,
893,
2964,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
520,
6990,
366,
15487,
1007,
29,
366,
8883,
29,
510,
4681,
39798,
4681,
54629,
510,
6236,
300,
39798,
882,
29,
933,
286,
12290,
31801,
520,
6990,
220,
717,
25,
2304,
309,
3434,
93363,
10991,
4722,
6,
4877,
50752,
4722,
198,
286,
12290,
31801,
520,
6990,
364,
18,
25,
2304,
309,
489,
18,
2919,
6,
364,
7006,
3262,
1065,
1250,
6,
4877,
28,
9471,
398,
1629,
300,
46712,
318,
198,
262,
45832,
262,
674,
1817,
2897,
198,
262,
422,
2479,
7506,
8,
366,
220,
17,
512,
286,
471,
5473,
32205,
1232,
3132,
633,
262,
674,
1977,
2683,
198,
262,
422,
364,
4681,
6,
304,
16901,
512,
286,
32469,
284,
364,
14711,
328,
36930,
25,
314,
15,
11281,
77,
90,
16,
24398,
2293,
71706,
681,
4681,
4181,
364,
6389,
6115,
7506,
58,
16,
25,
11147,
262,
775,
512,
286,
32469,
284,
364,
6389,
6115,
7506,
58,
16,
25,
9801,
262,
5556,
37335,
284,
5473,
52702,
1232,
32469,
11,
364,
12958,
50045,
1232,
3641,
534,
262,
422,
364,
6236,
300,
6,
304,
16901,
512,
286,
5556,
37335,
681,
6236,
300,
663,
284,
16901,
681,
6236,
300,
4532,
262,
594,
284,
1328,
43326,
565,
681,
8883,
7789,
5823,
663,
493,
266,
14190,
15487,
1007,
10064,
4527,
2293,
1021,
286,
72256,
32358,
58,
15,
933,
262,
7026,
3146,
8883,
37335,
696,
262,
674,
10356,
2683,
9886,
198,
262,
422,
594,
681,
2171,
1889,
663,
871,
220,
15,
512,
286,
422,
364,
14176,
892,
26185,
6,
304,
594,
681,
37522,
18888,
310,
471,
5473,
32205,
1232,
10277,
364,
850,
1232,
364,
12071,
72256,
16823,
286,
471,
5473,
32205,
1232,
10277,
364,
850,
1232,
594,
681,
37522,
63987,
262,
775,
512,
286,
2683,
307,
284,
594,
681,
37522,
7352,
7105,
8128,
10324,
16,
933,
286,
2683,
307,
284,
4848,
2858,
1857,
29429,
307,
5402
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2261,
264,
2683,
311,
279,
7325,
382,
262,
578,
364,
15487,
1007,
6,
11263,
279,
3645,
27470,
304,
279,
198,
262,
520,
7,
16,
8,
893,
2964,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
520,
6990,
366,
15487,
1007,
29,
366,
8883,
29,
510,
4681,
39798,
4681,
54629,
510,
6236,
300,
39798,
882,
29,
933,
286,
12290,
31801,
520,
6990,
220,
717,
25,
2304,
309,
3434,
93363,
10991,
4722,
6,
4877,
50752,
4722,
198,
286,
12290,
31801,
520,
6990,
364,
18,
25,
2304,
309,
489,
18,
2919,
6,
364,
7006,
3262,
1065,
1250,
6,
4877,
28,
9471,
398,
1629,
300,
46712,
318,
271,
14711,
6075,
512,
755,
520,
4163,
2164,
11,
3146,
9872,
1680,
220,
674,
51471,
25,
11404,
42017,
7755,
18,
198,
262,
11414,
262,
2758,
264,
2683,
311,
279,
7325,
382,
262,
578,
364,
15487,
1007,
6,
11263,
279,
3645,
27470,
304,
279,
198,
262,
520,
7,
16,
8,
893,
2964,
382,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
520,
6990,
366,
15487,
1007,
29,
366,
8883,
29,
510,
4681,
39798,
4681,
54629,
510,
6236,
300,
39798,
882,
29,
933,
286,
12290,
31801,
520,
6990,
220,
717,
25,
2304,
309,
3434,
93363,
10991,
4722,
6,
4877,
50752,
4722,
198,
286,
12290,
31801,
520,
6990,
364,
18,
25,
2304,
309,
489,
18,
2919,
6,
364,
7006,
3262,
1065,
1250,
6,
4877,
28,
9471,
398,
1629,
300,
46712,
318,
198,
262,
45832,
262,
674,
1817,
2897,
198,
262,
422,
2479,
7506,
8,
366,
220,
17,
512,
286,
471,
5473,
32205,
1232,
3132,
633,
262,
674,
1977,
2683,
198,
262,
422,
364,
4681,
6,
304,
16901,
512,
286,
32469,
284,
364,
14711,
328,
36930,
25,
314,
15,
11281,
77,
90,
16,
24398,
2293,
71706,
681,
4681,
4181,
364,
6389,
6115,
7506,
58,
16,
25,
11147,
262,
775,
512,
286,
32469,
284,
364,
6389,
6115,
7506,
58,
16,
25,
9801,
262,
5556,
37335,
284,
5473,
52702,
1232,
32469,
11,
364,
12958,
50045,
1232,
3641,
534,
262,
422,
364,
6236,
300,
6,
304,
16901,
512,
286,
5556,
37335,
681,
6236,
300,
663,
284,
16901,
681,
6236,
300,
4532,
262,
594,
284,
1328,
43326,
565,
681,
8883,
7789,
5823,
663,
493,
266,
14190,
15487,
1007,
10064,
4527,
2293,
1021,
286,
72256,
32358,
58,
15,
933,
262,
7026,
3146,
8883,
37335,
696,
262,
674,
10356,
2683,
9886,
198,
262,
422,
594,
681,
2171,
1889,
663,
871,
220,
15,
512,
286,
422,
364,
14176,
892,
26185,
6,
304,
594,
681,
37522,
18888,
310,
471,
5473,
32205,
1232,
10277,
364,
850,
1232,
364,
12071,
72256,
16823,
286,
471,
5473,
32205,
1232,
10277,
364,
850,
1232,
594,
681,
37522,
63987,
262,
775,
512,
286,
2683,
307,
284,
594,
681,
37522,
7352,
7105,
8128,
10324,
16,
933,
286,
2683,
307,
284,
4848,
2858,
1857,
29429,
307,
5402
] |
autokey/autokey | lib/autokey/scripting.py | GtkClipboard.get_selection | def get_selection(self):
"""
Read text from the X selection
Usage: C{clipboard.get_selection()}
@return: text contents of the mouse selection
@rtype: C{str}
@raise Exception: if no text was found in the selection
"""
Gdk.threads_enter()
text = self.selection.wait_for_text()
Gdk.threads_leave()
if text is not None:
return text
else:
raise Exception("No text found in X selection") | python | def get_selection(self):
"""
Read text from the X selection
Usage: C{clipboard.get_selection()}
@return: text contents of the mouse selection
@rtype: C{str}
@raise Exception: if no text was found in the selection
"""
Gdk.threads_enter()
text = self.selection.wait_for_text()
Gdk.threads_leave()
if text is not None:
return text
else:
raise Exception("No text found in X selection") | [
"def",
"get_selection",
"(",
"self",
")",
":",
"Gdk",
".",
"threads_enter",
"(",
")",
"text",
"=",
"self",
".",
"selection",
".",
"wait_for_text",
"(",
")",
"Gdk",
".",
"threads_leave",
"(",
")",
"if",
"text",
"is",
"not",
"None",
":",
"return",
"text",
"else",
":",
"raise",
"Exception",
"(",
"\"No text found in X selection\"",
")"
] | Read text from the X selection
Usage: C{clipboard.get_selection()}
@return: text contents of the mouse selection
@rtype: C{str}
@raise Exception: if no text was found in the selection | [
"Read",
"text",
"from",
"the",
"X",
"selection",
"Usage",
":",
"C",
"{",
"clipboard",
".",
"get_selection",
"()",
"}"
] | train | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L841-L857 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Read text from the X selection
Usage: C{clipboard.get_selection()}
@return: text contents of the mouse selection
@rtype: C{str}
@raise Exception: if no text was found in the selection
### Response:
def get_selection(self):
"""
Read text from the X selection
Usage: C{clipboard.get_selection()}
@return: text contents of the mouse selection
@rtype: C{str}
@raise Exception: if no text was found in the selection
"""
Gdk.threads_enter()
text = self.selection.wait_for_text()
Gdk.threads_leave()
if text is not None:
return text
else:
raise Exception("No text found in X selection")
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4518,
1495,
505,
279,
1630,
6727,
9122,
286,
25585,
25,
356,
90,
71948,
673,
24596,
368,
633,
286,
571,
693,
25,
1495,
8970,
315,
279,
8814,
6727,
198,
286,
571,
33613,
25,
356,
90,
496,
534,
286,
571,
19223,
4204,
25,
422,
912,
1495,
574,
1766,
304,
279,
6727,
271,
14711,
6075,
512,
755,
636,
24596,
1214,
997,
286,
3270,
286,
4557,
1495,
505,
279,
1630,
6727,
9122,
286,
25585,
25,
356,
90,
71948,
673,
24596,
368,
633,
286,
571,
693,
25,
1495,
8970,
315,
279,
8814,
6727,
198,
286,
571,
33613,
25,
356,
90,
496,
534,
286,
571,
19223,
4204,
25,
422,
912,
1495,
574,
1766,
304,
279,
6727,
198,
286,
3270,
286,
76640,
13,
28386,
38580,
746,
286,
1495,
284,
659,
32642,
16693,
5595,
4424,
746,
286,
76640,
13,
28386,
63766,
746,
286,
422,
1495,
374,
539,
2290,
512,
310,
471,
1495,
198,
286,
775,
512,
310,
4933,
4204,
446,
2822,
1495,
1766,
304,
1630,
6727,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4518,
1495,
505,
279,
1630,
6727,
9122,
286,
25585,
25,
356,
90,
71948,
673,
24596,
368,
633,
286,
571,
693,
25,
1495,
8970,
315,
279,
8814,
6727,
198,
286,
571,
33613,
25,
356,
90,
496,
534,
286,
571,
19223,
4204,
25,
422,
912,
1495,
574,
1766,
304,
279,
6727,
271,
14711,
6075,
512,
755,
636,
24596,
1214,
997,
286,
3270,
286,
4557,
1495,
505,
279,
1630,
6727,
9122,
286,
25585,
25,
356,
90,
71948,
673,
24596,
368,
633,
286,
571,
693,
25,
1495,
8970,
315,
279,
8814,
6727,
198,
286,
571,
33613,
25,
356,
90,
496,
534,
286,
571,
19223,
4204,
25,
422,
912,
1495,
574,
1766,
304,
279,
6727,
198,
286,
3270,
286,
76640,
13,
28386,
38580,
746,
286,
1495,
284,
659,
32642,
16693,
5595,
4424,
746,
286,
76640,
13,
28386,
63766,
746,
286,
422,
1495,
374,
539,
2290,
512,
310,
471,
1495,
198,
286,
775,
512,
310,
4933,
4204,
446,
2822,
1495,
1766,
304,
1630,
6727,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
tgsmith61591/pmdarima | pmdarima/preprocessing/endog/boxcox.py | BoxCoxEndogTransformer.fit | def fit(self, y, exogenous=None):
"""Fit the transformer
Learns the value of ``lmbda``, if not specified in the constructor.
If defined in the constructor, is not re-learned.
Parameters
----------
y : array-like or None, shape=(n_samples,)
The endogenous (time-series) array.
exogenous : array-like or None, shape=(n_samples, n_features), optional
The exogenous array of additional covariates. Not used for
endogenous transformers. Default is None, and non-None values will
serve as pass-through arrays.
"""
lam1 = self.lmbda
lam2 = self.lmbda2
if lam2 < 0:
raise ValueError("lmbda2 must be a non-negative scalar value")
if lam1 is None:
y, _ = self._check_y_exog(y, exogenous)
_, lam1 = stats.boxcox(y, lmbda=None, alpha=None)
self.lam1_ = lam1
self.lam2_ = lam2
return self | python | def fit(self, y, exogenous=None):
"""Fit the transformer
Learns the value of ``lmbda``, if not specified in the constructor.
If defined in the constructor, is not re-learned.
Parameters
----------
y : array-like or None, shape=(n_samples,)
The endogenous (time-series) array.
exogenous : array-like or None, shape=(n_samples, n_features), optional
The exogenous array of additional covariates. Not used for
endogenous transformers. Default is None, and non-None values will
serve as pass-through arrays.
"""
lam1 = self.lmbda
lam2 = self.lmbda2
if lam2 < 0:
raise ValueError("lmbda2 must be a non-negative scalar value")
if lam1 is None:
y, _ = self._check_y_exog(y, exogenous)
_, lam1 = stats.boxcox(y, lmbda=None, alpha=None)
self.lam1_ = lam1
self.lam2_ = lam2
return self | [
"def",
"fit",
"(",
"self",
",",
"y",
",",
"exogenous",
"=",
"None",
")",
":",
"lam1",
"=",
"self",
".",
"lmbda",
"lam2",
"=",
"self",
".",
"lmbda2",
"if",
"lam2",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"lmbda2 must be a non-negative scalar value\"",
")",
"if",
"lam1",
"is",
"None",
":",
"y",
",",
"_",
"=",
"self",
".",
"_check_y_exog",
"(",
"y",
",",
"exogenous",
")",
"_",
",",
"lam1",
"=",
"stats",
".",
"boxcox",
"(",
"y",
",",
"lmbda",
"=",
"None",
",",
"alpha",
"=",
"None",
")",
"self",
".",
"lam1_",
"=",
"lam1",
"self",
".",
"lam2_",
"=",
"lam2",
"return",
"self"
] | Fit the transformer
Learns the value of ``lmbda``, if not specified in the constructor.
If defined in the constructor, is not re-learned.
Parameters
----------
y : array-like or None, shape=(n_samples,)
The endogenous (time-series) array.
exogenous : array-like or None, shape=(n_samples, n_features), optional
The exogenous array of additional covariates. Not used for
endogenous transformers. Default is None, and non-None values will
serve as pass-through arrays. | [
"Fit",
"the",
"transformer"
] | train | https://github.com/tgsmith61591/pmdarima/blob/a133de78ba5bd68da9785b061f519ba28cd514cc/pmdarima/preprocessing/endog/boxcox.py#L52-L80 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Fit the transformer
Learns the value of ``lmbda``, if not specified in the constructor.
If defined in the constructor, is not re-learned.
Parameters
----------
y : array-like or None, shape=(n_samples,)
The endogenous (time-series) array.
exogenous : array-like or None, shape=(n_samples, n_features), optional
The exogenous array of additional covariates. Not used for
endogenous transformers. Default is None, and non-None values will
serve as pass-through arrays.
### Response:
def fit(self, y, exogenous=None):
"""Fit the transformer
Learns the value of ``lmbda``, if not specified in the constructor.
If defined in the constructor, is not re-learned.
Parameters
----------
y : array-like or None, shape=(n_samples,)
The endogenous (time-series) array.
exogenous : array-like or None, shape=(n_samples, n_features), optional
The exogenous array of additional covariates. Not used for
endogenous transformers. Default is None, and non-None values will
serve as pass-through arrays.
"""
lam1 = self.lmbda
lam2 = self.lmbda2
if lam2 < 0:
raise ValueError("lmbda2 must be a non-negative scalar value")
if lam1 is None:
y, _ = self._check_y_exog(y, exogenous)
_, lam1 = stats.boxcox(y, lmbda=None, alpha=None)
self.lam1_ = lam1
self.lam2_ = lam2
return self
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
24231,
279,
43678,
271,
286,
61078,
4511,
279,
907,
315,
10103,
75,
3172,
3315,
91816,
422,
539,
5300,
304,
279,
4797,
627,
286,
1442,
4613,
304,
279,
4797,
11,
374,
539,
312,
12,
12964,
291,
382,
286,
13831,
198,
286,
31423,
286,
379,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
55245,
310,
578,
842,
53595,
320,
1712,
57432,
8,
1358,
382,
286,
506,
53595,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
11,
308,
15314,
705,
10309,
198,
310,
578,
506,
53595,
1358,
315,
5217,
22590,
2850,
988,
13,
2876,
1511,
369,
198,
310,
842,
53595,
87970,
13,
8058,
374,
2290,
11,
323,
2536,
12,
4155,
2819,
690,
198,
310,
8854,
439,
1522,
43847,
18893,
382,
14711,
6075,
512,
755,
5052,
1214,
11,
379,
11,
506,
53595,
5980,
997,
286,
4304,
24231,
279,
43678,
271,
286,
61078,
4511,
279,
907,
315,
10103,
75,
3172,
3315,
91816,
422,
539,
5300,
304,
279,
4797,
627,
286,
1442,
4613,
304,
279,
4797,
11,
374,
539,
312,
12,
12964,
291,
382,
286,
13831,
198,
286,
31423,
286,
379,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
55245,
310,
578,
842,
53595,
320,
1712,
57432,
8,
1358,
382,
286,
506,
53595,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
11,
308,
15314,
705,
10309,
198,
310,
578,
506,
53595,
1358,
315,
5217,
22590,
2850,
988,
13,
2876,
1511,
369,
198,
310,
842,
53595,
87970,
13,
8058,
374,
2290,
11,
323,
2536,
12,
4155,
2819,
690,
198,
310,
8854,
439,
1522,
43847,
18893,
627,
286,
3270,
286,
32703,
16,
284,
659,
929,
3172,
3315,
198,
286,
32703,
17,
284,
659,
929,
3172,
3315,
17,
271,
286,
422,
32703,
17,
366,
220,
15,
512,
310,
4933,
15764,
446,
75,
3172,
3315,
17,
2011,
387,
264,
2536,
62035,
17722,
907,
5240,
286,
422,
32703,
16,
374,
2290,
512,
310,
379,
11,
721,
284,
659,
1462,
2071,
4271,
2769,
540,
7166,
11,
506,
53595,
340,
310,
8523,
32703,
16,
284,
10691,
33708,
83100,
7166,
11,
326,
3172,
3315,
5980,
11,
8451,
5980,
696,
286,
659,
929,
309,
16,
62,
284,
32703,
16,
198,
286,
659,
929,
309,
17,
62,
284,
32703,
17,
198,
286,
471,
659,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
24231,
279,
43678,
271,
286,
61078,
4511,
279,
907,
315,
10103,
75,
3172,
3315,
91816,
422,
539,
5300,
304,
279,
4797,
627,
286,
1442,
4613,
304,
279,
4797,
11,
374,
539,
312,
12,
12964,
291,
382,
286,
13831,
198,
286,
31423,
286,
379,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
55245,
310,
578,
842,
53595,
320,
1712,
57432,
8,
1358,
382,
286,
506,
53595,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
11,
308,
15314,
705,
10309,
198,
310,
578,
506,
53595,
1358,
315,
5217,
22590,
2850,
988,
13,
2876,
1511,
369,
198,
310,
842,
53595,
87970,
13,
8058,
374,
2290,
11,
323,
2536,
12,
4155,
2819,
690,
198,
310,
8854,
439,
1522,
43847,
18893,
382,
14711,
6075,
512,
755,
5052,
1214,
11,
379,
11,
506,
53595,
5980,
997,
286,
4304,
24231,
279,
43678,
271,
286,
61078,
4511,
279,
907,
315,
10103,
75,
3172,
3315,
91816,
422,
539,
5300,
304,
279,
4797,
627,
286,
1442,
4613,
304,
279,
4797,
11,
374,
539,
312,
12,
12964,
291,
382,
286,
13831,
198,
286,
31423,
286,
379,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
55245,
310,
578,
842,
53595,
320,
1712,
57432,
8,
1358,
382,
286,
506,
53595,
551,
1358,
12970,
477,
2290,
11,
6211,
4640,
77,
18801,
11,
308,
15314,
705,
10309,
198,
310,
578,
506,
53595,
1358,
315,
5217,
22590,
2850,
988,
13,
2876,
1511,
369,
198,
310,
842,
53595,
87970,
13,
8058,
374,
2290,
11,
323,
2536,
12,
4155,
2819,
690,
198,
310,
8854,
439,
1522,
43847,
18893,
627,
286,
3270,
286,
32703,
16,
284,
659,
929,
3172,
3315,
198,
286,
32703,
17,
284,
659,
929,
3172,
3315,
17,
271,
286,
422,
32703,
17,
366,
220,
15,
512,
310,
4933,
15764,
446,
75,
3172,
3315,
17,
2011,
387,
264,
2536,
62035,
17722,
907,
5240,
286,
422,
32703,
16,
374,
2290,
512,
310,
379,
11,
721,
284,
659,
1462,
2071,
4271,
2769,
540,
7166,
11,
506,
53595,
340,
310,
8523,
32703,
16,
284,
10691,
33708,
83100,
7166,
11,
326,
3172,
3315,
5980,
11,
8451,
5980,
696,
286,
659,
929,
309,
16,
62,
284,
32703,
16,
198,
286,
659,
929,
309,
17,
62,
284,
32703,
17,
198,
286,
471,
659,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Shapeways/coyote_framework | coyote_framework/drivers/coyote_driverfactory.py | _log_fail_callback | def _log_fail_callback(driver, *args, **kwargs):
"""Raises an assertion error if the page has severe console errors
@param driver: ShapewaysDriver
@return: None
"""
try:
logs = driver.get_browser_log(levels=[BROWSER_LOG_LEVEL_SEVERE])
failure_message = 'There were severe console errors on this page: {}'.format(logs)
failure_message = failure_message.replace('{', '{{').replace('}', '}}') # Escape braces for error message
driver.assertion.assert_false(
logs,
failure_message=failure_message
)
except (urllib2.URLError, socket.error, WebDriverException):
# The session has ended, don't check the logs
pass | python | def _log_fail_callback(driver, *args, **kwargs):
"""Raises an assertion error if the page has severe console errors
@param driver: ShapewaysDriver
@return: None
"""
try:
logs = driver.get_browser_log(levels=[BROWSER_LOG_LEVEL_SEVERE])
failure_message = 'There were severe console errors on this page: {}'.format(logs)
failure_message = failure_message.replace('{', '{{').replace('}', '}}') # Escape braces for error message
driver.assertion.assert_false(
logs,
failure_message=failure_message
)
except (urllib2.URLError, socket.error, WebDriverException):
# The session has ended, don't check the logs
pass | [
"def",
"_log_fail_callback",
"(",
"driver",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"logs",
"=",
"driver",
".",
"get_browser_log",
"(",
"levels",
"=",
"[",
"BROWSER_LOG_LEVEL_SEVERE",
"]",
")",
"failure_message",
"=",
"'There were severe console errors on this page: {}'",
".",
"format",
"(",
"logs",
")",
"failure_message",
"=",
"failure_message",
".",
"replace",
"(",
"'{'",
",",
"'{{'",
")",
".",
"replace",
"(",
"'}'",
",",
"'}}'",
")",
"# Escape braces for error message",
"driver",
".",
"assertion",
".",
"assert_false",
"(",
"logs",
",",
"failure_message",
"=",
"failure_message",
")",
"except",
"(",
"urllib2",
".",
"URLError",
",",
"socket",
".",
"error",
",",
"WebDriverException",
")",
":",
"# The session has ended, don't check the logs",
"pass"
] | Raises an assertion error if the page has severe console errors
@param driver: ShapewaysDriver
@return: None | [
"Raises",
"an",
"assertion",
"error",
"if",
"the",
"page",
"has",
"severe",
"console",
"errors"
] | train | https://github.com/Shapeways/coyote_framework/blob/cb29899b984a21d56bf65d0b1d907073948fe16c/coyote_framework/drivers/coyote_driverfactory.py#L70-L87 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Raises an assertion error if the page has severe console errors
@param driver: ShapewaysDriver
@return: None
### Response:
def _log_fail_callback(driver, *args, **kwargs):
"""Raises an assertion error if the page has severe console errors
@param driver: ShapewaysDriver
@return: None
"""
try:
logs = driver.get_browser_log(levels=[BROWSER_LOG_LEVEL_SEVERE])
failure_message = 'There were severe console errors on this page: {}'.format(logs)
failure_message = failure_message.replace('{', '{{').replace('}', '}}') # Escape braces for error message
driver.assertion.assert_false(
logs,
failure_message=failure_message
)
except (urllib2.URLError, socket.error, WebDriverException):
# The session has ended, don't check the logs
pass
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36120,
459,
28519,
1493,
422,
279,
2199,
706,
15748,
2393,
6103,
271,
262,
571,
913,
5696,
25,
1443,
391,
70371,
11603,
198,
262,
571,
693,
25,
2290,
271,
14711,
6075,
512,
755,
721,
848,
22902,
12802,
24994,
11,
353,
2164,
11,
3146,
9872,
997,
262,
4304,
36120,
459,
28519,
1493,
422,
279,
2199,
706,
15748,
2393,
6103,
271,
262,
571,
913,
5696,
25,
1443,
391,
70371,
11603,
198,
262,
571,
693,
25,
2290,
198,
262,
12713,
262,
1456,
512,
286,
18929,
284,
5696,
673,
54514,
5337,
99108,
5941,
33,
55431,
8585,
17871,
3704,
3848,
36,
2608,
286,
8060,
6598,
284,
364,
3947,
1051,
15748,
2393,
6103,
389,
420,
2199,
25,
26307,
2293,
12814,
82,
340,
286,
8060,
6598,
284,
8060,
6598,
7125,
34540,
518,
43642,
1861,
8319,
493,
17266,
364,
3500,
873,
220,
674,
46743,
60291,
369,
1493,
1984,
198,
286,
5696,
3798,
290,
3798,
37115,
1021,
310,
18929,
345,
310,
8060,
6598,
18603,
9557,
6598,
198,
286,
1763,
262,
3734,
320,
324,
21408,
17,
80047,
95718,
11,
7728,
4517,
11,
42996,
1378,
997,
286,
674,
578,
3882,
706,
9670,
11,
1541,
956,
1817,
279,
18929,
198,
286,
1522,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36120,
459,
28519,
1493,
422,
279,
2199,
706,
15748,
2393,
6103,
271,
262,
571,
913,
5696,
25,
1443,
391,
70371,
11603,
198,
262,
571,
693,
25,
2290,
271,
14711,
6075,
512,
755,
721,
848,
22902,
12802,
24994,
11,
353,
2164,
11,
3146,
9872,
997,
262,
4304,
36120,
459,
28519,
1493,
422,
279,
2199,
706,
15748,
2393,
6103,
271,
262,
571,
913,
5696,
25,
1443,
391,
70371,
11603,
198,
262,
571,
693,
25,
2290,
198,
262,
12713,
262,
1456,
512,
286,
18929,
284,
5696,
673,
54514,
5337,
99108,
5941,
33,
55431,
8585,
17871,
3704,
3848,
36,
2608,
286,
8060,
6598,
284,
364,
3947,
1051,
15748,
2393,
6103,
389,
420,
2199,
25,
26307,
2293,
12814,
82,
340,
286,
8060,
6598,
284,
8060,
6598,
7125,
34540,
518,
43642,
1861,
8319,
493,
17266,
364,
3500,
873,
220,
674,
46743,
60291,
369,
1493,
1984,
198,
286,
5696,
3798,
290,
3798,
37115,
1021,
310,
18929,
345,
310,
8060,
6598,
18603,
9557,
6598,
198,
286,
1763,
262,
3734,
320,
324,
21408,
17,
80047,
95718,
11,
7728,
4517,
11,
42996,
1378,
997,
286,
674,
578,
3882,
706,
9670,
11,
1541,
956,
1817,
279,
18929,
198,
286,
1522,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
saltstack/salt | salt/modules/ini_manage.py | get_ini | def get_ini(file_name, separator='='):
'''
Retrieve whole structure from an ini file and return it as dictionary.
API Example:
.. code-block:: python
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.get_ini',
[path_to_ini_file])
CLI Example:
.. code-block:: bash
salt '*' ini.get_ini /path/to/ini
'''
def ini_odict2dict(odict):
'''
Transform OrderedDict to regular dict recursively
:param odict: OrderedDict
:return: regular dict
'''
ret = {}
for key, val in six.iteritems(odict):
if key[0] != '#':
if isinstance(val, (dict, OrderedDict)):
ret.update({key: ini_odict2dict(val)})
else:
ret.update({key: val})
return ret
inifile = _Ini.get_ini_file(file_name, separator=separator)
return ini_odict2dict(inifile) | python | def get_ini(file_name, separator='='):
'''
Retrieve whole structure from an ini file and return it as dictionary.
API Example:
.. code-block:: python
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.get_ini',
[path_to_ini_file])
CLI Example:
.. code-block:: bash
salt '*' ini.get_ini /path/to/ini
'''
def ini_odict2dict(odict):
'''
Transform OrderedDict to regular dict recursively
:param odict: OrderedDict
:return: regular dict
'''
ret = {}
for key, val in six.iteritems(odict):
if key[0] != '#':
if isinstance(val, (dict, OrderedDict)):
ret.update({key: ini_odict2dict(val)})
else:
ret.update({key: val})
return ret
inifile = _Ini.get_ini_file(file_name, separator=separator)
return ini_odict2dict(inifile) | [
"def",
"get_ini",
"(",
"file_name",
",",
"separator",
"=",
"'='",
")",
":",
"def",
"ini_odict2dict",
"(",
"odict",
")",
":",
"'''\n Transform OrderedDict to regular dict recursively\n :param odict: OrderedDict\n :return: regular dict\n '''",
"ret",
"=",
"{",
"}",
"for",
"key",
",",
"val",
"in",
"six",
".",
"iteritems",
"(",
"odict",
")",
":",
"if",
"key",
"[",
"0",
"]",
"!=",
"'#'",
":",
"if",
"isinstance",
"(",
"val",
",",
"(",
"dict",
",",
"OrderedDict",
")",
")",
":",
"ret",
".",
"update",
"(",
"{",
"key",
":",
"ini_odict2dict",
"(",
"val",
")",
"}",
")",
"else",
":",
"ret",
".",
"update",
"(",
"{",
"key",
":",
"val",
"}",
")",
"return",
"ret",
"inifile",
"=",
"_Ini",
".",
"get_ini_file",
"(",
"file_name",
",",
"separator",
"=",
"separator",
")",
"return",
"ini_odict2dict",
"(",
"inifile",
")"
] | Retrieve whole structure from an ini file and return it as dictionary.
API Example:
.. code-block:: python
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.get_ini',
[path_to_ini_file])
CLI Example:
.. code-block:: bash
salt '*' ini.get_ini /path/to/ini | [
"Retrieve",
"whole",
"structure",
"from",
"an",
"ini",
"file",
"and",
"return",
"it",
"as",
"dictionary",
"."
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ini_manage.py#L210-L245 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Retrieve whole structure from an ini file and return it as dictionary.
API Example:
.. code-block:: python
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.get_ini',
[path_to_ini_file])
CLI Example:
.. code-block:: bash
salt '*' ini.get_ini /path/to/ini
### Response:
def get_ini(file_name, separator='='):
'''
Retrieve whole structure from an ini file and return it as dictionary.
API Example:
.. code-block:: python
import salt
sc = salt.client.get_local_client()
sc.cmd('target', 'ini.get_ini',
[path_to_ini_file])
CLI Example:
.. code-block:: bash
salt '*' ini.get_ini /path/to/ini
'''
def ini_odict2dict(odict):
'''
Transform OrderedDict to regular dict recursively
:param odict: OrderedDict
:return: regular dict
'''
ret = {}
for key, val in six.iteritems(odict):
if key[0] != '#':
if isinstance(val, (dict, OrderedDict)):
ret.update({key: ini_odict2dict(val)})
else:
ret.update({key: val})
return ret
inifile = _Ini.get_ini_file(file_name, separator=separator)
return ini_odict2dict(inifile)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
88765,
4459,
6070,
505,
459,
17225,
1052,
323,
471,
433,
439,
11240,
382,
262,
5446,
13688,
1473,
262,
5354,
2082,
9612,
487,
10344,
271,
286,
1179,
12290,
198,
286,
1156,
284,
12290,
6718,
673,
13876,
8342,
746,
286,
1156,
26808,
493,
5775,
518,
364,
6729,
673,
51606,
756,
2342,
510,
2398,
2401,
51606,
2517,
9801,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
17225,
673,
51606,
611,
2398,
33529,
14,
6729,
271,
14711,
6075,
512,
755,
636,
51606,
4971,
1292,
11,
25829,
1151,
28,
11290,
262,
11414,
262,
32662,
4459,
6070,
505,
459,
17225,
1052,
323,
471,
433,
439,
11240,
382,
262,
5446,
13688,
1473,
262,
5354,
2082,
9612,
487,
10344,
271,
286,
1179,
12290,
198,
286,
1156,
284,
12290,
6718,
673,
13876,
8342,
746,
286,
1156,
26808,
493,
5775,
518,
364,
6729,
673,
51606,
756,
2342,
510,
2398,
2401,
51606,
2517,
9801,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
17225,
673,
51606,
611,
2398,
33529,
14,
6729,
198,
262,
11414,
262,
711,
17225,
52897,
858,
17,
8644,
93100,
858,
997,
286,
11414,
286,
15583,
54313,
311,
5912,
6587,
53947,
198,
286,
551,
913,
297,
8644,
25,
54313,
198,
286,
551,
693,
25,
5912,
6587,
198,
286,
11414,
286,
2160,
284,
5731,
286,
369,
1401,
11,
1062,
304,
4848,
58542,
93100,
858,
997,
310,
422,
1401,
58,
15,
60,
976,
5999,
3730,
394,
422,
11656,
9276,
11,
320,
8644,
11,
54313,
10162,
504,
2160,
5430,
2358,
798,
25,
17225,
52897,
858,
17,
8644,
9276,
60309,
394,
775,
512,
504,
2160,
5430,
2358,
798,
25,
1062,
3602,
286,
471,
2160,
271,
262,
304,
333,
458,
284,
721,
44425,
673,
51606,
2517,
4971,
1292,
11,
25829,
28,
41220,
340,
262,
471,
17225,
52897,
858,
17,
8644,
6024,
333,
458,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
88765,
4459,
6070,
505,
459,
17225,
1052,
323,
471,
433,
439,
11240,
382,
262,
5446,
13688,
1473,
262,
5354,
2082,
9612,
487,
10344,
271,
286,
1179,
12290,
198,
286,
1156,
284,
12290,
6718,
673,
13876,
8342,
746,
286,
1156,
26808,
493,
5775,
518,
364,
6729,
673,
51606,
756,
2342,
510,
2398,
2401,
51606,
2517,
9801,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
17225,
673,
51606,
611,
2398,
33529,
14,
6729,
271,
14711,
6075,
512,
755,
636,
51606,
4971,
1292,
11,
25829,
1151,
28,
11290,
262,
11414,
262,
32662,
4459,
6070,
505,
459,
17225,
1052,
323,
471,
433,
439,
11240,
382,
262,
5446,
13688,
1473,
262,
5354,
2082,
9612,
487,
10344,
271,
286,
1179,
12290,
198,
286,
1156,
284,
12290,
6718,
673,
13876,
8342,
746,
286,
1156,
26808,
493,
5775,
518,
364,
6729,
673,
51606,
756,
2342,
510,
2398,
2401,
51606,
2517,
9801,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
286,
12290,
31801,
17225,
673,
51606,
611,
2398,
33529,
14,
6729,
198,
262,
11414,
262,
711,
17225,
52897,
858,
17,
8644,
93100,
858,
997,
286,
11414,
286,
15583,
54313,
311,
5912,
6587,
53947,
198,
286,
551,
913,
297,
8644,
25,
54313,
198,
286,
551,
693,
25,
5912,
6587,
198,
286,
11414,
286,
2160,
284,
5731,
286,
369,
1401,
11,
1062,
304,
4848,
58542,
93100,
858,
997,
310,
422,
1401,
58,
15,
60,
976,
5999,
3730,
394,
422,
11656,
9276,
11,
320,
8644,
11,
54313,
10162,
504,
2160,
5430,
2358,
798,
25,
17225,
52897,
858,
17,
8644,
9276,
60309,
394,
775,
512,
504,
2160,
5430,
2358,
798,
25,
1062,
3602,
286,
471,
2160,
271,
262,
304,
333,
458,
284,
721,
44425,
673,
51606,
2517,
4971,
1292,
11,
25829,
28,
41220,
340,
262,
471,
17225,
52897,
858,
17,
8644,
6024,
333,
458,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Fahreeve/aiovk | aiovk/sessions.py | ImplicitSession._get_auth_page | async def _get_auth_page(self) -> str:
"""
Get authorization mobile page without js
:return: html page
"""
# Prepare request
params = {
'client_id': self.app_id,
'redirect_uri': 'https://oauth.vk.com/blank.html',
'display': 'mobile',
'response_type': 'token',
'v': self.API_VERSION
}
if self.scope:
params['scope'] = self.scope
# Send request
status, response = await self.driver.get_text(self.AUTH_URL, params)
# Process response
if status != 200:
error_dict = json.loads(response)
raise VkAuthError(error_dict['error'], error_dict['error_description'], self.AUTH_URL, params)
return response | python | async def _get_auth_page(self) -> str:
"""
Get authorization mobile page without js
:return: html page
"""
# Prepare request
params = {
'client_id': self.app_id,
'redirect_uri': 'https://oauth.vk.com/blank.html',
'display': 'mobile',
'response_type': 'token',
'v': self.API_VERSION
}
if self.scope:
params['scope'] = self.scope
# Send request
status, response = await self.driver.get_text(self.AUTH_URL, params)
# Process response
if status != 200:
error_dict = json.loads(response)
raise VkAuthError(error_dict['error'], error_dict['error_description'], self.AUTH_URL, params)
return response | [
"async",
"def",
"_get_auth_page",
"(",
"self",
")",
"->",
"str",
":",
"# Prepare request",
"params",
"=",
"{",
"'client_id'",
":",
"self",
".",
"app_id",
",",
"'redirect_uri'",
":",
"'https://oauth.vk.com/blank.html'",
",",
"'display'",
":",
"'mobile'",
",",
"'response_type'",
":",
"'token'",
",",
"'v'",
":",
"self",
".",
"API_VERSION",
"}",
"if",
"self",
".",
"scope",
":",
"params",
"[",
"'scope'",
"]",
"=",
"self",
".",
"scope",
"# Send request",
"status",
",",
"response",
"=",
"await",
"self",
".",
"driver",
".",
"get_text",
"(",
"self",
".",
"AUTH_URL",
",",
"params",
")",
"# Process response",
"if",
"status",
"!=",
"200",
":",
"error_dict",
"=",
"json",
".",
"loads",
"(",
"response",
")",
"raise",
"VkAuthError",
"(",
"error_dict",
"[",
"'error'",
"]",
",",
"error_dict",
"[",
"'error_description'",
"]",
",",
"self",
".",
"AUTH_URL",
",",
"params",
")",
"return",
"response"
] | Get authorization mobile page without js
:return: html page | [
"Get",
"authorization",
"mobile",
"page",
"without",
"js",
":",
"return",
":",
"html",
"page"
] | train | https://github.com/Fahreeve/aiovk/blob/d454649d647d524c6753ba1d6ee16613355ec106/aiovk/sessions.py#L166-L189 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Get authorization mobile page without js
:return: html page
### Response:
async def _get_auth_page(self) -> str:
"""
Get authorization mobile page without js
:return: html page
"""
# Prepare request
params = {
'client_id': self.app_id,
'redirect_uri': 'https://oauth.vk.com/blank.html',
'display': 'mobile',
'response_type': 'token',
'v': self.API_VERSION
}
if self.scope:
params['scope'] = self.scope
# Send request
status, response = await self.driver.get_text(self.AUTH_URL, params)
# Process response
if status != 200:
error_dict = json.loads(response)
raise VkAuthError(error_dict['error'], error_dict['error_description'], self.AUTH_URL, params)
return response
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
24645,
6505,
2199,
2085,
7139,
198,
286,
551,
693,
25,
5385,
2199,
271,
14711,
6075,
512,
7847,
711,
721,
456,
14341,
6257,
1214,
8,
1492,
610,
512,
286,
3270,
286,
2175,
24645,
6505,
2199,
2085,
7139,
198,
286,
551,
693,
25,
5385,
2199,
198,
286,
3270,
286,
674,
32266,
1715,
198,
286,
3712,
284,
341,
310,
364,
3045,
851,
1232,
659,
1632,
851,
345,
310,
364,
8280,
15943,
1232,
364,
2485,
1129,
35463,
3211,
74,
916,
14,
10399,
2628,
756,
310,
364,
5610,
1232,
364,
15280,
756,
310,
364,
2376,
1857,
1232,
364,
5963,
756,
310,
364,
85,
1232,
659,
25967,
10907,
198,
286,
457,
286,
422,
659,
49471,
512,
310,
3712,
681,
4280,
663,
284,
659,
49471,
271,
286,
674,
11244,
1715,
198,
286,
2704,
11,
2077,
284,
2597,
659,
21491,
673,
4424,
1214,
65778,
8159,
11,
3712,
696,
286,
674,
8773,
2077,
198,
286,
422,
2704,
976,
220,
1049,
512,
310,
1493,
5356,
284,
3024,
23818,
5802,
340,
310,
4933,
33756,
5197,
1480,
6524,
5356,
681,
850,
4181,
1493,
5356,
681,
850,
11703,
4181,
659,
65778,
8159,
11,
3712,
340,
286,
471,
2077,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
24645,
6505,
2199,
2085,
7139,
198,
286,
551,
693,
25,
5385,
2199,
271,
14711,
6075,
512,
7847,
711,
721,
456,
14341,
6257,
1214,
8,
1492,
610,
512,
286,
3270,
286,
2175,
24645,
6505,
2199,
2085,
7139,
198,
286,
551,
693,
25,
5385,
2199,
198,
286,
3270,
286,
674,
32266,
1715,
198,
286,
3712,
284,
341,
310,
364,
3045,
851,
1232,
659,
1632,
851,
345,
310,
364,
8280,
15943,
1232,
364,
2485,
1129,
35463,
3211,
74,
916,
14,
10399,
2628,
756,
310,
364,
5610,
1232,
364,
15280,
756,
310,
364,
2376,
1857,
1232,
364,
5963,
756,
310,
364,
85,
1232,
659,
25967,
10907,
198,
286,
457,
286,
422,
659,
49471,
512,
310,
3712,
681,
4280,
663,
284,
659,
49471,
271,
286,
674,
11244,
1715,
198,
286,
2704,
11,
2077,
284,
2597,
659,
21491,
673,
4424,
1214,
65778,
8159,
11,
3712,
696,
286,
674,
8773,
2077,
198,
286,
422,
2704,
976,
220,
1049,
512,
310,
1493,
5356,
284,
3024,
23818,
5802,
340,
310,
4933,
33756,
5197,
1480,
6524,
5356,
681,
850,
4181,
1493,
5356,
681,
850,
11703,
4181,
659,
65778,
8159,
11,
3712,
340,
286,
471,
2077,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
googleapis/google-cloud-python | trace/google/cloud/trace/v1/client.py | Client.patch_traces | def patch_traces(self, traces, project_id=None):
"""Sends new traces to Stackdriver Trace or updates existing traces.
Args:
traces (dict): Required. The traces to be patched in the API call.
project_id (Optional[str]): ID of the Cloud project where the trace
data is stored.
"""
if project_id is None:
project_id = self.project
self.trace_api.patch_traces(project_id=project_id, traces=traces) | python | def patch_traces(self, traces, project_id=None):
"""Sends new traces to Stackdriver Trace or updates existing traces.
Args:
traces (dict): Required. The traces to be patched in the API call.
project_id (Optional[str]): ID of the Cloud project where the trace
data is stored.
"""
if project_id is None:
project_id = self.project
self.trace_api.patch_traces(project_id=project_id, traces=traces) | [
"def",
"patch_traces",
"(",
"self",
",",
"traces",
",",
"project_id",
"=",
"None",
")",
":",
"if",
"project_id",
"is",
"None",
":",
"project_id",
"=",
"self",
".",
"project",
"self",
".",
"trace_api",
".",
"patch_traces",
"(",
"project_id",
"=",
"project_id",
",",
"traces",
"=",
"traces",
")"
] | Sends new traces to Stackdriver Trace or updates existing traces.
Args:
traces (dict): Required. The traces to be patched in the API call.
project_id (Optional[str]): ID of the Cloud project where the trace
data is stored. | [
"Sends",
"new",
"traces",
"to",
"Stackdriver",
"Trace",
"or",
"updates",
"existing",
"traces",
"."
] | train | https://github.com/googleapis/google-cloud-python/blob/85e80125a59cb10f8cb105f25ecc099e4b940b50/trace/google/cloud/trace/v1/client.py#L60-L72 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Sends new traces to Stackdriver Trace or updates existing traces.
Args:
traces (dict): Required. The traces to be patched in the API call.
project_id (Optional[str]): ID of the Cloud project where the trace
data is stored.
### Response:
def patch_traces(self, traces, project_id=None):
"""Sends new traces to Stackdriver Trace or updates existing traces.
Args:
traces (dict): Required. The traces to be patched in the API call.
project_id (Optional[str]): ID of the Cloud project where the trace
data is stored.
"""
if project_id is None:
project_id = self.project
self.trace_api.patch_traces(project_id=project_id, traces=traces)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50,
1438,
502,
35483,
311,
14619,
12804,
28262,
477,
9013,
6484,
35483,
382,
286,
18161,
512,
310,
35483,
320,
8644,
1680,
12948,
13,
578,
35483,
311,
387,
72832,
304,
279,
5446,
1650,
382,
310,
2447,
851,
320,
15669,
17752,
25312,
3110,
315,
279,
15161,
2447,
1405,
279,
11917,
198,
394,
828,
374,
9967,
382,
14711,
6075,
512,
755,
11140,
3631,
2492,
1214,
11,
35483,
11,
2447,
851,
5980,
997,
286,
4304,
50,
1438,
502,
35483,
311,
14619,
12804,
28262,
477,
9013,
6484,
35483,
382,
286,
18161,
512,
310,
35483,
320,
8644,
1680,
12948,
13,
578,
35483,
311,
387,
72832,
304,
279,
5446,
1650,
382,
310,
2447,
851,
320,
15669,
17752,
25312,
3110,
315,
279,
15161,
2447,
1405,
279,
11917,
198,
394,
828,
374,
9967,
627,
286,
3270,
286,
422,
2447,
851,
374,
2290,
512,
310,
2447,
851,
284,
659,
14844,
271,
286,
659,
35512,
11959,
27799,
3631,
2492,
21855,
851,
28,
5094,
851,
11,
35483,
28,
376,
2492,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
50,
1438,
502,
35483,
311,
14619,
12804,
28262,
477,
9013,
6484,
35483,
382,
286,
18161,
512,
310,
35483,
320,
8644,
1680,
12948,
13,
578,
35483,
311,
387,
72832,
304,
279,
5446,
1650,
382,
310,
2447,
851,
320,
15669,
17752,
25312,
3110,
315,
279,
15161,
2447,
1405,
279,
11917,
198,
394,
828,
374,
9967,
382,
14711,
6075,
512,
755,
11140,
3631,
2492,
1214,
11,
35483,
11,
2447,
851,
5980,
997,
286,
4304,
50,
1438,
502,
35483,
311,
14619,
12804,
28262,
477,
9013,
6484,
35483,
382,
286,
18161,
512,
310,
35483,
320,
8644,
1680,
12948,
13,
578,
35483,
311,
387,
72832,
304,
279,
5446,
1650,
382,
310,
2447,
851,
320,
15669,
17752,
25312,
3110,
315,
279,
15161,
2447,
1405,
279,
11917,
198,
394,
828,
374,
9967,
627,
286,
3270,
286,
422,
2447,
851,
374,
2290,
512,
310,
2447,
851,
284,
659,
14844,
271,
286,
659,
35512,
11959,
27799,
3631,
2492,
21855,
851,
28,
5094,
851,
11,
35483,
28,
376,
2492,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
python/core-workflow | blurb/blurb.py | Blurbs.parse | def parse(self, text, *, metadata=None, filename="input"):
"""
Parses a string. Appends a list of blurb ENTRIES to self, as tuples:
(metadata, body)
metadata is a dict. body is a string.
"""
metadata = metadata or {}
body = []
in_metadata = True
line_number = None
def throw(s):
raise BlurbError(f("Error in {filename}:{line_number}:\n{s}"))
def finish_entry():
nonlocal body
nonlocal in_metadata
nonlocal metadata
nonlocal self
if not body:
throw("Blurb 'body' text must not be empty!")
text = textwrap_body(body)
for naughty_prefix in ("- ", "Issue #", "bpo-"):
if text.startswith(naughty_prefix):
throw("Blurb 'body' can't start with " + repr(naughty_prefix) + "!")
no_changes = metadata.get('no changes')
section = metadata.get('section')
if not no_changes:
if not section:
throw("No 'section' specified. You must provide one!")
elif section not in sections:
throw("Invalid 'section'! You must use one of the predefined sections.")
bpo = None
try:
bpo = int(metadata.get('bpo'))
except (TypeError, ValueError):
throw("Invalid bpo issue number! (" + repr(bpo) + ")")
self.append((metadata, text))
metadata = {}
body = []
in_metadata = True
for line_number, line in enumerate(text.split("\n")):
line = line.rstrip()
if in_metadata:
if line.startswith('..'):
line = line[2:].strip()
name, colon, value = line.partition(":")
assert colon
name = name.strip()
value = value.strip()
if name in metadata:
throw("Blurb metadata sets " + repr(name) + " twice!")
metadata[name] = value
continue
if line.startswith("#") or not line:
continue
in_metadata = False
if line == "..":
finish_entry()
continue
body.append(line)
finish_entry() | python | def parse(self, text, *, metadata=None, filename="input"):
"""
Parses a string. Appends a list of blurb ENTRIES to self, as tuples:
(metadata, body)
metadata is a dict. body is a string.
"""
metadata = metadata or {}
body = []
in_metadata = True
line_number = None
def throw(s):
raise BlurbError(f("Error in {filename}:{line_number}:\n{s}"))
def finish_entry():
nonlocal body
nonlocal in_metadata
nonlocal metadata
nonlocal self
if not body:
throw("Blurb 'body' text must not be empty!")
text = textwrap_body(body)
for naughty_prefix in ("- ", "Issue #", "bpo-"):
if text.startswith(naughty_prefix):
throw("Blurb 'body' can't start with " + repr(naughty_prefix) + "!")
no_changes = metadata.get('no changes')
section = metadata.get('section')
if not no_changes:
if not section:
throw("No 'section' specified. You must provide one!")
elif section not in sections:
throw("Invalid 'section'! You must use one of the predefined sections.")
bpo = None
try:
bpo = int(metadata.get('bpo'))
except (TypeError, ValueError):
throw("Invalid bpo issue number! (" + repr(bpo) + ")")
self.append((metadata, text))
metadata = {}
body = []
in_metadata = True
for line_number, line in enumerate(text.split("\n")):
line = line.rstrip()
if in_metadata:
if line.startswith('..'):
line = line[2:].strip()
name, colon, value = line.partition(":")
assert colon
name = name.strip()
value = value.strip()
if name in metadata:
throw("Blurb metadata sets " + repr(name) + " twice!")
metadata[name] = value
continue
if line.startswith("#") or not line:
continue
in_metadata = False
if line == "..":
finish_entry()
continue
body.append(line)
finish_entry() | [
"def",
"parse",
"(",
"self",
",",
"text",
",",
"*",
",",
"metadata",
"=",
"None",
",",
"filename",
"=",
"\"input\"",
")",
":",
"metadata",
"=",
"metadata",
"or",
"{",
"}",
"body",
"=",
"[",
"]",
"in_metadata",
"=",
"True",
"line_number",
"=",
"None",
"def",
"throw",
"(",
"s",
")",
":",
"raise",
"BlurbError",
"(",
"f",
"(",
"\"Error in {filename}:{line_number}:\\n{s}\"",
")",
")",
"def",
"finish_entry",
"(",
")",
":",
"nonlocal",
"body",
"nonlocal",
"in_metadata",
"nonlocal",
"metadata",
"nonlocal",
"self",
"if",
"not",
"body",
":",
"throw",
"(",
"\"Blurb 'body' text must not be empty!\"",
")",
"text",
"=",
"textwrap_body",
"(",
"body",
")",
"for",
"naughty_prefix",
"in",
"(",
"\"- \"",
",",
"\"Issue #\"",
",",
"\"bpo-\"",
")",
":",
"if",
"text",
".",
"startswith",
"(",
"naughty_prefix",
")",
":",
"throw",
"(",
"\"Blurb 'body' can't start with \"",
"+",
"repr",
"(",
"naughty_prefix",
")",
"+",
"\"!\"",
")",
"no_changes",
"=",
"metadata",
".",
"get",
"(",
"'no changes'",
")",
"section",
"=",
"metadata",
".",
"get",
"(",
"'section'",
")",
"if",
"not",
"no_changes",
":",
"if",
"not",
"section",
":",
"throw",
"(",
"\"No 'section' specified. You must provide one!\"",
")",
"elif",
"section",
"not",
"in",
"sections",
":",
"throw",
"(",
"\"Invalid 'section'! You must use one of the predefined sections.\"",
")",
"bpo",
"=",
"None",
"try",
":",
"bpo",
"=",
"int",
"(",
"metadata",
".",
"get",
"(",
"'bpo'",
")",
")",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"throw",
"(",
"\"Invalid bpo issue number! (\"",
"+",
"repr",
"(",
"bpo",
")",
"+",
"\")\"",
")",
"self",
".",
"append",
"(",
"(",
"metadata",
",",
"text",
")",
")",
"metadata",
"=",
"{",
"}",
"body",
"=",
"[",
"]",
"in_metadata",
"=",
"True",
"for",
"line_number",
",",
"line",
"in",
"enumerate",
"(",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
")",
":",
"line",
"=",
"line",
".",
"rstrip",
"(",
")",
"if",
"in_metadata",
":",
"if",
"line",
".",
"startswith",
"(",
"'..'",
")",
":",
"line",
"=",
"line",
"[",
"2",
":",
"]",
".",
"strip",
"(",
")",
"name",
",",
"colon",
",",
"value",
"=",
"line",
".",
"partition",
"(",
"\":\"",
")",
"assert",
"colon",
"name",
"=",
"name",
".",
"strip",
"(",
")",
"value",
"=",
"value",
".",
"strip",
"(",
")",
"if",
"name",
"in",
"metadata",
":",
"throw",
"(",
"\"Blurb metadata sets \"",
"+",
"repr",
"(",
"name",
")",
"+",
"\" twice!\"",
")",
"metadata",
"[",
"name",
"]",
"=",
"value",
"continue",
"if",
"line",
".",
"startswith",
"(",
"\"#\"",
")",
"or",
"not",
"line",
":",
"continue",
"in_metadata",
"=",
"False",
"if",
"line",
"==",
"\"..\"",
":",
"finish_entry",
"(",
")",
"continue",
"body",
".",
"append",
"(",
"line",
")",
"finish_entry",
"(",
")"
] | Parses a string. Appends a list of blurb ENTRIES to self, as tuples:
(metadata, body)
metadata is a dict. body is a string. | [
"Parses",
"a",
"string",
".",
"Appends",
"a",
"list",
"of",
"blurb",
"ENTRIES",
"to",
"self",
"as",
"tuples",
":",
"(",
"metadata",
"body",
")",
"metadata",
"is",
"a",
"dict",
".",
"body",
"is",
"a",
"string",
"."
] | train | https://github.com/python/core-workflow/blob/b93c76195f6db382cfcefee334380fb4c68d4e21/blurb/blurb.py#L472-L543 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Parses a string. Appends a list of blurb ENTRIES to self, as tuples:
(metadata, body)
metadata is a dict. body is a string.
### Response:
def parse(self, text, *, metadata=None, filename="input"):
"""
Parses a string. Appends a list of blurb ENTRIES to self, as tuples:
(metadata, body)
metadata is a dict. body is a string.
"""
metadata = metadata or {}
body = []
in_metadata = True
line_number = None
def throw(s):
raise BlurbError(f("Error in {filename}:{line_number}:\n{s}"))
def finish_entry():
nonlocal body
nonlocal in_metadata
nonlocal metadata
nonlocal self
if not body:
throw("Blurb 'body' text must not be empty!")
text = textwrap_body(body)
for naughty_prefix in ("- ", "Issue #", "bpo-"):
if text.startswith(naughty_prefix):
throw("Blurb 'body' can't start with " + repr(naughty_prefix) + "!")
no_changes = metadata.get('no changes')
section = metadata.get('section')
if not no_changes:
if not section:
throw("No 'section' specified. You must provide one!")
elif section not in sections:
throw("Invalid 'section'! You must use one of the predefined sections.")
bpo = None
try:
bpo = int(metadata.get('bpo'))
except (TypeError, ValueError):
throw("Invalid bpo issue number! (" + repr(bpo) + ")")
self.append((metadata, text))
metadata = {}
body = []
in_metadata = True
for line_number, line in enumerate(text.split("\n")):
line = line.rstrip()
if in_metadata:
if line.startswith('..'):
line = line[2:].strip()
name, colon, value = line.partition(":")
assert colon
name = name.strip()
value = value.strip()
if name in metadata:
throw("Blurb metadata sets " + repr(name) + " twice!")
metadata[name] = value
continue
if line.startswith("#") or not line:
continue
in_metadata = False
if line == "..":
finish_entry()
continue
body.append(line)
finish_entry()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47,
1590,
288,
264,
925,
13,
220,
1883,
1438,
264,
1160,
315,
1529,
9225,
5301,
79923,
311,
659,
11,
439,
46325,
512,
692,
320,
18103,
11,
2547,
340,
286,
11408,
374,
264,
6587,
13,
220,
2547,
374,
264,
925,
382,
14711,
6075,
512,
755,
4820,
1214,
11,
1495,
11,
12039,
11408,
5980,
11,
3986,
429,
1379,
15497,
286,
3270,
286,
74530,
264,
925,
13,
220,
1883,
1438,
264,
1160,
315,
1529,
9225,
5301,
79923,
311,
659,
11,
439,
46325,
512,
692,
320,
18103,
11,
2547,
340,
286,
11408,
374,
264,
6587,
13,
220,
2547,
374,
264,
925,
627,
286,
12713,
286,
11408,
284,
11408,
477,
5731,
286,
2547,
284,
4260,
286,
304,
23012,
284,
3082,
271,
286,
1584,
5617,
284,
2290,
271,
286,
711,
2571,
1161,
997,
310,
4933,
2563,
9225,
1480,
968,
446,
1480,
304,
314,
8570,
59246,
1074,
5617,
92,
7338,
77,
85486,
92,
29175,
286,
711,
6381,
9255,
4019,
310,
2536,
2497,
2547,
198,
310,
2536,
2497,
304,
23012,
198,
310,
2536,
2497,
11408,
198,
310,
2536,
2497,
659,
271,
310,
422,
539,
2547,
512,
394,
2571,
446,
5028,
9225,
364,
2664,
6,
1495,
2011,
539,
387,
4384,
23849,
310,
1495,
284,
1495,
10305,
14446,
15582,
340,
310,
369,
54043,
14301,
304,
99770,
3755,
330,
43106,
674,
498,
330,
65,
5481,
12,
15497,
394,
422,
1495,
27249,
1471,
64,
36616,
14301,
997,
504,
2571,
446,
5028,
9225,
364,
2664,
6,
649,
956,
1212,
449,
330,
489,
31736,
1471,
64,
36616,
14301,
8,
489,
54174,
5240,
310,
912,
48626,
284,
11408,
673,
493,
2201,
4442,
1329,
310,
3857,
284,
11408,
673,
493,
2879,
4713,
310,
422,
539,
912,
48626,
512,
394,
422,
539,
3857,
512,
504,
2571,
446,
2822,
364,
2879,
6,
5300,
13,
220,
1472,
2011,
3493,
832,
23849,
394,
4508,
3857,
539,
304,
14491,
512,
504,
2571,
446,
8087,
364,
2879,
6,
0,
220,
1472,
2011,
1005,
832,
315,
279,
64162,
14491,
32325,
310,
293,
5481,
284,
2290,
198,
310,
1456,
512,
394,
293,
5481,
284,
528,
55536,
673,
493,
65,
5481,
7132,
310,
3734,
320,
81176,
11,
15764,
997,
394,
2571,
446,
8087,
293,
5481,
4360,
1396,
0,
3573,
489,
31736,
1921,
5481,
8,
489,
12590,
5240,
310,
659,
2102,
1209,
18103,
11,
1495,
1192,
310,
11408,
284,
5731,
310,
2547,
284,
4260,
310,
304,
23012,
284,
3082,
271,
286,
369,
1584,
5617,
11,
1584,
304,
13555,
7383,
5402,
5026,
77,
2830,
512,
310,
1584,
284,
1584,
60663,
746,
310,
422,
304,
23012,
512,
394,
422,
1584,
27249,
493,
497,
11290,
504,
1584,
284,
1584,
58,
17,
73659,
13406,
746,
504,
836,
11,
15235,
11,
907,
284,
1584,
80109,
19427,
1158,
504,
2105,
15235,
198,
504,
836,
284,
836,
17624,
746,
504,
907,
284,
907,
17624,
746,
504,
422,
836,
304,
11408,
512,
667,
2571,
446,
5028,
9225,
11408,
7437,
330,
489,
31736,
3232,
8,
489,
330,
11157
] | [
1,
1,
1,
1,
1,
1,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
47,
1590,
288,
264,
925,
13,
220,
1883,
1438,
264,
1160,
315,
1529,
9225,
5301,
79923,
311,
659,
11,
439,
46325,
512,
692,
320,
18103,
11,
2547,
340,
286,
11408,
374,
264,
6587,
13,
220,
2547,
374,
264,
925,
382,
14711,
6075,
512,
755,
4820,
1214,
11,
1495,
11,
12039,
11408,
5980,
11,
3986,
429,
1379,
15497,
286,
3270,
286,
74530,
264,
925,
13,
220,
1883,
1438,
264,
1160,
315,
1529,
9225,
5301,
79923,
311,
659,
11,
439,
46325,
512,
692,
320,
18103,
11,
2547,
340,
286,
11408,
374,
264,
6587,
13,
220,
2547,
374,
264,
925,
627,
286,
12713,
286,
11408,
284,
11408,
477,
5731,
286,
2547,
284,
4260,
286,
304,
23012,
284,
3082,
271,
286,
1584,
5617,
284,
2290,
271,
286,
711,
2571,
1161,
997,
310,
4933,
2563,
9225,
1480,
968,
446,
1480,
304,
314,
8570,
59246,
1074,
5617,
92,
7338,
77,
85486,
92,
29175,
286,
711,
6381,
9255,
4019,
310,
2536,
2497,
2547,
198,
310,
2536,
2497,
304,
23012,
198,
310,
2536,
2497,
11408,
198,
310,
2536,
2497,
659,
271,
310,
422,
539,
2547,
512,
394,
2571,
446,
5028,
9225,
364,
2664,
6,
1495,
2011,
539,
387,
4384,
23849,
310,
1495,
284,
1495,
10305,
14446,
15582,
340,
310,
369,
54043,
14301,
304,
99770,
3755,
330,
43106,
674,
498,
330,
65,
5481,
12,
15497,
394,
422,
1495,
27249,
1471,
64,
36616,
14301,
997,
504,
2571,
446,
5028,
9225,
364,
2664,
6,
649,
956,
1212,
449,
330,
489,
31736,
1471,
64,
36616,
14301,
8,
489,
54174,
5240,
310,
912,
48626,
284,
11408,
673,
493,
2201,
4442,
1329,
310,
3857,
284,
11408,
673,
493,
2879,
4713,
310,
422,
539,
912,
48626,
512,
394,
422,
539,
3857,
512,
504,
2571,
446,
2822,
364,
2879,
6,
5300,
13,
220,
1472,
2011,
3493,
832,
23849,
394,
4508,
3857,
539,
304,
14491,
512,
504,
2571,
446,
8087,
364,
2879,
6,
0,
220,
1472,
2011,
1005,
832,
315,
279,
64162,
14491,
32325,
310,
293,
5481,
284,
2290,
198,
310,
1456,
512,
394,
293,
5481,
284,
528,
55536,
673,
493,
65,
5481,
7132,
310,
3734,
320,
81176,
11,
15764,
997,
394,
2571,
446,
8087,
293,
5481,
4360,
1396,
0,
3573,
489,
31736,
1921,
5481,
8,
489,
12590,
5240,
310,
659,
2102,
1209,
18103,
11,
1495,
1192,
310,
11408,
284,
5731,
310,
2547,
284,
4260,
310,
304,
23012,
284,
3082,
271,
286,
369,
1584,
5617,
11,
1584,
304,
13555,
7383,
5402,
5026,
77,
2830,
512,
310,
1584,
284,
1584,
60663,
746,
310,
422,
304,
23012,
512,
394,
422,
1584,
27249,
493,
497,
11290,
504,
1584,
284,
1584,
58,
17,
73659,
13406,
746,
504,
836,
11,
15235,
11,
907,
284,
1584,
80109,
19427,
1158,
504,
2105,
15235,
198,
504,
836,
284,
836,
17624,
746,
504,
907,
284,
907,
17624,
746,
504,
422,
836,
304,
11408,
512,
667,
2571,
446,
5028,
9225,
11408,
7437,
330,
489,
31736,
3232,
8,
489,
330,
11157
] |
eqcorrscan/EQcorrscan | eqcorrscan/utils/correlate.py | _get_registerd_func | def _get_registerd_func(name_or_func):
""" get a xcorr function from a str or callable. """
# get the function or register callable
if callable(name_or_func):
func = register_array_xcorr(name_or_func)
else:
func = XCOR_FUNCS[name_or_func or 'default']
assert callable(func), 'func is not callable'
# ensure func has the added methods
if not hasattr(func, 'registered'):
func = register_array_xcorr(func)
return func | python | def _get_registerd_func(name_or_func):
""" get a xcorr function from a str or callable. """
# get the function or register callable
if callable(name_or_func):
func = register_array_xcorr(name_or_func)
else:
func = XCOR_FUNCS[name_or_func or 'default']
assert callable(func), 'func is not callable'
# ensure func has the added methods
if not hasattr(func, 'registered'):
func = register_array_xcorr(func)
return func | [
"def",
"_get_registerd_func",
"(",
"name_or_func",
")",
":",
"# get the function or register callable",
"if",
"callable",
"(",
"name_or_func",
")",
":",
"func",
"=",
"register_array_xcorr",
"(",
"name_or_func",
")",
"else",
":",
"func",
"=",
"XCOR_FUNCS",
"[",
"name_or_func",
"or",
"'default'",
"]",
"assert",
"callable",
"(",
"func",
")",
",",
"'func is not callable'",
"# ensure func has the added methods",
"if",
"not",
"hasattr",
"(",
"func",
",",
"'registered'",
")",
":",
"func",
"=",
"register_array_xcorr",
"(",
"func",
")",
"return",
"func"
] | get a xcorr function from a str or callable. | [
"get",
"a",
"xcorr",
"function",
"from",
"a",
"str",
"or",
"callable",
"."
] | train | https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/correlate.py#L318-L329 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
get a xcorr function from a str or callable.
### Response:
def _get_registerd_func(name_or_func):
""" get a xcorr function from a str or callable. """
# get the function or register callable
if callable(name_or_func):
func = register_array_xcorr(name_or_func)
else:
func = XCOR_FUNCS[name_or_func or 'default']
assert callable(func), 'func is not callable'
# ensure func has the added methods
if not hasattr(func, 'registered'):
func = register_array_xcorr(func)
return func
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
456,
264,
865,
60377,
734,
505,
264,
610,
477,
42022,
382,
14711,
6075,
512,
755,
721,
456,
14327,
67,
9791,
3232,
8908,
9791,
997,
262,
4304,
636,
264,
865,
60377,
734,
505,
264,
610,
477,
42022,
13,
3270,
262,
674,
636,
279,
734,
477,
4254,
42022,
198,
262,
422,
42022,
3232,
8908,
9791,
997,
286,
2988,
284,
4254,
3943,
3292,
60377,
3232,
8908,
9791,
340,
262,
775,
512,
286,
2988,
284,
1630,
53420,
59973,
6546,
11174,
8908,
9791,
477,
364,
2309,
4532,
262,
2105,
42022,
19062,
705,
364,
2900,
374,
539,
42022,
1270,
262,
674,
6106,
2988,
706,
279,
3779,
5528,
198,
262,
422,
539,
32156,
19062,
11,
364,
36009,
11290,
286,
2988,
284,
4254,
3943,
3292,
60377,
19062,
340,
262,
471,
2988,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
456,
264,
865,
60377,
734,
505,
264,
610,
477,
42022,
382,
14711,
6075,
512,
755,
721,
456,
14327,
67,
9791,
3232,
8908,
9791,
997,
262,
4304,
636,
264,
865,
60377,
734,
505,
264,
610,
477,
42022,
13,
3270,
262,
674,
636,
279,
734,
477,
4254,
42022,
198,
262,
422,
42022,
3232,
8908,
9791,
997,
286,
2988,
284,
4254,
3943,
3292,
60377,
3232,
8908,
9791,
340,
262,
775,
512,
286,
2988,
284,
1630,
53420,
59973,
6546,
11174,
8908,
9791,
477,
364,
2309,
4532,
262,
2105,
42022,
19062,
705,
364,
2900,
374,
539,
42022,
1270,
262,
674,
6106,
2988,
706,
279,
3779,
5528,
198,
262,
422,
539,
32156,
19062,
11,
364,
36009,
11290,
286,
2988,
284,
4254,
3943,
3292,
60377,
19062,
340,
262,
471,
2988,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
CZ-NIC/yangson | yangson/schemanode.py | ChoiceNode._active_case | def _active_case(self, value: ObjectValue) -> Optional["CaseNode"]:
"""Return receiver's case that's active in an instance node value."""
for c in self.children:
for cc in c.data_children():
if cc.iname() in value:
return c | python | def _active_case(self, value: ObjectValue) -> Optional["CaseNode"]:
"""Return receiver's case that's active in an instance node value."""
for c in self.children:
for cc in c.data_children():
if cc.iname() in value:
return c | [
"def",
"_active_case",
"(",
"self",
",",
"value",
":",
"ObjectValue",
")",
"->",
"Optional",
"[",
"\"CaseNode\"",
"]",
":",
"for",
"c",
"in",
"self",
".",
"children",
":",
"for",
"cc",
"in",
"c",
".",
"data_children",
"(",
")",
":",
"if",
"cc",
".",
"iname",
"(",
")",
"in",
"value",
":",
"return",
"c"
] | Return receiver's case that's active in an instance node value. | [
"Return",
"receiver",
"s",
"case",
"that",
"s",
"active",
"in",
"an",
"instance",
"node",
"value",
"."
] | train | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/schemanode.py#L1138-L1143 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return receiver's case that's active in an instance node value.
### Response:
def _active_case(self, value: ObjectValue) -> Optional["CaseNode"]:
"""Return receiver's case that's active in an instance node value."""
for c in self.children:
for cc in c.data_children():
if cc.iname() in value:
return c
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
14291,
596,
1162,
430,
596,
4642,
304,
459,
2937,
2494,
907,
382,
14711,
6075,
512,
755,
721,
3104,
19640,
1214,
11,
907,
25,
3075,
1150,
8,
1492,
12536,
1204,
4301,
1997,
34834,
286,
4304,
5715,
14291,
596,
1162,
430,
596,
4642,
304,
459,
2937,
2494,
907,
14781,
286,
369,
272,
304,
659,
13664,
512,
310,
369,
12810,
304,
272,
2245,
32306,
4019,
394,
422,
12810,
1896,
373,
368,
304,
907,
512,
504,
471,
272,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
14291,
596,
1162,
430,
596,
4642,
304,
459,
2937,
2494,
907,
382,
14711,
6075,
512,
755,
721,
3104,
19640,
1214,
11,
907,
25,
3075,
1150,
8,
1492,
12536,
1204,
4301,
1997,
34834,
286,
4304,
5715,
14291,
596,
1162,
430,
596,
4642,
304,
459,
2937,
2494,
907,
14781,
286,
369,
272,
304,
659,
13664,
512,
310,
369,
12810,
304,
272,
2245,
32306,
4019,
394,
422,
12810,
1896,
373,
368,
304,
907,
512,
504,
471,
272,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
briancappello/flask-unchained | flask_unchained/bundles/api/model_resource.py | ModelResource.deleted | def deleted(self, instance):
"""
Convenience method for deleting a model (automatically commits the
delete to the database and returns with an HTTP 204 status code)
"""
self.session_manager.delete(instance, commit=True)
return '', HTTPStatus.NO_CONTENT | python | def deleted(self, instance):
"""
Convenience method for deleting a model (automatically commits the
delete to the database and returns with an HTTP 204 status code)
"""
self.session_manager.delete(instance, commit=True)
return '', HTTPStatus.NO_CONTENT | [
"def",
"deleted",
"(",
"self",
",",
"instance",
")",
":",
"self",
".",
"session_manager",
".",
"delete",
"(",
"instance",
",",
"commit",
"=",
"True",
")",
"return",
"''",
",",
"HTTPStatus",
".",
"NO_CONTENT"
] | Convenience method for deleting a model (automatically commits the
delete to the database and returns with an HTTP 204 status code) | [
"Convenience",
"method",
"for",
"deleting",
"a",
"model",
"(",
"automatically",
"commits",
"the",
"delete",
"to",
"the",
"database",
"and",
"returns",
"with",
"an",
"HTTP",
"204",
"status",
"code",
")"
] | train | https://github.com/briancappello/flask-unchained/blob/4d536cb90e2cc4829c1c05f2c74d3e22901a1399/flask_unchained/bundles/api/model_resource.py#L367-L373 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Convenience method for deleting a model (automatically commits the
delete to the database and returns with an HTTP 204 status code)
### Response:
def deleted(self, instance):
"""
Convenience method for deleting a model (automatically commits the
delete to the database and returns with an HTTP 204 status code)
"""
self.session_manager.delete(instance, commit=True)
return '', HTTPStatus.NO_CONTENT
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1128,
40647,
1749,
369,
34111,
264,
1646,
320,
28172,
7167,
42635,
279,
198,
286,
3783,
311,
279,
4729,
323,
4780,
449,
459,
10339,
220,
7854,
2704,
2082,
696,
14711,
6075,
512,
755,
11309,
1214,
11,
2937,
997,
286,
3270,
286,
81748,
1749,
369,
34111,
264,
1646,
320,
28172,
7167,
42635,
279,
198,
286,
3783,
311,
279,
4729,
323,
4780,
449,
459,
10339,
220,
7854,
2704,
2082,
340,
286,
3270,
286,
659,
10387,
12418,
7592,
22384,
11,
5379,
3702,
340,
286,
471,
9158,
10339,
2583,
43983,
26641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0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,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1128,
40647,
1749,
369,
34111,
264,
1646,
320,
28172,
7167,
42635,
279,
198,
286,
3783,
311,
279,
4729,
323,
4780,
449,
459,
10339,
220,
7854,
2704,
2082,
696,
14711,
6075,
512,
755,
11309,
1214,
11,
2937,
997,
286,
3270,
286,
81748,
1749,
369,
34111,
264,
1646,
320,
28172,
7167,
42635,
279,
198,
286,
3783,
311,
279,
4729,
323,
4780,
449,
459,
10339,
220,
7854,
2704,
2082,
340,
286,
3270,
286,
659,
10387,
12418,
7592,
22384,
11,
5379,
3702,
340,
286,
471,
9158,
10339,
2583,
43983,
26641,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
raiden-network/raiden | raiden/transfer/mediated_transfer/mediator.py | events_for_balanceproof | def events_for_balanceproof(
channelidentifiers_to_channels: ChannelMap,
transfers_pair: List[MediationPairState],
pseudo_random_generator: random.Random,
block_number: BlockNumber,
secret: Secret,
secrethash: SecretHash,
) -> List[Event]:
""" While it's safe do the off-chain unlock. """
events: List[Event] = list()
for pair in reversed(transfers_pair):
payee_knows_secret = pair.payee_state in STATE_SECRET_KNOWN
payee_payed = pair.payee_state in STATE_TRANSFER_PAID
payee_channel = get_payee_channel(channelidentifiers_to_channels, pair)
payee_channel_open = (
payee_channel and channel.get_status(payee_channel) == CHANNEL_STATE_OPENED
)
payer_channel = get_payer_channel(channelidentifiers_to_channels, pair)
# The mediator must not send to the payee a balance proof if the lock
# is in the danger zone, because the payer may not do the same and the
# on-chain unlock may fail. If the lock is nearing it's expiration
# block, then on-chain unlock should be done, and if successful it can
# be unlocked off-chain.
is_safe_to_send_balanceproof = False
if payer_channel:
is_safe_to_send_balanceproof, _ = is_safe_to_wait(
pair.payer_transfer.lock.expiration,
payer_channel.reveal_timeout,
block_number,
)
should_send_balanceproof_to_payee = (
payee_channel_open and
payee_knows_secret and
not payee_payed and
is_safe_to_send_balanceproof
)
if should_send_balanceproof_to_payee:
# At this point we are sure that payee_channel exists due to the
# payee_channel_open check above. So let mypy know about this
assert payee_channel
payee_channel = cast(NettingChannelState, payee_channel)
pair.payee_state = 'payee_balance_proof'
message_identifier = message_identifier_from_prng(pseudo_random_generator)
unlock_lock = channel.send_unlock(
channel_state=payee_channel,
message_identifier=message_identifier,
payment_identifier=pair.payee_transfer.payment_identifier,
secret=secret,
secrethash=secrethash,
)
unlock_success = EventUnlockSuccess(
pair.payer_transfer.payment_identifier,
pair.payer_transfer.lock.secrethash,
)
events.append(unlock_lock)
events.append(unlock_success)
return events | python | def events_for_balanceproof(
channelidentifiers_to_channels: ChannelMap,
transfers_pair: List[MediationPairState],
pseudo_random_generator: random.Random,
block_number: BlockNumber,
secret: Secret,
secrethash: SecretHash,
) -> List[Event]:
""" While it's safe do the off-chain unlock. """
events: List[Event] = list()
for pair in reversed(transfers_pair):
payee_knows_secret = pair.payee_state in STATE_SECRET_KNOWN
payee_payed = pair.payee_state in STATE_TRANSFER_PAID
payee_channel = get_payee_channel(channelidentifiers_to_channels, pair)
payee_channel_open = (
payee_channel and channel.get_status(payee_channel) == CHANNEL_STATE_OPENED
)
payer_channel = get_payer_channel(channelidentifiers_to_channels, pair)
# The mediator must not send to the payee a balance proof if the lock
# is in the danger zone, because the payer may not do the same and the
# on-chain unlock may fail. If the lock is nearing it's expiration
# block, then on-chain unlock should be done, and if successful it can
# be unlocked off-chain.
is_safe_to_send_balanceproof = False
if payer_channel:
is_safe_to_send_balanceproof, _ = is_safe_to_wait(
pair.payer_transfer.lock.expiration,
payer_channel.reveal_timeout,
block_number,
)
should_send_balanceproof_to_payee = (
payee_channel_open and
payee_knows_secret and
not payee_payed and
is_safe_to_send_balanceproof
)
if should_send_balanceproof_to_payee:
# At this point we are sure that payee_channel exists due to the
# payee_channel_open check above. So let mypy know about this
assert payee_channel
payee_channel = cast(NettingChannelState, payee_channel)
pair.payee_state = 'payee_balance_proof'
message_identifier = message_identifier_from_prng(pseudo_random_generator)
unlock_lock = channel.send_unlock(
channel_state=payee_channel,
message_identifier=message_identifier,
payment_identifier=pair.payee_transfer.payment_identifier,
secret=secret,
secrethash=secrethash,
)
unlock_success = EventUnlockSuccess(
pair.payer_transfer.payment_identifier,
pair.payer_transfer.lock.secrethash,
)
events.append(unlock_lock)
events.append(unlock_success)
return events | [
"def",
"events_for_balanceproof",
"(",
"channelidentifiers_to_channels",
":",
"ChannelMap",
",",
"transfers_pair",
":",
"List",
"[",
"MediationPairState",
"]",
",",
"pseudo_random_generator",
":",
"random",
".",
"Random",
",",
"block_number",
":",
"BlockNumber",
",",
"secret",
":",
"Secret",
",",
"secrethash",
":",
"SecretHash",
",",
")",
"->",
"List",
"[",
"Event",
"]",
":",
"events",
":",
"List",
"[",
"Event",
"]",
"=",
"list",
"(",
")",
"for",
"pair",
"in",
"reversed",
"(",
"transfers_pair",
")",
":",
"payee_knows_secret",
"=",
"pair",
".",
"payee_state",
"in",
"STATE_SECRET_KNOWN",
"payee_payed",
"=",
"pair",
".",
"payee_state",
"in",
"STATE_TRANSFER_PAID",
"payee_channel",
"=",
"get_payee_channel",
"(",
"channelidentifiers_to_channels",
",",
"pair",
")",
"payee_channel_open",
"=",
"(",
"payee_channel",
"and",
"channel",
".",
"get_status",
"(",
"payee_channel",
")",
"==",
"CHANNEL_STATE_OPENED",
")",
"payer_channel",
"=",
"get_payer_channel",
"(",
"channelidentifiers_to_channels",
",",
"pair",
")",
"# The mediator must not send to the payee a balance proof if the lock",
"# is in the danger zone, because the payer may not do the same and the",
"# on-chain unlock may fail. If the lock is nearing it's expiration",
"# block, then on-chain unlock should be done, and if successful it can",
"# be unlocked off-chain.",
"is_safe_to_send_balanceproof",
"=",
"False",
"if",
"payer_channel",
":",
"is_safe_to_send_balanceproof",
",",
"_",
"=",
"is_safe_to_wait",
"(",
"pair",
".",
"payer_transfer",
".",
"lock",
".",
"expiration",
",",
"payer_channel",
".",
"reveal_timeout",
",",
"block_number",
",",
")",
"should_send_balanceproof_to_payee",
"=",
"(",
"payee_channel_open",
"and",
"payee_knows_secret",
"and",
"not",
"payee_payed",
"and",
"is_safe_to_send_balanceproof",
")",
"if",
"should_send_balanceproof_to_payee",
":",
"# At this point we are sure that payee_channel exists due to the",
"# payee_channel_open check above. So let mypy know about this",
"assert",
"payee_channel",
"payee_channel",
"=",
"cast",
"(",
"NettingChannelState",
",",
"payee_channel",
")",
"pair",
".",
"payee_state",
"=",
"'payee_balance_proof'",
"message_identifier",
"=",
"message_identifier_from_prng",
"(",
"pseudo_random_generator",
")",
"unlock_lock",
"=",
"channel",
".",
"send_unlock",
"(",
"channel_state",
"=",
"payee_channel",
",",
"message_identifier",
"=",
"message_identifier",
",",
"payment_identifier",
"=",
"pair",
".",
"payee_transfer",
".",
"payment_identifier",
",",
"secret",
"=",
"secret",
",",
"secrethash",
"=",
"secrethash",
",",
")",
"unlock_success",
"=",
"EventUnlockSuccess",
"(",
"pair",
".",
"payer_transfer",
".",
"payment_identifier",
",",
"pair",
".",
"payer_transfer",
".",
"lock",
".",
"secrethash",
",",
")",
"events",
".",
"append",
"(",
"unlock_lock",
")",
"events",
".",
"append",
"(",
"unlock_success",
")",
"return",
"events"
] | While it's safe do the off-chain unlock. | [
"While",
"it",
"s",
"safe",
"do",
"the",
"off",
"-",
"chain",
"unlock",
"."
] | train | https://github.com/raiden-network/raiden/blob/407ba15c72074e9de88771d6b9661ff4dc36bef5/raiden/transfer/mediated_transfer/mediator.py#L797-L862 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
While it's safe do the off-chain unlock.
### Response:
def events_for_balanceproof(
channelidentifiers_to_channels: ChannelMap,
transfers_pair: List[MediationPairState],
pseudo_random_generator: random.Random,
block_number: BlockNumber,
secret: Secret,
secrethash: SecretHash,
) -> List[Event]:
""" While it's safe do the off-chain unlock. """
events: List[Event] = list()
for pair in reversed(transfers_pair):
payee_knows_secret = pair.payee_state in STATE_SECRET_KNOWN
payee_payed = pair.payee_state in STATE_TRANSFER_PAID
payee_channel = get_payee_channel(channelidentifiers_to_channels, pair)
payee_channel_open = (
payee_channel and channel.get_status(payee_channel) == CHANNEL_STATE_OPENED
)
payer_channel = get_payer_channel(channelidentifiers_to_channels, pair)
# The mediator must not send to the payee a balance proof if the lock
# is in the danger zone, because the payer may not do the same and the
# on-chain unlock may fail. If the lock is nearing it's expiration
# block, then on-chain unlock should be done, and if successful it can
# be unlocked off-chain.
is_safe_to_send_balanceproof = False
if payer_channel:
is_safe_to_send_balanceproof, _ = is_safe_to_wait(
pair.payer_transfer.lock.expiration,
payer_channel.reveal_timeout,
block_number,
)
should_send_balanceproof_to_payee = (
payee_channel_open and
payee_knows_secret and
not payee_payed and
is_safe_to_send_balanceproof
)
if should_send_balanceproof_to_payee:
# At this point we are sure that payee_channel exists due to the
# payee_channel_open check above. So let mypy know about this
assert payee_channel
payee_channel = cast(NettingChannelState, payee_channel)
pair.payee_state = 'payee_balance_proof'
message_identifier = message_identifier_from_prng(pseudo_random_generator)
unlock_lock = channel.send_unlock(
channel_state=payee_channel,
message_identifier=message_identifier,
payment_identifier=pair.payee_transfer.payment_identifier,
secret=secret,
secrethash=secrethash,
)
unlock_success = EventUnlockSuccess(
pair.payer_transfer.payment_identifier,
pair.payer_transfer.lock.secrethash,
)
events.append(unlock_lock)
events.append(unlock_success)
return events
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8142,
433,
596,
6220,
656,
279,
1022,
66286,
15405,
382,
14711,
6075,
512,
755,
4455,
5595,
30496,
16157,
1021,
286,
5613,
1748,
12099,
2401,
19848,
25,
13740,
2276,
345,
286,
31711,
14784,
25,
1796,
58,
13613,
7246,
12725,
1423,
1282,
286,
35850,
23471,
26898,
25,
4288,
27807,
345,
286,
2565,
5617,
25,
8527,
2903,
345,
286,
6367,
25,
8769,
345,
286,
19733,
339,
1003,
25,
8769,
6504,
345,
8,
1492,
1796,
58,
1585,
10556,
262,
4304,
6104,
433,
596,
6220,
656,
279,
1022,
66286,
15405,
13,
12713,
262,
4455,
25,
1796,
58,
1585,
60,
284,
1160,
746,
262,
369,
6857,
304,
28537,
34189,
50893,
14784,
997,
286,
2343,
2176,
4803,
3409,
82,
22729,
284,
6857,
38442,
2176,
4486,
304,
23233,
32508,
10310,
45,
7736,
198,
286,
2343,
2176,
30025,
291,
284,
6857,
38442,
2176,
4486,
304,
23233,
65797,
27283,
926,
271,
286,
2343,
2176,
14913,
284,
636,
30025,
2176,
14913,
27012,
1748,
12099,
2401,
19848,
11,
6857,
340,
286,
2343,
2176,
14913,
11563,
284,
2456,
310,
2343,
2176,
14913,
323,
5613,
673,
4878,
1319,
352,
2176,
14913,
8,
624,
59856,
11069,
25037,
1507,
198,
286,
5235,
286,
70375,
14913,
284,
636,
623,
1155,
14913,
27012,
1748,
12099,
2401,
19848,
11,
6857,
696,
286,
674,
578,
69030,
2011,
539,
3708,
311,
279,
2343,
2176,
264,
8335,
11311,
422,
279,
5409,
198,
286,
674,
374,
304,
279,
8137,
10353,
11,
1606,
279,
70375,
1253,
539,
656,
279,
1890,
323,
279,
198,
286,
674,
389,
66286,
15405,
1253,
3775,
13,
1442,
279,
5409,
374,
83399,
433,
596,
32792,
198,
286,
674,
2565,
11,
1243,
389,
66286,
15405,
1288,
387,
2884,
11,
323,
422,
6992,
433,
649,
198,
286,
674,
387,
36718,
1022,
66286,
627,
286,
374,
35167,
2401,
13877,
30496,
16157,
284,
3641,
198,
286,
422,
70375,
14913,
512,
310,
374,
35167,
2401,
13877,
30496,
16157,
11,
721,
284,
374,
35167,
2401,
19286,
1021,
394,
6857,
558,
1155,
36503,
21679,
2272,
29579,
345,
394,
70375,
14913,
1351,
41711,
21179,
345,
394,
2565,
5617,
345,
310,
5235,
286,
1288,
13877,
30496,
16157,
2401,
30025,
2176,
284,
2456,
310,
2343,
2176,
14913,
11563,
323,
198,
310,
2343,
2176,
4803,
3409,
82,
22729,
323,
198,
310,
539,
2343,
2176,
30025,
291,
323,
198,
310,
374,
35167,
2401,
13877,
30496,
16157,
198,
286,
5235,
286,
422,
1288,
13877,
30496,
16157,
2401,
30025,
2176,
512,
310,
674,
2468,
420,
1486,
584,
527,
2771,
430,
2343,
2176,
14913,
6866,
4245,
311,
279,
198,
310,
674,
2343,
2176,
14913,
11563,
1817,
3485,
13,
2100,
1095,
856,
3368,
1440,
922,
420,
198,
310,
2105,
2343,
2176,
14913,
198,
310,
2343,
2176,
14913,
284,
6445,
7,
7099,
1303,
9826,
1423,
11,
2343,
2176,
14913,
340,
310,
6857,
38442,
2176,
4486,
284,
364,
14214,
2176,
30496,
87857,
3961,
310,
1984,
34276,
284,
1984,
34276,
5791,
5407,
983,
1319,
22719,
23471,
26898,
340,
310,
15405,
10019,
284
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8142,
433,
596,
6220,
656,
279,
1022,
66286,
15405,
382,
14711,
6075,
512,
755,
4455,
5595,
30496,
16157,
1021,
286,
5613,
1748,
12099,
2401,
19848,
25,
13740,
2276,
345,
286,
31711,
14784,
25,
1796,
58,
13613,
7246,
12725,
1423,
1282,
286,
35850,
23471,
26898,
25,
4288,
27807,
345,
286,
2565,
5617,
25,
8527,
2903,
345,
286,
6367,
25,
8769,
345,
286,
19733,
339,
1003,
25,
8769,
6504,
345,
8,
1492,
1796,
58,
1585,
10556,
262,
4304,
6104,
433,
596,
6220,
656,
279,
1022,
66286,
15405,
13,
12713,
262,
4455,
25,
1796,
58,
1585,
60,
284,
1160,
746,
262,
369,
6857,
304,
28537,
34189,
50893,
14784,
997,
286,
2343,
2176,
4803,
3409,
82,
22729,
284,
6857,
38442,
2176,
4486,
304,
23233,
32508,
10310,
45,
7736,
198,
286,
2343,
2176,
30025,
291,
284,
6857,
38442,
2176,
4486,
304,
23233,
65797,
27283,
926,
271,
286,
2343,
2176,
14913,
284,
636,
30025,
2176,
14913,
27012,
1748,
12099,
2401,
19848,
11,
6857,
340,
286,
2343,
2176,
14913,
11563,
284,
2456,
310,
2343,
2176,
14913,
323,
5613,
673,
4878,
1319,
352,
2176,
14913,
8,
624,
59856,
11069,
25037,
1507,
198,
286,
5235,
286,
70375,
14913,
284,
636,
623,
1155,
14913,
27012,
1748,
12099,
2401,
19848,
11,
6857,
696,
286,
674,
578,
69030,
2011,
539,
3708,
311,
279,
2343,
2176,
264,
8335,
11311,
422,
279,
5409,
198,
286,
674,
374,
304,
279,
8137,
10353,
11,
1606,
279,
70375,
1253,
539,
656,
279,
1890,
323,
279,
198,
286,
674,
389,
66286,
15405,
1253,
3775,
13,
1442,
279,
5409,
374,
83399,
433,
596,
32792,
198,
286,
674,
2565,
11,
1243,
389,
66286,
15405,
1288,
387,
2884,
11,
323,
422,
6992,
433,
649,
198,
286,
674,
387,
36718,
1022,
66286,
627,
286,
374,
35167,
2401,
13877,
30496,
16157,
284,
3641,
198,
286,
422,
70375,
14913,
512,
310,
374,
35167,
2401,
13877,
30496,
16157,
11,
721,
284,
374,
35167,
2401,
19286,
1021,
394,
6857,
558,
1155,
36503,
21679,
2272,
29579,
345,
394,
70375,
14913,
1351,
41711,
21179,
345,
394,
2565,
5617,
345,
310,
5235,
286,
1288,
13877,
30496,
16157,
2401,
30025,
2176,
284,
2456,
310,
2343,
2176,
14913,
11563,
323,
198,
310,
2343,
2176,
4803,
3409,
82,
22729,
323,
198,
310,
539,
2343,
2176,
30025,
291,
323,
198,
310,
374,
35167,
2401,
13877,
30496,
16157,
198,
286,
5235,
286,
422,
1288,
13877,
30496,
16157,
2401,
30025,
2176,
512,
310,
674,
2468,
420,
1486,
584,
527,
2771,
430,
2343,
2176,
14913,
6866,
4245,
311,
279,
198,
310,
674,
2343,
2176,
14913,
11563,
1817,
3485,
13,
2100,
1095,
856,
3368,
1440,
922,
420,
198,
310,
2105,
2343,
2176,
14913,
198,
310,
2343,
2176,
14913,
284,
6445,
7,
7099,
1303,
9826,
1423,
11,
2343,
2176,
14913,
340,
310,
6857,
38442,
2176,
4486,
284,
364,
14214,
2176,
30496,
87857,
3961,
310,
1984,
34276,
284,
1984,
34276,
5791,
5407,
983,
1319,
22719,
23471,
26898,
340,
310,
15405,
10019,
284
] |
tomplus/kubernetes_asyncio | kubernetes_asyncio/client/api/batch_v2alpha1_api.py | BatchV2alpha1Api.replace_namespaced_cron_job_status | def replace_namespaced_cron_job_status(self, name, namespace, body, **kwargs): # noqa: E501
"""replace_namespaced_cron_job_status # noqa: E501
replace status of the specified CronJob # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_namespaced_cron_job_status(name, namespace, body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str name: name of the CronJob (required)
:param str namespace: object name and auth scope, such as for teams and projects (required)
:param V2alpha1CronJob body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:param str dry_run: When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
:return: V2alpha1CronJob
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.replace_namespaced_cron_job_status_with_http_info(name, namespace, body, **kwargs) # noqa: E501
else:
(data) = self.replace_namespaced_cron_job_status_with_http_info(name, namespace, body, **kwargs) # noqa: E501
return data | python | def replace_namespaced_cron_job_status(self, name, namespace, body, **kwargs): # noqa: E501
"""replace_namespaced_cron_job_status # noqa: E501
replace status of the specified CronJob # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_namespaced_cron_job_status(name, namespace, body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str name: name of the CronJob (required)
:param str namespace: object name and auth scope, such as for teams and projects (required)
:param V2alpha1CronJob body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:param str dry_run: When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
:return: V2alpha1CronJob
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.replace_namespaced_cron_job_status_with_http_info(name, namespace, body, **kwargs) # noqa: E501
else:
(data) = self.replace_namespaced_cron_job_status_with_http_info(name, namespace, body, **kwargs) # noqa: E501
return data | [
"def",
"replace_namespaced_cron_job_status",
"(",
"self",
",",
"name",
",",
"namespace",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
":",
"# noqa: E501",
"kwargs",
"[",
"'_return_http_data_only'",
"]",
"=",
"True",
"if",
"kwargs",
".",
"get",
"(",
"'async_req'",
")",
":",
"return",
"self",
".",
"replace_namespaced_cron_job_status_with_http_info",
"(",
"name",
",",
"namespace",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
"# noqa: E501",
"else",
":",
"(",
"data",
")",
"=",
"self",
".",
"replace_namespaced_cron_job_status_with_http_info",
"(",
"name",
",",
"namespace",
",",
"body",
",",
"*",
"*",
"kwargs",
")",
"# noqa: E501",
"return",
"data"
] | replace_namespaced_cron_job_status # noqa: E501
replace status of the specified CronJob # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_namespaced_cron_job_status(name, namespace, body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str name: name of the CronJob (required)
:param str namespace: object name and auth scope, such as for teams and projects (required)
:param V2alpha1CronJob body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:param str dry_run: When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
:return: V2alpha1CronJob
If the method is called asynchronously,
returns the request thread. | [
"replace_namespaced_cron_job_status",
"#",
"noqa",
":",
"E501"
] | train | https://github.com/tomplus/kubernetes_asyncio/blob/f9ab15317ec921409714c7afef11aeb0f579985d/kubernetes_asyncio/client/api/batch_v2alpha1_api.py#L1347-L1371 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
replace_namespaced_cron_job_status # noqa: E501
replace status of the specified CronJob # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_namespaced_cron_job_status(name, namespace, body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str name: name of the CronJob (required)
:param str namespace: object name and auth scope, such as for teams and projects (required)
:param V2alpha1CronJob body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:param str dry_run: When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
:return: V2alpha1CronJob
If the method is called asynchronously,
returns the request thread.
### Response:
def replace_namespaced_cron_job_status(self, name, namespace, body, **kwargs): # noqa: E501
"""replace_namespaced_cron_job_status # noqa: E501
replace status of the specified CronJob # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
>>> thread = api.replace_namespaced_cron_job_status(name, namespace, body, async_req=True)
>>> result = thread.get()
:param async_req bool
:param str name: name of the CronJob (required)
:param str namespace: object name and auth scope, such as for teams and projects (required)
:param V2alpha1CronJob body: (required)
:param str pretty: If 'true', then the output is pretty printed.
:param str dry_run: When present, indicates that modifications should not be persisted. An invalid or unrecognized dryRun directive will result in an error response and no further processing of the request. Valid values are: - All: all dry run stages will be processed
:return: V2alpha1CronJob
If the method is called asynchronously,
returns the request thread.
"""
kwargs['_return_http_data_only'] = True
if kwargs.get('async_req'):
return self.replace_namespaced_cron_job_status_with_http_info(name, namespace, body, **kwargs) # noqa: E501
else:
(data) = self.replace_namespaced_cron_job_status_with_http_info(name, namespace, body, **kwargs) # noqa: E501
return data
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8319,
9366,
69652,
669,
2298,
20916,
4878,
220,
674,
46721,
25,
469,
14408,
271,
286,
8454,
2704,
315,
279,
5300,
56917,
12524,
220,
674,
46721,
25,
469,
14408,
198,
286,
1115,
1749,
3727,
264,
67049,
10339,
1715,
555,
1670,
13,
2057,
1304,
459,
198,
286,
40107,
10339,
1715,
11,
4587,
1522,
3393,
18110,
3702,
198,
286,
12382,
4617,
284,
6464,
7125,
9366,
69652,
669,
2298,
20916,
4878,
3232,
11,
4573,
11,
2547,
11,
3393,
18110,
3702,
340,
286,
12382,
1121,
284,
4617,
673,
2892,
286,
551,
913,
3393,
18110,
1845,
198,
286,
551,
913,
610,
836,
25,
836,
315,
279,
56917,
12524,
320,
6413,
340,
286,
551,
913,
610,
4573,
25,
1665,
836,
323,
4259,
7036,
11,
1778,
439,
369,
7411,
323,
7224,
320,
6413,
340,
286,
551,
913,
650,
17,
7288,
16,
34,
2298,
12524,
2547,
25,
320,
6413,
340,
286,
551,
913,
610,
5128,
25,
1442,
364,
1904,
518,
1243,
279,
2612,
374,
5128,
17124,
627,
286,
551,
913,
610,
9235,
14334,
25,
3277,
3118,
11,
15151,
430,
29882,
1288,
539,
387,
54095,
13,
1556,
8482,
477,
97239,
9235,
6869,
34959,
690,
1121,
304,
459,
1493,
2077,
323,
912,
4726,
8863,
315,
279,
1715,
13,
7974,
2819,
527,
25,
482,
2052,
25,
682,
9235,
1629,
18094,
690,
387,
15590,
198,
286,
551,
693,
25,
650,
17,
7288,
16,
34,
2298,
12524,
198,
338,
1442,
279,
1749,
374,
2663,
68881,
345,
338,
4780,
279,
1715,
4617,
382,
14711,
6075,
512,
755,
8454,
9366,
69652,
669,
2298,
20916,
4878,
1214,
11,
836,
11,
4573,
11,
2547,
11,
3146,
9872,
1680,
220,
674,
46721,
25,
469,
14408,
198,
286,
4304,
8319,
9366,
69652,
669,
2298,
20916,
4878,
220,
674,
46721,
25,
469,
14408,
271,
286,
8454,
2704,
315,
279,
5300,
56917,
12524,
220,
674,
46721,
25,
469,
14408,
198,
286,
1115,
1749,
3727,
264,
67049,
10339,
1715,
555,
1670,
13,
2057,
1304,
459,
198,
286,
40107,
10339,
1715,
11,
4587,
1522,
3393,
18110,
3702,
198,
286,
12382,
4617,
284,
6464,
7125,
9366,
69652,
669,
2298,
20916,
4878,
3232,
11,
4573,
11,
2547,
11,
3393,
18110,
3702,
340,
286,
12382,
1121,
284,
4617,
673,
2892,
286,
551,
913,
3393,
18110,
1845,
198,
286,
551,
913,
610,
836,
25,
836,
315,
279,
56917,
12524,
320,
6413,
340,
286,
551,
913,
610,
4573,
25,
1665,
836,
323,
4259,
7036,
11,
1778,
439,
369,
7411,
323,
7224,
320,
6413,
340,
286,
551,
913,
650,
17,
7288,
16,
34,
2298,
12524,
2547,
25,
320,
6413,
340,
286,
551,
913,
610,
5128,
25,
1442,
364,
1904,
518,
1243,
279,
2612,
374,
5128,
17124,
627,
286,
551,
913,
610,
9235,
14334,
25,
3277,
3118,
11,
15151,
430,
29882,
1288,
539,
387,
54095,
13,
1556,
8482,
477,
97239,
9235,
6869,
34959,
690,
1121,
304,
459,
1493,
2077,
323,
912,
4726,
8863,
315,
279,
1715,
13,
7974,
2819,
527,
25,
482,
2052,
25
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
8319,
9366,
69652,
669,
2298,
20916,
4878,
220,
674,
46721,
25,
469,
14408,
271,
286,
8454,
2704,
315,
279,
5300,
56917,
12524,
220,
674,
46721,
25,
469,
14408,
198,
286,
1115,
1749,
3727,
264,
67049,
10339,
1715,
555,
1670,
13,
2057,
1304,
459,
198,
286,
40107,
10339,
1715,
11,
4587,
1522,
3393,
18110,
3702,
198,
286,
12382,
4617,
284,
6464,
7125,
9366,
69652,
669,
2298,
20916,
4878,
3232,
11,
4573,
11,
2547,
11,
3393,
18110,
3702,
340,
286,
12382,
1121,
284,
4617,
673,
2892,
286,
551,
913,
3393,
18110,
1845,
198,
286,
551,
913,
610,
836,
25,
836,
315,
279,
56917,
12524,
320,
6413,
340,
286,
551,
913,
610,
4573,
25,
1665,
836,
323,
4259,
7036,
11,
1778,
439,
369,
7411,
323,
7224,
320,
6413,
340,
286,
551,
913,
650,
17,
7288,
16,
34,
2298,
12524,
2547,
25,
320,
6413,
340,
286,
551,
913,
610,
5128,
25,
1442,
364,
1904,
518,
1243,
279,
2612,
374,
5128,
17124,
627,
286,
551,
913,
610,
9235,
14334,
25,
3277,
3118,
11,
15151,
430,
29882,
1288,
539,
387,
54095,
13,
1556,
8482,
477,
97239,
9235,
6869,
34959,
690,
1121,
304,
459,
1493,
2077,
323,
912,
4726,
8863,
315,
279,
1715,
13,
7974,
2819,
527,
25,
482,
2052,
25,
682,
9235,
1629,
18094,
690,
387,
15590,
198,
286,
551,
693,
25,
650,
17,
7288,
16,
34,
2298,
12524,
198,
338,
1442,
279,
1749,
374,
2663,
68881,
345,
338,
4780,
279,
1715,
4617,
382,
14711,
6075,
512,
755,
8454,
9366,
69652,
669,
2298,
20916,
4878,
1214,
11,
836,
11,
4573,
11,
2547,
11,
3146,
9872,
1680,
220,
674,
46721,
25,
469,
14408,
198,
286,
4304,
8319,
9366,
69652,
669,
2298,
20916,
4878,
220,
674,
46721,
25,
469,
14408,
271,
286,
8454,
2704,
315,
279,
5300,
56917,
12524,
220,
674,
46721,
25,
469,
14408,
198,
286,
1115,
1749,
3727,
264,
67049,
10339,
1715,
555,
1670,
13,
2057,
1304,
459,
198,
286,
40107,
10339,
1715,
11,
4587,
1522,
3393,
18110,
3702,
198,
286,
12382,
4617,
284,
6464,
7125,
9366,
69652,
669,
2298,
20916,
4878,
3232,
11,
4573,
11,
2547,
11,
3393,
18110,
3702,
340,
286,
12382,
1121,
284,
4617,
673,
2892,
286,
551,
913,
3393,
18110,
1845,
198,
286,
551,
913,
610,
836,
25,
836,
315,
279,
56917,
12524,
320,
6413,
340,
286,
551,
913,
610,
4573,
25,
1665,
836,
323,
4259,
7036,
11,
1778,
439,
369,
7411,
323,
7224,
320,
6413,
340,
286,
551,
913,
650,
17,
7288,
16,
34,
2298,
12524,
2547,
25,
320,
6413,
340,
286,
551,
913,
610,
5128,
25,
1442,
364,
1904,
518,
1243,
279,
2612,
374,
5128,
17124,
627,
286,
551,
913,
610,
9235,
14334,
25,
3277,
3118,
11,
15151,
430,
29882,
1288,
539,
387,
54095,
13,
1556,
8482,
477,
97239,
9235,
6869,
34959,
690,
1121,
304,
459,
1493,
2077,
323,
912,
4726,
8863,
315,
279,
1715,
13,
7974,
2819,
527,
25,
482,
2052,
25
] |
JdeRobot/base | src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/__init__.py | MapModule.drawing_update | def drawing_update(self):
'''update line drawing'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if self.draw_callback is None:
return
self.draw_line.append(self.click_position)
if len(self.draw_line) > 1:
self.mpstate.map.add_object(mp_slipmap.SlipPolygon('drawing', self.draw_line,
layer='Drawing', linewidth=2, colour=(128,128,255))) | python | def drawing_update(self):
'''update line drawing'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if self.draw_callback is None:
return
self.draw_line.append(self.click_position)
if len(self.draw_line) > 1:
self.mpstate.map.add_object(mp_slipmap.SlipPolygon('drawing', self.draw_line,
layer='Drawing', linewidth=2, colour=(128,128,255))) | [
"def",
"drawing_update",
"(",
"self",
")",
":",
"from",
"MAVProxy",
".",
"modules",
".",
"mavproxy_map",
"import",
"mp_slipmap",
"if",
"self",
".",
"draw_callback",
"is",
"None",
":",
"return",
"self",
".",
"draw_line",
".",
"append",
"(",
"self",
".",
"click_position",
")",
"if",
"len",
"(",
"self",
".",
"draw_line",
")",
">",
"1",
":",
"self",
".",
"mpstate",
".",
"map",
".",
"add_object",
"(",
"mp_slipmap",
".",
"SlipPolygon",
"(",
"'drawing'",
",",
"self",
".",
"draw_line",
",",
"layer",
"=",
"'Drawing'",
",",
"linewidth",
"=",
"2",
",",
"colour",
"=",
"(",
"128",
",",
"128",
",",
"255",
")",
")",
")"
] | update line drawing | [
"update",
"line",
"drawing"
] | train | https://github.com/JdeRobot/base/blob/303b18992785b2fe802212f2d758a60873007f1f/src/drivers/MAVLinkServer/MAVProxy/modules/mavproxy_map/__init__.py#L350-L358 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
update line drawing
### Response:
def drawing_update(self):
'''update line drawing'''
from MAVProxy.modules.mavproxy_map import mp_slipmap
if self.draw_callback is None:
return
self.draw_line.append(self.click_position)
if len(self.draw_line) > 1:
self.mpstate.map.add_object(mp_slipmap.SlipPolygon('drawing', self.draw_line,
layer='Drawing', linewidth=2, colour=(128,128,255)))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2443,
1584,
13633,
271,
14711,
6075,
512,
755,
13633,
9058,
1214,
997,
286,
11712,
2443,
1584,
13633,
15029,
286,
505,
81919,
16617,
27904,
749,
402,
23648,
5489,
1179,
10710,
12150,
51528,
198,
286,
422,
659,
7152,
12802,
374,
2290,
512,
310,
471,
198,
286,
659,
7152,
6665,
2102,
1214,
14798,
9858,
340,
286,
422,
2479,
1214,
7152,
6665,
8,
871,
220,
16,
512,
310,
659,
17295,
2513,
4875,
1388,
5427,
45735,
12150,
51528,
815,
34215,
38719,
493,
81949,
518,
659,
7152,
6665,
345,
27157,
6324,
1151,
38537,
518,
48947,
28,
17,
11,
12745,
4640,
4386,
11,
4386,
11,
3192,
6054,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2443,
1584,
13633,
271,
14711,
6075,
512,
755,
13633,
9058,
1214,
997,
286,
11712,
2443,
1584,
13633,
15029,
286,
505,
81919,
16617,
27904,
749,
402,
23648,
5489,
1179,
10710,
12150,
51528,
198,
286,
422,
659,
7152,
12802,
374,
2290,
512,
310,
471,
198,
286,
659,
7152,
6665,
2102,
1214,
14798,
9858,
340,
286,
422,
2479,
1214,
7152,
6665,
8,
871,
220,
16,
512,
310,
659,
17295,
2513,
4875,
1388,
5427,
45735,
12150,
51528,
815,
34215,
38719,
493,
81949,
518,
659,
7152,
6665,
345,
27157,
6324,
1151,
38537,
518,
48947,
28,
17,
11,
12745,
4640,
4386,
11,
4386,
11,
3192,
6054,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
google/grr | grr/core/grr_response_core/lib/config_lib.py | GrrConfigManager.DEFINE_integer_list | def DEFINE_integer_list(self, name, default, help, constant=False):
"""A helper for defining lists of integer options."""
self.AddOption(
type_info.List(
name=name,
default=default,
description=help,
validator=type_info.Integer()),
constant=constant) | python | def DEFINE_integer_list(self, name, default, help, constant=False):
"""A helper for defining lists of integer options."""
self.AddOption(
type_info.List(
name=name,
default=default,
description=help,
validator=type_info.Integer()),
constant=constant) | [
"def",
"DEFINE_integer_list",
"(",
"self",
",",
"name",
",",
"default",
",",
"help",
",",
"constant",
"=",
"False",
")",
":",
"self",
".",
"AddOption",
"(",
"type_info",
".",
"List",
"(",
"name",
"=",
"name",
",",
"default",
"=",
"default",
",",
"description",
"=",
"help",
",",
"validator",
"=",
"type_info",
".",
"Integer",
"(",
")",
")",
",",
"constant",
"=",
"constant",
")"
] | A helper for defining lists of integer options. | [
"A",
"helper",
"for",
"defining",
"lists",
"of",
"integer",
"options",
"."
] | train | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/config_lib.py#L1523-L1531 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
A helper for defining lists of integer options.
### Response:
def DEFINE_integer_list(self, name, default, help, constant=False):
"""A helper for defining lists of integer options."""
self.AddOption(
type_info.List(
name=name,
default=default,
description=help,
validator=type_info.Integer()),
constant=constant)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
13438,
369,
27409,
11725,
315,
7698,
2671,
382,
14711,
6075,
512,
755,
68014,
32825,
2062,
1214,
11,
836,
11,
1670,
11,
1520,
11,
6926,
5725,
997,
262,
4304,
32,
13438,
369,
27409,
11725,
315,
7698,
2671,
14781,
262,
659,
1943,
5454,
1021,
286,
955,
3186,
5937,
1021,
310,
836,
40341,
345,
310,
1670,
93728,
345,
310,
4096,
28,
8823,
345,
310,
23787,
28,
1337,
3186,
20443,
15044,
286,
6926,
28,
18568,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32,
13438,
369,
27409,
11725,
315,
7698,
2671,
382,
14711,
6075,
512,
755,
68014,
32825,
2062,
1214,
11,
836,
11,
1670,
11,
1520,
11,
6926,
5725,
997,
262,
4304,
32,
13438,
369,
27409,
11725,
315,
7698,
2671,
14781,
262,
659,
1943,
5454,
1021,
286,
955,
3186,
5937,
1021,
310,
836,
40341,
345,
310,
1670,
93728,
345,
310,
4096,
28,
8823,
345,
310,
23787,
28,
1337,
3186,
20443,
15044,
286,
6926,
28,
18568,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
kstateome/django-cas | cas/views.py | login | def login(request, next_page=None, required=False, gateway=False):
"""
Forwards to CAS login URL or verifies CAS ticket
:param: request RequestObj
:param: next_page Next page to redirect after login
:param: required
:param: gateway Gatewayed response
"""
if not next_page:
next_page = _redirect_url(request)
try:
# use callable for pre-django 2.0
is_authenticated = request.user.is_authenticated()
except TypeError:
is_authenticated = request.user.is_authenticated
if is_authenticated:
return HttpResponseRedirect(next_page)
ticket = request.GET.get('ticket')
if gateway:
service = _service_url(request, next_page, True)
else:
service = _service_url(request, next_page, False)
if ticket:
user = auth.authenticate(ticket=ticket, service=service)
if user is not None:
auth.login(request, user)
if settings.CAS_PROXY_CALLBACK:
proxy_callback(request)
return HttpResponseRedirect(next_page)
elif settings.CAS_RETRY_LOGIN or required:
if gateway:
return HttpResponseRedirect(_login_url(service, ticket, True))
else:
return HttpResponseRedirect(_login_url(service, ticket, False))
else:
logger.warning('User has a valid ticket but not a valid session')
# Has ticket, not session
if gateway:
# Gatewayed responses should nto redirect.
return False
if getattr(settings, 'CAS_CUSTOM_FORBIDDEN'):
return HttpResponseRedirect(reverse(settings.CAS_CUSTOM_FORBIDDEN) + "?" + request.META['QUERY_STRING'])
else:
error = "<h1>Forbidden</h1><p>Login failed.</p>"
return HttpResponseForbidden(error)
else:
if gateway:
return HttpResponseRedirect(_login_url(service, ticket, True))
else:
return HttpResponseRedirect(_login_url(service, ticket, False)) | python | def login(request, next_page=None, required=False, gateway=False):
"""
Forwards to CAS login URL or verifies CAS ticket
:param: request RequestObj
:param: next_page Next page to redirect after login
:param: required
:param: gateway Gatewayed response
"""
if not next_page:
next_page = _redirect_url(request)
try:
# use callable for pre-django 2.0
is_authenticated = request.user.is_authenticated()
except TypeError:
is_authenticated = request.user.is_authenticated
if is_authenticated:
return HttpResponseRedirect(next_page)
ticket = request.GET.get('ticket')
if gateway:
service = _service_url(request, next_page, True)
else:
service = _service_url(request, next_page, False)
if ticket:
user = auth.authenticate(ticket=ticket, service=service)
if user is not None:
auth.login(request, user)
if settings.CAS_PROXY_CALLBACK:
proxy_callback(request)
return HttpResponseRedirect(next_page)
elif settings.CAS_RETRY_LOGIN or required:
if gateway:
return HttpResponseRedirect(_login_url(service, ticket, True))
else:
return HttpResponseRedirect(_login_url(service, ticket, False))
else:
logger.warning('User has a valid ticket but not a valid session')
# Has ticket, not session
if gateway:
# Gatewayed responses should nto redirect.
return False
if getattr(settings, 'CAS_CUSTOM_FORBIDDEN'):
return HttpResponseRedirect(reverse(settings.CAS_CUSTOM_FORBIDDEN) + "?" + request.META['QUERY_STRING'])
else:
error = "<h1>Forbidden</h1><p>Login failed.</p>"
return HttpResponseForbidden(error)
else:
if gateway:
return HttpResponseRedirect(_login_url(service, ticket, True))
else:
return HttpResponseRedirect(_login_url(service, ticket, False)) | [
"def",
"login",
"(",
"request",
",",
"next_page",
"=",
"None",
",",
"required",
"=",
"False",
",",
"gateway",
"=",
"False",
")",
":",
"if",
"not",
"next_page",
":",
"next_page",
"=",
"_redirect_url",
"(",
"request",
")",
"try",
":",
"# use callable for pre-django 2.0",
"is_authenticated",
"=",
"request",
".",
"user",
".",
"is_authenticated",
"(",
")",
"except",
"TypeError",
":",
"is_authenticated",
"=",
"request",
".",
"user",
".",
"is_authenticated",
"if",
"is_authenticated",
":",
"return",
"HttpResponseRedirect",
"(",
"next_page",
")",
"ticket",
"=",
"request",
".",
"GET",
".",
"get",
"(",
"'ticket'",
")",
"if",
"gateway",
":",
"service",
"=",
"_service_url",
"(",
"request",
",",
"next_page",
",",
"True",
")",
"else",
":",
"service",
"=",
"_service_url",
"(",
"request",
",",
"next_page",
",",
"False",
")",
"if",
"ticket",
":",
"user",
"=",
"auth",
".",
"authenticate",
"(",
"ticket",
"=",
"ticket",
",",
"service",
"=",
"service",
")",
"if",
"user",
"is",
"not",
"None",
":",
"auth",
".",
"login",
"(",
"request",
",",
"user",
")",
"if",
"settings",
".",
"CAS_PROXY_CALLBACK",
":",
"proxy_callback",
"(",
"request",
")",
"return",
"HttpResponseRedirect",
"(",
"next_page",
")",
"elif",
"settings",
".",
"CAS_RETRY_LOGIN",
"or",
"required",
":",
"if",
"gateway",
":",
"return",
"HttpResponseRedirect",
"(",
"_login_url",
"(",
"service",
",",
"ticket",
",",
"True",
")",
")",
"else",
":",
"return",
"HttpResponseRedirect",
"(",
"_login_url",
"(",
"service",
",",
"ticket",
",",
"False",
")",
")",
"else",
":",
"logger",
".",
"warning",
"(",
"'User has a valid ticket but not a valid session'",
")",
"# Has ticket, not session",
"if",
"gateway",
":",
"# Gatewayed responses should nto redirect.",
"return",
"False",
"if",
"getattr",
"(",
"settings",
",",
"'CAS_CUSTOM_FORBIDDEN'",
")",
":",
"return",
"HttpResponseRedirect",
"(",
"reverse",
"(",
"settings",
".",
"CAS_CUSTOM_FORBIDDEN",
")",
"+",
"\"?\"",
"+",
"request",
".",
"META",
"[",
"'QUERY_STRING'",
"]",
")",
"else",
":",
"error",
"=",
"\"<h1>Forbidden</h1><p>Login failed.</p>\"",
"return",
"HttpResponseForbidden",
"(",
"error",
")",
"else",
":",
"if",
"gateway",
":",
"return",
"HttpResponseRedirect",
"(",
"_login_url",
"(",
"service",
",",
"ticket",
",",
"True",
")",
")",
"else",
":",
"return",
"HttpResponseRedirect",
"(",
"_login_url",
"(",
"service",
",",
"ticket",
",",
"False",
")",
")"
] | Forwards to CAS login URL or verifies CAS ticket
:param: request RequestObj
:param: next_page Next page to redirect after login
:param: required
:param: gateway Gatewayed response | [
"Forwards",
"to",
"CAS",
"login",
"URL",
"or",
"verifies",
"CAS",
"ticket"
] | train | https://github.com/kstateome/django-cas/blob/8a871093966f001b4dadf7d097ac326169f3c066/cas/views.py#L159-L222 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Forwards to CAS login URL or verifies CAS ticket
:param: request RequestObj
:param: next_page Next page to redirect after login
:param: required
:param: gateway Gatewayed response
### Response:
def login(request, next_page=None, required=False, gateway=False):
"""
Forwards to CAS login URL or verifies CAS ticket
:param: request RequestObj
:param: next_page Next page to redirect after login
:param: required
:param: gateway Gatewayed response
"""
if not next_page:
next_page = _redirect_url(request)
try:
# use callable for pre-django 2.0
is_authenticated = request.user.is_authenticated()
except TypeError:
is_authenticated = request.user.is_authenticated
if is_authenticated:
return HttpResponseRedirect(next_page)
ticket = request.GET.get('ticket')
if gateway:
service = _service_url(request, next_page, True)
else:
service = _service_url(request, next_page, False)
if ticket:
user = auth.authenticate(ticket=ticket, service=service)
if user is not None:
auth.login(request, user)
if settings.CAS_PROXY_CALLBACK:
proxy_callback(request)
return HttpResponseRedirect(next_page)
elif settings.CAS_RETRY_LOGIN or required:
if gateway:
return HttpResponseRedirect(_login_url(service, ticket, True))
else:
return HttpResponseRedirect(_login_url(service, ticket, False))
else:
logger.warning('User has a valid ticket but not a valid session')
# Has ticket, not session
if gateway:
# Gatewayed responses should nto redirect.
return False
if getattr(settings, 'CAS_CUSTOM_FORBIDDEN'):
return HttpResponseRedirect(reverse(settings.CAS_CUSTOM_FORBIDDEN) + "?" + request.META['QUERY_STRING'])
else:
error = "<h1>Forbidden</h1><p>Login failed.</p>"
return HttpResponseForbidden(error)
else:
if gateway:
return HttpResponseRedirect(_login_url(service, ticket, True))
else:
return HttpResponseRedirect(_login_url(service, ticket, False))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2520,
4102,
311,
42890,
5982,
5665,
477,
88956,
42890,
11989,
271,
262,
551,
913,
25,
1715,
6274,
5374,
198,
262,
551,
913,
25,
1828,
6257,
9479,
2199,
311,
6559,
1306,
5982,
198,
262,
551,
913,
25,
2631,
198,
262,
551,
913,
25,
29895,
40478,
291,
2077,
271,
14711,
6075,
512,
755,
5982,
4980,
11,
1828,
6257,
5980,
11,
2631,
5725,
11,
29895,
5725,
997,
262,
3270,
262,
1789,
4102,
311,
42890,
5982,
5665,
477,
88956,
42890,
11989,
271,
262,
551,
913,
25,
1715,
6274,
5374,
198,
262,
551,
913,
25,
1828,
6257,
9479,
2199,
311,
6559,
1306,
5982,
198,
262,
551,
913,
25,
2631,
198,
262,
551,
913,
25,
29895,
40478,
291,
2077,
271,
262,
12713,
262,
422,
539,
1828,
6257,
512,
286,
1828,
6257,
284,
721,
8280,
2975,
4980,
696,
262,
1456,
512,
286,
674,
1005,
42022,
369,
864,
1773,
5970,
220,
17,
13,
15,
198,
286,
374,
66013,
284,
1715,
3405,
2124,
66013,
746,
262,
3734,
26082,
512,
286,
374,
66013,
284,
1715,
3405,
2124,
66013,
271,
262,
422,
374,
66013,
512,
286,
471,
54130,
17342,
6257,
696,
262,
11989,
284,
1715,
17866,
673,
493,
27632,
4713,
262,
422,
29895,
512,
286,
2532,
284,
721,
8095,
2975,
4980,
11,
1828,
6257,
11,
3082,
340,
262,
775,
512,
286,
2532,
284,
721,
8095,
2975,
4980,
11,
1828,
6257,
11,
3641,
696,
262,
422,
11989,
512,
286,
1217,
284,
4259,
49898,
82539,
24957,
6021,
11,
2532,
28,
8095,
696,
286,
422,
1217,
374,
539,
2290,
1473,
310,
4259,
14011,
4980,
11,
1217,
696,
310,
422,
5110,
732,
1950,
60165,
36873,
512,
394,
13594,
12802,
4980,
696,
310,
471,
54130,
17342,
6257,
340,
286,
4508,
5110,
732,
1950,
79024,
39414,
477,
2631,
512,
310,
422,
29895,
512,
394,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3082,
1192,
310,
775,
512,
394,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3641,
1192,
286,
775,
512,
310,
6050,
29936,
493,
1502,
706,
264,
2764,
11989,
719,
539,
264,
2764,
3882,
1329,
310,
674,
11697,
11989,
11,
539,
3882,
271,
310,
422,
29895,
512,
394,
674,
40478,
291,
14847,
1288,
62918,
6559,
627,
394,
471,
3641,
271,
310,
422,
31097,
24258,
11,
364,
88616,
37414,
14856,
33,
39389,
11290,
394,
471,
54130,
48235,
24258,
732,
1950,
37414,
14856,
33,
39389,
8,
489,
83829,
489,
1715,
1345,
21352,
681,
42119,
12563,
7519,
310,
775,
512,
394,
1493,
284,
4145,
71,
16,
29,
70215,
524,
71,
16,
1822,
79,
87360,
4745,
4005,
79,
19681,
394,
471,
18040,
70215,
6524,
340,
262,
775,
512,
286,
422,
29895,
512,
310,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3082,
1192,
286,
775,
512,
310,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3641,
1192,
27,
91,
8862,
728,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2520,
4102,
311,
42890,
5982,
5665,
477,
88956,
42890,
11989,
271,
262,
551,
913,
25,
1715,
6274,
5374,
198,
262,
551,
913,
25,
1828,
6257,
9479,
2199,
311,
6559,
1306,
5982,
198,
262,
551,
913,
25,
2631,
198,
262,
551,
913,
25,
29895,
40478,
291,
2077,
271,
14711,
6075,
512,
755,
5982,
4980,
11,
1828,
6257,
5980,
11,
2631,
5725,
11,
29895,
5725,
997,
262,
3270,
262,
1789,
4102,
311,
42890,
5982,
5665,
477,
88956,
42890,
11989,
271,
262,
551,
913,
25,
1715,
6274,
5374,
198,
262,
551,
913,
25,
1828,
6257,
9479,
2199,
311,
6559,
1306,
5982,
198,
262,
551,
913,
25,
2631,
198,
262,
551,
913,
25,
29895,
40478,
291,
2077,
271,
262,
12713,
262,
422,
539,
1828,
6257,
512,
286,
1828,
6257,
284,
721,
8280,
2975,
4980,
696,
262,
1456,
512,
286,
674,
1005,
42022,
369,
864,
1773,
5970,
220,
17,
13,
15,
198,
286,
374,
66013,
284,
1715,
3405,
2124,
66013,
746,
262,
3734,
26082,
512,
286,
374,
66013,
284,
1715,
3405,
2124,
66013,
271,
262,
422,
374,
66013,
512,
286,
471,
54130,
17342,
6257,
696,
262,
11989,
284,
1715,
17866,
673,
493,
27632,
4713,
262,
422,
29895,
512,
286,
2532,
284,
721,
8095,
2975,
4980,
11,
1828,
6257,
11,
3082,
340,
262,
775,
512,
286,
2532,
284,
721,
8095,
2975,
4980,
11,
1828,
6257,
11,
3641,
696,
262,
422,
11989,
512,
286,
1217,
284,
4259,
49898,
82539,
24957,
6021,
11,
2532,
28,
8095,
696,
286,
422,
1217,
374,
539,
2290,
1473,
310,
4259,
14011,
4980,
11,
1217,
696,
310,
422,
5110,
732,
1950,
60165,
36873,
512,
394,
13594,
12802,
4980,
696,
310,
471,
54130,
17342,
6257,
340,
286,
4508,
5110,
732,
1950,
79024,
39414,
477,
2631,
512,
310,
422,
29895,
512,
394,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3082,
1192,
310,
775,
512,
394,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3641,
1192,
286,
775,
512,
310,
6050,
29936,
493,
1502,
706,
264,
2764,
11989,
719,
539,
264,
2764,
3882,
1329,
310,
674,
11697,
11989,
11,
539,
3882,
271,
310,
422,
29895,
512,
394,
674,
40478,
291,
14847,
1288,
62918,
6559,
627,
394,
471,
3641,
271,
310,
422,
31097,
24258,
11,
364,
88616,
37414,
14856,
33,
39389,
11290,
394,
471,
54130,
48235,
24258,
732,
1950,
37414,
14856,
33,
39389,
8,
489,
83829,
489,
1715,
1345,
21352,
681,
42119,
12563,
7519,
310,
775,
512,
394,
1493,
284,
4145,
71,
16,
29,
70215,
524,
71,
16,
1822,
79,
87360,
4745,
4005,
79,
19681,
394,
471,
18040,
70215,
6524,
340,
262,
775,
512,
286,
422,
29895,
512,
310,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3082,
1192,
286,
775,
512,
310,
471,
54130,
2551,
3758,
2975,
22392,
11,
11989,
11,
3641,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
smarie/python-parsyfiles | parsyfiles/parsing_combining_parsers.py | CascadingParser.add_parser_to_cascade | def add_parser_to_cascade(self, parser: AnyParser, typ: Type = None):
"""
Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
to the parser capabilities (single and multifile support, extensions).
Subsequent parsers will have to support the same capabilities at least, to be added.
:param parser:
:param typ:
:return:
"""
# the first parser added will configure the cascade
if not self.configured:
self.supported_exts = parser.supported_exts
self.supported_types = parser.supported_types
# check if new parser is compliant with previous ones
if self.supports_singlefile():
if not parser.supports_singlefile():
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (singlefile support)')
if self.supports_multifile():
if not parser.supports_multifile():
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (multifile support)')
if AnyObject not in parser.supported_types:
if typ is None:
# in that case the expected types for this parser will be self.supported_types
if AnyObject in self.supported_types:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (the cascade supports any type while the parser only supports '
+ str(parser.supported_types) + ')')
else:
missing_types = set(self.supported_types) - set(parser.supported_types)
if len(missing_types) > 0:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the '
'cascades configuration (supported types should at least contain the supported types '
'already in place. The parser misses type(s) ' + str(missing_types) + ')')
else:
# a parser is added but with a specific type target (parallel cascade)
if typ == AnyObject:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the expected type "Any", '
'it only supports ' + str(parser.supported_types))
# else:
# if get_base_generic_type(typ) not in parser.supported_types:
# raise ValueError(
# 'Cannot add this parser to this parsing cascade : it does not match the expected type ' +
# str(typ) + ', it only supports ' + str(parser.supported_types))
missing_exts = set(self.supported_exts) - set(parser.supported_exts)
if len(missing_exts) > 0:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (supported extensions should at least contain the supported extensions already in '
'place. The parser misses extension(s) ' + str(missing_exts) + ')')
# finally add it
self._parsers_list.append((typ, parser)) | python | def add_parser_to_cascade(self, parser: AnyParser, typ: Type = None):
"""
Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
to the parser capabilities (single and multifile support, extensions).
Subsequent parsers will have to support the same capabilities at least, to be added.
:param parser:
:param typ:
:return:
"""
# the first parser added will configure the cascade
if not self.configured:
self.supported_exts = parser.supported_exts
self.supported_types = parser.supported_types
# check if new parser is compliant with previous ones
if self.supports_singlefile():
if not parser.supports_singlefile():
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (singlefile support)')
if self.supports_multifile():
if not parser.supports_multifile():
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (multifile support)')
if AnyObject not in parser.supported_types:
if typ is None:
# in that case the expected types for this parser will be self.supported_types
if AnyObject in self.supported_types:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (the cascade supports any type while the parser only supports '
+ str(parser.supported_types) + ')')
else:
missing_types = set(self.supported_types) - set(parser.supported_types)
if len(missing_types) > 0:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the '
'cascades configuration (supported types should at least contain the supported types '
'already in place. The parser misses type(s) ' + str(missing_types) + ')')
else:
# a parser is added but with a specific type target (parallel cascade)
if typ == AnyObject:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the expected type "Any", '
'it only supports ' + str(parser.supported_types))
# else:
# if get_base_generic_type(typ) not in parser.supported_types:
# raise ValueError(
# 'Cannot add this parser to this parsing cascade : it does not match the expected type ' +
# str(typ) + ', it only supports ' + str(parser.supported_types))
missing_exts = set(self.supported_exts) - set(parser.supported_exts)
if len(missing_exts) > 0:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (supported extensions should at least contain the supported extensions already in '
'place. The parser misses extension(s) ' + str(missing_exts) + ')')
# finally add it
self._parsers_list.append((typ, parser)) | [
"def",
"add_parser_to_cascade",
"(",
"self",
",",
"parser",
":",
"AnyParser",
",",
"typ",
":",
"Type",
"=",
"None",
")",
":",
"# the first parser added will configure the cascade",
"if",
"not",
"self",
".",
"configured",
":",
"self",
".",
"supported_exts",
"=",
"parser",
".",
"supported_exts",
"self",
".",
"supported_types",
"=",
"parser",
".",
"supported_types",
"# check if new parser is compliant with previous ones",
"if",
"self",
".",
"supports_singlefile",
"(",
")",
":",
"if",
"not",
"parser",
".",
"supports_singlefile",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '",
"'configuration (singlefile support)'",
")",
"if",
"self",
".",
"supports_multifile",
"(",
")",
":",
"if",
"not",
"parser",
".",
"supports_multifile",
"(",
")",
":",
"raise",
"ValueError",
"(",
"'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '",
"'configuration (multifile support)'",
")",
"if",
"AnyObject",
"not",
"in",
"parser",
".",
"supported_types",
":",
"if",
"typ",
"is",
"None",
":",
"# in that case the expected types for this parser will be self.supported_types",
"if",
"AnyObject",
"in",
"self",
".",
"supported_types",
":",
"raise",
"ValueError",
"(",
"'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '",
"'configuration (the cascade supports any type while the parser only supports '",
"+",
"str",
"(",
"parser",
".",
"supported_types",
")",
"+",
"')'",
")",
"else",
":",
"missing_types",
"=",
"set",
"(",
"self",
".",
"supported_types",
")",
"-",
"set",
"(",
"parser",
".",
"supported_types",
")",
"if",
"len",
"(",
"missing_types",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"'Cannot add this parser to this parsing cascade : it does not match the rest of the '",
"'cascades configuration (supported types should at least contain the supported types '",
"'already in place. The parser misses type(s) '",
"+",
"str",
"(",
"missing_types",
")",
"+",
"')'",
")",
"else",
":",
"# a parser is added but with a specific type target (parallel cascade)",
"if",
"typ",
"==",
"AnyObject",
":",
"raise",
"ValueError",
"(",
"'Cannot add this parser to this parsing cascade : it does not match the expected type \"Any\", '",
"'it only supports '",
"+",
"str",
"(",
"parser",
".",
"supported_types",
")",
")",
"# else:",
"# if get_base_generic_type(typ) not in parser.supported_types:",
"# raise ValueError(",
"# 'Cannot add this parser to this parsing cascade : it does not match the expected type ' +",
"# str(typ) + ', it only supports ' + str(parser.supported_types))",
"missing_exts",
"=",
"set",
"(",
"self",
".",
"supported_exts",
")",
"-",
"set",
"(",
"parser",
".",
"supported_exts",
")",
"if",
"len",
"(",
"missing_exts",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '",
"'configuration (supported extensions should at least contain the supported extensions already in '",
"'place. The parser misses extension(s) '",
"+",
"str",
"(",
"missing_exts",
")",
"+",
"')'",
")",
"# finally add it",
"self",
".",
"_parsers_list",
".",
"append",
"(",
"(",
"typ",
",",
"parser",
")",
")"
] | Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
to the parser capabilities (single and multifile support, extensions).
Subsequent parsers will have to support the same capabilities at least, to be added.
:param parser:
:param typ:
:return: | [
"Adds",
"the",
"provided",
"parser",
"to",
"this",
"cascade",
".",
"If",
"this",
"is",
"the",
"first",
"parser",
"it",
"will",
"configure",
"the",
"cascade",
"according",
"to",
"the",
"parser",
"capabilities",
"(",
"single",
"and",
"multifile",
"support",
"extensions",
")",
".",
"Subsequent",
"parsers",
"will",
"have",
"to",
"support",
"the",
"same",
"capabilities",
"at",
"least",
"to",
"be",
"added",
"."
] | train | https://github.com/smarie/python-parsyfiles/blob/344b37e1151e8d4e7c2ee49ae09d6568715ae64e/parsyfiles/parsing_combining_parsers.py#L239-L302 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
to the parser capabilities (single and multifile support, extensions).
Subsequent parsers will have to support the same capabilities at least, to be added.
:param parser:
:param typ:
:return:
### Response:
def add_parser_to_cascade(self, parser: AnyParser, typ: Type = None):
"""
Adds the provided parser to this cascade. If this is the first parser, it will configure the cascade according
to the parser capabilities (single and multifile support, extensions).
Subsequent parsers will have to support the same capabilities at least, to be added.
:param parser:
:param typ:
:return:
"""
# the first parser added will configure the cascade
if not self.configured:
self.supported_exts = parser.supported_exts
self.supported_types = parser.supported_types
# check if new parser is compliant with previous ones
if self.supports_singlefile():
if not parser.supports_singlefile():
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (singlefile support)')
if self.supports_multifile():
if not parser.supports_multifile():
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (multifile support)')
if AnyObject not in parser.supported_types:
if typ is None:
# in that case the expected types for this parser will be self.supported_types
if AnyObject in self.supported_types:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (the cascade supports any type while the parser only supports '
+ str(parser.supported_types) + ')')
else:
missing_types = set(self.supported_types) - set(parser.supported_types)
if len(missing_types) > 0:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the '
'cascades configuration (supported types should at least contain the supported types '
'already in place. The parser misses type(s) ' + str(missing_types) + ')')
else:
# a parser is added but with a specific type target (parallel cascade)
if typ == AnyObject:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the expected type "Any", '
'it only supports ' + str(parser.supported_types))
# else:
# if get_base_generic_type(typ) not in parser.supported_types:
# raise ValueError(
# 'Cannot add this parser to this parsing cascade : it does not match the expected type ' +
# str(typ) + ', it only supports ' + str(parser.supported_types))
missing_exts = set(self.supported_exts) - set(parser.supported_exts)
if len(missing_exts) > 0:
raise ValueError(
'Cannot add this parser to this parsing cascade : it does not match the rest of the cascades '
'configuration (supported extensions should at least contain the supported extensions already in '
'place. The parser misses extension(s) ' + str(missing_exts) + ')')
# finally add it
self._parsers_list.append((typ, parser))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
73211,
279,
3984,
6871,
311,
420,
43118,
13,
1442,
420,
374,
279,
1176,
6871,
11,
433,
690,
14749,
279,
43118,
4184,
198,
286,
311,
279,
6871,
17357,
320,
15698,
323,
62387,
458,
1862,
11,
20300,
4390,
286,
3804,
72457,
88173,
690,
617,
311,
1862,
279,
1890,
17357,
520,
3325,
11,
311,
387,
3779,
382,
286,
551,
913,
6871,
512,
286,
551,
913,
3666,
512,
286,
551,
693,
1473,
14711,
6075,
512,
755,
923,
19024,
2401,
669,
20574,
1214,
11,
6871,
25,
5884,
6707,
11,
3666,
25,
4078,
284,
2290,
997,
286,
3270,
286,
25483,
279,
3984,
6871,
311,
420,
43118,
13,
1442,
420,
374,
279,
1176,
6871,
11,
433,
690,
14749,
279,
43118,
4184,
198,
286,
311,
279,
6871,
17357,
320,
15698,
323,
62387,
458,
1862,
11,
20300,
4390,
286,
3804,
72457,
88173,
690,
617,
311,
1862,
279,
1890,
17357,
520,
3325,
11,
311,
387,
3779,
382,
286,
551,
913,
6871,
512,
286,
551,
913,
3666,
512,
286,
551,
693,
512,
286,
3270,
286,
674,
279,
1176,
6871,
3779,
690,
14749,
279,
43118,
198,
286,
422,
539,
659,
5539,
3149,
512,
310,
659,
9582,
291,
10129,
82,
284,
6871,
9582,
291,
10129,
82,
198,
310,
659,
9582,
291,
9962,
284,
6871,
9582,
291,
9962,
271,
286,
674,
1817,
422,
502,
6871,
374,
49798,
449,
3766,
6305,
198,
286,
422,
659,
9582,
82,
20052,
1213,
4019,
310,
422,
539,
6871,
9582,
82,
20052,
1213,
4019,
394,
4933,
15764,
1021,
504,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279,
76057,
3536,
8044,
504,
364,
21822,
320,
15698,
1213,
1862,
8,
4713,
286,
422,
659,
9582,
82,
27386,
333,
458,
4019,
310,
422,
539,
6871,
9582,
82,
27386,
333,
458,
4019,
394,
4933,
15764,
1021,
504,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279,
76057,
3536,
8044,
504,
364,
21822,
320,
26961,
333,
458,
1862,
8,
4713,
286,
422,
42643,
539,
304,
6871,
9582,
291,
9962,
512,
310,
422,
3666,
374,
2290,
512,
394,
674,
304,
430,
1162,
279,
3685,
4595,
369,
420,
6871,
690,
387,
659,
9582,
291,
9962,
198,
394,
422,
42643,
304,
659,
9582,
291,
9962,
512,
504,
4933,
15764,
1021,
667,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279,
76057,
3536,
8044,
667,
364,
21822,
320,
1820,
43118,
11815,
904,
955,
1418,
279,
6871,
1193,
11815,
8044,
667,
489,
610,
36435,
9582,
291,
9962,
8,
489,
17081,
1329,
394,
775,
512,
504,
7554,
9962,
284,
743,
1214,
9582,
291,
9962,
8,
482,
743,
36435,
9582,
291,
9962,
340,
504,
422,
2479,
1278,
13889,
9962,
8,
871,
220,
15,
512,
667,
4933,
15764,
1021,
1014,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
73211,
279,
3984,
6871,
311,
420,
43118,
13,
1442,
420,
374,
279,
1176,
6871,
11,
433,
690,
14749,
279,
43118,
4184,
198,
286,
311,
279,
6871,
17357,
320,
15698,
323,
62387,
458,
1862,
11,
20300,
4390,
286,
3804,
72457,
88173,
690,
617,
311,
1862,
279,
1890,
17357,
520,
3325,
11,
311,
387,
3779,
382,
286,
551,
913,
6871,
512,
286,
551,
913,
3666,
512,
286,
551,
693,
1473,
14711,
6075,
512,
755,
923,
19024,
2401,
669,
20574,
1214,
11,
6871,
25,
5884,
6707,
11,
3666,
25,
4078,
284,
2290,
997,
286,
3270,
286,
25483,
279,
3984,
6871,
311,
420,
43118,
13,
1442,
420,
374,
279,
1176,
6871,
11,
433,
690,
14749,
279,
43118,
4184,
198,
286,
311,
279,
6871,
17357,
320,
15698,
323,
62387,
458,
1862,
11,
20300,
4390,
286,
3804,
72457,
88173,
690,
617,
311,
1862,
279,
1890,
17357,
520,
3325,
11,
311,
387,
3779,
382,
286,
551,
913,
6871,
512,
286,
551,
913,
3666,
512,
286,
551,
693,
512,
286,
3270,
286,
674,
279,
1176,
6871,
3779,
690,
14749,
279,
43118,
198,
286,
422,
539,
659,
5539,
3149,
512,
310,
659,
9582,
291,
10129,
82,
284,
6871,
9582,
291,
10129,
82,
198,
310,
659,
9582,
291,
9962,
284,
6871,
9582,
291,
9962,
271,
286,
674,
1817,
422,
502,
6871,
374,
49798,
449,
3766,
6305,
198,
286,
422,
659,
9582,
82,
20052,
1213,
4019,
310,
422,
539,
6871,
9582,
82,
20052,
1213,
4019,
394,
4933,
15764,
1021,
504,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279,
76057,
3536,
8044,
504,
364,
21822,
320,
15698,
1213,
1862,
8,
4713,
286,
422,
659,
9582,
82,
27386,
333,
458,
4019,
310,
422,
539,
6871,
9582,
82,
27386,
333,
458,
4019,
394,
4933,
15764,
1021,
504,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279,
76057,
3536,
8044,
504,
364,
21822,
320,
26961,
333,
458,
1862,
8,
4713,
286,
422,
42643,
539,
304,
6871,
9582,
291,
9962,
512,
310,
422,
3666,
374,
2290,
512,
394,
674,
304,
430,
1162,
279,
3685,
4595,
369,
420,
6871,
690,
387,
659,
9582,
291,
9962,
198,
394,
422,
42643,
304,
659,
9582,
291,
9962,
512,
504,
4933,
15764,
1021,
667,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279,
76057,
3536,
8044,
667,
364,
21822,
320,
1820,
43118,
11815,
904,
955,
1418,
279,
6871,
1193,
11815,
8044,
667,
489,
610,
36435,
9582,
291,
9962,
8,
489,
17081,
1329,
394,
775,
512,
504,
7554,
9962,
284,
743,
1214,
9582,
291,
9962,
8,
482,
743,
36435,
9582,
291,
9962,
340,
504,
422,
2479,
1278,
13889,
9962,
8,
871,
220,
15,
512,
667,
4933,
15764,
1021,
1014,
364,
17902,
923,
420,
6871,
311,
420,
23115,
43118,
551,
433,
1587,
539,
2489,
279,
2800,
315,
279
] |
acutesoftware/AIKIF | aikif/environments/happiness.py | Value.match_value_to_text | def match_value_to_text(self, text):
"""
this is going to be the tricky bit - probably not possible
to get the 'exact' rating for a value. Will need to do sentiment
analysis of the text to see how it matches the rating. Even that
sounds like it wont work - maybe a ML algorithm would do it, but
that requires a large body of text already matched to values - and
values aren't even defined as far as I have found.
UPDATE - this could work if we assume values can be single words,
eg tax=0.3, freedom=0.7, healthcare=0.3, welfare=0.3 etc
"""
if self.nme in text:
res = 0.8
else:
res = 0.2
return self.nme + ' = ' + str(res) + ' match against ' + text | python | def match_value_to_text(self, text):
"""
this is going to be the tricky bit - probably not possible
to get the 'exact' rating for a value. Will need to do sentiment
analysis of the text to see how it matches the rating. Even that
sounds like it wont work - maybe a ML algorithm would do it, but
that requires a large body of text already matched to values - and
values aren't even defined as far as I have found.
UPDATE - this could work if we assume values can be single words,
eg tax=0.3, freedom=0.7, healthcare=0.3, welfare=0.3 etc
"""
if self.nme in text:
res = 0.8
else:
res = 0.2
return self.nme + ' = ' + str(res) + ' match against ' + text | [
"def",
"match_value_to_text",
"(",
"self",
",",
"text",
")",
":",
"if",
"self",
".",
"nme",
"in",
"text",
":",
"res",
"=",
"0.8",
"else",
":",
"res",
"=",
"0.2",
"return",
"self",
".",
"nme",
"+",
"' = '",
"+",
"str",
"(",
"res",
")",
"+",
"' match against '",
"+",
"text"
] | this is going to be the tricky bit - probably not possible
to get the 'exact' rating for a value. Will need to do sentiment
analysis of the text to see how it matches the rating. Even that
sounds like it wont work - maybe a ML algorithm would do it, but
that requires a large body of text already matched to values - and
values aren't even defined as far as I have found.
UPDATE - this could work if we assume values can be single words,
eg tax=0.3, freedom=0.7, healthcare=0.3, welfare=0.3 etc | [
"this",
"is",
"going",
"to",
"be",
"the",
"tricky",
"bit",
"-",
"probably",
"not",
"possible",
"to",
"get",
"the",
"exact",
"rating",
"for",
"a",
"value",
".",
"Will",
"need",
"to",
"do",
"sentiment",
"analysis",
"of",
"the",
"text",
"to",
"see",
"how",
"it",
"matches",
"the",
"rating",
".",
"Even",
"that",
"sounds",
"like",
"it",
"wont",
"work",
"-",
"maybe",
"a",
"ML",
"algorithm",
"would",
"do",
"it",
"but",
"that",
"requires",
"a",
"large",
"body",
"of",
"text",
"already",
"matched",
"to",
"values",
"-",
"and",
"values",
"aren",
"t",
"even",
"defined",
"as",
"far",
"as",
"I",
"have",
"found",
"."
] | train | https://github.com/acutesoftware/AIKIF/blob/fcf1582dc5f884b9a4fa7c6e20e9de9d94d21d03/aikif/environments/happiness.py#L310-L329 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
this is going to be the tricky bit - probably not possible
to get the 'exact' rating for a value. Will need to do sentiment
analysis of the text to see how it matches the rating. Even that
sounds like it wont work - maybe a ML algorithm would do it, but
that requires a large body of text already matched to values - and
values aren't even defined as far as I have found.
UPDATE - this could work if we assume values can be single words,
eg tax=0.3, freedom=0.7, healthcare=0.3, welfare=0.3 etc
### Response:
def match_value_to_text(self, text):
"""
this is going to be the tricky bit - probably not possible
to get the 'exact' rating for a value. Will need to do sentiment
analysis of the text to see how it matches the rating. Even that
sounds like it wont work - maybe a ML algorithm would do it, but
that requires a large body of text already matched to values - and
values aren't even defined as far as I have found.
UPDATE - this could work if we assume values can be single words,
eg tax=0.3, freedom=0.7, healthcare=0.3, welfare=0.3 etc
"""
if self.nme in text:
res = 0.8
else:
res = 0.2
return self.nme + ' = ' + str(res) + ' match against ' + text
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
576,
374,
2133,
311,
387,
279,
34553,
2766,
482,
4762,
539,
3284,
198,
286,
311,
636,
279,
364,
47485,
6,
10959,
369,
264,
907,
13,
4946,
1205,
311,
656,
27065,
198,
286,
6492,
315,
279,
1495,
311,
1518,
1268,
433,
9248,
279,
10959,
13,
7570,
430,
198,
286,
10578,
1093,
433,
40464,
990,
482,
7344,
264,
20187,
12384,
1053,
656,
433,
11,
719,
198,
286,
430,
7612,
264,
3544,
2547,
315,
1495,
2736,
18545,
311,
2819,
482,
323,
198,
286,
2819,
7784,
956,
1524,
4613,
439,
3117,
439,
358,
617,
1766,
382,
286,
23743,
482,
420,
1436,
990,
422,
584,
9855,
2819,
649,
387,
3254,
4339,
345,
286,
8866,
3827,
28,
15,
13,
18,
11,
11542,
28,
15,
13,
22,
11,
18985,
28,
15,
13,
18,
11,
23460,
28,
15,
13,
18,
5099,
271,
14711,
6075,
512,
755,
2489,
3220,
2401,
4424,
1214,
11,
1495,
997,
286,
3270,
286,
420,
374,
2133,
311,
387,
279,
34553,
2766,
482,
4762,
539,
3284,
198,
286,
311,
636,
279,
364,
47485,
6,
10959,
369,
264,
907,
13,
4946,
1205,
311,
656,
27065,
198,
286,
6492,
315,
279,
1495,
311,
1518,
1268,
433,
9248,
279,
10959,
13,
7570,
430,
198,
286,
10578,
1093,
433,
40464,
990,
482,
7344,
264,
20187,
12384,
1053,
656,
433,
11,
719,
198,
286,
430,
7612,
264,
3544,
2547,
315,
1495,
2736,
18545,
311,
2819,
482,
323,
198,
286,
2819,
7784,
956,
1524,
4613,
439,
3117,
439,
358,
617,
1766,
382,
286,
23743,
482,
420,
1436,
990,
422,
584,
9855,
2819,
649,
387,
3254,
4339,
345,
286,
8866,
3827,
28,
15,
13,
18,
11,
11542,
28,
15,
13,
22,
11,
18985,
28,
15,
13,
18,
11,
23460,
28,
15,
13,
18,
5099,
198,
286,
12713,
286,
422,
659,
1276,
2727,
304,
1495,
1473,
310,
594,
284,
220,
15,
13,
23,
198,
286,
775,
512,
310,
594,
284,
220,
15,
13,
17,
271,
286,
471,
659,
1276,
2727,
489,
364,
284,
364,
489,
610,
4693,
8,
489,
364,
2489,
2403,
364,
489,
1495,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
576,
374,
2133,
311,
387,
279,
34553,
2766,
482,
4762,
539,
3284,
198,
286,
311,
636,
279,
364,
47485,
6,
10959,
369,
264,
907,
13,
4946,
1205,
311,
656,
27065,
198,
286,
6492,
315,
279,
1495,
311,
1518,
1268,
433,
9248,
279,
10959,
13,
7570,
430,
198,
286,
10578,
1093,
433,
40464,
990,
482,
7344,
264,
20187,
12384,
1053,
656,
433,
11,
719,
198,
286,
430,
7612,
264,
3544,
2547,
315,
1495,
2736,
18545,
311,
2819,
482,
323,
198,
286,
2819,
7784,
956,
1524,
4613,
439,
3117,
439,
358,
617,
1766,
382,
286,
23743,
482,
420,
1436,
990,
422,
584,
9855,
2819,
649,
387,
3254,
4339,
345,
286,
8866,
3827,
28,
15,
13,
18,
11,
11542,
28,
15,
13,
22,
11,
18985,
28,
15,
13,
18,
11,
23460,
28,
15,
13,
18,
5099,
271,
14711,
6075,
512,
755,
2489,
3220,
2401,
4424,
1214,
11,
1495,
997,
286,
3270,
286,
420,
374,
2133,
311,
387,
279,
34553,
2766,
482,
4762,
539,
3284,
198,
286,
311,
636,
279,
364,
47485,
6,
10959,
369,
264,
907,
13,
4946,
1205,
311,
656,
27065,
198,
286,
6492,
315,
279,
1495,
311,
1518,
1268,
433,
9248,
279,
10959,
13,
7570,
430,
198,
286,
10578,
1093,
433,
40464,
990,
482,
7344,
264,
20187,
12384,
1053,
656,
433,
11,
719,
198,
286,
430,
7612,
264,
3544,
2547,
315,
1495,
2736,
18545,
311,
2819,
482,
323,
198,
286,
2819,
7784,
956,
1524,
4613,
439,
3117,
439,
358,
617,
1766,
382,
286,
23743,
482,
420,
1436,
990,
422,
584,
9855,
2819,
649,
387,
3254,
4339,
345,
286,
8866,
3827,
28,
15,
13,
18,
11,
11542,
28,
15,
13,
22,
11,
18985,
28,
15,
13,
18,
11,
23460,
28,
15,
13,
18,
5099,
198,
286,
12713,
286,
422,
659,
1276,
2727,
304,
1495,
1473,
310,
594,
284,
220,
15,
13,
23,
198,
286,
775,
512,
310,
594,
284,
220,
15,
13,
17,
271,
286,
471,
659,
1276,
2727,
489,
364,
284,
364,
489,
610,
4693,
8,
489,
364,
2489,
2403,
364,
489,
1495,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
iotile/coretools | iotilegateway/iotilegateway/supervisor/service_manager.py | ServiceManager.service_status | def service_status(self, short_name):
"""Get the current status of a service.
Returns information about the service such as the length since the last
heartbeat, any status messages that have been posted about the service
and whether the heartbeat should be considered out of the ordinary.
Args:
short_name (string): The short name of the service to query
Returns:
dict: A dictionary with the status of the service
"""
if short_name not in self.services:
raise ArgumentError("Unknown service name", short_name=short_name)
info = {}
service = self.services[short_name]['state']
info['heartbeat_age'] = monotonic() - service.last_heartbeat
info['numeric_status'] = service.state
info['string_status'] = service.string_state
return info | python | def service_status(self, short_name):
"""Get the current status of a service.
Returns information about the service such as the length since the last
heartbeat, any status messages that have been posted about the service
and whether the heartbeat should be considered out of the ordinary.
Args:
short_name (string): The short name of the service to query
Returns:
dict: A dictionary with the status of the service
"""
if short_name not in self.services:
raise ArgumentError("Unknown service name", short_name=short_name)
info = {}
service = self.services[short_name]['state']
info['heartbeat_age'] = monotonic() - service.last_heartbeat
info['numeric_status'] = service.state
info['string_status'] = service.string_state
return info | [
"def",
"service_status",
"(",
"self",
",",
"short_name",
")",
":",
"if",
"short_name",
"not",
"in",
"self",
".",
"services",
":",
"raise",
"ArgumentError",
"(",
"\"Unknown service name\"",
",",
"short_name",
"=",
"short_name",
")",
"info",
"=",
"{",
"}",
"service",
"=",
"self",
".",
"services",
"[",
"short_name",
"]",
"[",
"'state'",
"]",
"info",
"[",
"'heartbeat_age'",
"]",
"=",
"monotonic",
"(",
")",
"-",
"service",
".",
"last_heartbeat",
"info",
"[",
"'numeric_status'",
"]",
"=",
"service",
".",
"state",
"info",
"[",
"'string_status'",
"]",
"=",
"service",
".",
"string_state",
"return",
"info"
] | Get the current status of a service.
Returns information about the service such as the length since the last
heartbeat, any status messages that have been posted about the service
and whether the heartbeat should be considered out of the ordinary.
Args:
short_name (string): The short name of the service to query
Returns:
dict: A dictionary with the status of the service | [
"Get",
"the",
"current",
"status",
"of",
"a",
"service",
"."
] | train | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilegateway/iotilegateway/supervisor/service_manager.py#L187-L212 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Get the current status of a service.
Returns information about the service such as the length since the last
heartbeat, any status messages that have been posted about the service
and whether the heartbeat should be considered out of the ordinary.
Args:
short_name (string): The short name of the service to query
Returns:
dict: A dictionary with the status of the service
### Response:
def service_status(self, short_name):
"""Get the current status of a service.
Returns information about the service such as the length since the last
heartbeat, any status messages that have been posted about the service
and whether the heartbeat should be considered out of the ordinary.
Args:
short_name (string): The short name of the service to query
Returns:
dict: A dictionary with the status of the service
"""
if short_name not in self.services:
raise ArgumentError("Unknown service name", short_name=short_name)
info = {}
service = self.services[short_name]['state']
info['heartbeat_age'] = monotonic() - service.last_heartbeat
info['numeric_status'] = service.state
info['string_status'] = service.string_state
return info
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
279,
1510,
2704,
315,
264,
2532,
382,
286,
5295,
2038,
922,
279,
2532,
1778,
439,
279,
3160,
2533,
279,
1566,
198,
286,
53205,
11,
904,
2704,
6743,
430,
617,
1027,
8621,
922,
279,
2532,
198,
286,
323,
3508,
279,
53205,
1288,
387,
6646,
704,
315,
279,
19664,
382,
286,
18161,
512,
310,
2875,
1292,
320,
928,
1680,
578,
2875,
836,
315,
279,
2532,
311,
3319,
271,
286,
5295,
512,
310,
6587,
25,
362,
11240,
449,
279,
2704,
315,
279,
2532,
271,
14711,
6075,
512,
755,
2532,
4878,
1214,
11,
2875,
1292,
997,
286,
4304,
1991,
279,
1510,
2704,
315,
264,
2532,
382,
286,
5295,
2038,
922,
279,
2532,
1778,
439,
279,
3160,
2533,
279,
1566,
198,
286,
53205,
11,
904,
2704,
6743,
430,
617,
1027,
8621,
922,
279,
2532,
198,
286,
323,
3508,
279,
53205,
1288,
387,
6646,
704,
315,
279,
19664,
382,
286,
18161,
512,
310,
2875,
1292,
320,
928,
1680,
578,
2875,
836,
315,
279,
2532,
311,
3319,
271,
286,
5295,
512,
310,
6587,
25,
362,
11240,
449,
279,
2704,
315,
279,
2532,
198,
286,
12713,
286,
422,
2875,
1292,
539,
304,
659,
20828,
512,
310,
4933,
77984,
446,
14109,
2532,
836,
498,
2875,
1292,
28,
8846,
1292,
696,
286,
3630,
284,
10294,
286,
2532,
284,
659,
20828,
58,
8846,
1292,
5465,
2513,
16049,
286,
3630,
681,
73571,
33153,
663,
284,
78316,
14338,
368,
482,
2532,
9288,
62,
73571,
198,
286,
3630,
681,
20173,
4878,
663,
284,
2532,
3551,
198,
286,
3630,
681,
928,
4878,
663,
284,
2532,
4909,
4486,
271,
286,
471,
3630,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
279,
1510,
2704,
315,
264,
2532,
382,
286,
5295,
2038,
922,
279,
2532,
1778,
439,
279,
3160,
2533,
279,
1566,
198,
286,
53205,
11,
904,
2704,
6743,
430,
617,
1027,
8621,
922,
279,
2532,
198,
286,
323,
3508,
279,
53205,
1288,
387,
6646,
704,
315,
279,
19664,
382,
286,
18161,
512,
310,
2875,
1292,
320,
928,
1680,
578,
2875,
836,
315,
279,
2532,
311,
3319,
271,
286,
5295,
512,
310,
6587,
25,
362,
11240,
449,
279,
2704,
315,
279,
2532,
271,
14711,
6075,
512,
755,
2532,
4878,
1214,
11,
2875,
1292,
997,
286,
4304,
1991,
279,
1510,
2704,
315,
264,
2532,
382,
286,
5295,
2038,
922,
279,
2532,
1778,
439,
279,
3160,
2533,
279,
1566,
198,
286,
53205,
11,
904,
2704,
6743,
430,
617,
1027,
8621,
922,
279,
2532,
198,
286,
323,
3508,
279,
53205,
1288,
387,
6646,
704,
315,
279,
19664,
382,
286,
18161,
512,
310,
2875,
1292,
320,
928,
1680,
578,
2875,
836,
315,
279,
2532,
311,
3319,
271,
286,
5295,
512,
310,
6587,
25,
362,
11240,
449,
279,
2704,
315,
279,
2532,
198,
286,
12713,
286,
422,
2875,
1292,
539,
304,
659,
20828,
512,
310,
4933,
77984,
446,
14109,
2532,
836,
498,
2875,
1292,
28,
8846,
1292,
696,
286,
3630,
284,
10294,
286,
2532,
284,
659,
20828,
58,
8846,
1292,
5465,
2513,
16049,
286,
3630,
681,
73571,
33153,
663,
284,
78316,
14338,
368,
482,
2532,
9288,
62,
73571,
198,
286,
3630,
681,
20173,
4878,
663,
284,
2532,
3551,
198,
286,
3630,
681,
928,
4878,
663,
284,
2532,
4909,
4486,
271,
286,
471,
3630,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
SpriteLink/NIPAP | nipap/nipap/authlib.py | SqliteAuth._create_database | def _create_database(self):
""" Set up database
Creates tables required for the authentication module.
"""
self._logger.info('creating user database')
sql = '''CREATE TABLE IF NOT EXISTS user (
username NOT NULL PRIMARY KEY,
pwd_salt NOT NULL,
pwd_hash NOT NULL,
full_name,
trusted NOT NULL DEFAULT 0,
readonly NOT NULL DEFAULT 0
)'''
self._db_curs.execute(sql)
self._db_conn.commit() | python | def _create_database(self):
""" Set up database
Creates tables required for the authentication module.
"""
self._logger.info('creating user database')
sql = '''CREATE TABLE IF NOT EXISTS user (
username NOT NULL PRIMARY KEY,
pwd_salt NOT NULL,
pwd_hash NOT NULL,
full_name,
trusted NOT NULL DEFAULT 0,
readonly NOT NULL DEFAULT 0
)'''
self._db_curs.execute(sql)
self._db_conn.commit() | [
"def",
"_create_database",
"(",
"self",
")",
":",
"self",
".",
"_logger",
".",
"info",
"(",
"'creating user database'",
")",
"sql",
"=",
"'''CREATE TABLE IF NOT EXISTS user (\n username NOT NULL PRIMARY KEY,\n pwd_salt NOT NULL,\n pwd_hash NOT NULL,\n full_name,\n trusted NOT NULL DEFAULT 0,\n readonly NOT NULL DEFAULT 0\n )'''",
"self",
".",
"_db_curs",
".",
"execute",
"(",
"sql",
")",
"self",
".",
"_db_conn",
".",
"commit",
"(",
")"
] | Set up database
Creates tables required for the authentication module. | [
"Set",
"up",
"database"
] | train | https://github.com/SpriteLink/NIPAP/blob/f96069f11ab952d80b13cab06e0528f2d24b3de9/nipap/nipap/authlib.py#L509-L525 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Set up database
Creates tables required for the authentication module.
### Response:
def _create_database(self):
""" Set up database
Creates tables required for the authentication module.
"""
self._logger.info('creating user database')
sql = '''CREATE TABLE IF NOT EXISTS user (
username NOT NULL PRIMARY KEY,
pwd_salt NOT NULL,
pwd_hash NOT NULL,
full_name,
trusted NOT NULL DEFAULT 0,
readonly NOT NULL DEFAULT 0
)'''
self._db_curs.execute(sql)
self._db_conn.commit()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
709,
4729,
271,
310,
15026,
12920,
2631,
369,
279,
17066,
4793,
382,
14711,
6075,
512,
755,
721,
3261,
28441,
1214,
997,
286,
4304,
2638,
709,
4729,
271,
310,
15026,
12920,
2631,
369,
279,
17066,
4793,
627,
286,
12713,
286,
659,
1462,
9985,
5506,
493,
46002,
1217,
4729,
1329,
286,
5822,
284,
11712,
23421,
14700,
11812,
4276,
35939,
1217,
2456,
310,
6059,
4276,
1808,
38567,
12282,
345,
310,
33806,
93380,
4276,
1808,
345,
310,
33806,
9127,
4276,
1808,
345,
310,
2539,
1292,
345,
310,
22542,
4276,
1808,
12221,
220,
15,
345,
310,
5881,
4276,
1808,
12221,
220,
15,
198,
286,
883,
15029,
286,
659,
1462,
2042,
669,
1759,
7925,
13449,
340,
286,
659,
1462,
2042,
17686,
16105,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
709,
4729,
271,
310,
15026,
12920,
2631,
369,
279,
17066,
4793,
382,
14711,
6075,
512,
755,
721,
3261,
28441,
1214,
997,
286,
4304,
2638,
709,
4729,
271,
310,
15026,
12920,
2631,
369,
279,
17066,
4793,
627,
286,
12713,
286,
659,
1462,
9985,
5506,
493,
46002,
1217,
4729,
1329,
286,
5822,
284,
11712,
23421,
14700,
11812,
4276,
35939,
1217,
2456,
310,
6059,
4276,
1808,
38567,
12282,
345,
310,
33806,
93380,
4276,
1808,
345,
310,
33806,
9127,
4276,
1808,
345,
310,
2539,
1292,
345,
310,
22542,
4276,
1808,
12221,
220,
15,
345,
310,
5881,
4276,
1808,
12221,
220,
15,
198,
286,
883,
15029,
286,
659,
1462,
2042,
669,
1759,
7925,
13449,
340,
286,
659,
1462,
2042,
17686,
16105,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
frictionlessdata/tableschema-pandas-py | tableschema_pandas/mapper.py | Mapper.convert_type | def convert_type(self, type):
"""Convert type to Pandas
"""
# Mapping
mapping = {
'any': np.dtype('O'),
'array': np.dtype(list),
'boolean': np.dtype(bool),
'date': np.dtype('O'),
'datetime': np.dtype('datetime64[ns]'),
'duration': np.dtype('O'),
'geojson': np.dtype('O'),
'geopoint': np.dtype('O'),
'integer': np.dtype(int),
'number': np.dtype(float),
'object': np.dtype(dict),
'string': np.dtype('O'),
'time': np.dtype('O'),
'year': np.dtype(int),
'yearmonth': np.dtype('O'),
}
# Get type
if type not in mapping:
message = 'Type "%s" is not supported' % type
raise tableschema.exceptions.StorageError(message)
return mapping[type] | python | def convert_type(self, type):
"""Convert type to Pandas
"""
# Mapping
mapping = {
'any': np.dtype('O'),
'array': np.dtype(list),
'boolean': np.dtype(bool),
'date': np.dtype('O'),
'datetime': np.dtype('datetime64[ns]'),
'duration': np.dtype('O'),
'geojson': np.dtype('O'),
'geopoint': np.dtype('O'),
'integer': np.dtype(int),
'number': np.dtype(float),
'object': np.dtype(dict),
'string': np.dtype('O'),
'time': np.dtype('O'),
'year': np.dtype(int),
'yearmonth': np.dtype('O'),
}
# Get type
if type not in mapping:
message = 'Type "%s" is not supported' % type
raise tableschema.exceptions.StorageError(message)
return mapping[type] | [
"def",
"convert_type",
"(",
"self",
",",
"type",
")",
":",
"# Mapping",
"mapping",
"=",
"{",
"'any'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"'array'",
":",
"np",
".",
"dtype",
"(",
"list",
")",
",",
"'boolean'",
":",
"np",
".",
"dtype",
"(",
"bool",
")",
",",
"'date'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"'datetime'",
":",
"np",
".",
"dtype",
"(",
"'datetime64[ns]'",
")",
",",
"'duration'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"'geojson'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"'geopoint'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"'integer'",
":",
"np",
".",
"dtype",
"(",
"int",
")",
",",
"'number'",
":",
"np",
".",
"dtype",
"(",
"float",
")",
",",
"'object'",
":",
"np",
".",
"dtype",
"(",
"dict",
")",
",",
"'string'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"'time'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"'year'",
":",
"np",
".",
"dtype",
"(",
"int",
")",
",",
"'yearmonth'",
":",
"np",
".",
"dtype",
"(",
"'O'",
")",
",",
"}",
"# Get type",
"if",
"type",
"not",
"in",
"mapping",
":",
"message",
"=",
"'Type \"%s\" is not supported'",
"%",
"type",
"raise",
"tableschema",
".",
"exceptions",
".",
"StorageError",
"(",
"message",
")",
"return",
"mapping",
"[",
"type",
"]"
] | Convert type to Pandas | [
"Convert",
"type",
"to",
"Pandas"
] | train | https://github.com/frictionlessdata/tableschema-pandas-py/blob/ef941dbc12f5d346e9612f8fec1b4b356b8493ca/tableschema_pandas/mapper.py#L89-L117 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Convert type to Pandas
### Response:
def convert_type(self, type):
"""Convert type to Pandas
"""
# Mapping
mapping = {
'any': np.dtype('O'),
'array': np.dtype(list),
'boolean': np.dtype(bool),
'date': np.dtype('O'),
'datetime': np.dtype('datetime64[ns]'),
'duration': np.dtype('O'),
'geojson': np.dtype('O'),
'geopoint': np.dtype('O'),
'integer': np.dtype(int),
'number': np.dtype(float),
'object': np.dtype(dict),
'string': np.dtype('O'),
'time': np.dtype('O'),
'year': np.dtype(int),
'yearmonth': np.dtype('O'),
}
# Get type
if type not in mapping:
message = 'Type "%s" is not supported' % type
raise tableschema.exceptions.StorageError(message)
return mapping[type]
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12281,
955,
311,
34606,
300,
271,
14711,
6075,
512,
755,
5625,
1857,
1214,
11,
955,
997,
286,
4304,
12281,
955,
311,
34606,
300,
198,
286,
12713,
286,
674,
39546,
198,
286,
13021,
284,
341,
310,
364,
3852,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
1686,
1232,
2660,
46855,
7455,
1350,
310,
364,
6245,
1232,
2660,
46855,
9963,
1350,
310,
364,
1045,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
15814,
1232,
2660,
46855,
493,
15814,
1227,
58,
4511,
60,
3379,
310,
364,
17456,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
13351,
2285,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
713,
454,
787,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
11924,
1232,
2660,
46855,
1577,
1350,
310,
364,
4174,
1232,
2660,
46855,
8432,
1350,
310,
364,
1735,
1232,
2660,
46855,
32378,
1350,
310,
364,
928,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
1712,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
3236,
1232,
2660,
46855,
1577,
1350,
310,
364,
3236,
10460,
1232,
2660,
46855,
493,
46,
3379,
286,
557,
286,
674,
2175,
955,
198,
286,
422,
955,
539,
304,
13021,
512,
310,
1984,
284,
364,
941,
6090,
82,
1,
374,
539,
7396,
6,
1034,
955,
198,
310,
4933,
12920,
3499,
26744,
44871,
1480,
7483,
696,
286,
471,
13021,
22283,
933,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
12281,
955,
311,
34606,
300,
271,
14711,
6075,
512,
755,
5625,
1857,
1214,
11,
955,
997,
286,
4304,
12281,
955,
311,
34606,
300,
198,
286,
12713,
286,
674,
39546,
198,
286,
13021,
284,
341,
310,
364,
3852,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
1686,
1232,
2660,
46855,
7455,
1350,
310,
364,
6245,
1232,
2660,
46855,
9963,
1350,
310,
364,
1045,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
15814,
1232,
2660,
46855,
493,
15814,
1227,
58,
4511,
60,
3379,
310,
364,
17456,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
13351,
2285,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
713,
454,
787,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
11924,
1232,
2660,
46855,
1577,
1350,
310,
364,
4174,
1232,
2660,
46855,
8432,
1350,
310,
364,
1735,
1232,
2660,
46855,
32378,
1350,
310,
364,
928,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
1712,
1232,
2660,
46855,
493,
46,
3379,
310,
364,
3236,
1232,
2660,
46855,
1577,
1350,
310,
364,
3236,
10460,
1232,
2660,
46855,
493,
46,
3379,
286,
557,
286,
674,
2175,
955,
198,
286,
422,
955,
539,
304,
13021,
512,
310,
1984,
284,
364,
941,
6090,
82,
1,
374,
539,
7396,
6,
1034,
955,
198,
310,
4933,
12920,
3499,
26744,
44871,
1480,
7483,
696,
286,
471,
13021,
22283,
933,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
iotile/coretools | iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Util.py | RenameFunction | def RenameFunction(function, name):
"""
Returns a function identical to the specified function, but with
the specified name.
"""
return FunctionType(function.__code__,
function.__globals__,
name,
function.__defaults__) | python | def RenameFunction(function, name):
"""
Returns a function identical to the specified function, but with
the specified name.
"""
return FunctionType(function.__code__,
function.__globals__,
name,
function.__defaults__) | [
"def",
"RenameFunction",
"(",
"function",
",",
"name",
")",
":",
"return",
"FunctionType",
"(",
"function",
".",
"__code__",
",",
"function",
".",
"__globals__",
",",
"name",
",",
"function",
".",
"__defaults__",
")"
] | Returns a function identical to the specified function, but with
the specified name. | [
"Returns",
"a",
"function",
"identical",
"to",
"the",
"specified",
"function",
"but",
"with",
"the",
"specified",
"name",
"."
] | train | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Util.py#L1488-L1496 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Returns a function identical to the specified function, but with
the specified name.
### Response:
def RenameFunction(function, name):
"""
Returns a function identical to the specified function, but with
the specified name.
"""
return FunctionType(function.__code__,
function.__globals__,
name,
function.__defaults__)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
264,
734,
20086,
311,
279,
5300,
734,
11,
719,
449,
198,
262,
279,
5300,
836,
382,
14711,
6075,
512,
755,
64808,
5263,
2993,
11,
836,
997,
262,
3270,
262,
5295,
264,
734,
20086,
311,
279,
5300,
734,
11,
719,
449,
198,
262,
279,
5300,
836,
627,
262,
3270,
262,
471,
5830,
941,
2993,
4952,
1889,
49666,
667,
734,
4952,
54267,
49666,
667,
836,
345,
667,
734,
4952,
27854,
24010,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
264,
734,
20086,
311,
279,
5300,
734,
11,
719,
449,
198,
262,
279,
5300,
836,
382,
14711,
6075,
512,
755,
64808,
5263,
2993,
11,
836,
997,
262,
3270,
262,
5295,
264,
734,
20086,
311,
279,
5300,
734,
11,
719,
449,
198,
262,
279,
5300,
836,
627,
262,
3270,
262,
471,
5830,
941,
2993,
4952,
1889,
49666,
667,
734,
4952,
54267,
49666,
667,
836,
345,
667,
734,
4952,
27854,
24010,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Gorialis/jishaku | jishaku/shell.py | ShellReader.clean_bytes | def clean_bytes(line):
"""
Cleans a byte sequence of shell directives and decodes it.
"""
text = line.decode('utf-8').replace('\r', '').strip('\n')
return re.sub(r'\x1b[^m]*m', '', text).replace("``", "`\u200b`").strip('\n') | python | def clean_bytes(line):
"""
Cleans a byte sequence of shell directives and decodes it.
"""
text = line.decode('utf-8').replace('\r', '').strip('\n')
return re.sub(r'\x1b[^m]*m', '', text).replace("``", "`\u200b`").strip('\n') | [
"def",
"clean_bytes",
"(",
"line",
")",
":",
"text",
"=",
"line",
".",
"decode",
"(",
"'utf-8'",
")",
".",
"replace",
"(",
"'\\r'",
",",
"''",
")",
".",
"strip",
"(",
"'\\n'",
")",
"return",
"re",
".",
"sub",
"(",
"r'\\x1b[^m]*m'",
",",
"''",
",",
"text",
")",
".",
"replace",
"(",
"\"``\"",
",",
"\"`\\u200b`\"",
")",
".",
"strip",
"(",
"'\\n'",
")"
] | Cleans a byte sequence of shell directives and decodes it. | [
"Cleans",
"a",
"byte",
"sequence",
"of",
"shell",
"directives",
"and",
"decodes",
"it",
"."
] | train | https://github.com/Gorialis/jishaku/blob/fc7c479b9d510ede189a929c8aa6f7c8ef7f9a6e/jishaku/shell.py#L91-L97 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Cleans a byte sequence of shell directives and decodes it.
### Response:
def clean_bytes(line):
"""
Cleans a byte sequence of shell directives and decodes it.
"""
text = line.decode('utf-8').replace('\r', '').strip('\n')
return re.sub(r'\x1b[^m]*m', '', text).replace("``", "`\u200b`").strip('\n')
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
34,
22451,
264,
5027,
8668,
315,
12811,
50353,
323,
1654,
2601,
433,
382,
14711,
6075,
512,
755,
4335,
12807,
8973,
997,
286,
3270,
286,
86762,
264,
5027,
8668,
315,
12811,
50353,
323,
1654,
2601,
433,
627,
286,
12713,
286,
1495,
284,
1584,
16301,
493,
4867,
12,
23,
1861,
8319,
11270,
81,
518,
41791,
13406,
11270,
77,
1329,
286,
471,
312,
4407,
2666,
16154,
87,
16,
65,
39913,
76,
8632,
76,
518,
9158,
1495,
570,
8319,
446,
14196,
498,
37073,
59,
84,
1049,
65,
63,
1865,
13406,
11270,
77,
1329,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
34,
22451,
264,
5027,
8668,
315,
12811,
50353,
323,
1654,
2601,
433,
382,
14711,
6075,
512,
755,
4335,
12807,
8973,
997,
286,
3270,
286,
86762,
264,
5027,
8668,
315,
12811,
50353,
323,
1654,
2601,
433,
627,
286,
12713,
286,
1495,
284,
1584,
16301,
493,
4867,
12,
23,
1861,
8319,
11270,
81,
518,
41791,
13406,
11270,
77,
1329,
286,
471,
312,
4407,
2666,
16154,
87,
16,
65,
39913,
76,
8632,
76,
518,
9158,
1495,
570,
8319,
446,
14196,
498,
37073,
59,
84,
1049,
65,
63,
1865,
13406,
11270,
77,
1329,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
glue-viz/glue-vispy-viewers | glue_vispy_viewers/extern/vispy/gloo/wrappers.py | BaseGlooFunctions.set_blend_equation | def set_blend_equation(self, mode_rgb, mode_alpha=None):
"""Specify the equation for RGB and alpha blending
Parameters
----------
mode_rgb : str
Mode for RGB.
mode_alpha : str | None
Mode for Alpha. If None, ``mode_rgb`` is used.
Notes
-----
See ``set_blend_equation`` for valid modes.
"""
mode_alpha = mode_rgb if mode_alpha is None else mode_alpha
self.glir.command('FUNC', 'glBlendEquationSeparate',
mode_rgb, mode_alpha) | python | def set_blend_equation(self, mode_rgb, mode_alpha=None):
"""Specify the equation for RGB and alpha blending
Parameters
----------
mode_rgb : str
Mode for RGB.
mode_alpha : str | None
Mode for Alpha. If None, ``mode_rgb`` is used.
Notes
-----
See ``set_blend_equation`` for valid modes.
"""
mode_alpha = mode_rgb if mode_alpha is None else mode_alpha
self.glir.command('FUNC', 'glBlendEquationSeparate',
mode_rgb, mode_alpha) | [
"def",
"set_blend_equation",
"(",
"self",
",",
"mode_rgb",
",",
"mode_alpha",
"=",
"None",
")",
":",
"mode_alpha",
"=",
"mode_rgb",
"if",
"mode_alpha",
"is",
"None",
"else",
"mode_alpha",
"self",
".",
"glir",
".",
"command",
"(",
"'FUNC'",
",",
"'glBlendEquationSeparate'",
",",
"mode_rgb",
",",
"mode_alpha",
")"
] | Specify the equation for RGB and alpha blending
Parameters
----------
mode_rgb : str
Mode for RGB.
mode_alpha : str | None
Mode for Alpha. If None, ``mode_rgb`` is used.
Notes
-----
See ``set_blend_equation`` for valid modes. | [
"Specify",
"the",
"equation",
"for",
"RGB",
"and",
"alpha",
"blending",
"Parameters",
"----------",
"mode_rgb",
":",
"str",
"Mode",
"for",
"RGB",
".",
"mode_alpha",
":",
"str",
"|",
"None",
"Mode",
"for",
"Alpha",
".",
"If",
"None",
"mode_rgb",
"is",
"used",
".",
"Notes",
"-----",
"See",
"set_blend_equation",
"for",
"valid",
"modes",
"."
] | train | https://github.com/glue-viz/glue-vispy-viewers/blob/54a4351d98c1f90dfb1a557d1b447c1f57470eea/glue_vispy_viewers/extern/vispy/gloo/wrappers.py#L283-L299 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Specify the equation for RGB and alpha blending
Parameters
----------
mode_rgb : str
Mode for RGB.
mode_alpha : str | None
Mode for Alpha. If None, ``mode_rgb`` is used.
Notes
-----
See ``set_blend_equation`` for valid modes.
### Response:
def set_blend_equation(self, mode_rgb, mode_alpha=None):
"""Specify the equation for RGB and alpha blending
Parameters
----------
mode_rgb : str
Mode for RGB.
mode_alpha : str | None
Mode for Alpha. If None, ``mode_rgb`` is used.
Notes
-----
See ``set_blend_equation`` for valid modes.
"""
mode_alpha = mode_rgb if mode_alpha is None else mode_alpha
self.glir.command('FUNC', 'glBlendEquationSeparate',
mode_rgb, mode_alpha)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
71152,
279,
24524,
369,
21653,
323,
8451,
56941,
7361,
286,
13831,
198,
286,
31423,
286,
3941,
38507,
551,
610,
198,
310,
14904,
369,
21653,
627,
286,
3941,
27731,
551,
610,
765,
2290,
198,
310,
14904,
369,
25737,
13,
1442,
2290,
11,
10103,
8684,
38507,
14196,
374,
1511,
627,
1084,
286,
18559,
198,
286,
81049,
286,
3580,
10103,
751,
89620,
42543,
367,
14196,
369,
2764,
20362,
382,
14711,
6075,
512,
755,
743,
89620,
42543,
367,
1214,
11,
3941,
38507,
11,
3941,
27731,
5980,
997,
286,
4304,
71152,
279,
24524,
369,
21653,
323,
8451,
56941,
7361,
286,
13831,
198,
286,
31423,
286,
3941,
38507,
551,
610,
198,
310,
14904,
369,
21653,
627,
286,
3941,
27731,
551,
610,
765,
2290,
198,
310,
14904,
369,
25737,
13,
1442,
2290,
11,
10103,
8684,
38507,
14196,
374,
1511,
627,
1084,
286,
18559,
198,
286,
81049,
286,
3580,
10103,
751,
89620,
42543,
367,
14196,
369,
2764,
20362,
627,
286,
3270,
286,
3941,
27731,
284,
3941,
38507,
422,
3941,
27731,
374,
2290,
775,
3941,
27731,
198,
286,
659,
20373,
404,
14475,
493,
42892,
518,
364,
6200,
46100,
25523,
367,
14832,
349,
518,
720,
3586,
3941,
38507,
11,
3941,
27731,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
71152,
279,
24524,
369,
21653,
323,
8451,
56941,
7361,
286,
13831,
198,
286,
31423,
286,
3941,
38507,
551,
610,
198,
310,
14904,
369,
21653,
627,
286,
3941,
27731,
551,
610,
765,
2290,
198,
310,
14904,
369,
25737,
13,
1442,
2290,
11,
10103,
8684,
38507,
14196,
374,
1511,
627,
1084,
286,
18559,
198,
286,
81049,
286,
3580,
10103,
751,
89620,
42543,
367,
14196,
369,
2764,
20362,
382,
14711,
6075,
512,
755,
743,
89620,
42543,
367,
1214,
11,
3941,
38507,
11,
3941,
27731,
5980,
997,
286,
4304,
71152,
279,
24524,
369,
21653,
323,
8451,
56941,
7361,
286,
13831,
198,
286,
31423,
286,
3941,
38507,
551,
610,
198,
310,
14904,
369,
21653,
627,
286,
3941,
27731,
551,
610,
765,
2290,
198,
310,
14904,
369,
25737,
13,
1442,
2290,
11,
10103,
8684,
38507,
14196,
374,
1511,
627,
1084,
286,
18559,
198,
286,
81049,
286,
3580,
10103,
751,
89620,
42543,
367,
14196,
369,
2764,
20362,
627,
286,
3270,
286,
3941,
27731,
284,
3941,
38507,
422,
3941,
27731,
374,
2290,
775,
3941,
27731,
198,
286,
659,
20373,
404,
14475,
493,
42892,
518,
364,
6200,
46100,
25523,
367,
14832,
349,
518,
720,
3586,
3941,
38507,
11,
3941,
27731,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
yamcs/yamcs-python | yamcs-client/examples/archive_retrieval.py | print_packet_range | def print_packet_range():
"""Print the range of archived packets."""
first_packet = next(iter(archive.list_packets()))
last_packet = next(iter(archive.list_packets(descending=True)))
print('First packet:', first_packet)
print('Last packet:', last_packet)
td = last_packet.generation_time - first_packet.generation_time
print('Timespan:', td) | python | def print_packet_range():
"""Print the range of archived packets."""
first_packet = next(iter(archive.list_packets()))
last_packet = next(iter(archive.list_packets(descending=True)))
print('First packet:', first_packet)
print('Last packet:', last_packet)
td = last_packet.generation_time - first_packet.generation_time
print('Timespan:', td) | [
"def",
"print_packet_range",
"(",
")",
":",
"first_packet",
"=",
"next",
"(",
"iter",
"(",
"archive",
".",
"list_packets",
"(",
")",
")",
")",
"last_packet",
"=",
"next",
"(",
"iter",
"(",
"archive",
".",
"list_packets",
"(",
"descending",
"=",
"True",
")",
")",
")",
"print",
"(",
"'First packet:'",
",",
"first_packet",
")",
"print",
"(",
"'Last packet:'",
",",
"last_packet",
")",
"td",
"=",
"last_packet",
".",
"generation_time",
"-",
"first_packet",
".",
"generation_time",
"print",
"(",
"'Timespan:'",
",",
"td",
")"
] | Print the range of archived packets. | [
"Print",
"the",
"range",
"of",
"archived",
"packets",
"."
] | train | https://github.com/yamcs/yamcs-python/blob/1082fee8a299010cc44416bbb7518fac0ef08b48/yamcs-client/examples/archive_retrieval.py#L15-L23 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Print the range of archived packets.
### Response:
def print_packet_range():
"""Print the range of archived packets."""
first_packet = next(iter(archive.list_packets()))
last_packet = next(iter(archive.list_packets(descending=True)))
print('First packet:', first_packet)
print('Last packet:', last_packet)
td = last_packet.generation_time - first_packet.generation_time
print('Timespan:', td)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
9171,
279,
2134,
315,
53093,
28133,
382,
14711,
6075,
512,
755,
1194,
21758,
9897,
4019,
262,
4304,
9171,
279,
2134,
315,
53093,
28133,
14781,
262,
1176,
21758,
284,
1828,
28169,
7,
16402,
6556,
64669,
12419,
262,
1566,
21758,
284,
1828,
28169,
7,
16402,
6556,
64669,
38773,
2518,
3702,
6054,
262,
1194,
493,
5451,
10361,
17898,
1176,
21758,
340,
262,
1194,
493,
5966,
10361,
17898,
1566,
21758,
696,
262,
18425,
284,
1566,
21758,
1326,
17699,
3084,
482,
1176,
21758,
1326,
17699,
3084,
198,
262,
1194,
493,
19422,
857,
17898,
18425,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
9171,
279,
2134,
315,
53093,
28133,
382,
14711,
6075,
512,
755,
1194,
21758,
9897,
4019,
262,
4304,
9171,
279,
2134,
315,
53093,
28133,
14781,
262,
1176,
21758,
284,
1828,
28169,
7,
16402,
6556,
64669,
12419,
262,
1566,
21758,
284,
1828,
28169,
7,
16402,
6556,
64669,
38773,
2518,
3702,
6054,
262,
1194,
493,
5451,
10361,
17898,
1176,
21758,
340,
262,
1194,
493,
5966,
10361,
17898,
1566,
21758,
696,
262,
18425,
284,
1566,
21758,
1326,
17699,
3084,
482,
1176,
21758,
1326,
17699,
3084,
198,
262,
1194,
493,
19422,
857,
17898,
18425,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
uber/doubles | doubles/method_double.py | MethodDouble.add_expectation | def add_expectation(self, caller):
"""Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation
"""
expectation = Expectation(self._target, self._method_name, caller)
self._expectations.insert(0, expectation)
return expectation | python | def add_expectation(self, caller):
"""Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation
"""
expectation = Expectation(self._target, self._method_name, caller)
self._expectations.insert(0, expectation)
return expectation | [
"def",
"add_expectation",
"(",
"self",
",",
"caller",
")",
":",
"expectation",
"=",
"Expectation",
"(",
"self",
".",
"_target",
",",
"self",
".",
"_method_name",
",",
"caller",
")",
"self",
".",
"_expectations",
".",
"insert",
"(",
"0",
",",
"expectation",
")",
"return",
"expectation"
] | Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation | [
"Adds",
"a",
"new",
"expectation",
"for",
"the",
"method",
"."
] | train | https://github.com/uber/doubles/blob/15e68dcf98f709b19a581915fa6af5ef49ebdd8a/doubles/method_double.py#L42-L51 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation
### Response:
def add_expectation(self, caller):
"""Adds a new expectation for the method.
:return: The new ``Expectation``.
:rtype: Expectation
"""
expectation = Expectation(self._target, self._method_name, caller)
self._expectations.insert(0, expectation)
return expectation
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
73211,
264,
502,
31293,
369,
279,
1749,
382,
286,
551,
693,
25,
578,
502,
10103,
17995,
367,
14196,
627,
286,
551,
33613,
25,
33185,
367,
271,
14711,
6075,
512,
755,
923,
70018,
367,
1214,
11,
20456,
997,
286,
4304,
73211,
264,
502,
31293,
369,
279,
1749,
382,
286,
551,
693,
25,
578,
502,
10103,
17995,
367,
14196,
627,
286,
551,
33613,
25,
33185,
367,
198,
286,
12713,
286,
31293,
284,
33185,
367,
1214,
1462,
5775,
11,
659,
1462,
4492,
1292,
11,
20456,
340,
286,
659,
1462,
17557,
811,
7175,
7,
15,
11,
31293,
340,
286,
471,
31293,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
73211,
264,
502,
31293,
369,
279,
1749,
382,
286,
551,
693,
25,
578,
502,
10103,
17995,
367,
14196,
627,
286,
551,
33613,
25,
33185,
367,
271,
14711,
6075,
512,
755,
923,
70018,
367,
1214,
11,
20456,
997,
286,
4304,
73211,
264,
502,
31293,
369,
279,
1749,
382,
286,
551,
693,
25,
578,
502,
10103,
17995,
367,
14196,
627,
286,
551,
33613,
25,
33185,
367,
198,
286,
12713,
286,
31293,
284,
33185,
367,
1214,
1462,
5775,
11,
659,
1462,
4492,
1292,
11,
20456,
340,
286,
659,
1462,
17557,
811,
7175,
7,
15,
11,
31293,
340,
286,
471,
31293,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
kgori/treeCl | treeCl/simulator.py | Simulator.make_alf_dirs_ | def make_alf_dirs_(self):
""" DEPRECATED """
alf_dirs = {}
for k in range(self.num_classes):
dirname = fileIO.join_path(self.tmpdir, 'class{0:0>1}'.format(
k + 1))
alf_dirs[k + 1] = errors.directorymake(dirname)
self.alf_dirs = alf_dirs | python | def make_alf_dirs_(self):
""" DEPRECATED """
alf_dirs = {}
for k in range(self.num_classes):
dirname = fileIO.join_path(self.tmpdir, 'class{0:0>1}'.format(
k + 1))
alf_dirs[k + 1] = errors.directorymake(dirname)
self.alf_dirs = alf_dirs | [
"def",
"make_alf_dirs_",
"(",
"self",
")",
":",
"alf_dirs",
"=",
"{",
"}",
"for",
"k",
"in",
"range",
"(",
"self",
".",
"num_classes",
")",
":",
"dirname",
"=",
"fileIO",
".",
"join_path",
"(",
"self",
".",
"tmpdir",
",",
"'class{0:0>1}'",
".",
"format",
"(",
"k",
"+",
"1",
")",
")",
"alf_dirs",
"[",
"k",
"+",
"1",
"]",
"=",
"errors",
".",
"directorymake",
"(",
"dirname",
")",
"self",
".",
"alf_dirs",
"=",
"alf_dirs"
] | DEPRECATED | [
"DEPRECATED"
] | train | https://github.com/kgori/treeCl/blob/fed624b3db1c19cc07175ca04e3eda6905a8d305/treeCl/simulator.py#L204-L211 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
DEPRECATED
### Response:
def make_alf_dirs_(self):
""" DEPRECATED """
alf_dirs = {}
for k in range(self.num_classes):
dirname = fileIO.join_path(self.tmpdir, 'class{0:0>1}'.format(
k + 1))
alf_dirs[k + 1] = errors.directorymake(dirname)
self.alf_dirs = alf_dirs
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1170,
58813,
271,
14711,
6075,
512,
755,
1304,
62,
3181,
45969,
8526,
726,
997,
286,
4304,
3467,
58813,
3270,
286,
85766,
45969,
284,
5731,
286,
369,
597,
304,
2134,
1214,
10744,
17255,
997,
310,
31008,
284,
1052,
3895,
5563,
2703,
1214,
45831,
3826,
11,
364,
1058,
90,
15,
25,
15,
29,
16,
24398,
2293,
1021,
394,
597,
489,
220,
16,
1192,
310,
85766,
45969,
6874,
489,
220,
16,
60,
284,
6103,
61037,
7072,
39902,
340,
286,
659,
13,
3181,
45969,
284,
85766,
45969,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1170,
58813,
271,
14711,
6075,
512,
755,
1304,
62,
3181,
45969,
8526,
726,
997,
286,
4304,
3467,
58813,
3270,
286,
85766,
45969,
284,
5731,
286,
369,
597,
304,
2134,
1214,
10744,
17255,
997,
310,
31008,
284,
1052,
3895,
5563,
2703,
1214,
45831,
3826,
11,
364,
1058,
90,
15,
25,
15,
29,
16,
24398,
2293,
1021,
394,
597,
489,
220,
16,
1192,
310,
85766,
45969,
6874,
489,
220,
16,
60,
284,
6103,
61037,
7072,
39902,
340,
286,
659,
13,
3181,
45969,
284,
85766,
45969,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
google/grr | grr/core/grr_response_core/lib/fingerprint.py | Fingerprinter.EvalGeneric | def EvalGeneric(self, hashers=None):
"""Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out of hashlib) which will
be instantiated for use. If hashers is not provided, or is
provided as 'None', the default hashers will get used. To
invoke this without hashers, provide an empty list.
Returns:
Always True, as all files are 'generic' files.
"""
if hashers is None:
hashers = Fingerprinter.GENERIC_HASH_CLASSES
hashfuncs = [x() for x in hashers]
finger = Finger(hashfuncs, [Range(0, self.filelength)], {'name': 'generic'})
self.fingers.append(finger)
return True | python | def EvalGeneric(self, hashers=None):
"""Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out of hashlib) which will
be instantiated for use. If hashers is not provided, or is
provided as 'None', the default hashers will get used. To
invoke this without hashers, provide an empty list.
Returns:
Always True, as all files are 'generic' files.
"""
if hashers is None:
hashers = Fingerprinter.GENERIC_HASH_CLASSES
hashfuncs = [x() for x in hashers]
finger = Finger(hashfuncs, [Range(0, self.filelength)], {'name': 'generic'})
self.fingers.append(finger)
return True | [
"def",
"EvalGeneric",
"(",
"self",
",",
"hashers",
"=",
"None",
")",
":",
"if",
"hashers",
"is",
"None",
":",
"hashers",
"=",
"Fingerprinter",
".",
"GENERIC_HASH_CLASSES",
"hashfuncs",
"=",
"[",
"x",
"(",
")",
"for",
"x",
"in",
"hashers",
"]",
"finger",
"=",
"Finger",
"(",
"hashfuncs",
",",
"[",
"Range",
"(",
"0",
",",
"self",
".",
"filelength",
")",
"]",
",",
"{",
"'name'",
":",
"'generic'",
"}",
")",
"self",
".",
"fingers",
".",
"append",
"(",
"finger",
")",
"return",
"True"
] | Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out of hashlib) which will
be instantiated for use. If hashers is not provided, or is
provided as 'None', the default hashers will get used. To
invoke this without hashers, provide an empty list.
Returns:
Always True, as all files are 'generic' files. | [
"Causes",
"the",
"entire",
"file",
"to",
"be",
"hashed",
"by",
"the",
"given",
"hash",
"functions",
"."
] | train | https://github.com/google/grr/blob/5cef4e8e2f0d5df43ea4877e9c798e0bf60bfe74/grr/core/grr_response_core/lib/fingerprint.py#L241-L261 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out of hashlib) which will
be instantiated for use. If hashers is not provided, or is
provided as 'None', the default hashers will get used. To
invoke this without hashers, provide an empty list.
Returns:
Always True, as all files are 'generic' files.
### Response:
def EvalGeneric(self, hashers=None):
"""Causes the entire file to be hashed by the given hash functions.
This sets up a 'finger' for fingerprinting, where the entire file
is passed through a pre-defined (or user defined) set of hash functions.
Args:
hashers: An iterable of hash classes (e.g. out of hashlib) which will
be instantiated for use. If hashers is not provided, or is
provided as 'None', the default hashers will get used. To
invoke this without hashers, provide an empty list.
Returns:
Always True, as all files are 'generic' files.
"""
if hashers is None:
hashers = Fingerprinter.GENERIC_HASH_CLASSES
hashfuncs = [x() for x in hashers]
finger = Finger(hashfuncs, [Range(0, self.filelength)], {'name': 'generic'})
self.fingers.append(finger)
return True
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
23389,
4881,
279,
4553,
1052,
311,
387,
51776,
555,
279,
2728,
5286,
5865,
382,
262,
1115,
7437,
709,
264,
364,
80216,
6,
369,
43697,
287,
11,
1405,
279,
4553,
1052,
198,
262,
374,
5946,
1555,
264,
864,
39817,
320,
269,
1217,
4613,
8,
743,
315,
5286,
5865,
382,
262,
18161,
512,
415,
5286,
388,
25,
1556,
51934,
315,
5286,
6989,
320,
68,
1326,
13,
704,
315,
55595,
8,
902,
690,
198,
2342,
387,
55686,
369,
1005,
13,
1442,
5286,
388,
374,
539,
3984,
11,
477,
374,
198,
2342,
3984,
439,
364,
4155,
518,
279,
1670,
5286,
388,
690,
636,
1511,
13,
2057,
198,
2342,
20466,
420,
2085,
5286,
388,
11,
3493,
459,
4384,
1160,
382,
262,
5295,
512,
415,
24119,
3082,
11,
439,
682,
3626,
527,
364,
36887,
6,
3626,
382,
14711,
6075,
512,
755,
59339,
20560,
1214,
11,
5286,
388,
5980,
997,
262,
4304,
23389,
4881,
279,
4553,
1052,
311,
387,
51776,
555,
279,
2728,
5286,
5865,
382,
262,
1115,
7437,
709,
264,
364,
80216,
6,
369,
43697,
287,
11,
1405,
279,
4553,
1052,
198,
262,
374,
5946,
1555,
264,
864,
39817,
320,
269,
1217,
4613,
8,
743,
315,
5286,
5865,
382,
262,
18161,
512,
415,
5286,
388,
25,
1556,
51934,
315,
5286,
6989,
320,
68,
1326,
13,
704,
315,
55595,
8,
902,
690,
198,
2342,
387,
55686,
369,
1005,
13,
1442,
5286,
388,
374,
539,
3984,
11,
477,
374,
198,
2342,
3984,
439,
364,
4155,
518,
279,
1670,
5286,
388,
690,
636,
1511,
13,
2057,
198,
2342,
20466,
420,
2085,
5286,
388,
11,
3493,
459,
4384,
1160,
382,
262,
5295,
512,
415,
24119,
3082,
11,
439,
682,
3626,
527,
364,
36887,
6,
3626,
627,
262,
3270,
262,
422,
5286,
388,
374,
2290,
512,
415,
5286,
388,
284,
435,
49018,
261,
1246,
12545,
1341,
33409,
70264,
198,
262,
5286,
88582,
284,
510,
87,
368,
369,
865,
304,
5286,
388,
933,
262,
14654,
284,
63961,
28680,
88582,
11,
510,
6174,
7,
15,
11,
659,
9914,
4222,
26090,
5473,
609,
1232,
364,
36887,
27482,
262,
659,
840,
14437,
2102,
968,
5248,
340,
262,
471,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
23389,
4881,
279,
4553,
1052,
311,
387,
51776,
555,
279,
2728,
5286,
5865,
382,
262,
1115,
7437,
709,
264,
364,
80216,
6,
369,
43697,
287,
11,
1405,
279,
4553,
1052,
198,
262,
374,
5946,
1555,
264,
864,
39817,
320,
269,
1217,
4613,
8,
743,
315,
5286,
5865,
382,
262,
18161,
512,
415,
5286,
388,
25,
1556,
51934,
315,
5286,
6989,
320,
68,
1326,
13,
704,
315,
55595,
8,
902,
690,
198,
2342,
387,
55686,
369,
1005,
13,
1442,
5286,
388,
374,
539,
3984,
11,
477,
374,
198,
2342,
3984,
439,
364,
4155,
518,
279,
1670,
5286,
388,
690,
636,
1511,
13,
2057,
198,
2342,
20466,
420,
2085,
5286,
388,
11,
3493,
459,
4384,
1160,
382,
262,
5295,
512,
415,
24119,
3082,
11,
439,
682,
3626,
527,
364,
36887,
6,
3626,
382,
14711,
6075,
512,
755,
59339,
20560,
1214,
11,
5286,
388,
5980,
997,
262,
4304,
23389,
4881,
279,
4553,
1052,
311,
387,
51776,
555,
279,
2728,
5286,
5865,
382,
262,
1115,
7437,
709,
264,
364,
80216,
6,
369,
43697,
287,
11,
1405,
279,
4553,
1052,
198,
262,
374,
5946,
1555,
264,
864,
39817,
320,
269,
1217,
4613,
8,
743,
315,
5286,
5865,
382,
262,
18161,
512,
415,
5286,
388,
25,
1556,
51934,
315,
5286,
6989,
320,
68,
1326,
13,
704,
315,
55595,
8,
902,
690,
198,
2342,
387,
55686,
369,
1005,
13,
1442,
5286,
388,
374,
539,
3984,
11,
477,
374,
198,
2342,
3984,
439,
364,
4155,
518,
279,
1670,
5286,
388,
690,
636,
1511,
13,
2057,
198,
2342,
20466,
420,
2085,
5286,
388,
11,
3493,
459,
4384,
1160,
382,
262,
5295,
512,
415,
24119,
3082,
11,
439,
682,
3626,
527,
364,
36887,
6,
3626,
627,
262,
3270,
262,
422,
5286,
388,
374,
2290,
512,
415,
5286,
388,
284,
435,
49018,
261,
1246,
12545,
1341,
33409,
70264,
198,
262,
5286,
88582,
284,
510,
87,
368,
369,
865,
304,
5286,
388,
933,
262,
14654,
284,
63961,
28680,
88582,
11,
510,
6174,
7,
15,
11,
659,
9914,
4222,
26090,
5473,
609,
1232,
364,
36887,
27482,
262,
659,
840,
14437,
2102,
968,
5248,
340,
262,
471,
3082,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pytroll/satpy | satpy/readers/scmi.py | SCMIFileHandler._get_cf_grid_mapping_var | def _get_cf_grid_mapping_var(self):
"""Figure out which grid mapping should be used"""
gmaps = ['fixedgrid_projection', 'goes_imager_projection',
'lambert_projection', 'polar_projection',
'mercator_projection']
if 'grid_mapping' in self.filename_info:
gmaps = [self.filename_info.get('grid_mapping')] + gmaps
for grid_mapping in gmaps:
if grid_mapping in self.nc:
return self.nc[grid_mapping]
raise KeyError("Can't find grid mapping variable in SCMI file") | python | def _get_cf_grid_mapping_var(self):
"""Figure out which grid mapping should be used"""
gmaps = ['fixedgrid_projection', 'goes_imager_projection',
'lambert_projection', 'polar_projection',
'mercator_projection']
if 'grid_mapping' in self.filename_info:
gmaps = [self.filename_info.get('grid_mapping')] + gmaps
for grid_mapping in gmaps:
if grid_mapping in self.nc:
return self.nc[grid_mapping]
raise KeyError("Can't find grid mapping variable in SCMI file") | [
"def",
"_get_cf_grid_mapping_var",
"(",
"self",
")",
":",
"gmaps",
"=",
"[",
"'fixedgrid_projection'",
",",
"'goes_imager_projection'",
",",
"'lambert_projection'",
",",
"'polar_projection'",
",",
"'mercator_projection'",
"]",
"if",
"'grid_mapping'",
"in",
"self",
".",
"filename_info",
":",
"gmaps",
"=",
"[",
"self",
".",
"filename_info",
".",
"get",
"(",
"'grid_mapping'",
")",
"]",
"+",
"gmaps",
"for",
"grid_mapping",
"in",
"gmaps",
":",
"if",
"grid_mapping",
"in",
"self",
".",
"nc",
":",
"return",
"self",
".",
"nc",
"[",
"grid_mapping",
"]",
"raise",
"KeyError",
"(",
"\"Can't find grid mapping variable in SCMI file\"",
")"
] | Figure out which grid mapping should be used | [
"Figure",
"out",
"which",
"grid",
"mapping",
"should",
"be",
"used"
] | train | https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/scmi.py#L176-L186 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Figure out which grid mapping should be used
### Response:
def _get_cf_grid_mapping_var(self):
"""Figure out which grid mapping should be used"""
gmaps = ['fixedgrid_projection', 'goes_imager_projection',
'lambert_projection', 'polar_projection',
'mercator_projection']
if 'grid_mapping' in self.filename_info:
gmaps = [self.filename_info.get('grid_mapping')] + gmaps
for grid_mapping in gmaps:
if grid_mapping in self.nc:
return self.nc[grid_mapping]
raise KeyError("Can't find grid mapping variable in SCMI file")
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
22804,
704,
902,
5950,
13021,
1288,
387,
1511,
271,
14711,
6075,
512,
755,
721,
456,
72243,
15977,
28028,
4715,
1214,
997,
286,
4304,
22804,
704,
902,
5950,
13021,
1288,
387,
1511,
7275,
286,
342,
18106,
284,
2570,
22795,
4297,
73838,
518,
364,
3427,
288,
18377,
1435,
73838,
756,
338,
364,
75,
3042,
531,
73838,
518,
364,
79,
7569,
73838,
756,
338,
364,
65522,
859,
73838,
4532,
286,
422,
364,
4297,
28028,
6,
304,
659,
31982,
3186,
512,
310,
342,
18106,
284,
510,
726,
31982,
3186,
673,
493,
4297,
28028,
52128,
489,
342,
18106,
198,
286,
369,
5950,
28028,
304,
342,
18106,
512,
310,
422,
5950,
28028,
304,
659,
33058,
512,
394,
471,
659,
33058,
58,
4297,
28028,
933,
286,
4933,
39194,
446,
6854,
956,
1505,
5950,
13021,
3977,
304,
7683,
9972,
1052,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
22804,
704,
902,
5950,
13021,
1288,
387,
1511,
271,
14711,
6075,
512,
755,
721,
456,
72243,
15977,
28028,
4715,
1214,
997,
286,
4304,
22804,
704,
902,
5950,
13021,
1288,
387,
1511,
7275,
286,
342,
18106,
284,
2570,
22795,
4297,
73838,
518,
364,
3427,
288,
18377,
1435,
73838,
756,
338,
364,
75,
3042,
531,
73838,
518,
364,
79,
7569,
73838,
756,
338,
364,
65522,
859,
73838,
4532,
286,
422,
364,
4297,
28028,
6,
304,
659,
31982,
3186,
512,
310,
342,
18106,
284,
510,
726,
31982,
3186,
673,
493,
4297,
28028,
52128,
489,
342,
18106,
198,
286,
369,
5950,
28028,
304,
342,
18106,
512,
310,
422,
5950,
28028,
304,
659,
33058,
512,
394,
471,
659,
33058,
58,
4297,
28028,
933,
286,
4933,
39194,
446,
6854,
956,
1505,
5950,
13021,
3977,
304,
7683,
9972,
1052,
1158,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
romanz/trezor-agent | libagent/device/trezor.py | Trezor.sign | def sign(self, identity, blob):
"""Sign given blob and return the signature (as bytes)."""
curve_name = identity.get_curve_name(ecdh=False)
log.debug('"%s" signing %r (%s) on %s',
identity.to_string(), blob, curve_name, self)
try:
result = self._defs.sign_identity(
self.conn,
identity=self._identity_proto(identity),
challenge_hidden=blob,
challenge_visual='',
ecdsa_curve_name=curve_name)
log.debug('result: %s', result)
assert len(result.signature) == 65
assert result.signature[:1] == b'\x00'
return bytes(result.signature[1:])
except self._defs.TrezorFailure as e:
msg = '{} error: {}'.format(self, e)
log.debug(msg, exc_info=True)
raise interface.DeviceError(msg) | python | def sign(self, identity, blob):
"""Sign given blob and return the signature (as bytes)."""
curve_name = identity.get_curve_name(ecdh=False)
log.debug('"%s" signing %r (%s) on %s',
identity.to_string(), blob, curve_name, self)
try:
result = self._defs.sign_identity(
self.conn,
identity=self._identity_proto(identity),
challenge_hidden=blob,
challenge_visual='',
ecdsa_curve_name=curve_name)
log.debug('result: %s', result)
assert len(result.signature) == 65
assert result.signature[:1] == b'\x00'
return bytes(result.signature[1:])
except self._defs.TrezorFailure as e:
msg = '{} error: {}'.format(self, e)
log.debug(msg, exc_info=True)
raise interface.DeviceError(msg) | [
"def",
"sign",
"(",
"self",
",",
"identity",
",",
"blob",
")",
":",
"curve_name",
"=",
"identity",
".",
"get_curve_name",
"(",
"ecdh",
"=",
"False",
")",
"log",
".",
"debug",
"(",
"'\"%s\" signing %r (%s) on %s'",
",",
"identity",
".",
"to_string",
"(",
")",
",",
"blob",
",",
"curve_name",
",",
"self",
")",
"try",
":",
"result",
"=",
"self",
".",
"_defs",
".",
"sign_identity",
"(",
"self",
".",
"conn",
",",
"identity",
"=",
"self",
".",
"_identity_proto",
"(",
"identity",
")",
",",
"challenge_hidden",
"=",
"blob",
",",
"challenge_visual",
"=",
"''",
",",
"ecdsa_curve_name",
"=",
"curve_name",
")",
"log",
".",
"debug",
"(",
"'result: %s'",
",",
"result",
")",
"assert",
"len",
"(",
"result",
".",
"signature",
")",
"==",
"65",
"assert",
"result",
".",
"signature",
"[",
":",
"1",
"]",
"==",
"b'\\x00'",
"return",
"bytes",
"(",
"result",
".",
"signature",
"[",
"1",
":",
"]",
")",
"except",
"self",
".",
"_defs",
".",
"TrezorFailure",
"as",
"e",
":",
"msg",
"=",
"'{} error: {}'",
".",
"format",
"(",
"self",
",",
"e",
")",
"log",
".",
"debug",
"(",
"msg",
",",
"exc_info",
"=",
"True",
")",
"raise",
"interface",
".",
"DeviceError",
"(",
"msg",
")"
] | Sign given blob and return the signature (as bytes). | [
"Sign",
"given",
"blob",
"and",
"return",
"the",
"signature",
"(",
"as",
"bytes",
")",
"."
] | train | https://github.com/romanz/trezor-agent/blob/513b1259c4d7aca5f88cd958edc11828d0712f1b/libagent/device/trezor.py#L95-L114 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Sign given blob and return the signature (as bytes).
### Response:
def sign(self, identity, blob):
"""Sign given blob and return the signature (as bytes)."""
curve_name = identity.get_curve_name(ecdh=False)
log.debug('"%s" signing %r (%s) on %s',
identity.to_string(), blob, curve_name, self)
try:
result = self._defs.sign_identity(
self.conn,
identity=self._identity_proto(identity),
challenge_hidden=blob,
challenge_visual='',
ecdsa_curve_name=curve_name)
log.debug('result: %s', result)
assert len(result.signature) == 65
assert result.signature[:1] == b'\x00'
return bytes(result.signature[1:])
except self._defs.TrezorFailure as e:
msg = '{} error: {}'.format(self, e)
log.debug(msg, exc_info=True)
raise interface.DeviceError(msg)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7412,
2728,
24295,
323,
471,
279,
12223,
320,
300,
5943,
3677,
14711,
6075,
512,
755,
1879,
1214,
11,
9764,
11,
24295,
997,
286,
4304,
7412,
2728,
24295,
323,
471,
279,
12223,
320,
300,
5943,
570,
7275,
286,
16029,
1292,
284,
9764,
673,
44507,
1292,
63640,
31721,
5725,
340,
286,
1515,
8042,
493,
32491,
82,
1,
16351,
1034,
81,
13764,
82,
8,
389,
1034,
82,
756,
1733,
9764,
2446,
3991,
1535,
24295,
11,
16029,
1292,
11,
659,
340,
286,
1456,
512,
310,
1121,
284,
659,
1462,
49585,
15867,
47344,
1021,
394,
659,
23656,
345,
394,
9764,
7822,
1462,
17341,
38789,
87943,
1350,
394,
8815,
27837,
22861,
1718,
345,
394,
8815,
65730,
97783,
394,
384,
4484,
9258,
44507,
1292,
28,
51151,
1292,
340,
310,
1515,
8042,
493,
1407,
25,
1034,
82,
518,
1121,
340,
310,
2105,
2479,
4556,
76285,
8,
624,
220,
2397,
198,
310,
2105,
1121,
76285,
3530,
16,
60,
624,
293,
16154,
87,
410,
1270,
310,
471,
5943,
4556,
76285,
58,
16,
44157,
286,
3734,
659,
1462,
49585,
844,
23577,
269,
17965,
439,
384,
512,
310,
3835,
284,
34012,
1493,
25,
26307,
2293,
1214,
11,
384,
340,
310,
1515,
8042,
8282,
11,
3521,
3186,
3702,
340,
310,
4933,
3834,
45095,
1480,
8282,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
7412,
2728,
24295,
323,
471,
279,
12223,
320,
300,
5943,
3677,
14711,
6075,
512,
755,
1879,
1214,
11,
9764,
11,
24295,
997,
286,
4304,
7412,
2728,
24295,
323,
471,
279,
12223,
320,
300,
5943,
570,
7275,
286,
16029,
1292,
284,
9764,
673,
44507,
1292,
63640,
31721,
5725,
340,
286,
1515,
8042,
493,
32491,
82,
1,
16351,
1034,
81,
13764,
82,
8,
389,
1034,
82,
756,
1733,
9764,
2446,
3991,
1535,
24295,
11,
16029,
1292,
11,
659,
340,
286,
1456,
512,
310,
1121,
284,
659,
1462,
49585,
15867,
47344,
1021,
394,
659,
23656,
345,
394,
9764,
7822,
1462,
17341,
38789,
87943,
1350,
394,
8815,
27837,
22861,
1718,
345,
394,
8815,
65730,
97783,
394,
384,
4484,
9258,
44507,
1292,
28,
51151,
1292,
340,
310,
1515,
8042,
493,
1407,
25,
1034,
82,
518,
1121,
340,
310,
2105,
2479,
4556,
76285,
8,
624,
220,
2397,
198,
310,
2105,
1121,
76285,
3530,
16,
60,
624,
293,
16154,
87,
410,
1270,
310,
471,
5943,
4556,
76285,
58,
16,
44157,
286,
3734,
659,
1462,
49585,
844,
23577,
269,
17965,
439,
384,
512,
310,
3835,
284,
34012,
1493,
25,
26307,
2293,
1214,
11,
384,
340,
310,
1515,
8042,
8282,
11,
3521,
3186,
3702,
340,
310,
4933,
3834,
45095,
1480,
8282,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
mitsei/dlkit | dlkit/json_/assessment_authoring/objects.py | SequenceRuleForm._init_metadata | def _init_metadata(self, **kwargs):
"""Initialize form metadata"""
osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
self._cumulative_default = self._mdata['cumulative']['default_boolean_values'][0]
self._minimum_score_default = self._mdata['minimum_score']['default_cardinal_values'][0]
self._maximum_score_default = self._mdata['maximum_score']['default_cardinal_values'][0] | python | def _init_metadata(self, **kwargs):
"""Initialize form metadata"""
osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
self._cumulative_default = self._mdata['cumulative']['default_boolean_values'][0]
self._minimum_score_default = self._mdata['minimum_score']['default_cardinal_values'][0]
self._maximum_score_default = self._mdata['maximum_score']['default_cardinal_values'][0] | [
"def",
"_init_metadata",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"osid_objects",
".",
"OsidObjectForm",
".",
"_init_metadata",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
"self",
".",
"_cumulative_default",
"=",
"self",
".",
"_mdata",
"[",
"'cumulative'",
"]",
"[",
"'default_boolean_values'",
"]",
"[",
"0",
"]",
"self",
".",
"_minimum_score_default",
"=",
"self",
".",
"_mdata",
"[",
"'minimum_score'",
"]",
"[",
"'default_cardinal_values'",
"]",
"[",
"0",
"]",
"self",
".",
"_maximum_score_default",
"=",
"self",
".",
"_mdata",
"[",
"'maximum_score'",
"]",
"[",
"'default_cardinal_values'",
"]",
"[",
"0",
"]"
] | Initialize form metadata | [
"Initialize",
"form",
"metadata"
] | train | https://github.com/mitsei/dlkit/blob/445f968a175d61c8d92c0f617a3c17dc1dc7c584/dlkit/json_/assessment_authoring/objects.py#L814-L819 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Initialize form metadata
### Response:
def _init_metadata(self, **kwargs):
"""Initialize form metadata"""
osid_objects.OsidObjectForm._init_metadata(self, **kwargs)
self._cumulative_default = self._mdata['cumulative']['default_boolean_values'][0]
self._minimum_score_default = self._mdata['minimum_score']['default_cardinal_values'][0]
self._maximum_score_default = self._mdata['maximum_score']['default_cardinal_values'][0]
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10130,
1376,
11408,
271,
14711,
6075,
512,
755,
721,
2381,
23012,
1214,
11,
3146,
9872,
997,
286,
4304,
10130,
1376,
11408,
7275,
286,
2709,
307,
25915,
8548,
21703,
1211,
1876,
1462,
2381,
23012,
1214,
11,
3146,
9872,
340,
286,
659,
1462,
60353,
22948,
10198,
284,
659,
1462,
76,
695,
681,
60353,
22948,
4274,
2309,
47742,
9324,
10136,
15,
933,
286,
659,
1462,
39088,
10622,
10198,
284,
659,
1462,
76,
695,
681,
39088,
10622,
4274,
2309,
17315,
992,
9324,
10136,
15,
933,
286,
659,
1462,
40287,
10622,
10198,
284,
659,
1462,
76,
695,
681,
40287,
10622,
4274,
2309,
17315,
992,
9324,
10136,
15,
933,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,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14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10130,
1376,
11408,
271,
14711,
6075,
512,
755,
721,
2381,
23012,
1214,
11,
3146,
9872,
997,
286,
4304,
10130,
1376,
11408,
7275,
286,
2709,
307,
25915,
8548,
21703,
1211,
1876,
1462,
2381,
23012,
1214,
11,
3146,
9872,
340,
286,
659,
1462,
60353,
22948,
10198,
284,
659,
1462,
76,
695,
681,
60353,
22948,
4274,
2309,
47742,
9324,
10136,
15,
933,
286,
659,
1462,
39088,
10622,
10198,
284,
659,
1462,
76,
695,
681,
39088,
10622,
4274,
2309,
17315,
992,
9324,
10136,
15,
933,
286,
659,
1462,
40287,
10622,
10198,
284,
659,
1462,
76,
695,
681,
40287,
10622,
4274,
2309,
17315,
992,
9324,
10136,
15,
933,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
SeattleTestbed/seash | pyreadline/console/console.py | Console.scroll | def scroll(self, rect, dx, dy, attr=None, fill=' '):
u'''Scroll a rectangle.'''
if attr is None:
attr = self.attr
x0, y0, x1, y1 = rect
source = SMALL_RECT(x0, y0, x1 - 1, y1 - 1)
dest = self.fixcoord(x0 + dx, y0 + dy)
style = CHAR_INFO()
style.Char.AsciiChar = ensure_str(fill[0])
style.Attributes = attr
return self.ScrollConsoleScreenBufferW(self.hout, byref(source),
byref(source), dest, byref(style)) | python | def scroll(self, rect, dx, dy, attr=None, fill=' '):
u'''Scroll a rectangle.'''
if attr is None:
attr = self.attr
x0, y0, x1, y1 = rect
source = SMALL_RECT(x0, y0, x1 - 1, y1 - 1)
dest = self.fixcoord(x0 + dx, y0 + dy)
style = CHAR_INFO()
style.Char.AsciiChar = ensure_str(fill[0])
style.Attributes = attr
return self.ScrollConsoleScreenBufferW(self.hout, byref(source),
byref(source), dest, byref(style)) | [
"def",
"scroll",
"(",
"self",
",",
"rect",
",",
"dx",
",",
"dy",
",",
"attr",
"=",
"None",
",",
"fill",
"=",
"' '",
")",
":",
"if",
"attr",
"is",
"None",
":",
"attr",
"=",
"self",
".",
"attr",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"=",
"rect",
"source",
"=",
"SMALL_RECT",
"(",
"x0",
",",
"y0",
",",
"x1",
"-",
"1",
",",
"y1",
"-",
"1",
")",
"dest",
"=",
"self",
".",
"fixcoord",
"(",
"x0",
"+",
"dx",
",",
"y0",
"+",
"dy",
")",
"style",
"=",
"CHAR_INFO",
"(",
")",
"style",
".",
"Char",
".",
"AsciiChar",
"=",
"ensure_str",
"(",
"fill",
"[",
"0",
"]",
")",
"style",
".",
"Attributes",
"=",
"attr",
"return",
"self",
".",
"ScrollConsoleScreenBufferW",
"(",
"self",
".",
"hout",
",",
"byref",
"(",
"source",
")",
",",
"byref",
"(",
"source",
")",
",",
"dest",
",",
"byref",
"(",
"style",
")",
")"
] | u'''Scroll a rectangle. | [
"u",
"Scroll",
"a",
"rectangle",
"."
] | train | https://github.com/SeattleTestbed/seash/blob/40f9d2285662ff8b61e0468b4196acee089b273b/pyreadline/console/console.py#L453-L465 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
u'''Scroll a rectangle.
### Response:
def scroll(self, rect, dx, dy, attr=None, fill=' '):
u'''Scroll a rectangle.'''
if attr is None:
attr = self.attr
x0, y0, x1, y1 = rect
source = SMALL_RECT(x0, y0, x1 - 1, y1 - 1)
dest = self.fixcoord(x0 + dx, y0 + dy)
style = CHAR_INFO()
style.Char.AsciiChar = ensure_str(fill[0])
style.Attributes = attr
return self.ScrollConsoleScreenBufferW(self.hout, byref(source),
byref(source), dest, byref(style))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
84,
19317,
8591,
264,
23596,
382,
14711,
6075,
512,
755,
9236,
1214,
11,
7763,
11,
14142,
11,
14282,
11,
6510,
5980,
11,
5266,
1151,
364,
5903,
286,
577,
19317,
8591,
264,
23596,
3238,
4708,
319,
286,
422,
6510,
374,
2290,
2904,
310,
6510,
284,
659,
13139,
319,
286,
865,
15,
11,
379,
15,
11,
865,
16,
11,
379,
16,
284,
7763,
319,
286,
2592,
284,
50297,
70721,
2120,
15,
11,
379,
15,
11,
865,
16,
482,
220,
16,
11,
379,
16,
482,
220,
16,
1240,
286,
3281,
284,
659,
68885,
27500,
2120,
15,
489,
14142,
11,
379,
15,
489,
14282,
1240,
286,
1742,
284,
24954,
9245,
3652,
286,
1742,
10664,
885,
2445,
3893,
4873,
284,
6106,
2966,
82754,
58,
15,
15364,
286,
1742,
32484,
284,
6510,
881,
286,
471,
659,
50092,
12653,
8130,
4187,
54,
1214,
870,
412,
11,
555,
1116,
12719,
705,
2591,
10724,
555,
1116,
12719,
705,
3281,
11,
555,
1116,
38383,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
84,
19317,
8591,
264,
23596,
382,
14711,
6075,
512,
755,
9236,
1214,
11,
7763,
11,
14142,
11,
14282,
11,
6510,
5980,
11,
5266,
1151,
364,
5903,
286,
577,
19317,
8591,
264,
23596,
3238,
4708,
319,
286,
422,
6510,
374,
2290,
2904,
310,
6510,
284,
659,
13139,
319,
286,
865,
15,
11,
379,
15,
11,
865,
16,
11,
379,
16,
284,
7763,
319,
286,
2592,
284,
50297,
70721,
2120,
15,
11,
379,
15,
11,
865,
16,
482,
220,
16,
11,
379,
16,
482,
220,
16,
1240,
286,
3281,
284,
659,
68885,
27500,
2120,
15,
489,
14142,
11,
379,
15,
489,
14282,
1240,
286,
1742,
284,
24954,
9245,
3652,
286,
1742,
10664,
885,
2445,
3893,
4873,
284,
6106,
2966,
82754,
58,
15,
15364,
286,
1742,
32484,
284,
6510,
881,
286,
471,
659,
50092,
12653,
8130,
4187,
54,
1214,
870,
412,
11,
555,
1116,
12719,
705,
2591,
10724,
555,
1116,
12719,
705,
3281,
11,
555,
1116,
38383,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
PedalPi/Raspberry-Physical | physical/liquidcristal/liquid_crystal.py | LiquidCrystal.home | def home(self):
"""Return to initial position (row=0, column=0)"""
self.row = 0
self.column = 0
self.command(Command.RETURN_HOME)
msleep(2) | python | def home(self):
"""Return to initial position (row=0, column=0)"""
self.row = 0
self.column = 0
self.command(Command.RETURN_HOME)
msleep(2) | [
"def",
"home",
"(",
"self",
")",
":",
"self",
".",
"row",
"=",
"0",
"self",
".",
"column",
"=",
"0",
"self",
".",
"command",
"(",
"Command",
".",
"RETURN_HOME",
")",
"msleep",
"(",
"2",
")"
] | Return to initial position (row=0, column=0) | [
"Return",
"to",
"initial",
"position",
"(",
"row",
"=",
"0",
"column",
"=",
"0",
")"
] | train | https://github.com/PedalPi/Raspberry-Physical/blob/3dc71b6997ef36d0de256c5db7a1b38178937fd5/physical/liquidcristal/liquid_crystal.py#L149-L155 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return to initial position (row=0, column=0)
### Response:
def home(self):
"""Return to initial position (row=0, column=0)"""
self.row = 0
self.column = 0
self.command(Command.RETURN_HOME)
msleep(2)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
311,
2926,
2361,
320,
654,
28,
15,
11,
3330,
28,
15,
696,
14711,
6075,
512,
755,
2162,
1214,
997,
286,
4304,
5715,
311,
2926,
2361,
320,
654,
28,
15,
11,
3330,
28,
15,
8,
7275,
286,
659,
11808,
284,
220,
15,
198,
286,
659,
13159,
284,
220,
15,
271,
286,
659,
14475,
42522,
15056,
16713,
29566,
340,
286,
10030,
3583,
7,
17,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
311,
2926,
2361,
320,
654,
28,
15,
11,
3330,
28,
15,
696,
14711,
6075,
512,
755,
2162,
1214,
997,
286,
4304,
5715,
311,
2926,
2361,
320,
654,
28,
15,
11,
3330,
28,
15,
8,
7275,
286,
659,
11808,
284,
220,
15,
198,
286,
659,
13159,
284,
220,
15,
271,
286,
659,
14475,
42522,
15056,
16713,
29566,
340,
286,
10030,
3583,
7,
17,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Knoema/knoema-python-driver | knoema/api_client.py | ApiClient.get_dimension | def get_dimension(self, dataset, dimension):
"""The method is getting information about dimension with items"""
path = '/api/1.0/meta/dataset/{}/dimension/{}'
return self._api_get(definition.Dimension, path.format(dataset, dimension)) | python | def get_dimension(self, dataset, dimension):
"""The method is getting information about dimension with items"""
path = '/api/1.0/meta/dataset/{}/dimension/{}'
return self._api_get(definition.Dimension, path.format(dataset, dimension)) | [
"def",
"get_dimension",
"(",
"self",
",",
"dataset",
",",
"dimension",
")",
":",
"path",
"=",
"'/api/1.0/meta/dataset/{}/dimension/{}'",
"return",
"self",
".",
"_api_get",
"(",
"definition",
".",
"Dimension",
",",
"path",
".",
"format",
"(",
"dataset",
",",
"dimension",
")",
")"
] | The method is getting information about dimension with items | [
"The",
"method",
"is",
"getting",
"information",
"about",
"dimension",
"with",
"items"
] | train | https://github.com/Knoema/knoema-python-driver/blob/e98b13db3e4df51c208c272e2977bfbe4c6e5532/knoema/api_client.py#L104-L108 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
The method is getting information about dimension with items
### Response:
def get_dimension(self, dataset, dimension):
"""The method is getting information about dimension with items"""
path = '/api/1.0/meta/dataset/{}/dimension/{}'
return self._api_get(definition.Dimension, path.format(dataset, dimension))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
791,
1749,
374,
3794,
2038,
922,
13167,
449,
3673,
271,
14711,
6075,
512,
755,
636,
50719,
1214,
11,
10550,
11,
13167,
5903,
286,
4304,
791,
1749,
374,
3794,
2038,
922,
13167,
449,
3673,
76683,
286,
1853,
284,
3434,
2113,
14,
16,
13,
15,
70307,
3529,
8534,
93609,
43639,
14,
6390,
9938,
286,
471,
659,
1462,
2113,
3138,
7,
18881,
54334,
11,
1853,
8180,
31635,
11,
13167,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
791,
1749,
374,
3794,
2038,
922,
13167,
449,
3673,
271,
14711,
6075,
512,
755,
636,
50719,
1214,
11,
10550,
11,
13167,
5903,
286,
4304,
791,
1749,
374,
3794,
2038,
922,
13167,
449,
3673,
76683,
286,
1853,
284,
3434,
2113,
14,
16,
13,
15,
70307,
3529,
8534,
93609,
43639,
14,
6390,
9938,
286,
471,
659,
1462,
2113,
3138,
7,
18881,
54334,
11,
1853,
8180,
31635,
11,
13167,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
jonathansick/paperweight | paperweight/texutils.py | inline | def inline(root_text,
base_dir="",
replacer=None,
ifexists_replacer=None):
"""Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (and include in-lined files).
base_dir : str
Base directory of file containing ``root_text``. Defaults to the
current working directory.
replacer : function
Function called by :func:`re.sub` to replace ``\input`` expressions
with a latex document. Changeable only for testing purposes.
ifexists_replacer : function
Function called by :func:`re.sub` to replace ``\InputIfExists``
expressions with a latex document. Changeable only for
testing purposes.
Returns
-------
txt : unicode
Text with referenced files included.
"""
def _sub_line(match):
"""Function to be used with re.sub to inline files for each match."""
fname = match.group(1)
if not fname.endswith('.tex'):
full_fname = ".".join((fname, 'tex'))
else:
full_fname = fname
full_path = os.path.abspath(os.path.join(base_dir, full_fname))
try:
with codecs.open(full_path, 'r', encoding='utf-8') as f:
included_text = f.read()
except IOError:
# TODO actually do logging here
print("Cannot open {0} for in-lining".format(full_path))
return u""
else:
# Recursively inline files
included_text = inline(included_text, base_dir=base_dir)
return included_text
def _sub_line_ifexists(match):
"""Function to be used with re.sub for the input_ifexists_pattern."""
fname = match.group(1)
if not fname.endswith('.tex'):
full_fname = ".".join((fname, 'tex'))
else:
full_fname = fname
full_path = os.path.abspath(os.path.join(base_dir, full_fname))
if os.path.exists(full_path):
with codecs.open(full_path, 'r', encoding='utf-8') as f:
included_text = f.read()
# Append extra info after input
included_text = "\n".join((included_text, match.group(2)))
else:
# Use the fall-back clause in InputIfExists
included_text = match.group(3)
# Recursively inline files
included_text = inline(included_text, base_dir=base_dir)
return included_text
# Text processing pipline
result = remove_comments(root_text)
result = input_pattern.sub(_sub_line, result)
result = include_pattern.sub(_sub_line, result)
result = input_ifexists_pattern.sub(_sub_line_ifexists, result)
return result | python | def inline(root_text,
base_dir="",
replacer=None,
ifexists_replacer=None):
"""Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (and include in-lined files).
base_dir : str
Base directory of file containing ``root_text``. Defaults to the
current working directory.
replacer : function
Function called by :func:`re.sub` to replace ``\input`` expressions
with a latex document. Changeable only for testing purposes.
ifexists_replacer : function
Function called by :func:`re.sub` to replace ``\InputIfExists``
expressions with a latex document. Changeable only for
testing purposes.
Returns
-------
txt : unicode
Text with referenced files included.
"""
def _sub_line(match):
"""Function to be used with re.sub to inline files for each match."""
fname = match.group(1)
if not fname.endswith('.tex'):
full_fname = ".".join((fname, 'tex'))
else:
full_fname = fname
full_path = os.path.abspath(os.path.join(base_dir, full_fname))
try:
with codecs.open(full_path, 'r', encoding='utf-8') as f:
included_text = f.read()
except IOError:
# TODO actually do logging here
print("Cannot open {0} for in-lining".format(full_path))
return u""
else:
# Recursively inline files
included_text = inline(included_text, base_dir=base_dir)
return included_text
def _sub_line_ifexists(match):
"""Function to be used with re.sub for the input_ifexists_pattern."""
fname = match.group(1)
if not fname.endswith('.tex'):
full_fname = ".".join((fname, 'tex'))
else:
full_fname = fname
full_path = os.path.abspath(os.path.join(base_dir, full_fname))
if os.path.exists(full_path):
with codecs.open(full_path, 'r', encoding='utf-8') as f:
included_text = f.read()
# Append extra info after input
included_text = "\n".join((included_text, match.group(2)))
else:
# Use the fall-back clause in InputIfExists
included_text = match.group(3)
# Recursively inline files
included_text = inline(included_text, base_dir=base_dir)
return included_text
# Text processing pipline
result = remove_comments(root_text)
result = input_pattern.sub(_sub_line, result)
result = include_pattern.sub(_sub_line, result)
result = input_ifexists_pattern.sub(_sub_line_ifexists, result)
return result | [
"def",
"inline",
"(",
"root_text",
",",
"base_dir",
"=",
"\"\"",
",",
"replacer",
"=",
"None",
",",
"ifexists_replacer",
"=",
"None",
")",
":",
"def",
"_sub_line",
"(",
"match",
")",
":",
"\"\"\"Function to be used with re.sub to inline files for each match.\"\"\"",
"fname",
"=",
"match",
".",
"group",
"(",
"1",
")",
"if",
"not",
"fname",
".",
"endswith",
"(",
"'.tex'",
")",
":",
"full_fname",
"=",
"\".\"",
".",
"join",
"(",
"(",
"fname",
",",
"'tex'",
")",
")",
"else",
":",
"full_fname",
"=",
"fname",
"full_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"base_dir",
",",
"full_fname",
")",
")",
"try",
":",
"with",
"codecs",
".",
"open",
"(",
"full_path",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"included_text",
"=",
"f",
".",
"read",
"(",
")",
"except",
"IOError",
":",
"# TODO actually do logging here",
"print",
"(",
"\"Cannot open {0} for in-lining\"",
".",
"format",
"(",
"full_path",
")",
")",
"return",
"u\"\"",
"else",
":",
"# Recursively inline files",
"included_text",
"=",
"inline",
"(",
"included_text",
",",
"base_dir",
"=",
"base_dir",
")",
"return",
"included_text",
"def",
"_sub_line_ifexists",
"(",
"match",
")",
":",
"\"\"\"Function to be used with re.sub for the input_ifexists_pattern.\"\"\"",
"fname",
"=",
"match",
".",
"group",
"(",
"1",
")",
"if",
"not",
"fname",
".",
"endswith",
"(",
"'.tex'",
")",
":",
"full_fname",
"=",
"\".\"",
".",
"join",
"(",
"(",
"fname",
",",
"'tex'",
")",
")",
"else",
":",
"full_fname",
"=",
"fname",
"full_path",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"base_dir",
",",
"full_fname",
")",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"full_path",
")",
":",
"with",
"codecs",
".",
"open",
"(",
"full_path",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"included_text",
"=",
"f",
".",
"read",
"(",
")",
"# Append extra info after input",
"included_text",
"=",
"\"\\n\"",
".",
"join",
"(",
"(",
"included_text",
",",
"match",
".",
"group",
"(",
"2",
")",
")",
")",
"else",
":",
"# Use the fall-back clause in InputIfExists",
"included_text",
"=",
"match",
".",
"group",
"(",
"3",
")",
"# Recursively inline files",
"included_text",
"=",
"inline",
"(",
"included_text",
",",
"base_dir",
"=",
"base_dir",
")",
"return",
"included_text",
"# Text processing pipline",
"result",
"=",
"remove_comments",
"(",
"root_text",
")",
"result",
"=",
"input_pattern",
".",
"sub",
"(",
"_sub_line",
",",
"result",
")",
"result",
"=",
"include_pattern",
".",
"sub",
"(",
"_sub_line",
",",
"result",
")",
"result",
"=",
"input_ifexists_pattern",
".",
"sub",
"(",
"_sub_line_ifexists",
",",
"result",
")",
"return",
"result"
] | Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (and include in-lined files).
base_dir : str
Base directory of file containing ``root_text``. Defaults to the
current working directory.
replacer : function
Function called by :func:`re.sub` to replace ``\input`` expressions
with a latex document. Changeable only for testing purposes.
ifexists_replacer : function
Function called by :func:`re.sub` to replace ``\InputIfExists``
expressions with a latex document. Changeable only for
testing purposes.
Returns
-------
txt : unicode
Text with referenced files included. | [
"Inline",
"all",
"input",
"latex",
"files",
"."
] | train | https://github.com/jonathansick/paperweight/blob/803535b939a56d375967cefecd5fdca81323041e/paperweight/texutils.py#L89-L164 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (and include in-lined files).
base_dir : str
Base directory of file containing ``root_text``. Defaults to the
current working directory.
replacer : function
Function called by :func:`re.sub` to replace ``\input`` expressions
with a latex document. Changeable only for testing purposes.
ifexists_replacer : function
Function called by :func:`re.sub` to replace ``\InputIfExists``
expressions with a latex document. Changeable only for
testing purposes.
Returns
-------
txt : unicode
Text with referenced files included.
### Response:
def inline(root_text,
base_dir="",
replacer=None,
ifexists_replacer=None):
"""Inline all input latex files.
The inlining is accomplished recursively. All files are opened as UTF-8
unicode files.
Parameters
----------
root_txt : unicode
Text to process (and include in-lined files).
base_dir : str
Base directory of file containing ``root_text``. Defaults to the
current working directory.
replacer : function
Function called by :func:`re.sub` to replace ``\input`` expressions
with a latex document. Changeable only for testing purposes.
ifexists_replacer : function
Function called by :func:`re.sub` to replace ``\InputIfExists``
expressions with a latex document. Changeable only for
testing purposes.
Returns
-------
txt : unicode
Text with referenced files included.
"""
def _sub_line(match):
"""Function to be used with re.sub to inline files for each match."""
fname = match.group(1)
if not fname.endswith('.tex'):
full_fname = ".".join((fname, 'tex'))
else:
full_fname = fname
full_path = os.path.abspath(os.path.join(base_dir, full_fname))
try:
with codecs.open(full_path, 'r', encoding='utf-8') as f:
included_text = f.read()
except IOError:
# TODO actually do logging here
print("Cannot open {0} for in-lining".format(full_path))
return u""
else:
# Recursively inline files
included_text = inline(included_text, base_dir=base_dir)
return included_text
def _sub_line_ifexists(match):
"""Function to be used with re.sub for the input_ifexists_pattern."""
fname = match.group(1)
if not fname.endswith('.tex'):
full_fname = ".".join((fname, 'tex'))
else:
full_fname = fname
full_path = os.path.abspath(os.path.join(base_dir, full_fname))
if os.path.exists(full_path):
with codecs.open(full_path, 'r', encoding='utf-8') as f:
included_text = f.read()
# Append extra info after input
included_text = "\n".join((included_text, match.group(2)))
else:
# Use the fall-back clause in InputIfExists
included_text = match.group(3)
# Recursively inline files
included_text = inline(included_text, base_dir=base_dir)
return included_text
# Text processing pipline
result = remove_comments(root_text)
result = input_pattern.sub(_sub_line, result)
result = include_pattern.sub(_sub_line, result)
result = input_ifexists_pattern.sub(_sub_line_ifexists, result)
return result
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
26392,
682,
1988,
45636,
3626,
382,
262,
578,
304,
35981,
374,
27332,
53947,
13,
2052,
3626,
527,
9107,
439,
20677,
12,
23,
198,
262,
27169,
3626,
382,
262,
13831,
198,
262,
31423,
262,
3789,
23244,
551,
27169,
198,
286,
2991,
311,
1920,
320,
438,
2997,
304,
90059,
3626,
4390,
262,
2385,
4432,
551,
610,
198,
286,
5464,
6352,
315,
1052,
8649,
10103,
2959,
4424,
14196,
13,
37090,
311,
279,
198,
286,
1510,
3318,
6352,
627,
262,
5911,
9779,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
1379,
14196,
24282,
198,
286,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
7649,
10096,
627,
262,
422,
16703,
1311,
91312,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
2566,
41332,
85374,
286,
24282,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
198,
286,
7649,
10096,
382,
262,
5295,
198,
262,
39707,
262,
8091,
551,
27169,
198,
286,
2991,
449,
25819,
3626,
5343,
382,
14711,
6075,
512,
755,
7533,
9387,
4424,
345,
1881,
2385,
4432,
429,
761,
1881,
5911,
9779,
5980,
345,
1881,
422,
16703,
1311,
91312,
5980,
997,
262,
4304,
26392,
682,
1988,
45636,
3626,
382,
262,
578,
304,
35981,
374,
27332,
53947,
13,
2052,
3626,
527,
9107,
439,
20677,
12,
23,
198,
262,
27169,
3626,
382,
262,
13831,
198,
262,
31423,
262,
3789,
23244,
551,
27169,
198,
286,
2991,
311,
1920,
320,
438,
2997,
304,
90059,
3626,
4390,
262,
2385,
4432,
551,
610,
198,
286,
5464,
6352,
315,
1052,
8649,
10103,
2959,
4424,
14196,
13,
37090,
311,
279,
198,
286,
1510,
3318,
6352,
627,
262,
5911,
9779,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
1379,
14196,
24282,
198,
286,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
7649,
10096,
627,
262,
422,
16703,
1311,
91312,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
2566,
41332,
85374,
286,
24282,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
198,
286,
7649,
10096,
382,
262,
5295,
198,
262,
39707,
262,
8091,
551,
27169,
198,
286,
2991,
449,
25819,
3626,
5343,
627,
262,
3270,
262,
711,
721,
2008,
6665,
26473,
997,
286,
4304,
5263,
311,
387,
1511,
449,
312,
4407,
311,
7533,
3626,
369,
1855,
2489,
14781,
286,
23364,
284,
2489,
6306,
7,
16,
340,
286,
422,
539,
23364,
41215,
4389,
34444,
11290,
310,
2539,
43434,
284,
23600,
13,
6115,
1209,
24949,
11,
364,
34444,
7132,
286,
775,
512,
310,
2539,
43434,
284,
23364,
198,
286,
2539,
2703,
284,
2709,
3960,
36652,
9835,
3960,
5563,
12952,
4432,
11,
2539,
43434,
1192,
286,
1456,
512,
310,
449,
57252,
5949,
30007,
2703,
11,
364,
81,
518,
11418,
1151,
4867,
12,
23,
873,
439,
282,
512,
394,
5343,
4424,
284,
282
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
26392,
682,
1988,
45636,
3626,
382,
262,
578,
304,
35981,
374,
27332,
53947,
13,
2052,
3626,
527,
9107,
439,
20677,
12,
23,
198,
262,
27169,
3626,
382,
262,
13831,
198,
262,
31423,
262,
3789,
23244,
551,
27169,
198,
286,
2991,
311,
1920,
320,
438,
2997,
304,
90059,
3626,
4390,
262,
2385,
4432,
551,
610,
198,
286,
5464,
6352,
315,
1052,
8649,
10103,
2959,
4424,
14196,
13,
37090,
311,
279,
198,
286,
1510,
3318,
6352,
627,
262,
5911,
9779,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
1379,
14196,
24282,
198,
286,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
7649,
10096,
627,
262,
422,
16703,
1311,
91312,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
2566,
41332,
85374,
286,
24282,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
198,
286,
7649,
10096,
382,
262,
5295,
198,
262,
39707,
262,
8091,
551,
27169,
198,
286,
2991,
449,
25819,
3626,
5343,
382,
14711,
6075,
512,
755,
7533,
9387,
4424,
345,
1881,
2385,
4432,
429,
761,
1881,
5911,
9779,
5980,
345,
1881,
422,
16703,
1311,
91312,
5980,
997,
262,
4304,
26392,
682,
1988,
45636,
3626,
382,
262,
578,
304,
35981,
374,
27332,
53947,
13,
2052,
3626,
527,
9107,
439,
20677,
12,
23,
198,
262,
27169,
3626,
382,
262,
13831,
198,
262,
31423,
262,
3789,
23244,
551,
27169,
198,
286,
2991,
311,
1920,
320,
438,
2997,
304,
90059,
3626,
4390,
262,
2385,
4432,
551,
610,
198,
286,
5464,
6352,
315,
1052,
8649,
10103,
2959,
4424,
14196,
13,
37090,
311,
279,
198,
286,
1510,
3318,
6352,
627,
262,
5911,
9779,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
1379,
14196,
24282,
198,
286,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
7649,
10096,
627,
262,
422,
16703,
1311,
91312,
551,
734,
198,
286,
5830,
2663,
555,
551,
2900,
19258,
265,
4407,
63,
311,
8454,
10103,
59,
2566,
41332,
85374,
286,
24282,
449,
264,
45636,
2246,
13,
10604,
481,
1193,
369,
198,
286,
7649,
10096,
382,
262,
5295,
198,
262,
39707,
262,
8091,
551,
27169,
198,
286,
2991,
449,
25819,
3626,
5343,
627,
262,
3270,
262,
711,
721,
2008,
6665,
26473,
997,
286,
4304,
5263,
311,
387,
1511,
449,
312,
4407,
311,
7533,
3626,
369,
1855,
2489,
14781,
286,
23364,
284,
2489,
6306,
7,
16,
340,
286,
422,
539,
23364,
41215,
4389,
34444,
11290,
310,
2539,
43434,
284,
23600,
13,
6115,
1209,
24949,
11,
364,
34444,
7132,
286,
775,
512,
310,
2539,
43434,
284,
23364,
198,
286,
2539,
2703,
284,
2709,
3960,
36652,
9835,
3960,
5563,
12952,
4432,
11,
2539,
43434,
1192,
286,
1456,
512,
310,
449,
57252,
5949,
30007,
2703,
11,
364,
81,
518,
11418,
1151,
4867,
12,
23,
873,
439,
282,
512,
394,
5343,
4424,
284,
282
] |
svenevs/exhale | exhale/graph.py | ExhaleRoot.generateNamespaceChildrenString | def generateNamespaceChildrenString(self, nspace):
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.generateSingleNamespace`, and
:func:`~exhale.graph.ExhaleRoot.generateFileNodeDocuments`. Builds the
body text for the namespace node document that links to all of the child
namespaces, structs, classes, functions, typedefs, unions, and variables
associated with this namespace.
:Parameters:
``nspace`` (ExhaleNode)
The namespace node we are generating the body text for.
:Return (str):
The string to be written to the namespace node's reStructuredText document.
'''
# sort the children
nsp_namespaces = []
nsp_nested_class_like = []
nsp_enums = []
nsp_functions = []
nsp_typedefs = []
nsp_unions = []
nsp_variables = []
for child in nspace.children:
# Skip children whose names were requested to be explicitly ignored.
should_exclude = False
for exclude in configs._compiled_listing_exclude:
if exclude.match(child.name):
should_exclude = True
if should_exclude:
continue
if child.kind == "namespace":
nsp_namespaces.append(child)
elif child.kind == "struct" or child.kind == "class":
child.findNestedClassLike(nsp_nested_class_like)
child.findNestedEnums(nsp_enums)
child.findNestedUnions(nsp_unions)
elif child.kind == "enum":
nsp_enums.append(child)
elif child.kind == "function":
nsp_functions.append(child)
elif child.kind == "typedef":
nsp_typedefs.append(child)
elif child.kind == "union":
nsp_unions.append(child)
elif child.kind == "variable":
nsp_variables.append(child)
# generate their headings if they exist (no Defines...that's not a C++ thing...)
children_stream = StringIO()
self.generateSortedChildListString(children_stream, "Namespaces", nsp_namespaces)
self.generateSortedChildListString(children_stream, "Classes", nsp_nested_class_like)
self.generateSortedChildListString(children_stream, "Enums", nsp_enums)
self.generateSortedChildListString(children_stream, "Functions", nsp_functions)
self.generateSortedChildListString(children_stream, "Typedefs", nsp_typedefs)
self.generateSortedChildListString(children_stream, "Unions", nsp_unions)
self.generateSortedChildListString(children_stream, "Variables", nsp_variables)
# read out the buffer contents, close it and return the desired string
children_string = children_stream.getvalue()
children_stream.close()
return children_string | python | def generateNamespaceChildrenString(self, nspace):
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.generateSingleNamespace`, and
:func:`~exhale.graph.ExhaleRoot.generateFileNodeDocuments`. Builds the
body text for the namespace node document that links to all of the child
namespaces, structs, classes, functions, typedefs, unions, and variables
associated with this namespace.
:Parameters:
``nspace`` (ExhaleNode)
The namespace node we are generating the body text for.
:Return (str):
The string to be written to the namespace node's reStructuredText document.
'''
# sort the children
nsp_namespaces = []
nsp_nested_class_like = []
nsp_enums = []
nsp_functions = []
nsp_typedefs = []
nsp_unions = []
nsp_variables = []
for child in nspace.children:
# Skip children whose names were requested to be explicitly ignored.
should_exclude = False
for exclude in configs._compiled_listing_exclude:
if exclude.match(child.name):
should_exclude = True
if should_exclude:
continue
if child.kind == "namespace":
nsp_namespaces.append(child)
elif child.kind == "struct" or child.kind == "class":
child.findNestedClassLike(nsp_nested_class_like)
child.findNestedEnums(nsp_enums)
child.findNestedUnions(nsp_unions)
elif child.kind == "enum":
nsp_enums.append(child)
elif child.kind == "function":
nsp_functions.append(child)
elif child.kind == "typedef":
nsp_typedefs.append(child)
elif child.kind == "union":
nsp_unions.append(child)
elif child.kind == "variable":
nsp_variables.append(child)
# generate their headings if they exist (no Defines...that's not a C++ thing...)
children_stream = StringIO()
self.generateSortedChildListString(children_stream, "Namespaces", nsp_namespaces)
self.generateSortedChildListString(children_stream, "Classes", nsp_nested_class_like)
self.generateSortedChildListString(children_stream, "Enums", nsp_enums)
self.generateSortedChildListString(children_stream, "Functions", nsp_functions)
self.generateSortedChildListString(children_stream, "Typedefs", nsp_typedefs)
self.generateSortedChildListString(children_stream, "Unions", nsp_unions)
self.generateSortedChildListString(children_stream, "Variables", nsp_variables)
# read out the buffer contents, close it and return the desired string
children_string = children_stream.getvalue()
children_stream.close()
return children_string | [
"def",
"generateNamespaceChildrenString",
"(",
"self",
",",
"nspace",
")",
":",
"# sort the children",
"nsp_namespaces",
"=",
"[",
"]",
"nsp_nested_class_like",
"=",
"[",
"]",
"nsp_enums",
"=",
"[",
"]",
"nsp_functions",
"=",
"[",
"]",
"nsp_typedefs",
"=",
"[",
"]",
"nsp_unions",
"=",
"[",
"]",
"nsp_variables",
"=",
"[",
"]",
"for",
"child",
"in",
"nspace",
".",
"children",
":",
"# Skip children whose names were requested to be explicitly ignored.",
"should_exclude",
"=",
"False",
"for",
"exclude",
"in",
"configs",
".",
"_compiled_listing_exclude",
":",
"if",
"exclude",
".",
"match",
"(",
"child",
".",
"name",
")",
":",
"should_exclude",
"=",
"True",
"if",
"should_exclude",
":",
"continue",
"if",
"child",
".",
"kind",
"==",
"\"namespace\"",
":",
"nsp_namespaces",
".",
"append",
"(",
"child",
")",
"elif",
"child",
".",
"kind",
"==",
"\"struct\"",
"or",
"child",
".",
"kind",
"==",
"\"class\"",
":",
"child",
".",
"findNestedClassLike",
"(",
"nsp_nested_class_like",
")",
"child",
".",
"findNestedEnums",
"(",
"nsp_enums",
")",
"child",
".",
"findNestedUnions",
"(",
"nsp_unions",
")",
"elif",
"child",
".",
"kind",
"==",
"\"enum\"",
":",
"nsp_enums",
".",
"append",
"(",
"child",
")",
"elif",
"child",
".",
"kind",
"==",
"\"function\"",
":",
"nsp_functions",
".",
"append",
"(",
"child",
")",
"elif",
"child",
".",
"kind",
"==",
"\"typedef\"",
":",
"nsp_typedefs",
".",
"append",
"(",
"child",
")",
"elif",
"child",
".",
"kind",
"==",
"\"union\"",
":",
"nsp_unions",
".",
"append",
"(",
"child",
")",
"elif",
"child",
".",
"kind",
"==",
"\"variable\"",
":",
"nsp_variables",
".",
"append",
"(",
"child",
")",
"# generate their headings if they exist (no Defines...that's not a C++ thing...)",
"children_stream",
"=",
"StringIO",
"(",
")",
"self",
".",
"generateSortedChildListString",
"(",
"children_stream",
",",
"\"Namespaces\"",
",",
"nsp_namespaces",
")",
"self",
".",
"generateSortedChildListString",
"(",
"children_stream",
",",
"\"Classes\"",
",",
"nsp_nested_class_like",
")",
"self",
".",
"generateSortedChildListString",
"(",
"children_stream",
",",
"\"Enums\"",
",",
"nsp_enums",
")",
"self",
".",
"generateSortedChildListString",
"(",
"children_stream",
",",
"\"Functions\"",
",",
"nsp_functions",
")",
"self",
".",
"generateSortedChildListString",
"(",
"children_stream",
",",
"\"Typedefs\"",
",",
"nsp_typedefs",
")",
"self",
".",
"generateSortedChildListString",
"(",
"children_stream",
",",
"\"Unions\"",
",",
"nsp_unions",
")",
"self",
".",
"generateSortedChildListString",
"(",
"children_stream",
",",
"\"Variables\"",
",",
"nsp_variables",
")",
"# read out the buffer contents, close it and return the desired string",
"children_string",
"=",
"children_stream",
".",
"getvalue",
"(",
")",
"children_stream",
".",
"close",
"(",
")",
"return",
"children_string"
] | Helper method for :func:`~exhale.graph.ExhaleRoot.generateSingleNamespace`, and
:func:`~exhale.graph.ExhaleRoot.generateFileNodeDocuments`. Builds the
body text for the namespace node document that links to all of the child
namespaces, structs, classes, functions, typedefs, unions, and variables
associated with this namespace.
:Parameters:
``nspace`` (ExhaleNode)
The namespace node we are generating the body text for.
:Return (str):
The string to be written to the namespace node's reStructuredText document. | [
"Helper",
"method",
"for",
":",
"func",
":",
"~exhale",
".",
"graph",
".",
"ExhaleRoot",
".",
"generateSingleNamespace",
"and",
":",
"func",
":",
"~exhale",
".",
"graph",
".",
"ExhaleRoot",
".",
"generateFileNodeDocuments",
".",
"Builds",
"the",
"body",
"text",
"for",
"the",
"namespace",
"node",
"document",
"that",
"links",
"to",
"all",
"of",
"the",
"child",
"namespaces",
"structs",
"classes",
"functions",
"typedefs",
"unions",
"and",
"variables",
"associated",
"with",
"this",
"namespace",
"."
] | train | https://github.com/svenevs/exhale/blob/fe7644829057af622e467bb529db6c03a830da99/exhale/graph.py#L2730-L2791 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Helper method for :func:`~exhale.graph.ExhaleRoot.generateSingleNamespace`, and
:func:`~exhale.graph.ExhaleRoot.generateFileNodeDocuments`. Builds the
body text for the namespace node document that links to all of the child
namespaces, structs, classes, functions, typedefs, unions, and variables
associated with this namespace.
:Parameters:
``nspace`` (ExhaleNode)
The namespace node we are generating the body text for.
:Return (str):
The string to be written to the namespace node's reStructuredText document.
### Response:
def generateNamespaceChildrenString(self, nspace):
'''
Helper method for :func:`~exhale.graph.ExhaleRoot.generateSingleNamespace`, and
:func:`~exhale.graph.ExhaleRoot.generateFileNodeDocuments`. Builds the
body text for the namespace node document that links to all of the child
namespaces, structs, classes, functions, typedefs, unions, and variables
associated with this namespace.
:Parameters:
``nspace`` (ExhaleNode)
The namespace node we are generating the body text for.
:Return (str):
The string to be written to the namespace node's reStructuredText document.
'''
# sort the children
nsp_namespaces = []
nsp_nested_class_like = []
nsp_enums = []
nsp_functions = []
nsp_typedefs = []
nsp_unions = []
nsp_variables = []
for child in nspace.children:
# Skip children whose names were requested to be explicitly ignored.
should_exclude = False
for exclude in configs._compiled_listing_exclude:
if exclude.match(child.name):
should_exclude = True
if should_exclude:
continue
if child.kind == "namespace":
nsp_namespaces.append(child)
elif child.kind == "struct" or child.kind == "class":
child.findNestedClassLike(nsp_nested_class_like)
child.findNestedEnums(nsp_enums)
child.findNestedUnions(nsp_unions)
elif child.kind == "enum":
nsp_enums.append(child)
elif child.kind == "function":
nsp_functions.append(child)
elif child.kind == "typedef":
nsp_typedefs.append(child)
elif child.kind == "union":
nsp_unions.append(child)
elif child.kind == "variable":
nsp_variables.append(child)
# generate their headings if they exist (no Defines...that's not a C++ thing...)
children_stream = StringIO()
self.generateSortedChildListString(children_stream, "Namespaces", nsp_namespaces)
self.generateSortedChildListString(children_stream, "Classes", nsp_nested_class_like)
self.generateSortedChildListString(children_stream, "Enums", nsp_enums)
self.generateSortedChildListString(children_stream, "Functions", nsp_functions)
self.generateSortedChildListString(children_stream, "Typedefs", nsp_typedefs)
self.generateSortedChildListString(children_stream, "Unions", nsp_unions)
self.generateSortedChildListString(children_stream, "Variables", nsp_variables)
# read out the buffer contents, close it and return the desired string
children_string = children_stream.getvalue()
children_stream.close()
return children_string
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5628,
1749,
369,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
11126,
23533,
7964,
323,
198,
286,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
1738,
1997,
28242,
29687,
220,
68218,
279,
198,
286,
2547,
1495,
369,
279,
4573,
2494,
2246,
430,
7902,
311,
682,
315,
279,
1716,
198,
286,
59191,
11,
63945,
11,
6989,
11,
5865,
11,
13809,
82,
11,
29590,
11,
323,
7482,
198,
286,
5938,
449,
420,
4573,
382,
286,
551,
9905,
512,
310,
10103,
4511,
1330,
14196,
320,
849,
71,
1604,
1997,
340,
394,
578,
4573,
2494,
584,
527,
24038,
279,
2547,
1495,
369,
382,
286,
551,
5715,
320,
496,
997,
310,
578,
925,
311,
387,
5439,
311,
279,
4573,
2494,
596,
312,
98557,
1199,
2246,
382,
14711,
6075,
512,
755,
7068,
23533,
11800,
707,
1214,
11,
308,
8920,
997,
286,
11414,
286,
13202,
1749,
369,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
11126,
23533,
7964,
323,
198,
286,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
1738,
1997,
28242,
29687,
220,
68218,
279,
198,
286,
2547,
1495,
369,
279,
4573,
2494,
2246,
430,
7902,
311,
682,
315,
279,
1716,
198,
286,
59191,
11,
63945,
11,
6989,
11,
5865,
11,
13809,
82,
11,
29590,
11,
323,
7482,
198,
286,
5938,
449,
420,
4573,
382,
286,
551,
9905,
512,
310,
10103,
4511,
1330,
14196,
320,
849,
71,
1604,
1997,
340,
394,
578,
4573,
2494,
584,
527,
24038,
279,
2547,
1495,
369,
382,
286,
551,
5715,
320,
496,
997,
310,
578,
925,
311,
387,
5439,
311,
279,
4573,
2494,
596,
312,
98557,
1199,
2246,
627,
286,
11414,
286,
674,
3460,
279,
2911,
198,
286,
308,
2203,
9366,
28438,
286,
284,
4260,
286,
308,
2203,
67379,
4895,
26616,
284,
4260,
286,
308,
2203,
6337,
6370,
1835,
284,
4260,
286,
308,
2203,
32808,
260,
284,
4260,
286,
308,
2203,
43211,
4313,
82,
692,
284,
4260,
286,
308,
2203,
5012,
919,
310,
284,
4260,
286,
308,
2203,
29282,
260,
284,
4260,
286,
369,
1716,
304,
308,
8920,
13664,
512,
310,
674,
26869,
2911,
6832,
5144,
1051,
11472,
311,
387,
21650,
12305,
627,
310,
1288,
89768,
284,
3641,
198,
310,
369,
22429,
304,
43409,
1462,
51945,
65314,
89768,
512,
394,
422,
22429,
11319,
18272,
2710,
997,
504,
1288,
89768,
284,
3082,
198,
310,
422,
1288,
89768,
512,
394,
3136,
271,
310,
422,
1716,
37732,
624,
330,
2280,
4764,
394,
308,
2203,
9366,
28438,
2102,
18272,
340,
310,
4508,
1716,
37732,
624,
330,
1257,
1,
477,
1716,
37732,
624,
330,
1058,
4764,
394,
1716,
2725,
73086,
1999,
13246,
1471,
2203,
67379,
4895,
26616,
340,
394,
1716,
2725,
73086,
72686,
1471,
2203,
6337,
6370,
340,
394,
1716,
2725,
73086,
1844,
919,
1471,
2203,
5012,
919,
340,
310,
4508,
1716,
37732,
624,
330,
9195,
4764,
394,
308,
2203,
6337,
6370,
2102
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5628,
1749,
369,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
11126,
23533,
7964,
323,
198,
286,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
1738,
1997,
28242,
29687,
220,
68218,
279,
198,
286,
2547,
1495,
369,
279,
4573,
2494,
2246,
430,
7902,
311,
682,
315,
279,
1716,
198,
286,
59191,
11,
63945,
11,
6989,
11,
5865,
11,
13809,
82,
11,
29590,
11,
323,
7482,
198,
286,
5938,
449,
420,
4573,
382,
286,
551,
9905,
512,
310,
10103,
4511,
1330,
14196,
320,
849,
71,
1604,
1997,
340,
394,
578,
4573,
2494,
584,
527,
24038,
279,
2547,
1495,
369,
382,
286,
551,
5715,
320,
496,
997,
310,
578,
925,
311,
387,
5439,
311,
279,
4573,
2494,
596,
312,
98557,
1199,
2246,
382,
14711,
6075,
512,
755,
7068,
23533,
11800,
707,
1214,
11,
308,
8920,
997,
286,
11414,
286,
13202,
1749,
369,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
11126,
23533,
7964,
323,
198,
286,
551,
2900,
78902,
327,
71,
1604,
10996,
5231,
71,
1604,
8605,
22793,
1738,
1997,
28242,
29687,
220,
68218,
279,
198,
286,
2547,
1495,
369,
279,
4573,
2494,
2246,
430,
7902,
311,
682,
315,
279,
1716,
198,
286,
59191,
11,
63945,
11,
6989,
11,
5865,
11,
13809,
82,
11,
29590,
11,
323,
7482,
198,
286,
5938,
449,
420,
4573,
382,
286,
551,
9905,
512,
310,
10103,
4511,
1330,
14196,
320,
849,
71,
1604,
1997,
340,
394,
578,
4573,
2494,
584,
527,
24038,
279,
2547,
1495,
369,
382,
286,
551,
5715,
320,
496,
997,
310,
578,
925,
311,
387,
5439,
311,
279,
4573,
2494,
596,
312,
98557,
1199,
2246,
627,
286,
11414,
286,
674,
3460,
279,
2911,
198,
286,
308,
2203,
9366,
28438,
286,
284,
4260,
286,
308,
2203,
67379,
4895,
26616,
284,
4260,
286,
308,
2203,
6337,
6370,
1835,
284,
4260,
286,
308,
2203,
32808,
260,
284,
4260,
286,
308,
2203,
43211,
4313,
82,
692,
284,
4260,
286,
308,
2203,
5012,
919,
310,
284,
4260,
286,
308,
2203,
29282,
260,
284,
4260,
286,
369,
1716,
304,
308,
8920,
13664,
512,
310,
674,
26869,
2911,
6832,
5144,
1051,
11472,
311,
387,
21650,
12305,
627,
310,
1288,
89768,
284,
3641,
198,
310,
369,
22429,
304,
43409,
1462,
51945,
65314,
89768,
512,
394,
422,
22429,
11319,
18272,
2710,
997,
504,
1288,
89768,
284,
3082,
198,
310,
422,
1288,
89768,
512,
394,
3136,
271,
310,
422,
1716,
37732,
624,
330,
2280,
4764,
394,
308,
2203,
9366,
28438,
2102,
18272,
340,
310,
4508,
1716,
37732,
624,
330,
1257,
1,
477,
1716,
37732,
624,
330,
1058,
4764,
394,
1716,
2725,
73086,
1999,
13246,
1471,
2203,
67379,
4895,
26616,
340,
394,
1716,
2725,
73086,
72686,
1471,
2203,
6337,
6370,
340,
394,
1716,
2725,
73086,
1844,
919,
1471,
2203,
5012,
919,
340,
310,
4508,
1716,
37732,
624,
330,
9195,
4764,
394,
308,
2203,
6337,
6370,
2102
] |
honzamach/pydgets | pydgets/widgets.py | BarChartWidget._render_content | def _render_content(self, content, **settings):
"""
Perform widget rendering, but do not print anything.
"""
result = []
bars = settings[self.SETTING_BARS]
label_width = self.chart_measure(bars)
if not settings[self.SETTING_BAR_WIDTH]:
settings[self.SETTING_BAR_WIDTH] = TERMINAL_WIDTH - label_width - 3
max_value = max(content)
i = 0
for bar in content:
result.append(self._render_bar(bars[i], bar, max_value, label_width, **settings))
i += 1
return result | python | def _render_content(self, content, **settings):
"""
Perform widget rendering, but do not print anything.
"""
result = []
bars = settings[self.SETTING_BARS]
label_width = self.chart_measure(bars)
if not settings[self.SETTING_BAR_WIDTH]:
settings[self.SETTING_BAR_WIDTH] = TERMINAL_WIDTH - label_width - 3
max_value = max(content)
i = 0
for bar in content:
result.append(self._render_bar(bars[i], bar, max_value, label_width, **settings))
i += 1
return result | [
"def",
"_render_content",
"(",
"self",
",",
"content",
",",
"*",
"*",
"settings",
")",
":",
"result",
"=",
"[",
"]",
"bars",
"=",
"settings",
"[",
"self",
".",
"SETTING_BARS",
"]",
"label_width",
"=",
"self",
".",
"chart_measure",
"(",
"bars",
")",
"if",
"not",
"settings",
"[",
"self",
".",
"SETTING_BAR_WIDTH",
"]",
":",
"settings",
"[",
"self",
".",
"SETTING_BAR_WIDTH",
"]",
"=",
"TERMINAL_WIDTH",
"-",
"label_width",
"-",
"3",
"max_value",
"=",
"max",
"(",
"content",
")",
"i",
"=",
"0",
"for",
"bar",
"in",
"content",
":",
"result",
".",
"append",
"(",
"self",
".",
"_render_bar",
"(",
"bars",
"[",
"i",
"]",
",",
"bar",
",",
"max_value",
",",
"label_width",
",",
"*",
"*",
"settings",
")",
")",
"i",
"+=",
"1",
"return",
"result"
] | Perform widget rendering, but do not print anything. | [
"Perform",
"widget",
"rendering",
"but",
"do",
"not",
"print",
"anything",
"."
] | train | https://github.com/honzamach/pydgets/blob/5ca4ce19fc2d9b5f41441fb9163810f8ca502e79/pydgets/widgets.py#L1373-L1388 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Perform widget rendering, but do not print anything.
### Response:
def _render_content(self, content, **settings):
"""
Perform widget rendering, but do not print anything.
"""
result = []
bars = settings[self.SETTING_BARS]
label_width = self.chart_measure(bars)
if not settings[self.SETTING_BAR_WIDTH]:
settings[self.SETTING_BAR_WIDTH] = TERMINAL_WIDTH - label_width - 3
max_value = max(content)
i = 0
for bar in content:
result.append(self._render_bar(bars[i], bar, max_value, label_width, **settings))
i += 1
return result
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
48051,
9264,
21568,
11,
719,
656,
539,
1194,
4205,
382,
14711,
6075,
512,
755,
721,
7472,
7647,
1214,
11,
2262,
11,
3146,
6648,
997,
286,
3270,
286,
26050,
9264,
21568,
11,
719,
656,
539,
1194,
4205,
627,
286,
3270,
286,
1121,
284,
4260,
286,
16283,
284,
5110,
14664,
42367,
26098,
1702,
17485,
2595,
286,
2440,
8086,
284,
659,
31772,
50038,
1921,
1590,
340,
286,
422,
539,
5110,
14664,
42367,
26098,
48505,
14273,
10556,
310,
5110,
14664,
42367,
26098,
48505,
14273,
60,
284,
94860,
984,
14273,
482,
2440,
8086,
482,
220,
18,
198,
286,
1973,
3220,
284,
1973,
15413,
340,
286,
602,
284,
220,
15,
198,
286,
369,
3703,
304,
2262,
512,
310,
1121,
2102,
1214,
1462,
7472,
14725,
1921,
1590,
1004,
1145,
3703,
11,
1973,
3220,
11,
2440,
8086,
11,
3146,
6648,
1192,
310,
602,
1447,
220,
16,
198,
286,
471,
1121,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
48051,
9264,
21568,
11,
719,
656,
539,
1194,
4205,
382,
14711,
6075,
512,
755,
721,
7472,
7647,
1214,
11,
2262,
11,
3146,
6648,
997,
286,
3270,
286,
26050,
9264,
21568,
11,
719,
656,
539,
1194,
4205,
627,
286,
3270,
286,
1121,
284,
4260,
286,
16283,
284,
5110,
14664,
42367,
26098,
1702,
17485,
2595,
286,
2440,
8086,
284,
659,
31772,
50038,
1921,
1590,
340,
286,
422,
539,
5110,
14664,
42367,
26098,
48505,
14273,
10556,
310,
5110,
14664,
42367,
26098,
48505,
14273,
60,
284,
94860,
984,
14273,
482,
2440,
8086,
482,
220,
18,
198,
286,
1973,
3220,
284,
1973,
15413,
340,
286,
602,
284,
220,
15,
198,
286,
369,
3703,
304,
2262,
512,
310,
1121,
2102,
1214,
1462,
7472,
14725,
1921,
1590,
1004,
1145,
3703,
11,
1973,
3220,
11,
2440,
8086,
11,
3146,
6648,
1192,
310,
602,
1447,
220,
16,
198,
286,
471,
1121,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
ewels/MultiQC | multiqc/modules/damageprofiler/damageprofiler.py | MultiqcModule.parseJSON | def parseJSON(self, f):
""" Parse the JSON output from DamageProfiler and save the summary statistics """
try:
parsed_json = json.load(f['f'])
except Exception as e:
print(e)
log.warn("Could not parse DamageProfiler JSON: '{}'".format(f['fn']))
return None
#Get sample name from JSON first
s_name = self.clean_s_name(parsed_json['metadata']['sample_name'],'')
self.add_data_source(f, s_name)
#Add 3' G to A data
self.threepGtoAfreq_data[s_name] = parsed_json['dmg_3p']
#Add 5' C to T data
self.fivepCtoTfreq_data[s_name] = parsed_json['dmg_5p']
#Add lendist forward
self.lgdist_fw_data[s_name] = parsed_json['lendist_fw']
#Add lendist reverse
self.lgdist_rv_data[s_name] = parsed_json['lendist_rv']
#Add summary metrics
self.summary_metrics_data[s_name] = parsed_json['summary_stats'] | python | def parseJSON(self, f):
""" Parse the JSON output from DamageProfiler and save the summary statistics """
try:
parsed_json = json.load(f['f'])
except Exception as e:
print(e)
log.warn("Could not parse DamageProfiler JSON: '{}'".format(f['fn']))
return None
#Get sample name from JSON first
s_name = self.clean_s_name(parsed_json['metadata']['sample_name'],'')
self.add_data_source(f, s_name)
#Add 3' G to A data
self.threepGtoAfreq_data[s_name] = parsed_json['dmg_3p']
#Add 5' C to T data
self.fivepCtoTfreq_data[s_name] = parsed_json['dmg_5p']
#Add lendist forward
self.lgdist_fw_data[s_name] = parsed_json['lendist_fw']
#Add lendist reverse
self.lgdist_rv_data[s_name] = parsed_json['lendist_rv']
#Add summary metrics
self.summary_metrics_data[s_name] = parsed_json['summary_stats'] | [
"def",
"parseJSON",
"(",
"self",
",",
"f",
")",
":",
"try",
":",
"parsed_json",
"=",
"json",
".",
"load",
"(",
"f",
"[",
"'f'",
"]",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"(",
"e",
")",
"log",
".",
"warn",
"(",
"\"Could not parse DamageProfiler JSON: '{}'\"",
".",
"format",
"(",
"f",
"[",
"'fn'",
"]",
")",
")",
"return",
"None",
"#Get sample name from JSON first",
"s_name",
"=",
"self",
".",
"clean_s_name",
"(",
"parsed_json",
"[",
"'metadata'",
"]",
"[",
"'sample_name'",
"]",
",",
"''",
")",
"self",
".",
"add_data_source",
"(",
"f",
",",
"s_name",
")",
"#Add 3' G to A data",
"self",
".",
"threepGtoAfreq_data",
"[",
"s_name",
"]",
"=",
"parsed_json",
"[",
"'dmg_3p'",
"]",
"#Add 5' C to T data",
"self",
".",
"fivepCtoTfreq_data",
"[",
"s_name",
"]",
"=",
"parsed_json",
"[",
"'dmg_5p'",
"]",
"#Add lendist forward",
"self",
".",
"lgdist_fw_data",
"[",
"s_name",
"]",
"=",
"parsed_json",
"[",
"'lendist_fw'",
"]",
"#Add lendist reverse",
"self",
".",
"lgdist_rv_data",
"[",
"s_name",
"]",
"=",
"parsed_json",
"[",
"'lendist_rv'",
"]",
"#Add summary metrics",
"self",
".",
"summary_metrics_data",
"[",
"s_name",
"]",
"=",
"parsed_json",
"[",
"'summary_stats'",
"]"
] | Parse the JSON output from DamageProfiler and save the summary statistics | [
"Parse",
"the",
"JSON",
"output",
"from",
"DamageProfiler",
"and",
"save",
"the",
"summary",
"statistics"
] | train | https://github.com/ewels/MultiQC/blob/2037d6322b2554146a74efbf869156ad20d4c4ec/multiqc/modules/damageprofiler/damageprofiler.py#L96-L123 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Parse the JSON output from DamageProfiler and save the summary statistics
### Response:
def parseJSON(self, f):
""" Parse the JSON output from DamageProfiler and save the summary statistics """
try:
parsed_json = json.load(f['f'])
except Exception as e:
print(e)
log.warn("Could not parse DamageProfiler JSON: '{}'".format(f['fn']))
return None
#Get sample name from JSON first
s_name = self.clean_s_name(parsed_json['metadata']['sample_name'],'')
self.add_data_source(f, s_name)
#Add 3' G to A data
self.threepGtoAfreq_data[s_name] = parsed_json['dmg_3p']
#Add 5' C to T data
self.fivepCtoTfreq_data[s_name] = parsed_json['dmg_5p']
#Add lendist forward
self.lgdist_fw_data[s_name] = parsed_json['lendist_fw']
#Add lendist reverse
self.lgdist_rv_data[s_name] = parsed_json['lendist_rv']
#Add summary metrics
self.summary_metrics_data[s_name] = parsed_json['summary_stats']
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14802,
279,
4823,
2612,
505,
21428,
51689,
323,
3665,
279,
12399,
13443,
271,
14711,
6075,
512,
755,
4820,
5483,
1214,
11,
282,
997,
286,
4304,
15118,
279,
4823,
2612,
505,
21428,
51689,
323,
3665,
279,
12399,
13443,
3270,
286,
1456,
512,
310,
16051,
9643,
284,
3024,
5214,
968,
681,
69,
7519,
286,
3734,
4204,
439,
384,
512,
310,
1194,
2069,
340,
310,
1515,
22123,
446,
13191,
539,
4820,
21428,
51689,
4823,
25,
70522,
3343,
2293,
968,
681,
8998,
20084,
310,
471,
2290,
271,
286,
674,
1991,
6205,
836,
505,
4823,
1176,
198,
286,
274,
1292,
284,
659,
26303,
646,
1292,
49562,
9643,
681,
18103,
4274,
13925,
1292,
40109,
1329,
286,
659,
1388,
1807,
10561,
968,
11,
274,
1292,
3707,
286,
674,
2261,
220,
18,
6,
480,
311,
362,
828,
198,
286,
659,
13991,
265,
752,
38,
998,
32,
34640,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
67,
12591,
62,
18,
79,
16049,
286,
674,
2261,
220,
20,
6,
356,
311,
350,
828,
198,
286,
659,
840,
535,
79,
34,
998,
51,
34640,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
67,
12591,
62,
20,
79,
16049,
286,
674,
2261,
39580,
380,
4741,
198,
286,
659,
929,
70,
12489,
58549,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
75,
408,
380,
58549,
16049,
286,
674,
2261,
39580,
380,
10134,
198,
286,
659,
929,
70,
12489,
1745,
85,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
75,
408,
380,
1745,
85,
16049,
286,
674,
2261,
12399,
17150,
198,
286,
659,
36441,
38786,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
1743,
15743,
4532,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14802,
279,
4823,
2612,
505,
21428,
51689,
323,
3665,
279,
12399,
13443,
271,
14711,
6075,
512,
755,
4820,
5483,
1214,
11,
282,
997,
286,
4304,
15118,
279,
4823,
2612,
505,
21428,
51689,
323,
3665,
279,
12399,
13443,
3270,
286,
1456,
512,
310,
16051,
9643,
284,
3024,
5214,
968,
681,
69,
7519,
286,
3734,
4204,
439,
384,
512,
310,
1194,
2069,
340,
310,
1515,
22123,
446,
13191,
539,
4820,
21428,
51689,
4823,
25,
70522,
3343,
2293,
968,
681,
8998,
20084,
310,
471,
2290,
271,
286,
674,
1991,
6205,
836,
505,
4823,
1176,
198,
286,
274,
1292,
284,
659,
26303,
646,
1292,
49562,
9643,
681,
18103,
4274,
13925,
1292,
40109,
1329,
286,
659,
1388,
1807,
10561,
968,
11,
274,
1292,
3707,
286,
674,
2261,
220,
18,
6,
480,
311,
362,
828,
198,
286,
659,
13991,
265,
752,
38,
998,
32,
34640,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
67,
12591,
62,
18,
79,
16049,
286,
674,
2261,
220,
20,
6,
356,
311,
350,
828,
198,
286,
659,
840,
535,
79,
34,
998,
51,
34640,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
67,
12591,
62,
20,
79,
16049,
286,
674,
2261,
39580,
380,
4741,
198,
286,
659,
929,
70,
12489,
58549,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
75,
408,
380,
58549,
16049,
286,
674,
2261,
39580,
380,
10134,
198,
286,
659,
929,
70,
12489,
1745,
85,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
75,
408,
380,
1745,
85,
16049,
286,
674,
2261,
12399,
17150,
198,
286,
659,
36441,
38786,
1807,
12144,
1292,
60,
284,
16051,
9643,
681,
1743,
15743,
4532,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
sibson/vncdotool | vncdotool/rfb.py | RFBDes.setKey | def setKey(self, key):
"""RFB protocol for authentication requires client to encrypt
challenge sent by server with password using DES method. However,
bits in each byte of the password are put in reverse order before
using it as encryption key."""
newkey = []
for ki in range(len(key)):
bsrc = ord(key[ki])
btgt = 0
for i in range(8):
if bsrc & (1 << i):
btgt = btgt | (1 << 7-i)
newkey.append(chr(btgt))
super(RFBDes, self).setKey(newkey) | python | def setKey(self, key):
"""RFB protocol for authentication requires client to encrypt
challenge sent by server with password using DES method. However,
bits in each byte of the password are put in reverse order before
using it as encryption key."""
newkey = []
for ki in range(len(key)):
bsrc = ord(key[ki])
btgt = 0
for i in range(8):
if bsrc & (1 << i):
btgt = btgt | (1 << 7-i)
newkey.append(chr(btgt))
super(RFBDes, self).setKey(newkey) | [
"def",
"setKey",
"(",
"self",
",",
"key",
")",
":",
"newkey",
"=",
"[",
"]",
"for",
"ki",
"in",
"range",
"(",
"len",
"(",
"key",
")",
")",
":",
"bsrc",
"=",
"ord",
"(",
"key",
"[",
"ki",
"]",
")",
"btgt",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"8",
")",
":",
"if",
"bsrc",
"&",
"(",
"1",
"<<",
"i",
")",
":",
"btgt",
"=",
"btgt",
"|",
"(",
"1",
"<<",
"7",
"-",
"i",
")",
"newkey",
".",
"append",
"(",
"chr",
"(",
"btgt",
")",
")",
"super",
"(",
"RFBDes",
",",
"self",
")",
".",
"setKey",
"(",
"newkey",
")"
] | RFB protocol for authentication requires client to encrypt
challenge sent by server with password using DES method. However,
bits in each byte of the password are put in reverse order before
using it as encryption key. | [
"RFB",
"protocol",
"for",
"authentication",
"requires",
"client",
"to",
"encrypt",
"challenge",
"sent",
"by",
"server",
"with",
"password",
"using",
"DES",
"method",
".",
"However",
"bits",
"in",
"each",
"byte",
"of",
"the",
"password",
"are",
"put",
"in",
"reverse",
"order",
"before",
"using",
"it",
"as",
"encryption",
"key",
"."
] | train | https://github.com/sibson/vncdotool/blob/e133a8916efaa0f5ed421e0aa737196624635b0c/vncdotool/rfb.py#L667-L680 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
RFB protocol for authentication requires client to encrypt
challenge sent by server with password using DES method. However,
bits in each byte of the password are put in reverse order before
using it as encryption key.
### Response:
def setKey(self, key):
"""RFB protocol for authentication requires client to encrypt
challenge sent by server with password using DES method. However,
bits in each byte of the password are put in reverse order before
using it as encryption key."""
newkey = []
for ki in range(len(key)):
bsrc = ord(key[ki])
btgt = 0
for i in range(8):
if bsrc & (1 << i):
btgt = btgt | (1 << 7-i)
newkey.append(chr(btgt))
super(RFBDes, self).setKey(newkey)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
49,
16606,
11766,
369,
17066,
7612,
3016,
311,
30725,
198,
1881,
8815,
3288,
555,
3622,
449,
3636,
1701,
13022,
1749,
13,
4452,
345,
1881,
9660,
304,
1855,
5027,
315,
279,
3636,
527,
2231,
304,
10134,
2015,
1603,
198,
1881,
1701,
433,
439,
26542,
1401,
382,
14711,
6075,
512,
755,
743,
1622,
1214,
11,
1401,
997,
286,
4304,
49,
16606,
11766,
369,
17066,
7612,
3016,
311,
30725,
198,
1881,
8815,
3288,
555,
3622,
449,
3636,
1701,
13022,
1749,
13,
4452,
345,
1881,
9660,
304,
1855,
5027,
315,
279,
3636,
527,
2231,
304,
10134,
2015,
1603,
198,
1881,
1701,
433,
439,
26542,
1401,
14781,
286,
502,
798,
284,
4260,
286,
369,
20548,
304,
2134,
7046,
4962,
10162,
310,
293,
3632,
284,
6141,
4962,
58,
6780,
2608,
310,
20164,
5289,
284,
220,
15,
198,
310,
369,
602,
304,
2134,
7,
23,
997,
394,
422,
293,
3632,
612,
320,
16,
1134,
602,
997,
504,
20164,
5289,
284,
20164,
5289,
765,
320,
16,
1134,
220,
22,
18064,
340,
310,
502,
798,
2102,
76807,
69517,
5289,
1192,
286,
2307,
2855,
16606,
5001,
11,
659,
570,
751,
1622,
1792,
798,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
49,
16606,
11766,
369,
17066,
7612,
3016,
311,
30725,
198,
1881,
8815,
3288,
555,
3622,
449,
3636,
1701,
13022,
1749,
13,
4452,
345,
1881,
9660,
304,
1855,
5027,
315,
279,
3636,
527,
2231,
304,
10134,
2015,
1603,
198,
1881,
1701,
433,
439,
26542,
1401,
382,
14711,
6075,
512,
755,
743,
1622,
1214,
11,
1401,
997,
286,
4304,
49,
16606,
11766,
369,
17066,
7612,
3016,
311,
30725,
198,
1881,
8815,
3288,
555,
3622,
449,
3636,
1701,
13022,
1749,
13,
4452,
345,
1881,
9660,
304,
1855,
5027,
315,
279,
3636,
527,
2231,
304,
10134,
2015,
1603,
198,
1881,
1701,
433,
439,
26542,
1401,
14781,
286,
502,
798,
284,
4260,
286,
369,
20548,
304,
2134,
7046,
4962,
10162,
310,
293,
3632,
284,
6141,
4962,
58,
6780,
2608,
310,
20164,
5289,
284,
220,
15,
198,
310,
369,
602,
304,
2134,
7,
23,
997,
394,
422,
293,
3632,
612,
320,
16,
1134,
602,
997,
504,
20164,
5289,
284,
20164,
5289,
765,
320,
16,
1134,
220,
22,
18064,
340,
310,
502,
798,
2102,
76807,
69517,
5289,
1192,
286,
2307,
2855,
16606,
5001,
11,
659,
570,
751,
1622,
1792,
798,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
calmjs/calmjs | src/calmjs/interrogate.py | yield_amd_require_string_arguments | def yield_amd_require_string_arguments(
node, pos,
reserved_module=reserved_module, wrapped=define_wrapped):
"""
This yields only strings within the lists provided in the argument
list at the specified position from a function call.
Originally, this was implemented for yield a list of module names to
be imported as represented by this given node, which must be of the
FunctionCall type.
"""
for i, child in enumerate(node.args.items[pos]):
if isinstance(child, asttypes.String):
result = to_str(child)
if ((result not in reserved_module) and (
result != define_wrapped.get(i))):
yield result | python | def yield_amd_require_string_arguments(
node, pos,
reserved_module=reserved_module, wrapped=define_wrapped):
"""
This yields only strings within the lists provided in the argument
list at the specified position from a function call.
Originally, this was implemented for yield a list of module names to
be imported as represented by this given node, which must be of the
FunctionCall type.
"""
for i, child in enumerate(node.args.items[pos]):
if isinstance(child, asttypes.String):
result = to_str(child)
if ((result not in reserved_module) and (
result != define_wrapped.get(i))):
yield result | [
"def",
"yield_amd_require_string_arguments",
"(",
"node",
",",
"pos",
",",
"reserved_module",
"=",
"reserved_module",
",",
"wrapped",
"=",
"define_wrapped",
")",
":",
"for",
"i",
",",
"child",
"in",
"enumerate",
"(",
"node",
".",
"args",
".",
"items",
"[",
"pos",
"]",
")",
":",
"if",
"isinstance",
"(",
"child",
",",
"asttypes",
".",
"String",
")",
":",
"result",
"=",
"to_str",
"(",
"child",
")",
"if",
"(",
"(",
"result",
"not",
"in",
"reserved_module",
")",
"and",
"(",
"result",
"!=",
"define_wrapped",
".",
"get",
"(",
"i",
")",
")",
")",
":",
"yield",
"result"
] | This yields only strings within the lists provided in the argument
list at the specified position from a function call.
Originally, this was implemented for yield a list of module names to
be imported as represented by this given node, which must be of the
FunctionCall type. | [
"This",
"yields",
"only",
"strings",
"within",
"the",
"lists",
"provided",
"in",
"the",
"argument",
"list",
"at",
"the",
"specified",
"position",
"from",
"a",
"function",
"call",
"."
] | train | https://github.com/calmjs/calmjs/blob/b9b407c2b6a7662da64bccba93bb8d92e7a5fafd/src/calmjs/interrogate.py#L110-L127 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
This yields only strings within the lists provided in the argument
list at the specified position from a function call.
Originally, this was implemented for yield a list of module names to
be imported as represented by this given node, which must be of the
FunctionCall type.
### Response:
def yield_amd_require_string_arguments(
node, pos,
reserved_module=reserved_module, wrapped=define_wrapped):
"""
This yields only strings within the lists provided in the argument
list at the specified position from a function call.
Originally, this was implemented for yield a list of module names to
be imported as represented by this given node, which must be of the
FunctionCall type.
"""
for i, child in enumerate(node.args.items[pos]):
if isinstance(child, asttypes.String):
result = to_str(child)
if ((result not in reserved_module) and (
result != define_wrapped.get(i))):
yield result
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2028,
36508,
1193,
9246,
2949,
279,
11725,
3984,
304,
279,
5811,
198,
262,
1160,
520,
279,
5300,
2361,
505,
264,
734,
1650,
382,
262,
25842,
11,
420,
574,
11798,
369,
7692,
264,
1160,
315,
4793,
5144,
311,
198,
262,
387,
25973,
439,
15609,
555,
420,
2728,
2494,
11,
902,
2011,
387,
315,
279,
198,
262,
5830,
7368,
955,
382,
14711,
6075,
512,
755,
7692,
23729,
67,
14112,
3991,
44533,
1021,
286,
2494,
11,
1153,
345,
286,
4694,
10983,
28,
52202,
10983,
11,
20037,
28,
1312,
45174,
5795,
997,
262,
3270,
262,
1115,
36508,
1193,
9246,
2949,
279,
11725,
3984,
304,
279,
5811,
198,
262,
1160,
520,
279,
5300,
2361,
505,
264,
734,
1650,
382,
262,
25842,
11,
420,
574,
11798,
369,
7692,
264,
1160,
315,
4793,
5144,
311,
198,
262,
387,
25973,
439,
15609,
555,
420,
2728,
2494,
11,
902,
2011,
387,
315,
279,
198,
262,
5830,
7368,
955,
627,
262,
12713,
262,
369,
602,
11,
1716,
304,
13555,
7103,
16769,
9812,
22376,
22953,
286,
422,
11656,
18272,
11,
12025,
9426,
6567,
997,
310,
1121,
284,
311,
2966,
18272,
340,
310,
422,
1819,
1407,
539,
304,
4694,
10983,
8,
323,
2456,
504,
1121,
976,
7124,
45174,
5795,
673,
1998,
97300,
394,
7692,
1121,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
2028,
36508,
1193,
9246,
2949,
279,
11725,
3984,
304,
279,
5811,
198,
262,
1160,
520,
279,
5300,
2361,
505,
264,
734,
1650,
382,
262,
25842,
11,
420,
574,
11798,
369,
7692,
264,
1160,
315,
4793,
5144,
311,
198,
262,
387,
25973,
439,
15609,
555,
420,
2728,
2494,
11,
902,
2011,
387,
315,
279,
198,
262,
5830,
7368,
955,
382,
14711,
6075,
512,
755,
7692,
23729,
67,
14112,
3991,
44533,
1021,
286,
2494,
11,
1153,
345,
286,
4694,
10983,
28,
52202,
10983,
11,
20037,
28,
1312,
45174,
5795,
997,
262,
3270,
262,
1115,
36508,
1193,
9246,
2949,
279,
11725,
3984,
304,
279,
5811,
198,
262,
1160,
520,
279,
5300,
2361,
505,
264,
734,
1650,
382,
262,
25842,
11,
420,
574,
11798,
369,
7692,
264,
1160,
315,
4793,
5144,
311,
198,
262,
387,
25973,
439,
15609,
555,
420,
2728,
2494,
11,
902,
2011,
387,
315,
279,
198,
262,
5830,
7368,
955,
627,
262,
12713,
262,
369,
602,
11,
1716,
304,
13555,
7103,
16769,
9812,
22376,
22953,
286,
422,
11656,
18272,
11,
12025,
9426,
6567,
997,
310,
1121,
284,
311,
2966,
18272,
340,
310,
422,
1819,
1407,
539,
304,
4694,
10983,
8,
323,
2456,
504,
1121,
976,
7124,
45174,
5795,
673,
1998,
97300,
394,
7692,
1121,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pandas-dev/pandas | pandas/core/generic.py | NDFrame._set_as_cached | def _set_as_cached(self, item, cacher):
"""Set the _cacher attribute on the calling object with a weakref to
cacher.
"""
self._cacher = (item, weakref.ref(cacher)) | python | def _set_as_cached(self, item, cacher):
"""Set the _cacher attribute on the calling object with a weakref to
cacher.
"""
self._cacher = (item, weakref.ref(cacher)) | [
"def",
"_set_as_cached",
"(",
"self",
",",
"item",
",",
"cacher",
")",
":",
"self",
".",
"_cacher",
"=",
"(",
"item",
",",
"weakref",
".",
"ref",
"(",
"cacher",
")",
")"
] | Set the _cacher attribute on the calling object with a weakref to
cacher. | [
"Set",
"the",
"_cacher",
"attribute",
"on",
"the",
"calling",
"object",
"with",
"a",
"weakref",
"to",
"cacher",
"."
] | train | https://github.com/pandas-dev/pandas/blob/9feb3ad92cc0397a04b665803a49299ee7aa1037/pandas/core/generic.py#L3100-L3104 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Set the _cacher attribute on the calling object with a weakref to
cacher.
### Response:
def _set_as_cached(self, item, cacher):
"""Set the _cacher attribute on the calling object with a weakref to
cacher.
"""
self._cacher = (item, weakref.ref(cacher))
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
279,
721,
66,
11252,
7180,
389,
279,
8260,
1665,
449,
264,
7621,
1116,
311,
198,
286,
272,
11252,
382,
14711,
6075,
512,
755,
721,
751,
12162,
65469,
1214,
11,
1537,
11,
272,
11252,
997,
286,
4304,
1681,
279,
721,
66,
11252,
7180,
389,
279,
8260,
1665,
449,
264,
7621,
1116,
311,
198,
286,
272,
11252,
627,
286,
3270,
286,
659,
1462,
66,
11252,
284,
320,
1224,
11,
7621,
1116,
11300,
1361,
11252,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1681,
279,
721,
66,
11252,
7180,
389,
279,
8260,
1665,
449,
264,
7621,
1116,
311,
198,
286,
272,
11252,
382,
14711,
6075,
512,
755,
721,
751,
12162,
65469,
1214,
11,
1537,
11,
272,
11252,
997,
286,
4304,
1681,
279,
721,
66,
11252,
7180,
389,
279,
8260,
1665,
449,
264,
7621,
1116,
311,
198,
286,
272,
11252,
627,
286,
3270,
286,
659,
1462,
66,
11252,
284,
320,
1224,
11,
7621,
1116,
11300,
1361,
11252,
1192,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
fkarb/xltable | xltable/table.py | Table.get_data | def get_data(self, workbook, row, col, formula_values={}):
"""
:return: 2d numpy array for this table with any formulas resolved to the final
excel formula.
:param xltable.Workbook workbook: Workbook the table has been added to.
:param int row: Row where the table will start in the sheet (used for resolving formulas).
:param int col: Column where the table will start in the sheet (used for resolving formulas).
:param formula_values: dict to add pre-calculated formula values to (keyed by row, col).
"""
if workbook:
prev_table = workbook.active_table
workbook.active_table = self
try:
return self._get_data_impl(workbook, row, col, formula_values)
finally:
if workbook:
workbook.active_table = prev_table | python | def get_data(self, workbook, row, col, formula_values={}):
"""
:return: 2d numpy array for this table with any formulas resolved to the final
excel formula.
:param xltable.Workbook workbook: Workbook the table has been added to.
:param int row: Row where the table will start in the sheet (used for resolving formulas).
:param int col: Column where the table will start in the sheet (used for resolving formulas).
:param formula_values: dict to add pre-calculated formula values to (keyed by row, col).
"""
if workbook:
prev_table = workbook.active_table
workbook.active_table = self
try:
return self._get_data_impl(workbook, row, col, formula_values)
finally:
if workbook:
workbook.active_table = prev_table | [
"def",
"get_data",
"(",
"self",
",",
"workbook",
",",
"row",
",",
"col",
",",
"formula_values",
"=",
"{",
"}",
")",
":",
"if",
"workbook",
":",
"prev_table",
"=",
"workbook",
".",
"active_table",
"workbook",
".",
"active_table",
"=",
"self",
"try",
":",
"return",
"self",
".",
"_get_data_impl",
"(",
"workbook",
",",
"row",
",",
"col",
",",
"formula_values",
")",
"finally",
":",
"if",
"workbook",
":",
"workbook",
".",
"active_table",
"=",
"prev_table"
] | :return: 2d numpy array for this table with any formulas resolved to the final
excel formula.
:param xltable.Workbook workbook: Workbook the table has been added to.
:param int row: Row where the table will start in the sheet (used for resolving formulas).
:param int col: Column where the table will start in the sheet (used for resolving formulas).
:param formula_values: dict to add pre-calculated formula values to (keyed by row, col). | [
":",
"return",
":",
"2d",
"numpy",
"array",
"for",
"this",
"table",
"with",
"any",
"formulas",
"resolved",
"to",
"the",
"final",
"excel",
"formula",
".",
":",
"param",
"xltable",
".",
"Workbook",
"workbook",
":",
"Workbook",
"the",
"table",
"has",
"been",
"added",
"to",
".",
":",
"param",
"int",
"row",
":",
"Row",
"where",
"the",
"table",
"will",
"start",
"in",
"the",
"sheet",
"(",
"used",
"for",
"resolving",
"formulas",
")",
".",
":",
"param",
"int",
"col",
":",
"Column",
"where",
"the",
"table",
"will",
"start",
"in",
"the",
"sheet",
"(",
"used",
"for",
"resolving",
"formulas",
")",
".",
":",
"param",
"formula_values",
":",
"dict",
"to",
"add",
"pre",
"-",
"calculated",
"formula",
"values",
"to",
"(",
"keyed",
"by",
"row",
"col",
")",
"."
] | train | https://github.com/fkarb/xltable/blob/7a592642d27ad5ee90d2aa8c26338abaa9d84bea/xltable/table.py#L204-L220 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
:return: 2d numpy array for this table with any formulas resolved to the final
excel formula.
:param xltable.Workbook workbook: Workbook the table has been added to.
:param int row: Row where the table will start in the sheet (used for resolving formulas).
:param int col: Column where the table will start in the sheet (used for resolving formulas).
:param formula_values: dict to add pre-calculated formula values to (keyed by row, col).
### Response:
def get_data(self, workbook, row, col, formula_values={}):
"""
:return: 2d numpy array for this table with any formulas resolved to the final
excel formula.
:param xltable.Workbook workbook: Workbook the table has been added to.
:param int row: Row where the table will start in the sheet (used for resolving formulas).
:param int col: Column where the table will start in the sheet (used for resolving formulas).
:param formula_values: dict to add pre-calculated formula values to (keyed by row, col).
"""
if workbook:
prev_table = workbook.active_table
workbook.active_table = self
try:
return self._get_data_impl(workbook, row, col, formula_values)
finally:
if workbook:
workbook.active_table = prev_table
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
67402,
25,
220,
17,
67,
8760,
1358,
369,
420,
2007,
449,
904,
55179,
20250,
311,
279,
1620,
198,
338,
25555,
15150,
627,
286,
551,
913,
34108,
2048,
29848,
2239,
46255,
25,
84562,
279,
2007,
706,
1027,
3779,
311,
627,
286,
551,
913,
528,
2872,
25,
11035,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
528,
1400,
25,
9516,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
15150,
9324,
25,
6587,
311,
923,
864,
49236,
50904,
15150,
2819,
311,
320,
798,
291,
555,
2872,
11,
1400,
3677,
14711,
6075,
512,
755,
636,
1807,
1214,
11,
46255,
11,
2872,
11,
1400,
11,
15150,
9324,
69185,
997,
286,
3270,
286,
551,
693,
25,
220,
17,
67,
8760,
1358,
369,
420,
2007,
449,
904,
55179,
20250,
311,
279,
1620,
198,
338,
25555,
15150,
627,
286,
551,
913,
34108,
2048,
29848,
2239,
46255,
25,
84562,
279,
2007,
706,
1027,
3779,
311,
627,
286,
551,
913,
528,
2872,
25,
11035,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
528,
1400,
25,
9516,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
15150,
9324,
25,
6587,
311,
923,
864,
49236,
50904,
15150,
2819,
311,
320,
798,
291,
555,
2872,
11,
1400,
4390,
286,
3270,
286,
422,
46255,
512,
310,
8031,
5350,
284,
46255,
13930,
5350,
198,
310,
46255,
13930,
5350,
284,
659,
198,
286,
1456,
512,
310,
471,
659,
1462,
456,
1807,
21683,
32570,
2239,
11,
2872,
11,
1400,
11,
15150,
9324,
340,
286,
5616,
512,
310,
422,
46255,
512,
394,
46255,
13930,
5350,
284,
8031,
5350,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
67402,
25,
220,
17,
67,
8760,
1358,
369,
420,
2007,
449,
904,
55179,
20250,
311,
279,
1620,
198,
338,
25555,
15150,
627,
286,
551,
913,
34108,
2048,
29848,
2239,
46255,
25,
84562,
279,
2007,
706,
1027,
3779,
311,
627,
286,
551,
913,
528,
2872,
25,
11035,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
528,
1400,
25,
9516,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
15150,
9324,
25,
6587,
311,
923,
864,
49236,
50904,
15150,
2819,
311,
320,
798,
291,
555,
2872,
11,
1400,
3677,
14711,
6075,
512,
755,
636,
1807,
1214,
11,
46255,
11,
2872,
11,
1400,
11,
15150,
9324,
69185,
997,
286,
3270,
286,
551,
693,
25,
220,
17,
67,
8760,
1358,
369,
420,
2007,
449,
904,
55179,
20250,
311,
279,
1620,
198,
338,
25555,
15150,
627,
286,
551,
913,
34108,
2048,
29848,
2239,
46255,
25,
84562,
279,
2007,
706,
1027,
3779,
311,
627,
286,
551,
913,
528,
2872,
25,
11035,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
528,
1400,
25,
9516,
1405,
279,
2007,
690,
1212,
304,
279,
11071,
320,
2656,
369,
53583,
55179,
4390,
286,
551,
913,
15150,
9324,
25,
6587,
311,
923,
864,
49236,
50904,
15150,
2819,
311,
320,
798,
291,
555,
2872,
11,
1400,
4390,
286,
3270,
286,
422,
46255,
512,
310,
8031,
5350,
284,
46255,
13930,
5350,
198,
310,
46255,
13930,
5350,
284,
659,
198,
286,
1456,
512,
310,
471,
659,
1462,
456,
1807,
21683,
32570,
2239,
11,
2872,
11,
1400,
11,
15150,
9324,
340,
286,
5616,
512,
310,
422,
46255,
512,
394,
46255,
13930,
5350,
284,
8031,
5350,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
wikimedia/ores | ores/wsgi/util.py | build_precache_map | def build_precache_map(config):
"""
Build a mapping of contexts and models from the configuration
"""
precache_map = {}
ss_name = config['ores']['scoring_system']
for context in config['scoring_systems'][ss_name]['scoring_contexts']:
precache_map[context] = {}
for model in config['scoring_contexts'][context].get('precache', []):
precached_config = \
config['scoring_contexts'][context]['precache'][model]
events = precached_config['on']
if len(set(events) - AVAILABLE_EVENTS) > 0:
logger.warning("{0} events are not available"
.format(set(events) - AVAILABLE_EVENTS))
for event in precached_config['on']:
if event in precache_map[context]:
precache_map[context][event].add(model)
else:
precache_map[context][event] = {model}
logger.debug("Setting up precaching for {0} in {1} on {2}"
.format(model, context, event))
return precache_map | python | def build_precache_map(config):
"""
Build a mapping of contexts and models from the configuration
"""
precache_map = {}
ss_name = config['ores']['scoring_system']
for context in config['scoring_systems'][ss_name]['scoring_contexts']:
precache_map[context] = {}
for model in config['scoring_contexts'][context].get('precache', []):
precached_config = \
config['scoring_contexts'][context]['precache'][model]
events = precached_config['on']
if len(set(events) - AVAILABLE_EVENTS) > 0:
logger.warning("{0} events are not available"
.format(set(events) - AVAILABLE_EVENTS))
for event in precached_config['on']:
if event in precache_map[context]:
precache_map[context][event].add(model)
else:
precache_map[context][event] = {model}
logger.debug("Setting up precaching for {0} in {1} on {2}"
.format(model, context, event))
return precache_map | [
"def",
"build_precache_map",
"(",
"config",
")",
":",
"precache_map",
"=",
"{",
"}",
"ss_name",
"=",
"config",
"[",
"'ores'",
"]",
"[",
"'scoring_system'",
"]",
"for",
"context",
"in",
"config",
"[",
"'scoring_systems'",
"]",
"[",
"ss_name",
"]",
"[",
"'scoring_contexts'",
"]",
":",
"precache_map",
"[",
"context",
"]",
"=",
"{",
"}",
"for",
"model",
"in",
"config",
"[",
"'scoring_contexts'",
"]",
"[",
"context",
"]",
".",
"get",
"(",
"'precache'",
",",
"[",
"]",
")",
":",
"precached_config",
"=",
"config",
"[",
"'scoring_contexts'",
"]",
"[",
"context",
"]",
"[",
"'precache'",
"]",
"[",
"model",
"]",
"events",
"=",
"precached_config",
"[",
"'on'",
"]",
"if",
"len",
"(",
"set",
"(",
"events",
")",
"-",
"AVAILABLE_EVENTS",
")",
">",
"0",
":",
"logger",
".",
"warning",
"(",
"\"{0} events are not available\"",
".",
"format",
"(",
"set",
"(",
"events",
")",
"-",
"AVAILABLE_EVENTS",
")",
")",
"for",
"event",
"in",
"precached_config",
"[",
"'on'",
"]",
":",
"if",
"event",
"in",
"precache_map",
"[",
"context",
"]",
":",
"precache_map",
"[",
"context",
"]",
"[",
"event",
"]",
".",
"add",
"(",
"model",
")",
"else",
":",
"precache_map",
"[",
"context",
"]",
"[",
"event",
"]",
"=",
"{",
"model",
"}",
"logger",
".",
"debug",
"(",
"\"Setting up precaching for {0} in {1} on {2}\"",
".",
"format",
"(",
"model",
",",
"context",
",",
"event",
")",
")",
"return",
"precache_map"
] | Build a mapping of contexts and models from the configuration | [
"Build",
"a",
"mapping",
"of",
"contexts",
"and",
"models",
"from",
"the",
"configuration"
] | train | https://github.com/wikimedia/ores/blob/75599b6ba0172c86d94f7f7e1e05a3c282333a18/ores/wsgi/util.py#L209-L233 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Build a mapping of contexts and models from the configuration
### Response:
def build_precache_map(config):
"""
Build a mapping of contexts and models from the configuration
"""
precache_map = {}
ss_name = config['ores']['scoring_system']
for context in config['scoring_systems'][ss_name]['scoring_contexts']:
precache_map[context] = {}
for model in config['scoring_contexts'][context].get('precache', []):
precached_config = \
config['scoring_contexts'][context]['precache'][model]
events = precached_config['on']
if len(set(events) - AVAILABLE_EVENTS) > 0:
logger.warning("{0} events are not available"
.format(set(events) - AVAILABLE_EVENTS))
for event in precached_config['on']:
if event in precache_map[context]:
precache_map[context][event].add(model)
else:
precache_map[context][event] = {model}
logger.debug("Setting up precaching for {0} in {1} on {2}"
.format(model, context, event))
return precache_map
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11313,
264,
13021,
315,
38697,
323,
4211,
505,
279,
6683,
271,
14711,
6075,
512,
755,
1977,
60279,
1815,
5489,
8928,
997,
262,
3270,
262,
8012,
264,
13021,
315,
38697,
323,
4211,
505,
279,
6683,
198,
262,
3270,
262,
5956,
1815,
5489,
284,
5731,
262,
11107,
1292,
284,
2242,
681,
4692,
4274,
2445,
5620,
18155,
4532,
262,
369,
2317,
304,
2242,
681,
2445,
5620,
18155,
82,
10136,
784,
1292,
5465,
2445,
5620,
8634,
82,
18888,
286,
5956,
1815,
5489,
58,
2196,
60,
284,
5731,
286,
369,
1646,
304,
2242,
681,
2445,
5620,
8634,
82,
10136,
2196,
948,
456,
493,
1762,
9544,
518,
3132,
997,
310,
5956,
3939,
5445,
284,
3120,
394,
2242,
681,
2445,
5620,
8634,
82,
10136,
2196,
5465,
1762,
9544,
10136,
2590,
2595,
310,
4455,
284,
5956,
3939,
5445,
681,
263,
4532,
310,
422,
2479,
14505,
51596,
8,
482,
68819,
62457,
8,
871,
220,
15,
512,
394,
6050,
29936,
14303,
15,
92,
4455,
527,
539,
2561,
702,
7714,
662,
2293,
14505,
51596,
8,
482,
68819,
62457,
1192,
310,
369,
1567,
304,
5956,
3939,
5445,
681,
263,
18888,
394,
422,
1567,
304,
5956,
1815,
5489,
58,
2196,
10556,
504,
5956,
1815,
5489,
58,
2196,
1483,
3163,
948,
723,
7790,
340,
394,
775,
512,
504,
5956,
1815,
5489,
58,
2196,
1483,
3163,
60,
284,
314,
2590,
534,
394,
6050,
8042,
446,
15762,
709,
5956,
12092,
369,
314,
15,
92,
304,
314,
16,
92,
389,
314,
17,
11444,
6663,
662,
2293,
7790,
11,
2317,
11,
1567,
4489,
262,
471,
5956,
1815,
5489,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
11313,
264,
13021,
315,
38697,
323,
4211,
505,
279,
6683,
271,
14711,
6075,
512,
755,
1977,
60279,
1815,
5489,
8928,
997,
262,
3270,
262,
8012,
264,
13021,
315,
38697,
323,
4211,
505,
279,
6683,
198,
262,
3270,
262,
5956,
1815,
5489,
284,
5731,
262,
11107,
1292,
284,
2242,
681,
4692,
4274,
2445,
5620,
18155,
4532,
262,
369,
2317,
304,
2242,
681,
2445,
5620,
18155,
82,
10136,
784,
1292,
5465,
2445,
5620,
8634,
82,
18888,
286,
5956,
1815,
5489,
58,
2196,
60,
284,
5731,
286,
369,
1646,
304,
2242,
681,
2445,
5620,
8634,
82,
10136,
2196,
948,
456,
493,
1762,
9544,
518,
3132,
997,
310,
5956,
3939,
5445,
284,
3120,
394,
2242,
681,
2445,
5620,
8634,
82,
10136,
2196,
5465,
1762,
9544,
10136,
2590,
2595,
310,
4455,
284,
5956,
3939,
5445,
681,
263,
4532,
310,
422,
2479,
14505,
51596,
8,
482,
68819,
62457,
8,
871,
220,
15,
512,
394,
6050,
29936,
14303,
15,
92,
4455,
527,
539,
2561,
702,
7714,
662,
2293,
14505,
51596,
8,
482,
68819,
62457,
1192,
310,
369,
1567,
304,
5956,
3939,
5445,
681,
263,
18888,
394,
422,
1567,
304,
5956,
1815,
5489,
58,
2196,
10556,
504,
5956,
1815,
5489,
58,
2196,
1483,
3163,
948,
723,
7790,
340,
394,
775,
512,
504,
5956,
1815,
5489,
58,
2196,
1483,
3163,
60,
284,
314,
2590,
534,
394,
6050,
8042,
446,
15762,
709,
5956,
12092,
369,
314,
15,
92,
304,
314,
16,
92,
389,
314,
17,
11444,
6663,
662,
2293,
7790,
11,
2317,
11,
1567,
4489,
262,
471,
5956,
1815,
5489,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
skelsec/minikerberos | minikerberos/communication.py | KerbrosComm.get_TGS | def get_TGS(self, spn_user, override_etype = None):
"""
Requests a TGS ticket for the specified user.
Retruns the TGS ticket, end the decrpyted encTGSRepPart.
spn_user: KerberosTarget: the service user you want to get TGS for.
override_etype: None or list of etype values (int) Used mostly for kerberoasting, will override the AP_REQ supported etype values (which is derived from the TGT) to be able to recieve whatever tgs tiecket
"""
#construct tgs_req
logger.debug('Constructing TGS request for user %s' % spn_user.get_formatted_pname())
now = datetime.datetime.utcnow()
kdc_req_body = {}
kdc_req_body['kdc-options'] = KDCOptions(set(['forwardable','renewable','renewable_ok', 'canonicalize']))
kdc_req_body['realm'] = spn_user.domain.upper()
kdc_req_body['sname'] = PrincipalName({'name-type': NAME_TYPE.SRV_INST.value, 'name-string': spn_user.get_principalname()})
kdc_req_body['till'] = now + datetime.timedelta(days=1)
kdc_req_body['nonce'] = secrets.randbits(31)
if override_etype:
kdc_req_body['etype'] = override_etype
else:
kdc_req_body['etype'] = [self.kerberos_cipher_type]
authenticator_data = {}
authenticator_data['authenticator-vno'] = krb5_pvno
authenticator_data['crealm'] = Realm(self.kerberos_TGT['crealm'])
authenticator_data['cname'] = self.kerberos_TGT['cname']
authenticator_data['cusec'] = now.microsecond
authenticator_data['ctime'] = now
authenticator_data_enc = self.kerberos_cipher.encrypt(self.kerberos_session_key, 7, Authenticator(authenticator_data).dump(), None)
ap_req = {}
ap_req['pvno'] = krb5_pvno
ap_req['msg-type'] = MESSAGE_TYPE.KRB_AP_REQ.value
ap_req['ap-options'] = APOptions(set())
ap_req['ticket'] = Ticket(self.kerberos_TGT['ticket'])
ap_req['authenticator'] = EncryptedData({'etype': self.kerberos_cipher_type, 'cipher': authenticator_data_enc})
pa_data_1 = {}
pa_data_1['padata-type'] = PaDataType.TGS_REQ.value
pa_data_1['padata-value'] = AP_REQ(ap_req).dump()
kdc_req = {}
kdc_req['pvno'] = krb5_pvno
kdc_req['msg-type'] = MESSAGE_TYPE.KRB_TGS_REQ.value
kdc_req['padata'] = [pa_data_1]
kdc_req['req-body'] = KDC_REQ_BODY(kdc_req_body)
req = TGS_REQ(kdc_req)
logger.debug('Constructing TGS request to server')
rep = self.ksoc.sendrecv(req.dump())
logger.debug('Got TGS reply, decrypting...')
tgs = rep.native
encTGSRepPart = EncTGSRepPart.load(self.kerberos_cipher.decrypt(self.kerberos_session_key, 8, tgs['enc-part']['cipher'])).native
key = Key(encTGSRepPart['key']['keytype'], encTGSRepPart['key']['keyvalue'])
self.ccache.add_tgs(tgs, encTGSRepPart)
logger.debug('Got valid TGS reply')
self.kerberos_TGS = tgs
return tgs, encTGSRepPart, key | python | def get_TGS(self, spn_user, override_etype = None):
"""
Requests a TGS ticket for the specified user.
Retruns the TGS ticket, end the decrpyted encTGSRepPart.
spn_user: KerberosTarget: the service user you want to get TGS for.
override_etype: None or list of etype values (int) Used mostly for kerberoasting, will override the AP_REQ supported etype values (which is derived from the TGT) to be able to recieve whatever tgs tiecket
"""
#construct tgs_req
logger.debug('Constructing TGS request for user %s' % spn_user.get_formatted_pname())
now = datetime.datetime.utcnow()
kdc_req_body = {}
kdc_req_body['kdc-options'] = KDCOptions(set(['forwardable','renewable','renewable_ok', 'canonicalize']))
kdc_req_body['realm'] = spn_user.domain.upper()
kdc_req_body['sname'] = PrincipalName({'name-type': NAME_TYPE.SRV_INST.value, 'name-string': spn_user.get_principalname()})
kdc_req_body['till'] = now + datetime.timedelta(days=1)
kdc_req_body['nonce'] = secrets.randbits(31)
if override_etype:
kdc_req_body['etype'] = override_etype
else:
kdc_req_body['etype'] = [self.kerberos_cipher_type]
authenticator_data = {}
authenticator_data['authenticator-vno'] = krb5_pvno
authenticator_data['crealm'] = Realm(self.kerberos_TGT['crealm'])
authenticator_data['cname'] = self.kerberos_TGT['cname']
authenticator_data['cusec'] = now.microsecond
authenticator_data['ctime'] = now
authenticator_data_enc = self.kerberos_cipher.encrypt(self.kerberos_session_key, 7, Authenticator(authenticator_data).dump(), None)
ap_req = {}
ap_req['pvno'] = krb5_pvno
ap_req['msg-type'] = MESSAGE_TYPE.KRB_AP_REQ.value
ap_req['ap-options'] = APOptions(set())
ap_req['ticket'] = Ticket(self.kerberos_TGT['ticket'])
ap_req['authenticator'] = EncryptedData({'etype': self.kerberos_cipher_type, 'cipher': authenticator_data_enc})
pa_data_1 = {}
pa_data_1['padata-type'] = PaDataType.TGS_REQ.value
pa_data_1['padata-value'] = AP_REQ(ap_req).dump()
kdc_req = {}
kdc_req['pvno'] = krb5_pvno
kdc_req['msg-type'] = MESSAGE_TYPE.KRB_TGS_REQ.value
kdc_req['padata'] = [pa_data_1]
kdc_req['req-body'] = KDC_REQ_BODY(kdc_req_body)
req = TGS_REQ(kdc_req)
logger.debug('Constructing TGS request to server')
rep = self.ksoc.sendrecv(req.dump())
logger.debug('Got TGS reply, decrypting...')
tgs = rep.native
encTGSRepPart = EncTGSRepPart.load(self.kerberos_cipher.decrypt(self.kerberos_session_key, 8, tgs['enc-part']['cipher'])).native
key = Key(encTGSRepPart['key']['keytype'], encTGSRepPart['key']['keyvalue'])
self.ccache.add_tgs(tgs, encTGSRepPart)
logger.debug('Got valid TGS reply')
self.kerberos_TGS = tgs
return tgs, encTGSRepPart, key | [
"def",
"get_TGS",
"(",
"self",
",",
"spn_user",
",",
"override_etype",
"=",
"None",
")",
":",
"#construct tgs_req",
"logger",
".",
"debug",
"(",
"'Constructing TGS request for user %s'",
"%",
"spn_user",
".",
"get_formatted_pname",
"(",
")",
")",
"now",
"=",
"datetime",
".",
"datetime",
".",
"utcnow",
"(",
")",
"kdc_req_body",
"=",
"{",
"}",
"kdc_req_body",
"[",
"'kdc-options'",
"]",
"=",
"KDCOptions",
"(",
"set",
"(",
"[",
"'forwardable'",
",",
"'renewable'",
",",
"'renewable_ok'",
",",
"'canonicalize'",
"]",
")",
")",
"kdc_req_body",
"[",
"'realm'",
"]",
"=",
"spn_user",
".",
"domain",
".",
"upper",
"(",
")",
"kdc_req_body",
"[",
"'sname'",
"]",
"=",
"PrincipalName",
"(",
"{",
"'name-type'",
":",
"NAME_TYPE",
".",
"SRV_INST",
".",
"value",
",",
"'name-string'",
":",
"spn_user",
".",
"get_principalname",
"(",
")",
"}",
")",
"kdc_req_body",
"[",
"'till'",
"]",
"=",
"now",
"+",
"datetime",
".",
"timedelta",
"(",
"days",
"=",
"1",
")",
"kdc_req_body",
"[",
"'nonce'",
"]",
"=",
"secrets",
".",
"randbits",
"(",
"31",
")",
"if",
"override_etype",
":",
"kdc_req_body",
"[",
"'etype'",
"]",
"=",
"override_etype",
"else",
":",
"kdc_req_body",
"[",
"'etype'",
"]",
"=",
"[",
"self",
".",
"kerberos_cipher_type",
"]",
"authenticator_data",
"=",
"{",
"}",
"authenticator_data",
"[",
"'authenticator-vno'",
"]",
"=",
"krb5_pvno",
"authenticator_data",
"[",
"'crealm'",
"]",
"=",
"Realm",
"(",
"self",
".",
"kerberos_TGT",
"[",
"'crealm'",
"]",
")",
"authenticator_data",
"[",
"'cname'",
"]",
"=",
"self",
".",
"kerberos_TGT",
"[",
"'cname'",
"]",
"authenticator_data",
"[",
"'cusec'",
"]",
"=",
"now",
".",
"microsecond",
"authenticator_data",
"[",
"'ctime'",
"]",
"=",
"now",
"authenticator_data_enc",
"=",
"self",
".",
"kerberos_cipher",
".",
"encrypt",
"(",
"self",
".",
"kerberos_session_key",
",",
"7",
",",
"Authenticator",
"(",
"authenticator_data",
")",
".",
"dump",
"(",
")",
",",
"None",
")",
"ap_req",
"=",
"{",
"}",
"ap_req",
"[",
"'pvno'",
"]",
"=",
"krb5_pvno",
"ap_req",
"[",
"'msg-type'",
"]",
"=",
"MESSAGE_TYPE",
".",
"KRB_AP_REQ",
".",
"value",
"ap_req",
"[",
"'ap-options'",
"]",
"=",
"APOptions",
"(",
"set",
"(",
")",
")",
"ap_req",
"[",
"'ticket'",
"]",
"=",
"Ticket",
"(",
"self",
".",
"kerberos_TGT",
"[",
"'ticket'",
"]",
")",
"ap_req",
"[",
"'authenticator'",
"]",
"=",
"EncryptedData",
"(",
"{",
"'etype'",
":",
"self",
".",
"kerberos_cipher_type",
",",
"'cipher'",
":",
"authenticator_data_enc",
"}",
")",
"pa_data_1",
"=",
"{",
"}",
"pa_data_1",
"[",
"'padata-type'",
"]",
"=",
"PaDataType",
".",
"TGS_REQ",
".",
"value",
"pa_data_1",
"[",
"'padata-value'",
"]",
"=",
"AP_REQ",
"(",
"ap_req",
")",
".",
"dump",
"(",
")",
"kdc_req",
"=",
"{",
"}",
"kdc_req",
"[",
"'pvno'",
"]",
"=",
"krb5_pvno",
"kdc_req",
"[",
"'msg-type'",
"]",
"=",
"MESSAGE_TYPE",
".",
"KRB_TGS_REQ",
".",
"value",
"kdc_req",
"[",
"'padata'",
"]",
"=",
"[",
"pa_data_1",
"]",
"kdc_req",
"[",
"'req-body'",
"]",
"=",
"KDC_REQ_BODY",
"(",
"kdc_req_body",
")",
"req",
"=",
"TGS_REQ",
"(",
"kdc_req",
")",
"logger",
".",
"debug",
"(",
"'Constructing TGS request to server'",
")",
"rep",
"=",
"self",
".",
"ksoc",
".",
"sendrecv",
"(",
"req",
".",
"dump",
"(",
")",
")",
"logger",
".",
"debug",
"(",
"'Got TGS reply, decrypting...'",
")",
"tgs",
"=",
"rep",
".",
"native",
"encTGSRepPart",
"=",
"EncTGSRepPart",
".",
"load",
"(",
"self",
".",
"kerberos_cipher",
".",
"decrypt",
"(",
"self",
".",
"kerberos_session_key",
",",
"8",
",",
"tgs",
"[",
"'enc-part'",
"]",
"[",
"'cipher'",
"]",
")",
")",
".",
"native",
"key",
"=",
"Key",
"(",
"encTGSRepPart",
"[",
"'key'",
"]",
"[",
"'keytype'",
"]",
",",
"encTGSRepPart",
"[",
"'key'",
"]",
"[",
"'keyvalue'",
"]",
")",
"self",
".",
"ccache",
".",
"add_tgs",
"(",
"tgs",
",",
"encTGSRepPart",
")",
"logger",
".",
"debug",
"(",
"'Got valid TGS reply'",
")",
"self",
".",
"kerberos_TGS",
"=",
"tgs",
"return",
"tgs",
",",
"encTGSRepPart",
",",
"key"
] | Requests a TGS ticket for the specified user.
Retruns the TGS ticket, end the decrpyted encTGSRepPart.
spn_user: KerberosTarget: the service user you want to get TGS for.
override_etype: None or list of etype values (int) Used mostly for kerberoasting, will override the AP_REQ supported etype values (which is derived from the TGT) to be able to recieve whatever tgs tiecket | [
"Requests",
"a",
"TGS",
"ticket",
"for",
"the",
"specified",
"user",
".",
"Retruns",
"the",
"TGS",
"ticket",
"end",
"the",
"decrpyted",
"encTGSRepPart",
"."
] | train | https://github.com/skelsec/minikerberos/blob/caf14c1d0132119d6e8a8f05120efb7d0824b2c6/minikerberos/communication.py#L287-L348 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Requests a TGS ticket for the specified user.
Retruns the TGS ticket, end the decrpyted encTGSRepPart.
spn_user: KerberosTarget: the service user you want to get TGS for.
override_etype: None or list of etype values (int) Used mostly for kerberoasting, will override the AP_REQ supported etype values (which is derived from the TGT) to be able to recieve whatever tgs tiecket
### Response:
def get_TGS(self, spn_user, override_etype = None):
"""
Requests a TGS ticket for the specified user.
Retruns the TGS ticket, end the decrpyted encTGSRepPart.
spn_user: KerberosTarget: the service user you want to get TGS for.
override_etype: None or list of etype values (int) Used mostly for kerberoasting, will override the AP_REQ supported etype values (which is derived from the TGT) to be able to recieve whatever tgs tiecket
"""
#construct tgs_req
logger.debug('Constructing TGS request for user %s' % spn_user.get_formatted_pname())
now = datetime.datetime.utcnow()
kdc_req_body = {}
kdc_req_body['kdc-options'] = KDCOptions(set(['forwardable','renewable','renewable_ok', 'canonicalize']))
kdc_req_body['realm'] = spn_user.domain.upper()
kdc_req_body['sname'] = PrincipalName({'name-type': NAME_TYPE.SRV_INST.value, 'name-string': spn_user.get_principalname()})
kdc_req_body['till'] = now + datetime.timedelta(days=1)
kdc_req_body['nonce'] = secrets.randbits(31)
if override_etype:
kdc_req_body['etype'] = override_etype
else:
kdc_req_body['etype'] = [self.kerberos_cipher_type]
authenticator_data = {}
authenticator_data['authenticator-vno'] = krb5_pvno
authenticator_data['crealm'] = Realm(self.kerberos_TGT['crealm'])
authenticator_data['cname'] = self.kerberos_TGT['cname']
authenticator_data['cusec'] = now.microsecond
authenticator_data['ctime'] = now
authenticator_data_enc = self.kerberos_cipher.encrypt(self.kerberos_session_key, 7, Authenticator(authenticator_data).dump(), None)
ap_req = {}
ap_req['pvno'] = krb5_pvno
ap_req['msg-type'] = MESSAGE_TYPE.KRB_AP_REQ.value
ap_req['ap-options'] = APOptions(set())
ap_req['ticket'] = Ticket(self.kerberos_TGT['ticket'])
ap_req['authenticator'] = EncryptedData({'etype': self.kerberos_cipher_type, 'cipher': authenticator_data_enc})
pa_data_1 = {}
pa_data_1['padata-type'] = PaDataType.TGS_REQ.value
pa_data_1['padata-value'] = AP_REQ(ap_req).dump()
kdc_req = {}
kdc_req['pvno'] = krb5_pvno
kdc_req['msg-type'] = MESSAGE_TYPE.KRB_TGS_REQ.value
kdc_req['padata'] = [pa_data_1]
kdc_req['req-body'] = KDC_REQ_BODY(kdc_req_body)
req = TGS_REQ(kdc_req)
logger.debug('Constructing TGS request to server')
rep = self.ksoc.sendrecv(req.dump())
logger.debug('Got TGS reply, decrypting...')
tgs = rep.native
encTGSRepPart = EncTGSRepPart.load(self.kerberos_cipher.decrypt(self.kerberos_session_key, 8, tgs['enc-part']['cipher'])).native
key = Key(encTGSRepPart['key']['keytype'], encTGSRepPart['key']['keyvalue'])
self.ccache.add_tgs(tgs, encTGSRepPart)
logger.debug('Got valid TGS reply')
self.kerberos_TGS = tgs
return tgs, encTGSRepPart, key
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36395,
264,
350,
16929,
11989,
369,
279,
5300,
1217,
627,
197,
11391,
295,
54410,
279,
350,
16929,
11989,
11,
842,
279,
1654,
81,
3368,
6702,
3289,
51,
16929,
18833,
5920,
382,
197,
1942,
20553,
3398,
25,
36258,
93895,
6531,
25,
279,
2532,
1217,
499,
1390,
311,
636,
350,
16929,
369,
627,
197,
51384,
62,
16612,
25,
2290,
477,
1160,
315,
1880,
500,
2819,
320,
396,
8,
12477,
10213,
369,
34801,
81884,
15067,
11,
690,
2882,
279,
10314,
31856,
7396,
1880,
500,
2819,
320,
8370,
374,
14592,
505,
279,
350,
26460,
8,
311,
387,
3025,
311,
1421,
19704,
8996,
259,
5981,
18623,
4084,
271,
14711,
6075,
512,
755,
636,
1159,
16929,
1214,
11,
993,
77,
3398,
11,
2882,
62,
16612,
284,
2290,
997,
197,
197,
7275,
197,
197,
36395,
264,
350,
16929,
11989,
369,
279,
5300,
1217,
627,
197,
11391,
295,
54410,
279,
350,
16929,
11989,
11,
842,
279,
1654,
81,
3368,
6702,
3289,
51,
16929,
18833,
5920,
382,
197,
1942,
20553,
3398,
25,
36258,
93895,
6531,
25,
279,
2532,
1217,
499,
1390,
311,
636,
350,
16929,
369,
627,
197,
51384,
62,
16612,
25,
2290,
477,
1160,
315,
1880,
500,
2819,
320,
396,
8,
12477,
10213,
369,
34801,
81884,
15067,
11,
690,
2882,
279,
10314,
31856,
7396,
1880,
500,
2819,
320,
8370,
374,
14592,
505,
279,
350,
26460,
8,
311,
387,
3025,
311,
1421,
19704,
8996,
259,
5981,
18623,
4084,
720,
197,
197,
7275,
197,
197,
2,
7750,
259,
5981,
18110,
198,
197,
17497,
8042,
493,
29568,
287,
350,
16929,
1715,
369,
1217,
1034,
82,
6,
1034,
993,
77,
3398,
673,
87710,
623,
609,
2455,
197,
82022,
284,
9050,
20296,
73435,
368,
720,
197,
16868,
7783,
18110,
14446,
284,
5731,
197,
16868,
7783,
18110,
14446,
681,
74,
7783,
40833,
663,
284,
735,
5744,
3883,
14505,
6561,
13741,
481,
1882,
265,
943,
481,
1882,
265,
943,
481,
20404,
518,
364,
79042,
553,
20084,
197,
16868,
7783,
18110,
14446,
681,
70997,
663,
284,
993,
77,
3398,
11248,
34764,
746,
197,
16868,
7783,
18110,
14446,
681,
82,
609,
663,
284,
37409,
678,
15597,
609,
10827,
1232,
19668,
4283,
815,
36381,
50993,
2894,
11,
364,
609,
31981,
1232,
993,
77,
3398,
673,
83502,
609,
97603,
197,
16868,
7783,
18110,
14446,
681,
83,
484,
663,
284,
1457,
489,
9050,
58939,
43695,
28,
16,
340,
197,
16868,
7783,
18110,
14446,
681,
40693,
663,
284,
24511,
15874,
11777,
7,
2148,
340,
197,
748,
2882,
62,
16612,
512,
298,
16868,
7783,
18110,
14446,
681,
16612,
663,
284,
2882,
62,
16612,
198,
197,
2525,
512,
298,
16868,
7783,
18110,
14446,
681,
16612,
663,
284,
510,
726,
5314,
261,
93895,
77792,
1857,
2595,
197,
79111,
62493,
1807,
284,
5731,
197,
79111,
62493,
1807,
681,
3322,
62493,
8437,
2201,
663,
284,
80232,
20,
92239,
2201,
198,
197,
79111,
62493,
1807,
681,
846,
7828,
663,
284,
42206,
1214,
5314,
261,
93895,
1159,
26460,
681,
846,
7828
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1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,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
36395,
264,
350,
16929,
11989,
369,
279,
5300,
1217,
627,
197,
11391,
295,
54410,
279,
350,
16929,
11989,
11,
842,
279,
1654,
81,
3368,
6702,
3289,
51,
16929,
18833,
5920,
382,
197,
1942,
20553,
3398,
25,
36258,
93895,
6531,
25,
279,
2532,
1217,
499,
1390,
311,
636,
350,
16929,
369,
627,
197,
51384,
62,
16612,
25,
2290,
477,
1160,
315,
1880,
500,
2819,
320,
396,
8,
12477,
10213,
369,
34801,
81884,
15067,
11,
690,
2882,
279,
10314,
31856,
7396,
1880,
500,
2819,
320,
8370,
374,
14592,
505,
279,
350,
26460,
8,
311,
387,
3025,
311,
1421,
19704,
8996,
259,
5981,
18623,
4084,
271,
14711,
6075,
512,
755,
636,
1159,
16929,
1214,
11,
993,
77,
3398,
11,
2882,
62,
16612,
284,
2290,
997,
197,
197,
7275,
197,
197,
36395,
264,
350,
16929,
11989,
369,
279,
5300,
1217,
627,
197,
11391,
295,
54410,
279,
350,
16929,
11989,
11,
842,
279,
1654,
81,
3368,
6702,
3289,
51,
16929,
18833,
5920,
382,
197,
1942,
20553,
3398,
25,
36258,
93895,
6531,
25,
279,
2532,
1217,
499,
1390,
311,
636,
350,
16929,
369,
627,
197,
51384,
62,
16612,
25,
2290,
477,
1160,
315,
1880,
500,
2819,
320,
396,
8,
12477,
10213,
369,
34801,
81884,
15067,
11,
690,
2882,
279,
10314,
31856,
7396,
1880,
500,
2819,
320,
8370,
374,
14592,
505,
279,
350,
26460,
8,
311,
387,
3025,
311,
1421,
19704,
8996,
259,
5981,
18623,
4084,
720,
197,
197,
7275,
197,
197,
2,
7750,
259,
5981,
18110,
198,
197,
17497,
8042,
493,
29568,
287,
350,
16929,
1715,
369,
1217,
1034,
82,
6,
1034,
993,
77,
3398,
673,
87710,
623,
609,
2455,
197,
82022,
284,
9050,
20296,
73435,
368,
720,
197,
16868,
7783,
18110,
14446,
284,
5731,
197,
16868,
7783,
18110,
14446,
681,
74,
7783,
40833,
663,
284,
735,
5744,
3883,
14505,
6561,
13741,
481,
1882,
265,
943,
481,
1882,
265,
943,
481,
20404,
518,
364,
79042,
553,
20084,
197,
16868,
7783,
18110,
14446,
681,
70997,
663,
284,
993,
77,
3398,
11248,
34764,
746,
197,
16868,
7783,
18110,
14446,
681,
82,
609,
663,
284,
37409,
678,
15597,
609,
10827,
1232,
19668,
4283,
815,
36381,
50993,
2894,
11,
364,
609,
31981,
1232,
993,
77,
3398,
673,
83502,
609,
97603,
197,
16868,
7783,
18110,
14446,
681,
83,
484,
663,
284,
1457,
489,
9050,
58939,
43695,
28,
16,
340,
197,
16868,
7783,
18110,
14446,
681,
40693,
663,
284,
24511,
15874,
11777,
7,
2148,
340,
197,
748,
2882,
62,
16612,
512,
298,
16868,
7783,
18110,
14446,
681,
16612,
663,
284,
2882,
62,
16612,
198,
197,
2525,
512,
298,
16868,
7783,
18110,
14446,
681,
16612,
663,
284,
510,
726,
5314,
261,
93895,
77792,
1857,
2595,
197,
79111,
62493,
1807,
284,
5731,
197,
79111,
62493,
1807,
681,
3322,
62493,
8437,
2201,
663,
284,
80232,
20,
92239,
2201,
198,
197,
79111,
62493,
1807,
681,
846,
7828,
663,
284,
42206,
1214,
5314,
261,
93895,
1159,
26460,
681,
846,
7828
] |
aiogram/aiogram | aiogram/types/message.py | Message.send_contact | async def send_contact(self, phone_number: base.String,
first_name: base.String, last_name: typing.Union[base.String, None] = None,
disable_notification: typing.Union[base.Boolean, None] = None,
reply_markup=None,
reply=True) -> Message:
"""
Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
:param phone_number: Contact's phone number
:type phone_number: :obj:`base.String`
:param first_name: Contact's first name
:type first_name: :obj:`base.String`
:param last_name: Contact's last name
:type last_name: :obj:`typing.Union[base.String, None]`
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
:param reply_markup: Additional interface options.
:type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]`
:param reply: fill 'reply_to_message_id'
:return: On success, the sent Message is returned.
:rtype: :obj:`types.Message`
"""
warn_deprecated('"Message.send_contact" method will be removed in 2.2 version.\n'
'Use "Message.reply_contact" instead.',
stacklevel=8)
return await self.bot.send_contact(chat_id=self.chat.id,
phone_number=phone_number,
first_name=first_name, last_name=last_name,
disable_notification=disable_notification,
reply_to_message_id=self.message_id if reply else None,
reply_markup=reply_markup) | python | async def send_contact(self, phone_number: base.String,
first_name: base.String, last_name: typing.Union[base.String, None] = None,
disable_notification: typing.Union[base.Boolean, None] = None,
reply_markup=None,
reply=True) -> Message:
"""
Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
:param phone_number: Contact's phone number
:type phone_number: :obj:`base.String`
:param first_name: Contact's first name
:type first_name: :obj:`base.String`
:param last_name: Contact's last name
:type last_name: :obj:`typing.Union[base.String, None]`
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
:param reply_markup: Additional interface options.
:type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]`
:param reply: fill 'reply_to_message_id'
:return: On success, the sent Message is returned.
:rtype: :obj:`types.Message`
"""
warn_deprecated('"Message.send_contact" method will be removed in 2.2 version.\n'
'Use "Message.reply_contact" instead.',
stacklevel=8)
return await self.bot.send_contact(chat_id=self.chat.id,
phone_number=phone_number,
first_name=first_name, last_name=last_name,
disable_notification=disable_notification,
reply_to_message_id=self.message_id if reply else None,
reply_markup=reply_markup) | [
"async",
"def",
"send_contact",
"(",
"self",
",",
"phone_number",
":",
"base",
".",
"String",
",",
"first_name",
":",
"base",
".",
"String",
",",
"last_name",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"String",
",",
"None",
"]",
"=",
"None",
",",
"disable_notification",
":",
"typing",
".",
"Union",
"[",
"base",
".",
"Boolean",
",",
"None",
"]",
"=",
"None",
",",
"reply_markup",
"=",
"None",
",",
"reply",
"=",
"True",
")",
"->",
"Message",
":",
"warn_deprecated",
"(",
"'\"Message.send_contact\" method will be removed in 2.2 version.\\n'",
"'Use \"Message.reply_contact\" instead.'",
",",
"stacklevel",
"=",
"8",
")",
"return",
"await",
"self",
".",
"bot",
".",
"send_contact",
"(",
"chat_id",
"=",
"self",
".",
"chat",
".",
"id",
",",
"phone_number",
"=",
"phone_number",
",",
"first_name",
"=",
"first_name",
",",
"last_name",
"=",
"last_name",
",",
"disable_notification",
"=",
"disable_notification",
",",
"reply_to_message_id",
"=",
"self",
".",
"message_id",
"if",
"reply",
"else",
"None",
",",
"reply_markup",
"=",
"reply_markup",
")"
] | Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
:param phone_number: Contact's phone number
:type phone_number: :obj:`base.String`
:param first_name: Contact's first name
:type first_name: :obj:`base.String`
:param last_name: Contact's last name
:type last_name: :obj:`typing.Union[base.String, None]`
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
:param reply_markup: Additional interface options.
:type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]`
:param reply: fill 'reply_to_message_id'
:return: On success, the sent Message is returned.
:rtype: :obj:`types.Message` | [
"Use",
"this",
"method",
"to",
"send",
"phone",
"contacts",
"."
] | train | https://github.com/aiogram/aiogram/blob/2af930149ce2482547721e2c8755c10307295e48/aiogram/types/message.py#L1230-L1264 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
:param phone_number: Contact's phone number
:type phone_number: :obj:`base.String`
:param first_name: Contact's first name
:type first_name: :obj:`base.String`
:param last_name: Contact's last name
:type last_name: :obj:`typing.Union[base.String, None]`
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
:param reply_markup: Additional interface options.
:type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]`
:param reply: fill 'reply_to_message_id'
:return: On success, the sent Message is returned.
:rtype: :obj:`types.Message`
### Response:
async def send_contact(self, phone_number: base.String,
first_name: base.String, last_name: typing.Union[base.String, None] = None,
disable_notification: typing.Union[base.Boolean, None] = None,
reply_markup=None,
reply=True) -> Message:
"""
Use this method to send phone contacts.
Source: https://core.telegram.org/bots/api#sendcontact
:param phone_number: Contact's phone number
:type phone_number: :obj:`base.String`
:param first_name: Contact's first name
:type first_name: :obj:`base.String`
:param last_name: Contact's last name
:type last_name: :obj:`typing.Union[base.String, None]`
:param disable_notification: Sends the message silently. Users will receive a notification with no sound.
:type disable_notification: :obj:`typing.Union[base.Boolean, None]`
:param reply_markup: Additional interface options.
:type reply_markup: :obj:`typing.Union[types.InlineKeyboardMarkup,
types.ReplyKeyboardMarkup, types.ReplyKeyboardRemove, types.ForceReply, None]`
:param reply: fill 'reply_to_message_id'
:return: On success, the sent Message is returned.
:rtype: :obj:`types.Message`
"""
warn_deprecated('"Message.send_contact" method will be removed in 2.2 version.\n'
'Use "Message.reply_contact" instead.',
stacklevel=8)
return await self.bot.send_contact(chat_id=self.chat.id,
phone_number=phone_number,
first_name=first_name, last_name=last_name,
disable_notification=disable_notification,
reply_to_message_id=self.message_id if reply else None,
reply_markup=reply_markup)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10464,
420,
1749,
311,
3708,
4641,
19015,
382,
286,
8922,
25,
3788,
1129,
2202,
83903,
2726,
3554,
2469,
10729,
2,
6820,
6421,
271,
286,
551,
913,
4641,
5617,
25,
9359,
596,
4641,
1396,
198,
286,
551,
1337,
4641,
5617,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1176,
1292,
25,
9359,
596,
1176,
836,
198,
286,
551,
1337,
1176,
1292,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1566,
1292,
25,
9359,
596,
1566,
836,
198,
286,
551,
1337,
1566,
1292,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
6567,
11,
2290,
60,
4077,
286,
551,
913,
11404,
35396,
25,
65502,
279,
1984,
50494,
13,
14969,
690,
5371,
264,
11801,
449,
912,
5222,
627,
286,
551,
1337,
11404,
35396,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
19712,
11,
2290,
60,
4077,
286,
551,
913,
10052,
55549,
25,
24086,
3834,
2671,
627,
286,
551,
1337,
10052,
55549,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
9426,
5450,
1074,
19448,
54188,
345,
310,
4595,
2887,
2603,
19448,
54188,
11,
4595,
2887,
2603,
19448,
13319,
11,
4595,
1006,
16716,
21509,
11,
2290,
60,
4077,
286,
551,
913,
10052,
25,
5266,
364,
21710,
2401,
6598,
851,
1270,
286,
551,
693,
25,
1952,
2450,
11,
279,
3288,
4961,
374,
6052,
627,
286,
551,
33613,
25,
551,
2347,
19258,
9426,
8639,
19884,
14711,
6075,
512,
7847,
711,
3708,
21245,
1214,
11,
4641,
5617,
25,
2385,
6567,
345,
6096,
1176,
1292,
25,
2385,
6567,
11,
1566,
1292,
25,
20061,
10840,
290,
58,
3231,
6567,
11,
2290,
60,
284,
2290,
345,
6096,
11404,
35396,
25,
20061,
10840,
290,
58,
3231,
19712,
11,
2290,
60,
284,
2290,
345,
6096,
10052,
55549,
5980,
345,
6096,
10052,
3702,
8,
1492,
4961,
512,
286,
3270,
286,
5560,
420,
1749,
311,
3708,
4641,
19015,
382,
286,
8922,
25,
3788,
1129,
2202,
83903,
2726,
3554,
2469,
10729,
2,
6820,
6421,
271,
286,
551,
913,
4641,
5617,
25,
9359,
596,
4641,
1396,
198,
286,
551,
1337,
4641,
5617,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1176,
1292,
25,
9359,
596,
1176,
836,
198,
286,
551,
1337,
1176,
1292,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1566,
1292,
25,
9359,
596,
1566,
836,
198,
286,
551,
1337,
1566,
1292,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
6567,
11,
2290,
60,
4077,
286,
551,
913,
11404,
35396,
25,
65502,
279,
1984,
50494,
13,
14969,
690,
5371,
264,
11801,
449,
912,
5222,
627,
286,
551,
1337,
11404,
35396,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
19712,
11,
2290,
60,
4077,
286,
551,
913,
10052,
55549,
25,
24086,
3834,
2671,
627,
286,
551,
1337,
10052,
55549,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
9426,
5450,
1074,
19448,
54188,
345,
310,
4595,
2887,
2603,
19448,
54188,
11,
4595,
2887,
2603,
19448,
13319,
11,
4595,
1006
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
10464,
420,
1749,
311,
3708,
4641,
19015,
382,
286,
8922,
25,
3788,
1129,
2202,
83903,
2726,
3554,
2469,
10729,
2,
6820,
6421,
271,
286,
551,
913,
4641,
5617,
25,
9359,
596,
4641,
1396,
198,
286,
551,
1337,
4641,
5617,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1176,
1292,
25,
9359,
596,
1176,
836,
198,
286,
551,
1337,
1176,
1292,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1566,
1292,
25,
9359,
596,
1566,
836,
198,
286,
551,
1337,
1566,
1292,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
6567,
11,
2290,
60,
4077,
286,
551,
913,
11404,
35396,
25,
65502,
279,
1984,
50494,
13,
14969,
690,
5371,
264,
11801,
449,
912,
5222,
627,
286,
551,
1337,
11404,
35396,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
19712,
11,
2290,
60,
4077,
286,
551,
913,
10052,
55549,
25,
24086,
3834,
2671,
627,
286,
551,
1337,
10052,
55549,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
9426,
5450,
1074,
19448,
54188,
345,
310,
4595,
2887,
2603,
19448,
54188,
11,
4595,
2887,
2603,
19448,
13319,
11,
4595,
1006,
16716,
21509,
11,
2290,
60,
4077,
286,
551,
913,
10052,
25,
5266,
364,
21710,
2401,
6598,
851,
1270,
286,
551,
693,
25,
1952,
2450,
11,
279,
3288,
4961,
374,
6052,
627,
286,
551,
33613,
25,
551,
2347,
19258,
9426,
8639,
19884,
14711,
6075,
512,
7847,
711,
3708,
21245,
1214,
11,
4641,
5617,
25,
2385,
6567,
345,
6096,
1176,
1292,
25,
2385,
6567,
11,
1566,
1292,
25,
20061,
10840,
290,
58,
3231,
6567,
11,
2290,
60,
284,
2290,
345,
6096,
11404,
35396,
25,
20061,
10840,
290,
58,
3231,
19712,
11,
2290,
60,
284,
2290,
345,
6096,
10052,
55549,
5980,
345,
6096,
10052,
3702,
8,
1492,
4961,
512,
286,
3270,
286,
5560,
420,
1749,
311,
3708,
4641,
19015,
382,
286,
8922,
25,
3788,
1129,
2202,
83903,
2726,
3554,
2469,
10729,
2,
6820,
6421,
271,
286,
551,
913,
4641,
5617,
25,
9359,
596,
4641,
1396,
198,
286,
551,
1337,
4641,
5617,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1176,
1292,
25,
9359,
596,
1176,
836,
198,
286,
551,
1337,
1176,
1292,
25,
551,
2347,
19258,
3231,
6567,
4077,
286,
551,
913,
1566,
1292,
25,
9359,
596,
1566,
836,
198,
286,
551,
1337,
1566,
1292,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
6567,
11,
2290,
60,
4077,
286,
551,
913,
11404,
35396,
25,
65502,
279,
1984,
50494,
13,
14969,
690,
5371,
264,
11801,
449,
912,
5222,
627,
286,
551,
1337,
11404,
35396,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
3231,
19712,
11,
2290,
60,
4077,
286,
551,
913,
10052,
55549,
25,
24086,
3834,
2671,
627,
286,
551,
1337,
10052,
55549,
25,
551,
2347,
19258,
90902,
10840,
290,
58,
9426,
5450,
1074,
19448,
54188,
345,
310,
4595,
2887,
2603,
19448,
54188,
11,
4595,
2887,
2603,
19448,
13319,
11,
4595,
1006
] |
oanda/v20-python | src/v20/account.py | AccountChanges.from_dict | def from_dict(data, ctx):
"""
Instantiate a new AccountChanges from a dict (generally from loading a
JSON response). The data used to instantiate the AccountChanges is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately.
"""
data = data.copy()
if data.get('ordersCreated') is not None:
data['ordersCreated'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersCreated')
]
if data.get('ordersCancelled') is not None:
data['ordersCancelled'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersCancelled')
]
if data.get('ordersFilled') is not None:
data['ordersFilled'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersFilled')
]
if data.get('ordersTriggered') is not None:
data['ordersTriggered'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersTriggered')
]
if data.get('tradesOpened') is not None:
data['tradesOpened'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesOpened')
]
if data.get('tradesReduced') is not None:
data['tradesReduced'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesReduced')
]
if data.get('tradesClosed') is not None:
data['tradesClosed'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesClosed')
]
if data.get('positions') is not None:
data['positions'] = [
ctx.position.Position.from_dict(d, ctx)
for d in data.get('positions')
]
if data.get('transactions') is not None:
data['transactions'] = [
ctx.transaction.Transaction.from_dict(d, ctx)
for d in data.get('transactions')
]
return AccountChanges(**data) | python | def from_dict(data, ctx):
"""
Instantiate a new AccountChanges from a dict (generally from loading a
JSON response). The data used to instantiate the AccountChanges is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately.
"""
data = data.copy()
if data.get('ordersCreated') is not None:
data['ordersCreated'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersCreated')
]
if data.get('ordersCancelled') is not None:
data['ordersCancelled'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersCancelled')
]
if data.get('ordersFilled') is not None:
data['ordersFilled'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersFilled')
]
if data.get('ordersTriggered') is not None:
data['ordersTriggered'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersTriggered')
]
if data.get('tradesOpened') is not None:
data['tradesOpened'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesOpened')
]
if data.get('tradesReduced') is not None:
data['tradesReduced'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesReduced')
]
if data.get('tradesClosed') is not None:
data['tradesClosed'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesClosed')
]
if data.get('positions') is not None:
data['positions'] = [
ctx.position.Position.from_dict(d, ctx)
for d in data.get('positions')
]
if data.get('transactions') is not None:
data['transactions'] = [
ctx.transaction.Transaction.from_dict(d, ctx)
for d in data.get('transactions')
]
return AccountChanges(**data) | [
"def",
"from_dict",
"(",
"data",
",",
"ctx",
")",
":",
"data",
"=",
"data",
".",
"copy",
"(",
")",
"if",
"data",
".",
"get",
"(",
"'ordersCreated'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'ordersCreated'",
"]",
"=",
"[",
"ctx",
".",
"order",
".",
"Order",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'ordersCreated'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'ordersCancelled'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'ordersCancelled'",
"]",
"=",
"[",
"ctx",
".",
"order",
".",
"Order",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'ordersCancelled'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'ordersFilled'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'ordersFilled'",
"]",
"=",
"[",
"ctx",
".",
"order",
".",
"Order",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'ordersFilled'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'ordersTriggered'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'ordersTriggered'",
"]",
"=",
"[",
"ctx",
".",
"order",
".",
"Order",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'ordersTriggered'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'tradesOpened'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'tradesOpened'",
"]",
"=",
"[",
"ctx",
".",
"trade",
".",
"TradeSummary",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'tradesOpened'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'tradesReduced'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'tradesReduced'",
"]",
"=",
"[",
"ctx",
".",
"trade",
".",
"TradeSummary",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'tradesReduced'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'tradesClosed'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'tradesClosed'",
"]",
"=",
"[",
"ctx",
".",
"trade",
".",
"TradeSummary",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'tradesClosed'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'positions'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'positions'",
"]",
"=",
"[",
"ctx",
".",
"position",
".",
"Position",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'positions'",
")",
"]",
"if",
"data",
".",
"get",
"(",
"'transactions'",
")",
"is",
"not",
"None",
":",
"data",
"[",
"'transactions'",
"]",
"=",
"[",
"ctx",
".",
"transaction",
".",
"Transaction",
".",
"from_dict",
"(",
"d",
",",
"ctx",
")",
"for",
"d",
"in",
"data",
".",
"get",
"(",
"'transactions'",
")",
"]",
"return",
"AccountChanges",
"(",
"*",
"*",
"data",
")"
] | Instantiate a new AccountChanges from a dict (generally from loading a
JSON response). The data used to instantiate the AccountChanges is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately. | [
"Instantiate",
"a",
"new",
"AccountChanges",
"from",
"a",
"dict",
"(",
"generally",
"from",
"loading",
"a",
"JSON",
"response",
")",
".",
"The",
"data",
"used",
"to",
"instantiate",
"the",
"AccountChanges",
"is",
"a",
"shallow",
"copy",
"of",
"the",
"dict",
"passed",
"in",
"with",
"any",
"complex",
"child",
"types",
"instantiated",
"appropriately",
"."
] | train | https://github.com/oanda/v20-python/blob/f28192f4a31bce038cf6dfa302f5878bec192fe5/src/v20/account.py#L1238-L1302 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Instantiate a new AccountChanges from a dict (generally from loading a
JSON response). The data used to instantiate the AccountChanges is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately.
### Response:
def from_dict(data, ctx):
"""
Instantiate a new AccountChanges from a dict (generally from loading a
JSON response). The data used to instantiate the AccountChanges is a
shallow copy of the dict passed in, with any complex child types
instantiated appropriately.
"""
data = data.copy()
if data.get('ordersCreated') is not None:
data['ordersCreated'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersCreated')
]
if data.get('ordersCancelled') is not None:
data['ordersCancelled'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersCancelled')
]
if data.get('ordersFilled') is not None:
data['ordersFilled'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersFilled')
]
if data.get('ordersTriggered') is not None:
data['ordersTriggered'] = [
ctx.order.Order.from_dict(d, ctx)
for d in data.get('ordersTriggered')
]
if data.get('tradesOpened') is not None:
data['tradesOpened'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesOpened')
]
if data.get('tradesReduced') is not None:
data['tradesReduced'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesReduced')
]
if data.get('tradesClosed') is not None:
data['tradesClosed'] = [
ctx.trade.TradeSummary.from_dict(d, ctx)
for d in data.get('tradesClosed')
]
if data.get('positions') is not None:
data['positions'] = [
ctx.position.Position.from_dict(d, ctx)
for d in data.get('positions')
]
if data.get('transactions') is not None:
data['transactions'] = [
ctx.transaction.Transaction.from_dict(d, ctx)
for d in data.get('transactions')
]
return AccountChanges(**data)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
81651,
264,
502,
8785,
11569,
505,
264,
6587,
320,
7642,
750,
505,
8441,
264,
198,
286,
4823,
2077,
570,
578,
828,
1511,
311,
42002,
279,
8785,
11569,
374,
264,
198,
286,
26682,
3048,
315,
279,
6587,
5946,
304,
11,
449,
904,
6485,
1716,
4595,
198,
286,
55686,
36001,
382,
14711,
6075,
512,
755,
505,
5356,
2657,
11,
5753,
997,
286,
3270,
286,
33388,
264,
502,
8785,
11569,
505,
264,
6587,
320,
7642,
750,
505,
8441,
264,
198,
286,
4823,
2077,
570,
578,
828,
1511,
311,
42002,
279,
8785,
11569,
374,
264,
198,
286,
26682,
3048,
315,
279,
6587,
5946,
304,
11,
449,
904,
6485,
1716,
4595,
198,
286,
55686,
36001,
627,
286,
12713,
286,
828,
284,
828,
12511,
2892,
286,
422,
828,
673,
493,
8076,
11956,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
11956,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
11956,
1329,
310,
10661,
286,
422,
828,
673,
493,
8076,
40573,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
40573,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
40573,
1329,
310,
10661,
286,
422,
828,
673,
493,
8076,
77146,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
77146,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
77146,
1329,
310,
10661,
286,
422,
828,
673,
493,
8076,
18423,
291,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
18423,
291,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
18423,
291,
1329,
310,
10661,
286,
422,
828,
673,
493,
376,
3536,
54622,
873,
374,
539,
2290,
512,
310,
828,
681,
376,
3536,
54622,
663,
284,
2330,
394,
5753,
82784,
8404,
1037,
19791,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
376,
3536,
54622,
1329,
310,
10661,
286,
422,
828,
673,
493,
376,
3536,
17020,
291,
873,
374,
539,
2290,
512,
310,
828,
681,
376,
3536,
17020,
291,
663,
284,
2330,
394,
5753,
82784,
8404,
1037,
19791,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
376,
3536,
17020,
291,
1329,
310,
10661,
286,
422,
828,
673,
493,
376,
3536,
27982,
873,
374,
539,
2290,
512,
310,
828,
681,
376,
3536,
27982,
663,
284,
2330,
394,
5753,
82784,
8404,
1037,
19791,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
376,
3536,
27982,
1329,
310,
10661,
286,
422,
828,
673,
493,
28536,
873,
374,
539,
2290,
512,
310,
828,
681,
28536,
663,
284,
2330,
394,
5753,
6318,
22721,
6521,
5356,
1528,
11,
5753,
340,
394,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
81651,
264,
502,
8785,
11569,
505,
264,
6587,
320,
7642,
750,
505,
8441,
264,
198,
286,
4823,
2077,
570,
578,
828,
1511,
311,
42002,
279,
8785,
11569,
374,
264,
198,
286,
26682,
3048,
315,
279,
6587,
5946,
304,
11,
449,
904,
6485,
1716,
4595,
198,
286,
55686,
36001,
382,
14711,
6075,
512,
755,
505,
5356,
2657,
11,
5753,
997,
286,
3270,
286,
33388,
264,
502,
8785,
11569,
505,
264,
6587,
320,
7642,
750,
505,
8441,
264,
198,
286,
4823,
2077,
570,
578,
828,
1511,
311,
42002,
279,
8785,
11569,
374,
264,
198,
286,
26682,
3048,
315,
279,
6587,
5946,
304,
11,
449,
904,
6485,
1716,
4595,
198,
286,
55686,
36001,
627,
286,
12713,
286,
828,
284,
828,
12511,
2892,
286,
422,
828,
673,
493,
8076,
11956,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
11956,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
11956,
1329,
310,
10661,
286,
422,
828,
673,
493,
8076,
40573,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
40573,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
40573,
1329,
310,
10661,
286,
422,
828,
673,
493,
8076,
77146,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
77146,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
77146,
1329,
310,
10661,
286,
422,
828,
673,
493,
8076,
18423,
291,
873,
374,
539,
2290,
512,
310,
828,
681,
8076,
18423,
291,
663,
284,
2330,
394,
5753,
14368,
20240,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
8076,
18423,
291,
1329,
310,
10661,
286,
422,
828,
673,
493,
376,
3536,
54622,
873,
374,
539,
2290,
512,
310,
828,
681,
376,
3536,
54622,
663,
284,
2330,
394,
5753,
82784,
8404,
1037,
19791,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
376,
3536,
54622,
1329,
310,
10661,
286,
422,
828,
673,
493,
376,
3536,
17020,
291,
873,
374,
539,
2290,
512,
310,
828,
681,
376,
3536,
17020,
291,
663,
284,
2330,
394,
5753,
82784,
8404,
1037,
19791,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
376,
3536,
17020,
291,
1329,
310,
10661,
286,
422,
828,
673,
493,
376,
3536,
27982,
873,
374,
539,
2290,
512,
310,
828,
681,
376,
3536,
27982,
663,
284,
2330,
394,
5753,
82784,
8404,
1037,
19791,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
376,
3536,
27982,
1329,
310,
10661,
286,
422,
828,
673,
493,
28536,
873,
374,
539,
2290,
512,
310,
828,
681,
28536,
663,
284,
2330,
394,
5753,
6318,
22721,
6521,
5356,
1528,
11,
5753,
340,
394,
369,
294,
304,
828,
673,
493,
28536,
1329,
310,
10661
] |
crocs-muni/roca | roca/detect.py | RocaFingerprinter.init_parser | def init_parser(self):
"""
Init command line parser
:return:
"""
parser = argparse.ArgumentParser(description='ROCA Fingerprinter')
parser.add_argument('--tmp', dest='tmp_dir', default='.',
help='Temporary dir for subprocessing (e.g. APK parsing scratch)')
parser.add_argument('--debug', dest='debug', default=False, action='store_const', const=True,
help='Debugging logging')
parser.add_argument('--dump', dest='dump', default=False, action='store_const', const=True,
help='Dump all processed info')
parser.add_argument('--flatten', dest='flatten', default=False, action='store_const', const=True,
help='Flatten the dump')
parser.add_argument('--indent', dest='indent', default=False, action='store_const', const=True,
help='Indent the dump')
parser.add_argument('--old', dest='old', default=False, action='store_const', const=True,
help='Old fingerprinting algorithm - moduli detector')
parser.add_argument('--base64-stdin', dest='base64stdin', default=False, action='store_const', const=True,
help='Decode STDIN as base64')
parser.add_argument('--file-pem', dest='file_pem', default=False, action='store_const', const=True,
help='Force read as PEM encoded file')
parser.add_argument('--file-der', dest='file_der', default=False, action='store_const', const=True,
help='Force read as DER encoded file')
parser.add_argument('--file-pgp', dest='file_pgp', default=False, action='store_const', const=True,
help='Force read as PGP ASC encoded file')
parser.add_argument('--file-ssh', dest='file_ssh', default=False, action='store_const', const=True,
help='Force read as SSH public key file')
parser.add_argument('--file-mod', dest='file_mod', default=False, action='store_const', const=True,
help='Force read as One modulus per line')
parser.add_argument('--file-json', dest='file_json', default=False, action='store_const', const=True,
help='Force read as JSON file')
parser.add_argument('--file-ldiff', dest='file_ldiff', default=False, action='store_const', const=True,
help='Force read as LDIFF file')
parser.add_argument('--file-pkcs7', dest='file_pkcs7', default=False, action='store_const', const=True,
help='Force read as PKCS7 file')
parser.add_argument('--key-fmt-base64', dest='key_fmt_base64', default=False, action='store_const', const=True,
help='Modulus per line, base64 encoded')
parser.add_argument('--key-fmt-hex', dest='key_fmt_hex', default=False, action='store_const', const=True,
help='Modulus per line, hex encoded')
parser.add_argument('--key-fmt-dec', dest='key_fmt_dec', default=False, action='store_const', const=True,
help='Modulus per line, dec encoded')
parser.add_argument('--jks-pass-file', dest='jks_pass_file', default=None,
help='Password file for JKS, one per line')
parser.add_argument('files', nargs=argparse.ZERO_OR_MORE, default=[],
help='files to process')
return parser | python | def init_parser(self):
"""
Init command line parser
:return:
"""
parser = argparse.ArgumentParser(description='ROCA Fingerprinter')
parser.add_argument('--tmp', dest='tmp_dir', default='.',
help='Temporary dir for subprocessing (e.g. APK parsing scratch)')
parser.add_argument('--debug', dest='debug', default=False, action='store_const', const=True,
help='Debugging logging')
parser.add_argument('--dump', dest='dump', default=False, action='store_const', const=True,
help='Dump all processed info')
parser.add_argument('--flatten', dest='flatten', default=False, action='store_const', const=True,
help='Flatten the dump')
parser.add_argument('--indent', dest='indent', default=False, action='store_const', const=True,
help='Indent the dump')
parser.add_argument('--old', dest='old', default=False, action='store_const', const=True,
help='Old fingerprinting algorithm - moduli detector')
parser.add_argument('--base64-stdin', dest='base64stdin', default=False, action='store_const', const=True,
help='Decode STDIN as base64')
parser.add_argument('--file-pem', dest='file_pem', default=False, action='store_const', const=True,
help='Force read as PEM encoded file')
parser.add_argument('--file-der', dest='file_der', default=False, action='store_const', const=True,
help='Force read as DER encoded file')
parser.add_argument('--file-pgp', dest='file_pgp', default=False, action='store_const', const=True,
help='Force read as PGP ASC encoded file')
parser.add_argument('--file-ssh', dest='file_ssh', default=False, action='store_const', const=True,
help='Force read as SSH public key file')
parser.add_argument('--file-mod', dest='file_mod', default=False, action='store_const', const=True,
help='Force read as One modulus per line')
parser.add_argument('--file-json', dest='file_json', default=False, action='store_const', const=True,
help='Force read as JSON file')
parser.add_argument('--file-ldiff', dest='file_ldiff', default=False, action='store_const', const=True,
help='Force read as LDIFF file')
parser.add_argument('--file-pkcs7', dest='file_pkcs7', default=False, action='store_const', const=True,
help='Force read as PKCS7 file')
parser.add_argument('--key-fmt-base64', dest='key_fmt_base64', default=False, action='store_const', const=True,
help='Modulus per line, base64 encoded')
parser.add_argument('--key-fmt-hex', dest='key_fmt_hex', default=False, action='store_const', const=True,
help='Modulus per line, hex encoded')
parser.add_argument('--key-fmt-dec', dest='key_fmt_dec', default=False, action='store_const', const=True,
help='Modulus per line, dec encoded')
parser.add_argument('--jks-pass-file', dest='jks_pass_file', default=None,
help='Password file for JKS, one per line')
parser.add_argument('files', nargs=argparse.ZERO_OR_MORE, default=[],
help='files to process')
return parser | [
"def",
"init_parser",
"(",
"self",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'ROCA Fingerprinter'",
")",
"parser",
".",
"add_argument",
"(",
"'--tmp'",
",",
"dest",
"=",
"'tmp_dir'",
",",
"default",
"=",
"'.'",
",",
"help",
"=",
"'Temporary dir for subprocessing (e.g. APK parsing scratch)'",
")",
"parser",
".",
"add_argument",
"(",
"'--debug'",
",",
"dest",
"=",
"'debug'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Debugging logging'",
")",
"parser",
".",
"add_argument",
"(",
"'--dump'",
",",
"dest",
"=",
"'dump'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Dump all processed info'",
")",
"parser",
".",
"add_argument",
"(",
"'--flatten'",
",",
"dest",
"=",
"'flatten'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Flatten the dump'",
")",
"parser",
".",
"add_argument",
"(",
"'--indent'",
",",
"dest",
"=",
"'indent'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Indent the dump'",
")",
"parser",
".",
"add_argument",
"(",
"'--old'",
",",
"dest",
"=",
"'old'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Old fingerprinting algorithm - moduli detector'",
")",
"parser",
".",
"add_argument",
"(",
"'--base64-stdin'",
",",
"dest",
"=",
"'base64stdin'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Decode STDIN as base64'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-pem'",
",",
"dest",
"=",
"'file_pem'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as PEM encoded file'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-der'",
",",
"dest",
"=",
"'file_der'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as DER encoded file'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-pgp'",
",",
"dest",
"=",
"'file_pgp'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as PGP ASC encoded file'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-ssh'",
",",
"dest",
"=",
"'file_ssh'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as SSH public key file'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-mod'",
",",
"dest",
"=",
"'file_mod'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as One modulus per line'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-json'",
",",
"dest",
"=",
"'file_json'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as JSON file'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-ldiff'",
",",
"dest",
"=",
"'file_ldiff'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as LDIFF file'",
")",
"parser",
".",
"add_argument",
"(",
"'--file-pkcs7'",
",",
"dest",
"=",
"'file_pkcs7'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Force read as PKCS7 file'",
")",
"parser",
".",
"add_argument",
"(",
"'--key-fmt-base64'",
",",
"dest",
"=",
"'key_fmt_base64'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Modulus per line, base64 encoded'",
")",
"parser",
".",
"add_argument",
"(",
"'--key-fmt-hex'",
",",
"dest",
"=",
"'key_fmt_hex'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Modulus per line, hex encoded'",
")",
"parser",
".",
"add_argument",
"(",
"'--key-fmt-dec'",
",",
"dest",
"=",
"'key_fmt_dec'",
",",
"default",
"=",
"False",
",",
"action",
"=",
"'store_const'",
",",
"const",
"=",
"True",
",",
"help",
"=",
"'Modulus per line, dec encoded'",
")",
"parser",
".",
"add_argument",
"(",
"'--jks-pass-file'",
",",
"dest",
"=",
"'jks_pass_file'",
",",
"default",
"=",
"None",
",",
"help",
"=",
"'Password file for JKS, one per line'",
")",
"parser",
".",
"add_argument",
"(",
"'files'",
",",
"nargs",
"=",
"argparse",
".",
"ZERO_OR_MORE",
",",
"default",
"=",
"[",
"]",
",",
"help",
"=",
"'files to process'",
")",
"return",
"parser"
] | Init command line parser
:return: | [
"Init",
"command",
"line",
"parser",
":",
"return",
":"
] | train | https://github.com/crocs-muni/roca/blob/74ad6ce63c428d83dcffce9c5e26ef7b9e30faa5/roca/detect.py#L2169-L2235 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Init command line parser
:return:
### Response:
def init_parser(self):
"""
Init command line parser
:return:
"""
parser = argparse.ArgumentParser(description='ROCA Fingerprinter')
parser.add_argument('--tmp', dest='tmp_dir', default='.',
help='Temporary dir for subprocessing (e.g. APK parsing scratch)')
parser.add_argument('--debug', dest='debug', default=False, action='store_const', const=True,
help='Debugging logging')
parser.add_argument('--dump', dest='dump', default=False, action='store_const', const=True,
help='Dump all processed info')
parser.add_argument('--flatten', dest='flatten', default=False, action='store_const', const=True,
help='Flatten the dump')
parser.add_argument('--indent', dest='indent', default=False, action='store_const', const=True,
help='Indent the dump')
parser.add_argument('--old', dest='old', default=False, action='store_const', const=True,
help='Old fingerprinting algorithm - moduli detector')
parser.add_argument('--base64-stdin', dest='base64stdin', default=False, action='store_const', const=True,
help='Decode STDIN as base64')
parser.add_argument('--file-pem', dest='file_pem', default=False, action='store_const', const=True,
help='Force read as PEM encoded file')
parser.add_argument('--file-der', dest='file_der', default=False, action='store_const', const=True,
help='Force read as DER encoded file')
parser.add_argument('--file-pgp', dest='file_pgp', default=False, action='store_const', const=True,
help='Force read as PGP ASC encoded file')
parser.add_argument('--file-ssh', dest='file_ssh', default=False, action='store_const', const=True,
help='Force read as SSH public key file')
parser.add_argument('--file-mod', dest='file_mod', default=False, action='store_const', const=True,
help='Force read as One modulus per line')
parser.add_argument('--file-json', dest='file_json', default=False, action='store_const', const=True,
help='Force read as JSON file')
parser.add_argument('--file-ldiff', dest='file_ldiff', default=False, action='store_const', const=True,
help='Force read as LDIFF file')
parser.add_argument('--file-pkcs7', dest='file_pkcs7', default=False, action='store_const', const=True,
help='Force read as PKCS7 file')
parser.add_argument('--key-fmt-base64', dest='key_fmt_base64', default=False, action='store_const', const=True,
help='Modulus per line, base64 encoded')
parser.add_argument('--key-fmt-hex', dest='key_fmt_hex', default=False, action='store_const', const=True,
help='Modulus per line, hex encoded')
parser.add_argument('--key-fmt-dec', dest='key_fmt_dec', default=False, action='store_const', const=True,
help='Modulus per line, dec encoded')
parser.add_argument('--jks-pass-file', dest='jks_pass_file', default=None,
help='Password file for JKS, one per line')
parser.add_argument('files', nargs=argparse.ZERO_OR_MORE, default=[],
help='files to process')
return parser
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
3888,
3290,
1584,
6871,
198,
286,
551,
693,
1473,
14711,
6075,
512,
755,
3003,
19024,
1214,
997,
286,
3270,
286,
16065,
3290,
1584,
6871,
198,
286,
551,
693,
512,
286,
3270,
286,
6871,
284,
23122,
39066,
30933,
1151,
1308,
5158,
435,
49018,
261,
4713,
286,
6871,
1388,
9202,
17052,
5284,
518,
3281,
1151,
5284,
4432,
518,
1670,
1151,
12068,
1014,
1520,
1151,
60462,
5534,
369,
1207,
21315,
320,
68,
1326,
13,
63586,
23115,
19307,
8,
4713,
286,
6871,
1388,
9202,
17052,
8514,
518,
3281,
1151,
8514,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
8098,
3252,
8558,
4713,
286,
6871,
1388,
9202,
17052,
28760,
518,
3281,
1151,
28760,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
52156,
682,
15590,
3630,
4713,
286,
6871,
1388,
9202,
17052,
48166,
518,
3281,
1151,
48166,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
3968,
14795,
279,
10488,
4713,
286,
6871,
1388,
9202,
17052,
33940,
518,
3281,
1151,
33940,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
43829,
279,
10488,
4713,
286,
6871,
1388,
9202,
17052,
820,
518,
3281,
1151,
820,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
18788,
43697,
287,
12384,
482,
1491,
24520,
32314,
4713,
286,
6871,
1388,
9202,
17052,
3231,
1227,
12,
52702,
518,
3281,
1151,
3231,
1227,
52702,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
33664,
30959,
691,
439,
2385,
1227,
4713,
286,
6871,
1388,
9202,
17052,
1213,
2320,
336,
518,
3281,
1151,
1213,
623,
336,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
97834,
21136,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
12,
1126,
518,
3281,
1151,
1213,
36445,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
47877,
21136,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
2320,
22650,
518,
3281,
1151,
1213,
623,
22650,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
393,
25434,
20382,
21136,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
12,
26618,
518,
3281,
1151,
1213,
83905,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
41563,
586,
1401,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
17515,
518,
3281,
1151,
1213,
7632,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
3861,
75124,
824,
1584,
4713,
286,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1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
3888,
3290,
1584,
6871,
198,
286,
551,
693,
1473,
14711,
6075,
512,
755,
3003,
19024,
1214,
997,
286,
3270,
286,
16065,
3290,
1584,
6871,
198,
286,
551,
693,
512,
286,
3270,
286,
6871,
284,
23122,
39066,
30933,
1151,
1308,
5158,
435,
49018,
261,
4713,
286,
6871,
1388,
9202,
17052,
5284,
518,
3281,
1151,
5284,
4432,
518,
1670,
1151,
12068,
1014,
1520,
1151,
60462,
5534,
369,
1207,
21315,
320,
68,
1326,
13,
63586,
23115,
19307,
8,
4713,
286,
6871,
1388,
9202,
17052,
8514,
518,
3281,
1151,
8514,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
8098,
3252,
8558,
4713,
286,
6871,
1388,
9202,
17052,
28760,
518,
3281,
1151,
28760,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
52156,
682,
15590,
3630,
4713,
286,
6871,
1388,
9202,
17052,
48166,
518,
3281,
1151,
48166,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
3968,
14795,
279,
10488,
4713,
286,
6871,
1388,
9202,
17052,
33940,
518,
3281,
1151,
33940,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
43829,
279,
10488,
4713,
286,
6871,
1388,
9202,
17052,
820,
518,
3281,
1151,
820,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
18788,
43697,
287,
12384,
482,
1491,
24520,
32314,
4713,
286,
6871,
1388,
9202,
17052,
3231,
1227,
12,
52702,
518,
3281,
1151,
3231,
1227,
52702,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
33664,
30959,
691,
439,
2385,
1227,
4713,
286,
6871,
1388,
9202,
17052,
1213,
2320,
336,
518,
3281,
1151,
1213,
623,
336,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
97834,
21136,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
12,
1126,
518,
3281,
1151,
1213,
36445,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
47877,
21136,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
2320,
22650,
518,
3281,
1151,
1213,
623,
22650,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
393,
25434,
20382,
21136,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
12,
26618,
518,
3281,
1151,
1213,
83905,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
41563,
586,
1401,
1052,
4713,
286,
6871,
1388,
9202,
17052,
1213,
17515,
518,
3281,
1151,
1213,
7632,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085,
1373,
439,
3861,
75124,
824,
1584,
4713,
286,
6871,
1388,
9202,
17052,
1213,
57180,
518,
3281,
1151,
1213,
9643,
518,
1670,
5725,
11,
1957,
1151,
4412,
13924,
518,
738,
3702,
345,
1014,
1520,
1151,
19085
] |
saltstack/salt | salt/utils/hashutils.py | sha1_digest | def sha1_digest(instr):
'''
Generate an sha1 hash of a given string.
'''
if six.PY3:
b = salt.utils.stringutils.to_bytes(instr)
return hashlib.sha1(b).hexdigest()
return hashlib.sha1(instr).hexdigest() | python | def sha1_digest(instr):
'''
Generate an sha1 hash of a given string.
'''
if six.PY3:
b = salt.utils.stringutils.to_bytes(instr)
return hashlib.sha1(b).hexdigest()
return hashlib.sha1(instr).hexdigest() | [
"def",
"sha1_digest",
"(",
"instr",
")",
":",
"if",
"six",
".",
"PY3",
":",
"b",
"=",
"salt",
".",
"utils",
".",
"stringutils",
".",
"to_bytes",
"(",
"instr",
")",
"return",
"hashlib",
".",
"sha1",
"(",
"b",
")",
".",
"hexdigest",
"(",
")",
"return",
"hashlib",
".",
"sha1",
"(",
"instr",
")",
".",
"hexdigest",
"(",
")"
] | Generate an sha1 hash of a given string. | [
"Generate",
"an",
"sha1",
"hash",
"of",
"a",
"given",
"string",
"."
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/hashutils.py#L96-L103 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Generate an sha1 hash of a given string.
### Response:
def sha1_digest(instr):
'''
Generate an sha1 hash of a given string.
'''
if six.PY3:
b = salt.utils.stringutils.to_bytes(instr)
return hashlib.sha1(b).hexdigest()
return hashlib.sha1(instr).hexdigest()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32215,
459,
16249,
16,
5286,
315,
264,
2728,
925,
382,
14711,
6075,
512,
755,
16249,
16,
54094,
80023,
997,
262,
11414,
262,
20400,
459,
16249,
16,
5286,
315,
264,
2728,
925,
627,
262,
11414,
262,
422,
4848,
1087,
56,
18,
512,
286,
293,
284,
12290,
8576,
4909,
6159,
2446,
12807,
80023,
340,
286,
471,
55595,
65470,
16,
1921,
570,
98324,
746,
262,
471,
55595,
65470,
16,
80023,
570,
98324,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
32215,
459,
16249,
16,
5286,
315,
264,
2728,
925,
382,
14711,
6075,
512,
755,
16249,
16,
54094,
80023,
997,
262,
11414,
262,
20400,
459,
16249,
16,
5286,
315,
264,
2728,
925,
627,
262,
11414,
262,
422,
4848,
1087,
56,
18,
512,
286,
293,
284,
12290,
8576,
4909,
6159,
2446,
12807,
80023,
340,
286,
471,
55595,
65470,
16,
1921,
570,
98324,
746,
262,
471,
55595,
65470,
16,
80023,
570,
98324,
746,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
miyakogi/wdom | wdom/node.py | ParentNode.prepend | def prepend(self, *nodes: Union[str, AbstractNode]) -> None:
"""Insert new nodes before first child node."""
node = _to_node_list(nodes)
if self.firstChild:
self.insertBefore(node, self.firstChild)
else:
self.appendChild(node) | python | def prepend(self, *nodes: Union[str, AbstractNode]) -> None:
"""Insert new nodes before first child node."""
node = _to_node_list(nodes)
if self.firstChild:
self.insertBefore(node, self.firstChild)
else:
self.appendChild(node) | [
"def",
"prepend",
"(",
"self",
",",
"*",
"nodes",
":",
"Union",
"[",
"str",
",",
"AbstractNode",
"]",
")",
"->",
"None",
":",
"node",
"=",
"_to_node_list",
"(",
"nodes",
")",
"if",
"self",
".",
"firstChild",
":",
"self",
".",
"insertBefore",
"(",
"node",
",",
"self",
".",
"firstChild",
")",
"else",
":",
"self",
".",
"appendChild",
"(",
"node",
")"
] | Insert new nodes before first child node. | [
"Insert",
"new",
"nodes",
"before",
"first",
"child",
"node",
"."
] | train | https://github.com/miyakogi/wdom/blob/a21bcd23e94baceee71161829f6897bee3fd39c1/wdom/node.py#L432-L438 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Insert new nodes before first child node.
### Response:
def prepend(self, *nodes: Union[str, AbstractNode]) -> None:
"""Insert new nodes before first child node."""
node = _to_node_list(nodes)
if self.firstChild:
self.insertBefore(node, self.firstChild)
else:
self.appendChild(node)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14099,
502,
7954,
1603,
1176,
1716,
2494,
382,
14711,
6075,
512,
755,
74747,
1214,
11,
353,
20606,
25,
9323,
17752,
11,
13822,
1997,
2526,
1492,
2290,
512,
286,
4304,
14099,
502,
7954,
1603,
1176,
1716,
2494,
14781,
286,
2494,
284,
721,
998,
5194,
2062,
39805,
340,
286,
422,
659,
51006,
512,
310,
659,
58467,
7103,
11,
659,
51006,
340,
286,
775,
512,
310,
659,
12746,
7103,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
14099,
502,
7954,
1603,
1176,
1716,
2494,
382,
14711,
6075,
512,
755,
74747,
1214,
11,
353,
20606,
25,
9323,
17752,
11,
13822,
1997,
2526,
1492,
2290,
512,
286,
4304,
14099,
502,
7954,
1603,
1176,
1716,
2494,
14781,
286,
2494,
284,
721,
998,
5194,
2062,
39805,
340,
286,
422,
659,
51006,
512,
310,
659,
58467,
7103,
11,
659,
51006,
340,
286,
775,
512,
310,
659,
12746,
7103,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
EventRegistry/event-registry-python | eventregistry/QueryEvent.py | QueryEventArticlesIter.count | def count(self, eventRegistry):
"""
return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data
"""
self.setRequestedResult(RequestEventArticles(**self.queryParams))
res = eventRegistry.execQuery(self)
if "error" in res:
print(res["error"])
count = res.get(self.queryParams["eventUri"], {}).get("articles", {}).get("totalResults", 0)
return count | python | def count(self, eventRegistry):
"""
return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data
"""
self.setRequestedResult(RequestEventArticles(**self.queryParams))
res = eventRegistry.execQuery(self)
if "error" in res:
print(res["error"])
count = res.get(self.queryParams["eventUri"], {}).get("articles", {}).get("totalResults", 0)
return count | [
"def",
"count",
"(",
"self",
",",
"eventRegistry",
")",
":",
"self",
".",
"setRequestedResult",
"(",
"RequestEventArticles",
"(",
"*",
"*",
"self",
".",
"queryParams",
")",
")",
"res",
"=",
"eventRegistry",
".",
"execQuery",
"(",
"self",
")",
"if",
"\"error\"",
"in",
"res",
":",
"print",
"(",
"res",
"[",
"\"error\"",
"]",
")",
"count",
"=",
"res",
".",
"get",
"(",
"self",
".",
"queryParams",
"[",
"\"eventUri\"",
"]",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"articles\"",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"totalResults\"",
",",
"0",
")",
"return",
"count"
] | return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data | [
"return",
"the",
"number",
"of",
"articles",
"that",
"match",
"the",
"criteria"
] | train | https://github.com/EventRegistry/event-registry-python/blob/534d20b616de02f5e1cd73665a02d189645dbeb6/eventregistry/QueryEvent.py#L150-L160 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data
### Response:
def count(self, eventRegistry):
"""
return the number of articles that match the criteria
@param eventRegistry: instance of EventRegistry class. used to obtain the necessary data
"""
self.setRequestedResult(RequestEventArticles(**self.queryParams))
res = eventRegistry.execQuery(self)
if "error" in res:
print(res["error"])
count = res.get(self.queryParams["eventUri"], {}).get("articles", {}).get("totalResults", 0)
return count
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
693,
279,
1396,
315,
9908,
430,
2489,
279,
13186,
198,
286,
571,
913,
1567,
15976,
25,
2937,
315,
3749,
15976,
538,
13,
1511,
311,
6994,
279,
5995,
828,
271,
14711,
6075,
512,
755,
1797,
1214,
11,
1567,
15976,
997,
286,
3270,
286,
471,
279,
1396,
315,
9908,
430,
2489,
279,
13186,
198,
286,
571,
913,
1567,
15976,
25,
2937,
315,
3749,
15976,
538,
13,
1511,
311,
6994,
279,
5995,
828,
198,
286,
3270,
286,
659,
995,
38730,
2122,
13248,
1585,
47235,
22551,
726,
4891,
4975,
1192,
286,
594,
284,
1567,
15976,
16153,
2929,
1214,
340,
286,
422,
330,
850,
1,
304,
594,
512,
310,
1194,
4693,
1204,
850,
14440,
286,
1797,
284,
594,
673,
1214,
4891,
4975,
1204,
3163,
14223,
8073,
73827,
456,
446,
16641,
498,
73827,
456,
446,
5143,
10001,
498,
220,
15,
340,
286,
471,
1797,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,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0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
693,
279,
1396,
315,
9908,
430,
2489,
279,
13186,
198,
286,
571,
913,
1567,
15976,
25,
2937,
315,
3749,
15976,
538,
13,
1511,
311,
6994,
279,
5995,
828,
271,
14711,
6075,
512,
755,
1797,
1214,
11,
1567,
15976,
997,
286,
3270,
286,
471,
279,
1396,
315,
9908,
430,
2489,
279,
13186,
198,
286,
571,
913,
1567,
15976,
25,
2937,
315,
3749,
15976,
538,
13,
1511,
311,
6994,
279,
5995,
828,
198,
286,
3270,
286,
659,
995,
38730,
2122,
13248,
1585,
47235,
22551,
726,
4891,
4975,
1192,
286,
594,
284,
1567,
15976,
16153,
2929,
1214,
340,
286,
422,
330,
850,
1,
304,
594,
512,
310,
1194,
4693,
1204,
850,
14440,
286,
1797,
284,
594,
673,
1214,
4891,
4975,
1204,
3163,
14223,
8073,
73827,
456,
446,
16641,
498,
73827,
456,
446,
5143,
10001,
498,
220,
15,
340,
286,
471,
1797,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
romansalin/django-seo2 | djangoseo/backends.py | MetadataBaseModel._resolve_template | def _resolve_template(value, model_instance=None, context=None):
"""Resolves any template references in the given value."""
if isinstance(value, string_types) and "{" in value:
if context is None:
context = Context()
if model_instance is not None:
context[model_instance._meta.model_name] = model_instance
value = Template(value).render(context)
return value | python | def _resolve_template(value, model_instance=None, context=None):
"""Resolves any template references in the given value."""
if isinstance(value, string_types) and "{" in value:
if context is None:
context = Context()
if model_instance is not None:
context[model_instance._meta.model_name] = model_instance
value = Template(value).render(context)
return value | [
"def",
"_resolve_template",
"(",
"value",
",",
"model_instance",
"=",
"None",
",",
"context",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"string_types",
")",
"and",
"\"{\"",
"in",
"value",
":",
"if",
"context",
"is",
"None",
":",
"context",
"=",
"Context",
"(",
")",
"if",
"model_instance",
"is",
"not",
"None",
":",
"context",
"[",
"model_instance",
".",
"_meta",
".",
"model_name",
"]",
"=",
"model_instance",
"value",
"=",
"Template",
"(",
"value",
")",
".",
"render",
"(",
"context",
")",
"return",
"value"
] | Resolves any template references in the given value. | [
"Resolves",
"any",
"template",
"references",
"in",
"the",
"given",
"value",
"."
] | train | https://github.com/romansalin/django-seo2/blob/f788699a88e286ab9a698759d9b42f57852865d8/djangoseo/backends.py#L75-L83 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Resolves any template references in the given value.
### Response:
def _resolve_template(value, model_instance=None, context=None):
"""Resolves any template references in the given value."""
if isinstance(value, string_types) and "{" in value:
if context is None:
context = Context()
if model_instance is not None:
context[model_instance._meta.model_name] = model_instance
value = Template(value).render(context)
return value
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1079,
18685,
904,
3896,
15407,
304,
279,
2728,
907,
382,
14711,
6075,
512,
755,
721,
17775,
8864,
3764,
11,
1646,
12169,
5980,
11,
2317,
5980,
997,
286,
4304,
1079,
18685,
904,
3896,
15407,
304,
279,
2728,
907,
14781,
286,
422,
11656,
3764,
11,
925,
9962,
8,
323,
98149,
304,
907,
512,
310,
422,
2317,
374,
2290,
512,
394,
2317,
284,
9805,
746,
310,
422,
1646,
12169,
374,
539,
2290,
512,
394,
2317,
81038,
12169,
1462,
5607,
3272,
1292,
60,
284,
1646,
12169,
198,
310,
907,
284,
14692,
3764,
570,
7472,
5491,
340,
286,
471,
907,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1079,
18685,
904,
3896,
15407,
304,
279,
2728,
907,
382,
14711,
6075,
512,
755,
721,
17775,
8864,
3764,
11,
1646,
12169,
5980,
11,
2317,
5980,
997,
286,
4304,
1079,
18685,
904,
3896,
15407,
304,
279,
2728,
907,
14781,
286,
422,
11656,
3764,
11,
925,
9962,
8,
323,
98149,
304,
907,
512,
310,
422,
2317,
374,
2290,
512,
394,
2317,
284,
9805,
746,
310,
422,
1646,
12169,
374,
539,
2290,
512,
394,
2317,
81038,
12169,
1462,
5607,
3272,
1292,
60,
284,
1646,
12169,
198,
310,
907,
284,
14692,
3764,
570,
7472,
5491,
340,
286,
471,
907,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
nerdvegas/rez | src/rezgui/dialogs/WriteGraphDialog.py | view_graph | def view_graph(graph_str, parent=None, prune_to=None):
"""View a graph."""
from rezgui.dialogs.ImageViewerDialog import ImageViewerDialog
from rez.config import config
# check for already written tempfile
h = hash((graph_str, prune_to))
filepath = graph_file_lookup.get(h)
if filepath and not os.path.exists(filepath):
filepath = None
# write graph to tempfile
if filepath is None:
suffix = ".%s" % config.dot_image_format
fd, filepath = tempfile.mkstemp(suffix=suffix, prefix="rez-graph-")
os.close(fd)
dlg = WriteGraphDialog(graph_str, filepath, parent, prune_to=prune_to)
if not dlg.write_graph():
return
# display graph
graph_file_lookup[h] = filepath
dlg = ImageViewerDialog(filepath, parent)
dlg.exec_() | python | def view_graph(graph_str, parent=None, prune_to=None):
"""View a graph."""
from rezgui.dialogs.ImageViewerDialog import ImageViewerDialog
from rez.config import config
# check for already written tempfile
h = hash((graph_str, prune_to))
filepath = graph_file_lookup.get(h)
if filepath and not os.path.exists(filepath):
filepath = None
# write graph to tempfile
if filepath is None:
suffix = ".%s" % config.dot_image_format
fd, filepath = tempfile.mkstemp(suffix=suffix, prefix="rez-graph-")
os.close(fd)
dlg = WriteGraphDialog(graph_str, filepath, parent, prune_to=prune_to)
if not dlg.write_graph():
return
# display graph
graph_file_lookup[h] = filepath
dlg = ImageViewerDialog(filepath, parent)
dlg.exec_() | [
"def",
"view_graph",
"(",
"graph_str",
",",
"parent",
"=",
"None",
",",
"prune_to",
"=",
"None",
")",
":",
"from",
"rezgui",
".",
"dialogs",
".",
"ImageViewerDialog",
"import",
"ImageViewerDialog",
"from",
"rez",
".",
"config",
"import",
"config",
"# check for already written tempfile",
"h",
"=",
"hash",
"(",
"(",
"graph_str",
",",
"prune_to",
")",
")",
"filepath",
"=",
"graph_file_lookup",
".",
"get",
"(",
"h",
")",
"if",
"filepath",
"and",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"filepath",
")",
":",
"filepath",
"=",
"None",
"# write graph to tempfile",
"if",
"filepath",
"is",
"None",
":",
"suffix",
"=",
"\".%s\"",
"%",
"config",
".",
"dot_image_format",
"fd",
",",
"filepath",
"=",
"tempfile",
".",
"mkstemp",
"(",
"suffix",
"=",
"suffix",
",",
"prefix",
"=",
"\"rez-graph-\"",
")",
"os",
".",
"close",
"(",
"fd",
")",
"dlg",
"=",
"WriteGraphDialog",
"(",
"graph_str",
",",
"filepath",
",",
"parent",
",",
"prune_to",
"=",
"prune_to",
")",
"if",
"not",
"dlg",
".",
"write_graph",
"(",
")",
":",
"return",
"# display graph",
"graph_file_lookup",
"[",
"h",
"]",
"=",
"filepath",
"dlg",
"=",
"ImageViewerDialog",
"(",
"filepath",
",",
"parent",
")",
"dlg",
".",
"exec_",
"(",
")"
] | View a graph. | [
"View",
"a",
"graph",
"."
] | train | https://github.com/nerdvegas/rez/blob/1d3b846d53b5b5404edfe8ddb9083f9ceec8c5e7/src/rezgui/dialogs/WriteGraphDialog.py#L109-L133 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
View a graph.
### Response:
def view_graph(graph_str, parent=None, prune_to=None):
"""View a graph."""
from rezgui.dialogs.ImageViewerDialog import ImageViewerDialog
from rez.config import config
# check for already written tempfile
h = hash((graph_str, prune_to))
filepath = graph_file_lookup.get(h)
if filepath and not os.path.exists(filepath):
filepath = None
# write graph to tempfile
if filepath is None:
suffix = ".%s" % config.dot_image_format
fd, filepath = tempfile.mkstemp(suffix=suffix, prefix="rez-graph-")
os.close(fd)
dlg = WriteGraphDialog(graph_str, filepath, parent, prune_to=prune_to)
if not dlg.write_graph():
return
# display graph
graph_file_lookup[h] = filepath
dlg = ImageViewerDialog(filepath, parent)
dlg.exec_()
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
860,
264,
4876,
382,
14711,
6075,
512,
755,
1684,
15080,
25301,
2966,
11,
2748,
5980,
11,
80626,
2401,
5980,
997,
262,
4304,
860,
264,
4876,
14781,
262,
505,
49158,
19654,
25978,
82,
7680,
29371,
4568,
1179,
26761,
261,
4568,
198,
262,
505,
49158,
5539,
1179,
2242,
271,
262,
674,
1817,
369,
2736,
5439,
55919,
198,
262,
305,
284,
5286,
1209,
4539,
2966,
11,
80626,
2401,
1192,
262,
27146,
284,
4876,
2517,
28564,
673,
3283,
340,
262,
422,
27146,
323,
539,
2709,
3960,
12347,
35893,
997,
286,
27146,
284,
2290,
271,
262,
674,
3350,
4876,
311,
55919,
198,
262,
422,
27146,
374,
2290,
512,
286,
21166,
284,
6058,
4,
82,
1,
1034,
2242,
23633,
5060,
9132,
198,
286,
12696,
11,
27146,
284,
55919,
36111,
267,
3342,
97566,
14481,
13866,
11,
9436,
429,
23577,
74116,
12,
1158,
286,
2709,
4757,
18074,
696,
286,
41971,
284,
9842,
11461,
4568,
25301,
2966,
11,
27146,
11,
2748,
11,
80626,
2401,
28,
652,
2957,
2401,
340,
286,
422,
539,
41971,
3921,
15080,
4019,
310,
471,
271,
262,
674,
3113,
4876,
198,
262,
4876,
2517,
28564,
35577,
60,
284,
27146,
198,
262,
41971,
284,
26761,
261,
4568,
35893,
11,
2748,
340,
262,
41971,
16153,
88458,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0
] | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
860,
264,
4876,
382,
14711,
6075,
512,
755,
1684,
15080,
25301,
2966,
11,
2748,
5980,
11,
80626,
2401,
5980,
997,
262,
4304,
860,
264,
4876,
14781,
262,
505,
49158,
19654,
25978,
82,
7680,
29371,
4568,
1179,
26761,
261,
4568,
198,
262,
505,
49158,
5539,
1179,
2242,
271,
262,
674,
1817,
369,
2736,
5439,
55919,
198,
262,
305,
284,
5286,
1209,
4539,
2966,
11,
80626,
2401,
1192,
262,
27146,
284,
4876,
2517,
28564,
673,
3283,
340,
262,
422,
27146,
323,
539,
2709,
3960,
12347,
35893,
997,
286,
27146,
284,
2290,
271,
262,
674,
3350,
4876,
311,
55919,
198,
262,
422,
27146,
374,
2290,
512,
286,
21166,
284,
6058,
4,
82,
1,
1034,
2242,
23633,
5060,
9132,
198,
286,
12696,
11,
27146,
284,
55919,
36111,
267,
3342,
97566,
14481,
13866,
11,
9436,
429,
23577,
74116,
12,
1158,
286,
2709,
4757,
18074,
696,
286,
41971,
284,
9842,
11461,
4568,
25301,
2966,
11,
27146,
11,
2748,
11,
80626,
2401,
28,
652,
2957,
2401,
340,
286,
422,
539,
41971,
3921,
15080,
4019,
310,
471,
271,
262,
674,
3113,
4876,
198,
262,
4876,
2517,
28564,
35577,
60,
284,
27146,
198,
262,
41971,
284,
26761,
261,
4568,
35893,
11,
2748,
340,
262,
41971,
16153,
88458,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
materialsproject/pymatgen | pymatgen/apps/battery/battery_abc.py | AbstractElectrode.get_capacity_vol | def get_capacity_vol(self, min_voltage=None, max_voltage=None,
use_overall_normalization=True):
"""
Get the volumetric capacity of the electrode.
Args:
min_voltage (float): The minimum allowable voltage for a given
step.
max_voltage (float): The maximum allowable voltage allowable for a
given step.
use_overall_normalization (booL): If False, normalize by the
discharged state of only the voltage pairs matching the voltage
criteria. if True, use default normalization of the full
electrode path.
Returns:
Volumetric capacity in mAh/cc across the insertion path (a subset
of the path can be chosen by the optional arguments)
"""
pairs_in_range = self._select_in_voltage_range(min_voltage,
max_voltage)
normalization_vol = self.normalization_volume \
if use_overall_normalization or len(pairs_in_range) == 0 \
else pairs_in_range[-1].vol_discharge
return sum([pair.mAh for pair in pairs_in_range]) / normalization_vol \
* 1e24 / N_A | python | def get_capacity_vol(self, min_voltage=None, max_voltage=None,
use_overall_normalization=True):
"""
Get the volumetric capacity of the electrode.
Args:
min_voltage (float): The minimum allowable voltage for a given
step.
max_voltage (float): The maximum allowable voltage allowable for a
given step.
use_overall_normalization (booL): If False, normalize by the
discharged state of only the voltage pairs matching the voltage
criteria. if True, use default normalization of the full
electrode path.
Returns:
Volumetric capacity in mAh/cc across the insertion path (a subset
of the path can be chosen by the optional arguments)
"""
pairs_in_range = self._select_in_voltage_range(min_voltage,
max_voltage)
normalization_vol = self.normalization_volume \
if use_overall_normalization or len(pairs_in_range) == 0 \
else pairs_in_range[-1].vol_discharge
return sum([pair.mAh for pair in pairs_in_range]) / normalization_vol \
* 1e24 / N_A | [
"def",
"get_capacity_vol",
"(",
"self",
",",
"min_voltage",
"=",
"None",
",",
"max_voltage",
"=",
"None",
",",
"use_overall_normalization",
"=",
"True",
")",
":",
"pairs_in_range",
"=",
"self",
".",
"_select_in_voltage_range",
"(",
"min_voltage",
",",
"max_voltage",
")",
"normalization_vol",
"=",
"self",
".",
"normalization_volume",
"if",
"use_overall_normalization",
"or",
"len",
"(",
"pairs_in_range",
")",
"==",
"0",
"else",
"pairs_in_range",
"[",
"-",
"1",
"]",
".",
"vol_discharge",
"return",
"sum",
"(",
"[",
"pair",
".",
"mAh",
"for",
"pair",
"in",
"pairs_in_range",
"]",
")",
"/",
"normalization_vol",
"*",
"1e24",
"/",
"N_A"
] | Get the volumetric capacity of the electrode.
Args:
min_voltage (float): The minimum allowable voltage for a given
step.
max_voltage (float): The maximum allowable voltage allowable for a
given step.
use_overall_normalization (booL): If False, normalize by the
discharged state of only the voltage pairs matching the voltage
criteria. if True, use default normalization of the full
electrode path.
Returns:
Volumetric capacity in mAh/cc across the insertion path (a subset
of the path can be chosen by the optional arguments) | [
"Get",
"the",
"volumetric",
"capacity",
"of",
"the",
"electrode",
"."
] | train | https://github.com/materialsproject/pymatgen/blob/4ca558cf72f8d5f8a1f21dfdfc0181a971c186da/pymatgen/apps/battery/battery_abc.py#L257-L282 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Get the volumetric capacity of the electrode.
Args:
min_voltage (float): The minimum allowable voltage for a given
step.
max_voltage (float): The maximum allowable voltage allowable for a
given step.
use_overall_normalization (booL): If False, normalize by the
discharged state of only the voltage pairs matching the voltage
criteria. if True, use default normalization of the full
electrode path.
Returns:
Volumetric capacity in mAh/cc across the insertion path (a subset
of the path can be chosen by the optional arguments)
### Response:
def get_capacity_vol(self, min_voltage=None, max_voltage=None,
use_overall_normalization=True):
"""
Get the volumetric capacity of the electrode.
Args:
min_voltage (float): The minimum allowable voltage for a given
step.
max_voltage (float): The maximum allowable voltage allowable for a
given step.
use_overall_normalization (booL): If False, normalize by the
discharged state of only the voltage pairs matching the voltage
criteria. if True, use default normalization of the full
electrode path.
Returns:
Volumetric capacity in mAh/cc across the insertion path (a subset
of the path can be chosen by the optional arguments)
"""
pairs_in_range = self._select_in_voltage_range(min_voltage,
max_voltage)
normalization_vol = self.normalization_volume \
if use_overall_normalization or len(pairs_in_range) == 0 \
else pairs_in_range[-1].vol_discharge
return sum([pair.mAh for pair in pairs_in_range]) / normalization_vol \
* 1e24 / N_A
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
279,
63920,
16743,
8824,
315,
279,
72048,
382,
286,
18161,
512,
310,
1332,
63856,
320,
3733,
1680,
578,
8187,
85852,
22465,
369,
264,
2728,
198,
394,
3094,
627,
310,
1973,
63856,
320,
3733,
1680,
578,
7340,
85852,
22465,
85852,
369,
264,
198,
394,
2728,
3094,
627,
310,
1005,
15793,
543,
14300,
2065,
320,
34093,
43,
1680,
1442,
3641,
11,
22436,
555,
279,
198,
394,
57191,
1614,
315,
1193,
279,
22465,
13840,
12864,
279,
22465,
198,
394,
13186,
13,
422,
3082,
11,
1005,
1670,
49823,
315,
279,
2539,
198,
394,
72048,
1853,
382,
286,
5295,
512,
310,
650,
1152,
16743,
8824,
304,
296,
25797,
88410,
4028,
279,
37027,
1853,
320,
64,
27084,
198,
310,
315,
279,
1853,
649,
387,
12146,
555,
279,
10309,
6105,
696,
14711,
6075,
512,
755,
636,
36703,
43884,
1214,
11,
1332,
63856,
5980,
11,
1973,
63856,
5980,
345,
5218,
1005,
15793,
543,
14300,
2065,
3702,
997,
286,
3270,
286,
2175,
279,
63920,
16743,
8824,
315,
279,
72048,
382,
286,
18161,
512,
310,
1332,
63856,
320,
3733,
1680,
578,
8187,
85852,
22465,
369,
264,
2728,
198,
394,
3094,
627,
310,
1973,
63856,
320,
3733,
1680,
578,
7340,
85852,
22465,
85852,
369,
264,
198,
394,
2728,
3094,
627,
310,
1005,
15793,
543,
14300,
2065,
320,
34093,
43,
1680,
1442,
3641,
11,
22436,
555,
279,
198,
394,
57191,
1614,
315,
1193,
279,
22465,
13840,
12864,
279,
22465,
198,
394,
13186,
13,
422,
3082,
11,
1005,
1670,
49823,
315,
279,
2539,
198,
394,
72048,
1853,
382,
286,
5295,
512,
310,
650,
1152,
16743,
8824,
304,
296,
25797,
88410,
4028,
279,
37027,
1853,
320,
64,
27084,
198,
310,
315,
279,
1853,
649,
387,
12146,
555,
279,
10309,
6105,
340,
286,
3270,
286,
13840,
1265,
9897,
284,
659,
1462,
1779,
1265,
63856,
9897,
14478,
63856,
345,
26857,
1973,
63856,
340,
286,
49823,
43884,
284,
659,
20738,
2065,
28039,
3120,
310,
422,
1005,
15793,
543,
14300,
2065,
477,
2479,
1319,
4825,
1265,
9897,
8,
624,
220,
15,
3120,
310,
775,
13840,
1265,
9897,
7764,
16,
948,
12821,
10135,
14215,
198,
286,
471,
2694,
2625,
12959,
749,
25797,
369,
6857,
304,
13840,
1265,
9897,
2526,
611,
49823,
43884,
3120,
310,
353,
220,
16,
68,
1187,
611,
452,
1596,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
279,
63920,
16743,
8824,
315,
279,
72048,
382,
286,
18161,
512,
310,
1332,
63856,
320,
3733,
1680,
578,
8187,
85852,
22465,
369,
264,
2728,
198,
394,
3094,
627,
310,
1973,
63856,
320,
3733,
1680,
578,
7340,
85852,
22465,
85852,
369,
264,
198,
394,
2728,
3094,
627,
310,
1005,
15793,
543,
14300,
2065,
320,
34093,
43,
1680,
1442,
3641,
11,
22436,
555,
279,
198,
394,
57191,
1614,
315,
1193,
279,
22465,
13840,
12864,
279,
22465,
198,
394,
13186,
13,
422,
3082,
11,
1005,
1670,
49823,
315,
279,
2539,
198,
394,
72048,
1853,
382,
286,
5295,
512,
310,
650,
1152,
16743,
8824,
304,
296,
25797,
88410,
4028,
279,
37027,
1853,
320,
64,
27084,
198,
310,
315,
279,
1853,
649,
387,
12146,
555,
279,
10309,
6105,
696,
14711,
6075,
512,
755,
636,
36703,
43884,
1214,
11,
1332,
63856,
5980,
11,
1973,
63856,
5980,
345,
5218,
1005,
15793,
543,
14300,
2065,
3702,
997,
286,
3270,
286,
2175,
279,
63920,
16743,
8824,
315,
279,
72048,
382,
286,
18161,
512,
310,
1332,
63856,
320,
3733,
1680,
578,
8187,
85852,
22465,
369,
264,
2728,
198,
394,
3094,
627,
310,
1973,
63856,
320,
3733,
1680,
578,
7340,
85852,
22465,
85852,
369,
264,
198,
394,
2728,
3094,
627,
310,
1005,
15793,
543,
14300,
2065,
320,
34093,
43,
1680,
1442,
3641,
11,
22436,
555,
279,
198,
394,
57191,
1614,
315,
1193,
279,
22465,
13840,
12864,
279,
22465,
198,
394,
13186,
13,
422,
3082,
11,
1005,
1670,
49823,
315,
279,
2539,
198,
394,
72048,
1853,
382,
286,
5295,
512,
310,
650,
1152,
16743,
8824,
304,
296,
25797,
88410,
4028,
279,
37027,
1853,
320,
64,
27084,
198,
310,
315,
279,
1853,
649,
387,
12146,
555,
279,
10309,
6105,
340,
286,
3270,
286,
13840,
1265,
9897,
284,
659,
1462,
1779,
1265,
63856,
9897,
14478,
63856,
345,
26857,
1973,
63856,
340,
286,
49823,
43884,
284,
659,
20738,
2065,
28039,
3120,
310,
422,
1005,
15793,
543,
14300,
2065,
477,
2479,
1319,
4825,
1265,
9897,
8,
624,
220,
15,
3120,
310,
775,
13840,
1265,
9897,
7764,
16,
948,
12821,
10135,
14215,
198,
286,
471,
2694,
2625,
12959,
749,
25797,
369,
6857,
304,
13840,
1265,
9897,
2526,
611,
49823,
43884,
3120,
310,
353,
220,
16,
68,
1187,
611,
452,
1596,
198,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
rigetti/quantumflow | quantumflow/ops.py | Channel.partial_trace | def partial_trace(self, qubits: Qubits) -> 'Channel':
"""Return the partial trace over the specified qubits"""
vec = self.vec.partial_trace(qubits)
return Channel(vec.tensor, vec.qubits) | python | def partial_trace(self, qubits: Qubits) -> 'Channel':
"""Return the partial trace over the specified qubits"""
vec = self.vec.partial_trace(qubits)
return Channel(vec.tensor, vec.qubits) | [
"def",
"partial_trace",
"(",
"self",
",",
"qubits",
":",
"Qubits",
")",
"->",
"'Channel'",
":",
"vec",
"=",
"self",
".",
"vec",
".",
"partial_trace",
"(",
"qubits",
")",
"return",
"Channel",
"(",
"vec",
".",
"tensor",
",",
"vec",
".",
"qubits",
")"
] | Return the partial trace over the specified qubits | [
"Return",
"the",
"partial",
"trace",
"over",
"the",
"specified",
"qubits"
] | train | https://github.com/rigetti/quantumflow/blob/13a66cabbe8aabf6e023cc675f4a4ebe6ccda8fb/quantumflow/ops.py#L407-L410 | <|startoftext|>
### Instruction:
You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English.
### Task:
Return the partial trace over the specified qubits
### Response:
def partial_trace(self, qubits: Qubits) -> 'Channel':
"""Return the partial trace over the specified qubits"""
vec = self.vec.partial_trace(qubits)
return Channel(vec.tensor, vec.qubits)
<|endoftext|> | [
128000,
27,
91,
2527,
14450,
428,
91,
397,
14711,
30151,
512,
2675,
527,
264,
19903,
4476,
25922,
323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
7276,
11917,
927,
279,
5300,
2874,
82502,
271,
14711,
6075,
512,
755,
7276,
24489,
1214,
11,
2874,
82502,
25,
1229,
82502,
8,
1492,
364,
9826,
3730,
286,
4304,
5715,
279,
7276,
11917,
927,
279,
5300,
2874,
82502,
7275,
286,
7638,
284,
659,
71972,
83999,
24489,
10806,
82502,
340,
286,
471,
13740,
26674,
41688,
11,
7638,
11608,
82502,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0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082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
5715,
279,
7276,
11917,
927,
279,
5300,
2874,
82502,
271,
14711,
6075,
512,
755,
7276,
24489,
1214,
11,
2874,
82502,
25,
1229,
82502,
8,
1492,
364,
9826,
3730,
286,
4304,
5715,
279,
7276,
11917,
927,
279,
5300,
2874,
82502,
7275,
286,
7638,
284,
659,
71972,
83999,
24489,
10806,
82502,
340,
286,
471,
13740,
26674,
41688,
11,
7638,
11608,
82502,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.