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
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
mcieslik-mctp/papy | src/papy/core.py | _comp_task | def _comp_task(inbox, args, kwargs):
"""
(internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs".
"""
# Note. this function uses a global variable which must be defined on the
# remote host.
for func, args, kwargs in itertools.izip(TASK, args, kwargs):
inbox = (func(inbox, *args, **kwargs),)
return inbox[0] | python | def _comp_task(inbox, args, kwargs):
"""
(internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs".
"""
# Note. this function uses a global variable which must be defined on the
# remote host.
for func, args, kwargs in itertools.izip(TASK, args, kwargs):
inbox = (func(inbox, *args, **kwargs),)
return inbox[0] | [
"def",
"_comp_task",
"(",
"inbox",
",",
"args",
",",
"kwargs",
")",
":",
"# Note. this function uses a global variable which must be defined on the ",
"# remote host.",
"for",
"func",
",",
"args",
",",
"kwargs",
"in",
"itertools",
".",
"izip",
"(",
"TASK",
",",
"args",
",",
"kwargs",
")",
":",
"inbox",
"=",
"(",
"func",
"(",
"inbox",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
",",
")",
"return",
"inbox",
"[",
"0",
"]"
] | (internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs". | [
"(",
"internal",
")",
"Composes",
"a",
"sequence",
"of",
"functions",
"in",
"the",
"global",
"variable",
"TASK",
".",
"The",
"resulting",
"composition",
"is",
"given",
"the",
"input",
"inbox",
"and",
"arguments",
"args",
"kwargs",
"."
] | train | https://github.com/mcieslik-mctp/papy/blob/708e50827b5db46bbea081982cb74b9b0e464064/src/papy/core.py#L1436-L1447 | <|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:
(internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs".
### Response:
def _comp_task(inbox, args, kwargs):
"""
(internal) Composes a sequence of functions in the global variable TASK. The
resulting composition is given the input "inbox" and arguments "args",
"kwargs".
"""
# Note. this function uses a global variable which must be defined on the
# remote host.
for func, args, kwargs in itertools.izip(TASK, args, kwargs):
inbox = (func(inbox, *args, **kwargs),)
return inbox[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,
99464,
8,
1219,
8449,
264,
8668,
315,
5865,
304,
279,
3728,
3977,
44079,
13,
578,
198,
262,
13239,
18528,
374,
2728,
279,
1988,
330,
85799,
1,
323,
6105,
330,
2164,
498,
720,
262,
330,
9872,
11690,
14711,
6075,
512,
755,
721,
5807,
12461,
6024,
2054,
11,
2897,
11,
16901,
997,
262,
3270,
262,
320,
10701,
8,
1219,
8449,
264,
8668,
315,
5865,
304,
279,
3728,
3977,
44079,
13,
578,
198,
262,
13239,
18528,
374,
2728,
279,
1988,
330,
85799,
1,
323,
6105,
330,
2164,
498,
720,
262,
330,
9872,
23811,
1084,
262,
3270,
262,
674,
7181,
13,
420,
734,
5829,
264,
3728,
3977,
902,
2011,
387,
4613,
389,
279,
720,
262,
674,
8870,
3552,
627,
262,
369,
2988,
11,
2897,
11,
16901,
304,
42431,
13,
450,
575,
4233,
7536,
11,
2897,
11,
16901,
997,
286,
23732,
284,
320,
2900,
6024,
2054,
11,
353,
2164,
11,
3146,
9872,
705,
340,
262,
471,
23732,
58,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
99464,
8,
1219,
8449,
264,
8668,
315,
5865,
304,
279,
3728,
3977,
44079,
13,
578,
198,
262,
13239,
18528,
374,
2728,
279,
1988,
330,
85799,
1,
323,
6105,
330,
2164,
498,
720,
262,
330,
9872,
11690,
14711,
6075,
512,
755,
721,
5807,
12461,
6024,
2054,
11,
2897,
11,
16901,
997,
262,
3270,
262,
320,
10701,
8,
1219,
8449,
264,
8668,
315,
5865,
304,
279,
3728,
3977,
44079,
13,
578,
198,
262,
13239,
18528,
374,
2728,
279,
1988,
330,
85799,
1,
323,
6105,
330,
2164,
498,
720,
262,
330,
9872,
23811,
1084,
262,
3270,
262,
674,
7181,
13,
420,
734,
5829,
264,
3728,
3977,
902,
2011,
387,
4613,
389,
279,
720,
262,
674,
8870,
3552,
627,
262,
369,
2988,
11,
2897,
11,
16901,
304,
42431,
13,
450,
575,
4233,
7536,
11,
2897,
11,
16901,
997,
286,
23732,
284,
320,
2900,
6024,
2054,
11,
353,
2164,
11,
3146,
9872,
705,
340,
262,
471,
23732,
58,
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
] |
Dallinger/Dallinger | dallinger/recruiters.py | CLIRecruiter.recruit | def recruit(self, n=1):
"""Generate experiemnt URLs and print them to the console."""
logger.info("Recruiting {} CLI participants".format(n))
urls = []
template = "{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}"
for i in range(n):
ad_url = template.format(
get_base_url(),
self.nickname,
generate_random_id(),
generate_random_id(),
generate_random_id(),
self._get_mode(),
)
logger.info("{} {}".format(NEW_RECRUIT_LOG_PREFIX, ad_url))
urls.append(ad_url)
return urls | python | def recruit(self, n=1):
"""Generate experiemnt URLs and print them to the console."""
logger.info("Recruiting {} CLI participants".format(n))
urls = []
template = "{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}"
for i in range(n):
ad_url = template.format(
get_base_url(),
self.nickname,
generate_random_id(),
generate_random_id(),
generate_random_id(),
self._get_mode(),
)
logger.info("{} {}".format(NEW_RECRUIT_LOG_PREFIX, ad_url))
urls.append(ad_url)
return urls | [
"def",
"recruit",
"(",
"self",
",",
"n",
"=",
"1",
")",
":",
"logger",
".",
"info",
"(",
"\"Recruiting {} CLI participants\"",
".",
"format",
"(",
"n",
")",
")",
"urls",
"=",
"[",
"]",
"template",
"=",
"\"{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}\"",
"for",
"i",
"in",
"range",
"(",
"n",
")",
":",
"ad_url",
"=",
"template",
".",
"format",
"(",
"get_base_url",
"(",
")",
",",
"self",
".",
"nickname",
",",
"generate_random_id",
"(",
")",
",",
"generate_random_id",
"(",
")",
",",
"generate_random_id",
"(",
")",
",",
"self",
".",
"_get_mode",
"(",
")",
",",
")",
"logger",
".",
"info",
"(",
"\"{} {}\"",
".",
"format",
"(",
"NEW_RECRUIT_LOG_PREFIX",
",",
"ad_url",
")",
")",
"urls",
".",
"append",
"(",
"ad_url",
")",
"return",
"urls"
] | Generate experiemnt URLs and print them to the console. | [
"Generate",
"experiemnt",
"URLs",
"and",
"print",
"them",
"to",
"the",
"console",
"."
] | train | https://github.com/Dallinger/Dallinger/blob/76ca8217c709989c116d0ebd8fca37bd22f591af/dallinger/recruiters.py#L143-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:
Generate experiemnt URLs and print them to the console.
### Response:
def recruit(self, n=1):
"""Generate experiemnt URLs and print them to the console."""
logger.info("Recruiting {} CLI participants".format(n))
urls = []
template = "{}/ad?recruiter={}&assignmentId={}&hitId={}&workerId={}&mode={}"
for i in range(n):
ad_url = template.format(
get_base_url(),
self.nickname,
generate_random_id(),
generate_random_id(),
generate_random_id(),
self._get_mode(),
)
logger.info("{} {}".format(NEW_RECRUIT_LOG_PREFIX, ad_url))
urls.append(ad_url)
return urls
<|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,
5866,
336,
406,
36106,
323,
1194,
1124,
311,
279,
2393,
382,
14711,
6075,
512,
755,
20927,
1214,
11,
308,
28,
16,
997,
286,
4304,
32215,
5866,
336,
406,
36106,
323,
1194,
1124,
311,
279,
2393,
14781,
286,
6050,
5506,
446,
3905,
2739,
5977,
4792,
40377,
13324,
3343,
2293,
1471,
1192,
286,
31084,
284,
4260,
286,
3896,
284,
14190,
4572,
329,
30,
2827,
2739,
2058,
1185,
25813,
31051,
769,
1185,
25813,
23306,
769,
1185,
25813,
22179,
769,
1185,
25813,
8684,
1185,
11444,
286,
369,
602,
304,
2134,
1471,
997,
310,
1008,
2975,
284,
3896,
8180,
1021,
394,
636,
7806,
2975,
3227,
394,
659,
68621,
345,
394,
7068,
23471,
851,
3227,
394,
7068,
23471,
851,
3227,
394,
7068,
23471,
851,
3227,
394,
659,
1462,
456,
7450,
3227,
310,
1763,
310,
6050,
5506,
54530,
21532,
2293,
7,
21242,
2241,
9150,
22572,
8585,
19026,
11,
1008,
2975,
1192,
310,
31084,
2102,
44879,
2975,
696,
286,
471,
31084,
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,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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
] | [
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,
5866,
336,
406,
36106,
323,
1194,
1124,
311,
279,
2393,
382,
14711,
6075,
512,
755,
20927,
1214,
11,
308,
28,
16,
997,
286,
4304,
32215,
5866,
336,
406,
36106,
323,
1194,
1124,
311,
279,
2393,
14781,
286,
6050,
5506,
446,
3905,
2739,
5977,
4792,
40377,
13324,
3343,
2293,
1471,
1192,
286,
31084,
284,
4260,
286,
3896,
284,
14190,
4572,
329,
30,
2827,
2739,
2058,
1185,
25813,
31051,
769,
1185,
25813,
23306,
769,
1185,
25813,
22179,
769,
1185,
25813,
8684,
1185,
11444,
286,
369,
602,
304,
2134,
1471,
997,
310,
1008,
2975,
284,
3896,
8180,
1021,
394,
636,
7806,
2975,
3227,
394,
659,
68621,
345,
394,
7068,
23471,
851,
3227,
394,
7068,
23471,
851,
3227,
394,
7068,
23471,
851,
3227,
394,
659,
1462,
456,
7450,
3227,
310,
1763,
310,
6050,
5506,
54530,
21532,
2293,
7,
21242,
2241,
9150,
22572,
8585,
19026,
11,
1008,
2975,
1192,
310,
31084,
2102,
44879,
2975,
696,
286,
471,
31084,
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
] |
horazont/aioxmpp | aioxmpp/shim/service.py | SHIMService.register_header | def register_header(self, name):
"""
Register support for the SHIM header with the given `name`.
If the header has already been registered as supported,
:class:`ValueError` is raised.
"""
self._node.register_feature(
"#".join([namespaces.xep0131_shim, name])
) | python | def register_header(self, name):
"""
Register support for the SHIM header with the given `name`.
If the header has already been registered as supported,
:class:`ValueError` is raised.
"""
self._node.register_feature(
"#".join([namespaces.xep0131_shim, name])
) | [
"def",
"register_header",
"(",
"self",
",",
"name",
")",
":",
"self",
".",
"_node",
".",
"register_feature",
"(",
"\"#\"",
".",
"join",
"(",
"[",
"namespaces",
".",
"xep0131_shim",
",",
"name",
"]",
")",
")"
] | Register support for the SHIM header with the given `name`.
If the header has already been registered as supported,
:class:`ValueError` is raised. | [
"Register",
"support",
"for",
"the",
"SHIM",
"header",
"with",
"the",
"given",
"name",
"."
] | train | https://github.com/horazont/aioxmpp/blob/22a68e5e1d23f2a4dee470092adbd4672f9ef061/aioxmpp/shim/service.py#L71-L81 | <|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:
Register support for the SHIM header with the given `name`.
If the header has already been registered as supported,
:class:`ValueError` is raised.
### Response:
def register_header(self, name):
"""
Register support for the SHIM header with the given `name`.
If the header has already been registered as supported,
:class:`ValueError` is raised.
"""
self._node.register_feature(
"#".join([namespaces.xep0131_shim, name])
)
<|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,
8861,
1862,
369,
279,
6570,
1829,
4342,
449,
279,
2728,
1595,
609,
63438,
286,
1442,
279,
4342,
706,
2736,
1027,
9879,
439,
7396,
345,
286,
551,
1058,
19258,
1150,
1480,
63,
374,
9408,
382,
14711,
6075,
512,
755,
4254,
8932,
1214,
11,
836,
997,
286,
3270,
286,
8618,
1862,
369,
279,
6570,
1829,
4342,
449,
279,
2728,
1595,
609,
63438,
286,
1442,
279,
4342,
706,
2736,
1027,
9879,
439,
7396,
345,
286,
551,
1058,
19258,
1150,
1480,
63,
374,
9408,
627,
286,
12713,
286,
659,
1462,
3593,
10131,
17506,
1021,
310,
5993,
3343,
6115,
2625,
11654,
28438,
2036,
752,
16368,
16,
3797,
318,
11,
836,
2608,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
8861,
1862,
369,
279,
6570,
1829,
4342,
449,
279,
2728,
1595,
609,
63438,
286,
1442,
279,
4342,
706,
2736,
1027,
9879,
439,
7396,
345,
286,
551,
1058,
19258,
1150,
1480,
63,
374,
9408,
382,
14711,
6075,
512,
755,
4254,
8932,
1214,
11,
836,
997,
286,
3270,
286,
8618,
1862,
369,
279,
6570,
1829,
4342,
449,
279,
2728,
1595,
609,
63438,
286,
1442,
279,
4342,
706,
2736,
1027,
9879,
439,
7396,
345,
286,
551,
1058,
19258,
1150,
1480,
63,
374,
9408,
627,
286,
12713,
286,
659,
1462,
3593,
10131,
17506,
1021,
310,
5993,
3343,
6115,
2625,
11654,
28438,
2036,
752,
16368,
16,
3797,
318,
11,
836,
2608,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
cloud-custodian/cloud-custodian | c7n/utils.py | reformat_schema | def reformat_schema(model):
""" Reformat schema to be in a more displayable format. """
if not hasattr(model, 'schema'):
return "Model '{}' does not have a schema".format(model)
if 'properties' not in model.schema:
return "Schema in unexpected format."
ret = copy.deepcopy(model.schema['properties'])
if 'type' in ret:
del(ret['type'])
for key in model.schema.get('required', []):
if key in ret:
ret[key]['required'] = True
return ret | python | def reformat_schema(model):
""" Reformat schema to be in a more displayable format. """
if not hasattr(model, 'schema'):
return "Model '{}' does not have a schema".format(model)
if 'properties' not in model.schema:
return "Schema in unexpected format."
ret = copy.deepcopy(model.schema['properties'])
if 'type' in ret:
del(ret['type'])
for key in model.schema.get('required', []):
if key in ret:
ret[key]['required'] = True
return ret | [
"def",
"reformat_schema",
"(",
"model",
")",
":",
"if",
"not",
"hasattr",
"(",
"model",
",",
"'schema'",
")",
":",
"return",
"\"Model '{}' does not have a schema\"",
".",
"format",
"(",
"model",
")",
"if",
"'properties'",
"not",
"in",
"model",
".",
"schema",
":",
"return",
"\"Schema in unexpected format.\"",
"ret",
"=",
"copy",
".",
"deepcopy",
"(",
"model",
".",
"schema",
"[",
"'properties'",
"]",
")",
"if",
"'type'",
"in",
"ret",
":",
"del",
"(",
"ret",
"[",
"'type'",
"]",
")",
"for",
"key",
"in",
"model",
".",
"schema",
".",
"get",
"(",
"'required'",
",",
"[",
"]",
")",
":",
"if",
"key",
"in",
"ret",
":",
"ret",
"[",
"key",
"]",
"[",
"'required'",
"]",
"=",
"True",
"return",
"ret"
] | Reformat schema to be in a more displayable format. | [
"Reformat",
"schema",
"to",
"be",
"in",
"a",
"more",
"displayable",
"format",
"."
] | train | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/c7n/utils.py#L449-L466 | <|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:
Reformat schema to be in a more displayable format.
### Response:
def reformat_schema(model):
""" Reformat schema to be in a more displayable format. """
if not hasattr(model, 'schema'):
return "Model '{}' does not have a schema".format(model)
if 'properties' not in model.schema:
return "Schema in unexpected format."
ret = copy.deepcopy(model.schema['properties'])
if 'type' in ret:
del(ret['type'])
for key in model.schema.get('required', []):
if key in ret:
ret[key]['required'] = True
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,
697,
2293,
11036,
311,
387,
304,
264,
810,
3113,
481,
3645,
382,
14711,
6075,
512,
755,
312,
2293,
26443,
7790,
997,
262,
4304,
1050,
2293,
11036,
311,
387,
304,
264,
810,
3113,
481,
3645,
13,
3270,
262,
422,
539,
32156,
7790,
11,
364,
17801,
11290,
286,
471,
330,
1747,
70522,
1587,
539,
617,
264,
11036,
3343,
2293,
7790,
696,
262,
422,
364,
13495,
6,
539,
304,
1646,
31992,
512,
286,
471,
330,
8802,
304,
16907,
3645,
2266,
262,
2160,
284,
3048,
52748,
7790,
31992,
681,
13495,
24287,
262,
422,
364,
1337,
6,
304,
2160,
512,
286,
1624,
16442,
681,
1337,
24287,
262,
369,
1401,
304,
1646,
31992,
673,
493,
6413,
518,
3132,
997,
286,
422,
1401,
304,
2160,
512,
310,
2160,
8320,
5465,
6413,
663,
284,
3082,
271,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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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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
] | [
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,
697,
2293,
11036,
311,
387,
304,
264,
810,
3113,
481,
3645,
382,
14711,
6075,
512,
755,
312,
2293,
26443,
7790,
997,
262,
4304,
1050,
2293,
11036,
311,
387,
304,
264,
810,
3113,
481,
3645,
13,
3270,
262,
422,
539,
32156,
7790,
11,
364,
17801,
11290,
286,
471,
330,
1747,
70522,
1587,
539,
617,
264,
11036,
3343,
2293,
7790,
696,
262,
422,
364,
13495,
6,
539,
304,
1646,
31992,
512,
286,
471,
330,
8802,
304,
16907,
3645,
2266,
262,
2160,
284,
3048,
52748,
7790,
31992,
681,
13495,
24287,
262,
422,
364,
1337,
6,
304,
2160,
512,
286,
1624,
16442,
681,
1337,
24287,
262,
369,
1401,
304,
1646,
31992,
673,
493,
6413,
518,
3132,
997,
286,
422,
1401,
304,
2160,
512,
310,
2160,
8320,
5465,
6413,
663,
284,
3082,
271,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
qiniu/python-sdk | qiniu/services/storage/bucket.py | BucketManager.prefetch | def prefetch(self, bucket, key):
"""镜像回源预取文件:
从镜像源站抓取资源到空间中,如果空间中已经存在,则覆盖该资源,具体规格参考
http://developer.qiniu.com/docs/v6/api/reference/rs/prefetch.html
Args:
bucket: 待获取资源所在的空间
key: 代获取资源文件名
Returns:
一个dict变量,成功返回NULL,失败返回{"error": "<errMsg string>"}
一个ResponseInfo对象
"""
resource = entry(bucket, key)
return self.__io_do(bucket, 'prefetch', resource) | python | def prefetch(self, bucket, key):
"""镜像回源预取文件:
从镜像源站抓取资源到空间中,如果空间中已经存在,则覆盖该资源,具体规格参考
http://developer.qiniu.com/docs/v6/api/reference/rs/prefetch.html
Args:
bucket: 待获取资源所在的空间
key: 代获取资源文件名
Returns:
一个dict变量,成功返回NULL,失败返回{"error": "<errMsg string>"}
一个ResponseInfo对象
"""
resource = entry(bucket, key)
return self.__io_do(bucket, 'prefetch', resource) | [
"def",
"prefetch",
"(",
"self",
",",
"bucket",
",",
"key",
")",
":",
"resource",
"=",
"entry",
"(",
"bucket",
",",
"key",
")",
"return",
"self",
".",
"__io_do",
"(",
"bucket",
",",
"'prefetch'",
",",
"resource",
")"
] | 镜像回源预取文件:
从镜像源站抓取资源到空间中,如果空间中已经存在,则覆盖该资源,具体规格参考
http://developer.qiniu.com/docs/v6/api/reference/rs/prefetch.html
Args:
bucket: 待获取资源所在的空间
key: 代获取资源文件名
Returns:
一个dict变量,成功返回NULL,失败返回{"error": "<errMsg string>"}
一个ResponseInfo对象 | [
"镜像回源预取文件",
":"
] | train | https://github.com/qiniu/python-sdk/blob/a69fbef4e3e6ea1ebe09f4610a5b18bb2c17de59/qiniu/services/storage/bucket.py#L182-L197 | <|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://developer.qiniu.com/docs/v6/api/reference/rs/prefetch.html
Args:
bucket: 待获取资源所在的空间
key: 代获取资源文件名
Returns:
一个dict变量,成功返回NULL,失败返回{"error": "<errMsg string>"}
一个ResponseInfo对象
### Response:
def prefetch(self, bucket, key):
"""镜像回源预取文件:
从镜像源站抓取资源到空间中,如果空间中已经存在,则覆盖该资源,具体规格参考
http://developer.qiniu.com/docs/v6/api/reference/rs/prefetch.html
Args:
bucket: 待获取资源所在的空间
key: 代获取资源文件名
Returns:
一个dict变量,成功返回NULL,失败返回{"error": "<errMsg string>"}
一个ResponseInfo对象
"""
resource = entry(bucket, key)
return self.__io_do(bucket, 'prefetch', resource)
<|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,
116979,
66201,
18904,
39084,
99941,
18655,
27996,
1473,
286,
116211,
116979,
66201,
39084,
71890,
116328,
18655,
86429,
28037,
118582,
16325,
114806,
118582,
16325,
104724,
48706,
96153,
117633,
113333,
76982,
86429,
3922,
118789,
75486,
35083,
121846,
198,
286,
1795,
1129,
35501,
11608,
6729,
84,
916,
27057,
5574,
21,
10729,
66880,
92985,
4420,
1116,
3068,
2628,
271,
286,
18161,
512,
310,
15994,
25,
85241,
227,
47012,
86429,
32938,
19000,
9554,
118582,
198,
310,
1401,
25,
262,
123003,
47012,
86429,
27996,
13372,
271,
286,
5295,
512,
310,
220,
48044,
8644,
75140,
33857,
3922,
19653,
32626,
4679,
3922,
22820,
32626,
5018,
850,
794,
4145,
99971,
925,
10078,
534,
310,
220,
48044,
2647,
1767,
65529,
271,
14711,
6075,
512,
755,
91577,
1214,
11,
15994,
11,
1401,
997,
286,
4304,
116979,
66201,
18904,
39084,
99941,
18655,
27996,
1473,
286,
116211,
116979,
66201,
39084,
71890,
116328,
18655,
86429,
28037,
118582,
16325,
114806,
118582,
16325,
104724,
48706,
96153,
117633,
113333,
76982,
86429,
3922,
118789,
75486,
35083,
121846,
198,
286,
1795,
1129,
35501,
11608,
6729,
84,
916,
27057,
5574,
21,
10729,
66880,
92985,
4420,
1116,
3068,
2628,
271,
286,
18161,
512,
310,
15994,
25,
85241,
227,
47012,
86429,
32938,
19000,
9554,
118582,
198,
310,
1401,
25,
262,
123003,
47012,
86429,
27996,
13372,
271,
286,
5295,
512,
310,
220,
48044,
8644,
75140,
33857,
3922,
19653,
32626,
4679,
3922,
22820,
32626,
5018,
850,
794,
4145,
99971,
925,
10078,
534,
310,
220,
48044,
2647,
1767,
65529,
198,
286,
3270,
286,
5211,
284,
4441,
60034,
11,
1401,
340,
286,
471,
659,
4952,
822,
27405,
60034,
11,
364,
31652,
3068,
518,
5211,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
116979,
66201,
18904,
39084,
99941,
18655,
27996,
1473,
286,
116211,
116979,
66201,
39084,
71890,
116328,
18655,
86429,
28037,
118582,
16325,
114806,
118582,
16325,
104724,
48706,
96153,
117633,
113333,
76982,
86429,
3922,
118789,
75486,
35083,
121846,
198,
286,
1795,
1129,
35501,
11608,
6729,
84,
916,
27057,
5574,
21,
10729,
66880,
92985,
4420,
1116,
3068,
2628,
271,
286,
18161,
512,
310,
15994,
25,
85241,
227,
47012,
86429,
32938,
19000,
9554,
118582,
198,
310,
1401,
25,
262,
123003,
47012,
86429,
27996,
13372,
271,
286,
5295,
512,
310,
220,
48044,
8644,
75140,
33857,
3922,
19653,
32626,
4679,
3922,
22820,
32626,
5018,
850,
794,
4145,
99971,
925,
10078,
534,
310,
220,
48044,
2647,
1767,
65529,
271,
14711,
6075,
512,
755,
91577,
1214,
11,
15994,
11,
1401,
997,
286,
4304,
116979,
66201,
18904,
39084,
99941,
18655,
27996,
1473,
286,
116211,
116979,
66201,
39084,
71890,
116328,
18655,
86429,
28037,
118582,
16325,
114806,
118582,
16325,
104724,
48706,
96153,
117633,
113333,
76982,
86429,
3922,
118789,
75486,
35083,
121846,
198,
286,
1795,
1129,
35501,
11608,
6729,
84,
916,
27057,
5574,
21,
10729,
66880,
92985,
4420,
1116,
3068,
2628,
271,
286,
18161,
512,
310,
15994,
25,
85241,
227,
47012,
86429,
32938,
19000,
9554,
118582,
198,
310,
1401,
25,
262,
123003,
47012,
86429,
27996,
13372,
271,
286,
5295,
512,
310,
220,
48044,
8644,
75140,
33857,
3922,
19653,
32626,
4679,
3922,
22820,
32626,
5018,
850,
794,
4145,
99971,
925,
10078,
534,
310,
220,
48044,
2647,
1767,
65529,
198,
286,
3270,
286,
5211,
284,
4441,
60034,
11,
1401,
340,
286,
471,
659,
4952,
822,
27405,
60034,
11,
364,
31652,
3068,
518,
5211,
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
] |
O365/python-o365 | O365/mailbox.py | Folder.copy_folder | def copy_folder(self, to_folder):
""" Copy this folder and it's contents to into another folder
:param to_folder: the destination Folder/folder_id to copy into
:type to_folder: mailbox.Folder or str
:return: The new folder after copying
:rtype: mailbox.Folder or None
"""
to_folder_id = to_folder.folder_id if isinstance(to_folder,
Folder) else to_folder
if self.root or not self.folder_id or not to_folder_id:
return None
url = self.build_url(
self._endpoints.get('copy_folder').format(id=self.folder_id))
response = self.con.post(url,
data={self._cc('destinationId'): to_folder_id})
if not response:
return None
folder = response.json()
self_class = getattr(self, 'folder_constructor', type(self))
# Everything received from cloud must be passed as self._cloud_data_key
return self_class(con=self.con, main_resource=self.main_resource,
**{self._cloud_data_key: folder}) | python | def copy_folder(self, to_folder):
""" Copy this folder and it's contents to into another folder
:param to_folder: the destination Folder/folder_id to copy into
:type to_folder: mailbox.Folder or str
:return: The new folder after copying
:rtype: mailbox.Folder or None
"""
to_folder_id = to_folder.folder_id if isinstance(to_folder,
Folder) else to_folder
if self.root or not self.folder_id or not to_folder_id:
return None
url = self.build_url(
self._endpoints.get('copy_folder').format(id=self.folder_id))
response = self.con.post(url,
data={self._cc('destinationId'): to_folder_id})
if not response:
return None
folder = response.json()
self_class = getattr(self, 'folder_constructor', type(self))
# Everything received from cloud must be passed as self._cloud_data_key
return self_class(con=self.con, main_resource=self.main_resource,
**{self._cloud_data_key: folder}) | [
"def",
"copy_folder",
"(",
"self",
",",
"to_folder",
")",
":",
"to_folder_id",
"=",
"to_folder",
".",
"folder_id",
"if",
"isinstance",
"(",
"to_folder",
",",
"Folder",
")",
"else",
"to_folder",
"if",
"self",
".",
"root",
"or",
"not",
"self",
".",
"folder_id",
"or",
"not",
"to_folder_id",
":",
"return",
"None",
"url",
"=",
"self",
".",
"build_url",
"(",
"self",
".",
"_endpoints",
".",
"get",
"(",
"'copy_folder'",
")",
".",
"format",
"(",
"id",
"=",
"self",
".",
"folder_id",
")",
")",
"response",
"=",
"self",
".",
"con",
".",
"post",
"(",
"url",
",",
"data",
"=",
"{",
"self",
".",
"_cc",
"(",
"'destinationId'",
")",
":",
"to_folder_id",
"}",
")",
"if",
"not",
"response",
":",
"return",
"None",
"folder",
"=",
"response",
".",
"json",
"(",
")",
"self_class",
"=",
"getattr",
"(",
"self",
",",
"'folder_constructor'",
",",
"type",
"(",
"self",
")",
")",
"# Everything received from cloud must be passed as self._cloud_data_key",
"return",
"self_class",
"(",
"con",
"=",
"self",
".",
"con",
",",
"main_resource",
"=",
"self",
".",
"main_resource",
",",
"*",
"*",
"{",
"self",
".",
"_cloud_data_key",
":",
"folder",
"}",
")"
] | Copy this folder and it's contents to into another folder
:param to_folder: the destination Folder/folder_id to copy into
:type to_folder: mailbox.Folder or str
:return: The new folder after copying
:rtype: mailbox.Folder or None | [
"Copy",
"this",
"folder",
"and",
"it",
"s",
"contents",
"to",
"into",
"another",
"folder"
] | train | https://github.com/O365/python-o365/blob/02a71cf3775cc6a3c042e003365d6a07c8c75a73/O365/mailbox.py#L405-L432 | <|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:
Copy this folder and it's contents to into another folder
:param to_folder: the destination Folder/folder_id to copy into
:type to_folder: mailbox.Folder or str
:return: The new folder after copying
:rtype: mailbox.Folder or None
### Response:
def copy_folder(self, to_folder):
""" Copy this folder and it's contents to into another folder
:param to_folder: the destination Folder/folder_id to copy into
:type to_folder: mailbox.Folder or str
:return: The new folder after copying
:rtype: mailbox.Folder or None
"""
to_folder_id = to_folder.folder_id if isinstance(to_folder,
Folder) else to_folder
if self.root or not self.folder_id or not to_folder_id:
return None
url = self.build_url(
self._endpoints.get('copy_folder').format(id=self.folder_id))
response = self.con.post(url,
data={self._cc('destinationId'): to_folder_id})
if not response:
return None
folder = response.json()
self_class = getattr(self, 'folder_constructor', type(self))
# Everything received from cloud must be passed as self._cloud_data_key
return self_class(con=self.con, main_resource=self.main_resource,
**{self._cloud_data_key: folder})
<|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,
12379,
420,
8695,
323,
433,
596,
8970,
311,
1139,
2500,
8695,
271,
286,
551,
913,
311,
15626,
25,
279,
9284,
36943,
6801,
2061,
851,
311,
3048,
1139,
198,
286,
551,
1337,
311,
15626,
25,
46842,
1006,
2061,
477,
610,
198,
286,
551,
693,
25,
578,
502,
8695,
1306,
32139,
198,
286,
551,
33613,
25,
46842,
1006,
2061,
477,
2290,
271,
14711,
6075,
512,
755,
3048,
15626,
1214,
11,
311,
15626,
997,
286,
4304,
14882,
420,
8695,
323,
433,
596,
8970,
311,
1139,
2500,
8695,
271,
286,
551,
913,
311,
15626,
25,
279,
9284,
36943,
6801,
2061,
851,
311,
3048,
1139,
198,
286,
551,
1337,
311,
15626,
25,
46842,
1006,
2061,
477,
610,
198,
286,
551,
693,
25,
578,
502,
8695,
1306,
32139,
198,
286,
551,
33613,
25,
46842,
1006,
2061,
477,
2290,
198,
286,
3270,
286,
311,
15626,
851,
284,
311,
15626,
61629,
851,
422,
11656,
12464,
15626,
345,
29902,
36943,
8,
775,
311,
15626,
271,
286,
422,
659,
12861,
477,
539,
659,
61629,
851,
477,
539,
311,
15626,
851,
512,
310,
471,
2290,
271,
286,
2576,
284,
659,
13542,
2975,
1021,
310,
659,
1462,
408,
7862,
673,
493,
8728,
15626,
1861,
2293,
3809,
7822,
61629,
851,
4489,
286,
2077,
284,
659,
2932,
6679,
6659,
345,
792,
828,
1185,
726,
1462,
641,
493,
18481,
769,
36039,
311,
15626,
851,
3602,
286,
422,
539,
2077,
512,
310,
471,
2290,
271,
286,
8695,
284,
2077,
4421,
2892,
286,
659,
4895,
284,
31097,
1214,
11,
364,
18135,
67310,
518,
955,
1214,
1192,
286,
674,
20696,
4036,
505,
9624,
2011,
387,
5946,
439,
659,
1462,
12641,
1807,
3173,
198,
286,
471,
659,
4895,
18350,
7822,
2932,
11,
1925,
18446,
7822,
9056,
18446,
345,
3586,
3146,
90,
726,
1462,
12641,
1807,
3173,
25,
8695,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
12379,
420,
8695,
323,
433,
596,
8970,
311,
1139,
2500,
8695,
271,
286,
551,
913,
311,
15626,
25,
279,
9284,
36943,
6801,
2061,
851,
311,
3048,
1139,
198,
286,
551,
1337,
311,
15626,
25,
46842,
1006,
2061,
477,
610,
198,
286,
551,
693,
25,
578,
502,
8695,
1306,
32139,
198,
286,
551,
33613,
25,
46842,
1006,
2061,
477,
2290,
271,
14711,
6075,
512,
755,
3048,
15626,
1214,
11,
311,
15626,
997,
286,
4304,
14882,
420,
8695,
323,
433,
596,
8970,
311,
1139,
2500,
8695,
271,
286,
551,
913,
311,
15626,
25,
279,
9284,
36943,
6801,
2061,
851,
311,
3048,
1139,
198,
286,
551,
1337,
311,
15626,
25,
46842,
1006,
2061,
477,
610,
198,
286,
551,
693,
25,
578,
502,
8695,
1306,
32139,
198,
286,
551,
33613,
25,
46842,
1006,
2061,
477,
2290,
198,
286,
3270,
286,
311,
15626,
851,
284,
311,
15626,
61629,
851,
422,
11656,
12464,
15626,
345,
29902,
36943,
8,
775,
311,
15626,
271,
286,
422,
659,
12861,
477,
539,
659,
61629,
851,
477,
539,
311,
15626,
851,
512,
310,
471,
2290,
271,
286,
2576,
284,
659,
13542,
2975,
1021,
310,
659,
1462,
408,
7862,
673,
493,
8728,
15626,
1861,
2293,
3809,
7822,
61629,
851,
4489,
286,
2077,
284,
659,
2932,
6679,
6659,
345,
792,
828,
1185,
726,
1462,
641,
493,
18481,
769,
36039,
311,
15626,
851,
3602,
286,
422,
539,
2077,
512,
310,
471,
2290,
271,
286,
8695,
284,
2077,
4421,
2892,
286,
659,
4895,
284,
31097,
1214,
11,
364,
18135,
67310,
518,
955,
1214,
1192,
286,
674,
20696,
4036,
505,
9624,
2011,
387,
5946,
439,
659,
1462,
12641,
1807,
3173,
198,
286,
471,
659,
4895,
18350,
7822,
2932,
11,
1925,
18446,
7822,
9056,
18446,
345,
3586,
3146,
90,
726,
1462,
12641,
1807,
3173,
25,
8695,
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
] |
saltstack/salt | salt/modules/mac_power.py | get_harddisk_sleep | def get_harddisk_sleep():
'''
Display the amount of idle time until the hard disk sleeps.
:return: A string representing the sleep settings for the hard disk
:rtype: str
CLI Example:
..code-block:: bash
salt '*' power.get_harddisk_sleep
'''
ret = salt.utils.mac_utils.execute_return_result(
'systemsetup -getharddisksleep')
return salt.utils.mac_utils.parse_return(ret) | python | def get_harddisk_sleep():
'''
Display the amount of idle time until the hard disk sleeps.
:return: A string representing the sleep settings for the hard disk
:rtype: str
CLI Example:
..code-block:: bash
salt '*' power.get_harddisk_sleep
'''
ret = salt.utils.mac_utils.execute_return_result(
'systemsetup -getharddisksleep')
return salt.utils.mac_utils.parse_return(ret) | [
"def",
"get_harddisk_sleep",
"(",
")",
":",
"ret",
"=",
"salt",
".",
"utils",
".",
"mac_utils",
".",
"execute_return_result",
"(",
"'systemsetup -getharddisksleep'",
")",
"return",
"salt",
".",
"utils",
".",
"mac_utils",
".",
"parse_return",
"(",
"ret",
")"
] | Display the amount of idle time until the hard disk sleeps.
:return: A string representing the sleep settings for the hard disk
:rtype: str
CLI Example:
..code-block:: bash
salt '*' power.get_harddisk_sleep | [
"Display",
"the",
"amount",
"of",
"idle",
"time",
"until",
"the",
"hard",
"disk",
"sleeps",
"."
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mac_power.py#L220-L235 | <|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:
Display the amount of idle time until the hard disk sleeps.
:return: A string representing the sleep settings for the hard disk
:rtype: str
CLI Example:
..code-block:: bash
salt '*' power.get_harddisk_sleep
### Response:
def get_harddisk_sleep():
'''
Display the amount of idle time until the hard disk sleeps.
:return: A string representing the sleep settings for the hard disk
:rtype: str
CLI Example:
..code-block:: bash
salt '*' power.get_harddisk_sleep
'''
ret = salt.utils.mac_utils.execute_return_result(
'systemsetup -getharddisksleep')
return salt.utils.mac_utils.parse_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,
7165,
279,
3392,
315,
28747,
892,
3156,
279,
2653,
13668,
72490,
382,
262,
551,
693,
25,
362,
925,
14393,
279,
6212,
5110,
369,
279,
2653,
13668,
198,
262,
551,
33613,
25,
610,
271,
262,
40377,
13688,
1473,
262,
5354,
1889,
9612,
487,
28121,
271,
286,
12290,
31801,
2410,
673,
78812,
31596,
50493,
271,
14711,
6075,
512,
755,
636,
78812,
31596,
50493,
4019,
262,
11414,
262,
10848,
279,
3392,
315,
28747,
892,
3156,
279,
2653,
13668,
72490,
382,
262,
551,
693,
25,
362,
925,
14393,
279,
6212,
5110,
369,
279,
2653,
13668,
198,
262,
551,
33613,
25,
610,
271,
262,
40377,
13688,
1473,
262,
5354,
1889,
9612,
487,
28121,
271,
286,
12290,
31801,
2410,
673,
78812,
31596,
50493,
198,
262,
11414,
262,
2160,
284,
12290,
8576,
62925,
17758,
7925,
12794,
5400,
1021,
286,
364,
9125,
15543,
482,
456,
19221,
4338,
2857,
3583,
1329,
262,
471,
12290,
8576,
62925,
17758,
4736,
12794,
16442,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
7165,
279,
3392,
315,
28747,
892,
3156,
279,
2653,
13668,
72490,
382,
262,
551,
693,
25,
362,
925,
14393,
279,
6212,
5110,
369,
279,
2653,
13668,
198,
262,
551,
33613,
25,
610,
271,
262,
40377,
13688,
1473,
262,
5354,
1889,
9612,
487,
28121,
271,
286,
12290,
31801,
2410,
673,
78812,
31596,
50493,
271,
14711,
6075,
512,
755,
636,
78812,
31596,
50493,
4019,
262,
11414,
262,
10848,
279,
3392,
315,
28747,
892,
3156,
279,
2653,
13668,
72490,
382,
262,
551,
693,
25,
362,
925,
14393,
279,
6212,
5110,
369,
279,
2653,
13668,
198,
262,
551,
33613,
25,
610,
271,
262,
40377,
13688,
1473,
262,
5354,
1889,
9612,
487,
28121,
271,
286,
12290,
31801,
2410,
673,
78812,
31596,
50493,
198,
262,
11414,
262,
2160,
284,
12290,
8576,
62925,
17758,
7925,
12794,
5400,
1021,
286,
364,
9125,
15543,
482,
456,
19221,
4338,
2857,
3583,
1329,
262,
471,
12290,
8576,
62925,
17758,
4736,
12794,
16442,
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
] |
inasafe/inasafe | extras/xml_tools.py | get_elements | def get_elements(nodelist):
"""Return list of nodes that are ELEMENT_NODE
"""
element_list = []
for node in nodelist:
if node.nodeType == Node.ELEMENT_NODE:
element_list.append(node)
return element_list | python | def get_elements(nodelist):
"""Return list of nodes that are ELEMENT_NODE
"""
element_list = []
for node in nodelist:
if node.nodeType == Node.ELEMENT_NODE:
element_list.append(node)
return element_list | [
"def",
"get_elements",
"(",
"nodelist",
")",
":",
"element_list",
"=",
"[",
"]",
"for",
"node",
"in",
"nodelist",
":",
"if",
"node",
".",
"nodeType",
"==",
"Node",
".",
"ELEMENT_NODE",
":",
"element_list",
".",
"append",
"(",
"node",
")",
"return",
"element_list"
] | Return list of nodes that are ELEMENT_NODE | [
"Return",
"list",
"of",
"nodes",
"that",
"are",
"ELEMENT_NODE"
] | train | https://github.com/inasafe/inasafe/blob/831d60abba919f6d481dc94a8d988cc205130724/extras/xml_tools.py#L40-L49 | <|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 list of nodes that are ELEMENT_NODE
### Response:
def get_elements(nodelist):
"""Return list of nodes that are ELEMENT_NODE
"""
element_list = []
for node in nodelist:
if node.nodeType == Node.ELEMENT_NODE:
element_list.append(node)
return element_list
<|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,
1160,
315,
7954,
430,
527,
63456,
19769,
271,
14711,
6075,
512,
755,
636,
23646,
1471,
85113,
997,
262,
4304,
5715,
1160,
315,
7954,
430,
527,
63456,
19769,
198,
262,
12713,
262,
2449,
2062,
284,
4260,
262,
369,
2494,
304,
308,
85113,
512,
286,
422,
2494,
61472,
624,
6146,
5253,
18315,
19769,
512,
310,
2449,
2062,
2102,
7103,
696,
262,
471,
2449,
2062,
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,
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,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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
] | [
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,
1160,
315,
7954,
430,
527,
63456,
19769,
271,
14711,
6075,
512,
755,
636,
23646,
1471,
85113,
997,
262,
4304,
5715,
1160,
315,
7954,
430,
527,
63456,
19769,
198,
262,
12713,
262,
2449,
2062,
284,
4260,
262,
369,
2494,
304,
308,
85113,
512,
286,
422,
2494,
61472,
624,
6146,
5253,
18315,
19769,
512,
310,
2449,
2062,
2102,
7103,
696,
262,
471,
2449,
2062,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
thespacedoctor/sherlock | sherlock/imports/ifs.py | ifs._create_dictionary_of_IFS | def _create_dictionary_of_IFS(
self):
"""*Generate the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
from sherlock.imports import IFS
stream = IFS(
log=log,
settings=settings
)
dictList = stream._create_dictionary_of_IFS()
"""
self.log.debug(
'starting the ``_create_dictionary_of_IFS`` method')
# GRAB THE CONTENT OF THE IFS CSV
try:
response = requests.get(
url=self.settings["ifs galaxies url"],
)
thisData = response.content
thisData = thisData.split("\n")
status_code = response.status_code
except requests.exceptions.RequestException:
print 'HTTP Request failed'
sys.exit(0)
dictList = []
columns = ["name", "raDeg", "decDeg", "z"]
for line in thisData:
thisDict = {}
line = line.strip()
line = line.replace("\t", " ")
values = line.split("|")
if len(values) > 3:
thisDict["name"] = values[0].strip()
# ASTROCALC UNIT CONVERTER OBJECT
converter = unit_conversion(
log=self.log
)
try:
raDeg = converter.ra_sexegesimal_to_decimal(
ra=values[1].strip()
)
thisDict["raDeg"] = raDeg
decDeg = converter.dec_sexegesimal_to_decimal(
dec=values[2].strip()
)
thisDict["decDeg"] = decDeg
except:
name = thisDict["name"]
self.log.warning(
'Could not convert the coordinates for IFS source %(name)s. Skipping import of this source.' % locals())
continue
try:
z = float(values[3].strip())
if z > 0.:
thisDict["z"] = float(values[3].strip())
else:
thisDict["z"] = None
except:
thisDict["z"] = None
dictList.append(thisDict)
self.log.debug(
'completed the ``_create_dictionary_of_IFS`` method')
return dictList | python | def _create_dictionary_of_IFS(
self):
"""*Generate the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
from sherlock.imports import IFS
stream = IFS(
log=log,
settings=settings
)
dictList = stream._create_dictionary_of_IFS()
"""
self.log.debug(
'starting the ``_create_dictionary_of_IFS`` method')
# GRAB THE CONTENT OF THE IFS CSV
try:
response = requests.get(
url=self.settings["ifs galaxies url"],
)
thisData = response.content
thisData = thisData.split("\n")
status_code = response.status_code
except requests.exceptions.RequestException:
print 'HTTP Request failed'
sys.exit(0)
dictList = []
columns = ["name", "raDeg", "decDeg", "z"]
for line in thisData:
thisDict = {}
line = line.strip()
line = line.replace("\t", " ")
values = line.split("|")
if len(values) > 3:
thisDict["name"] = values[0].strip()
# ASTROCALC UNIT CONVERTER OBJECT
converter = unit_conversion(
log=self.log
)
try:
raDeg = converter.ra_sexegesimal_to_decimal(
ra=values[1].strip()
)
thisDict["raDeg"] = raDeg
decDeg = converter.dec_sexegesimal_to_decimal(
dec=values[2].strip()
)
thisDict["decDeg"] = decDeg
except:
name = thisDict["name"]
self.log.warning(
'Could not convert the coordinates for IFS source %(name)s. Skipping import of this source.' % locals())
continue
try:
z = float(values[3].strip())
if z > 0.:
thisDict["z"] = float(values[3].strip())
else:
thisDict["z"] = None
except:
thisDict["z"] = None
dictList.append(thisDict)
self.log.debug(
'completed the ``_create_dictionary_of_IFS`` method')
return dictList | [
"def",
"_create_dictionary_of_IFS",
"(",
"self",
")",
":",
"self",
".",
"log",
".",
"debug",
"(",
"'starting the ``_create_dictionary_of_IFS`` method'",
")",
"# GRAB THE CONTENT OF THE IFS CSV",
"try",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
"=",
"self",
".",
"settings",
"[",
"\"ifs galaxies url\"",
"]",
",",
")",
"thisData",
"=",
"response",
".",
"content",
"thisData",
"=",
"thisData",
".",
"split",
"(",
"\"\\n\"",
")",
"status_code",
"=",
"response",
".",
"status_code",
"except",
"requests",
".",
"exceptions",
".",
"RequestException",
":",
"print",
"'HTTP Request failed'",
"sys",
".",
"exit",
"(",
"0",
")",
"dictList",
"=",
"[",
"]",
"columns",
"=",
"[",
"\"name\"",
",",
"\"raDeg\"",
",",
"\"decDeg\"",
",",
"\"z\"",
"]",
"for",
"line",
"in",
"thisData",
":",
"thisDict",
"=",
"{",
"}",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"line",
"=",
"line",
".",
"replace",
"(",
"\"\\t\"",
",",
"\" \"",
")",
"values",
"=",
"line",
".",
"split",
"(",
"\"|\"",
")",
"if",
"len",
"(",
"values",
")",
">",
"3",
":",
"thisDict",
"[",
"\"name\"",
"]",
"=",
"values",
"[",
"0",
"]",
".",
"strip",
"(",
")",
"# ASTROCALC UNIT CONVERTER OBJECT",
"converter",
"=",
"unit_conversion",
"(",
"log",
"=",
"self",
".",
"log",
")",
"try",
":",
"raDeg",
"=",
"converter",
".",
"ra_sexegesimal_to_decimal",
"(",
"ra",
"=",
"values",
"[",
"1",
"]",
".",
"strip",
"(",
")",
")",
"thisDict",
"[",
"\"raDeg\"",
"]",
"=",
"raDeg",
"decDeg",
"=",
"converter",
".",
"dec_sexegesimal_to_decimal",
"(",
"dec",
"=",
"values",
"[",
"2",
"]",
".",
"strip",
"(",
")",
")",
"thisDict",
"[",
"\"decDeg\"",
"]",
"=",
"decDeg",
"except",
":",
"name",
"=",
"thisDict",
"[",
"\"name\"",
"]",
"self",
".",
"log",
".",
"warning",
"(",
"'Could not convert the coordinates for IFS source %(name)s. Skipping import of this source.'",
"%",
"locals",
"(",
")",
")",
"continue",
"try",
":",
"z",
"=",
"float",
"(",
"values",
"[",
"3",
"]",
".",
"strip",
"(",
")",
")",
"if",
"z",
">",
"0.",
":",
"thisDict",
"[",
"\"z\"",
"]",
"=",
"float",
"(",
"values",
"[",
"3",
"]",
".",
"strip",
"(",
")",
")",
"else",
":",
"thisDict",
"[",
"\"z\"",
"]",
"=",
"None",
"except",
":",
"thisDict",
"[",
"\"z\"",
"]",
"=",
"None",
"dictList",
".",
"append",
"(",
"thisDict",
")",
"self",
".",
"log",
".",
"debug",
"(",
"'completed the ``_create_dictionary_of_IFS`` method'",
")",
"return",
"dictList"
] | *Generate the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
from sherlock.imports import IFS
stream = IFS(
log=log,
settings=settings
)
dictList = stream._create_dictionary_of_IFS() | [
"*",
"Generate",
"the",
"list",
"of",
"dictionaries",
"containing",
"all",
"the",
"rows",
"in",
"the",
"IFS",
"stream",
"*"
] | train | https://github.com/thespacedoctor/sherlock/blob/2c80fb6fa31b04e7820e6928e3d437a21e692dd3/sherlock/imports/ifs.py#L107-L181 | <|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 the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
from sherlock.imports import IFS
stream = IFS(
log=log,
settings=settings
)
dictList = stream._create_dictionary_of_IFS()
### Response:
def _create_dictionary_of_IFS(
self):
"""*Generate the list of dictionaries containing all the rows in the IFS stream*
**Return:**
- ``dictList`` - a list of dictionaries containing all the rows in the IFS stream
**Usage:**
.. code-block:: python
from sherlock.imports import IFS
stream = IFS(
log=log,
settings=settings
)
dictList = stream._create_dictionary_of_IFS()
"""
self.log.debug(
'starting the ``_create_dictionary_of_IFS`` method')
# GRAB THE CONTENT OF THE IFS CSV
try:
response = requests.get(
url=self.settings["ifs galaxies url"],
)
thisData = response.content
thisData = thisData.split("\n")
status_code = response.status_code
except requests.exceptions.RequestException:
print 'HTTP Request failed'
sys.exit(0)
dictList = []
columns = ["name", "raDeg", "decDeg", "z"]
for line in thisData:
thisDict = {}
line = line.strip()
line = line.replace("\t", " ")
values = line.split("|")
if len(values) > 3:
thisDict["name"] = values[0].strip()
# ASTROCALC UNIT CONVERTER OBJECT
converter = unit_conversion(
log=self.log
)
try:
raDeg = converter.ra_sexegesimal_to_decimal(
ra=values[1].strip()
)
thisDict["raDeg"] = raDeg
decDeg = converter.dec_sexegesimal_to_decimal(
dec=values[2].strip()
)
thisDict["decDeg"] = decDeg
except:
name = thisDict["name"]
self.log.warning(
'Could not convert the coordinates for IFS source %(name)s. Skipping import of this source.' % locals())
continue
try:
z = float(values[3].strip())
if z > 0.:
thisDict["z"] = float(values[3].strip())
else:
thisDict["z"] = None
except:
thisDict["z"] = None
dictList.append(thisDict)
self.log.debug(
'completed the ``_create_dictionary_of_IFS`` method')
return dictList
<|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,
9,
32215,
279,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
22242,
286,
3146,
5715,
25,
1035,
310,
482,
10103,
8644,
861,
14196,
482,
264,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
271,
286,
3146,
15126,
25,
57277,
310,
5354,
2082,
9612,
487,
10344,
4815,
394,
505,
35313,
1039,
35997,
82,
1179,
358,
8653,
198,
394,
4365,
284,
358,
8653,
1021,
504,
1515,
84404,
345,
504,
5110,
73752,
198,
394,
1763,
394,
6587,
861,
284,
4365,
1462,
3261,
43705,
3659,
19573,
50,
2892,
14711,
6075,
512,
755,
721,
3261,
43705,
3659,
19573,
50,
1021,
310,
659,
997,
286,
4304,
9,
32215,
279,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
22242,
286,
3146,
5715,
25,
1035,
310,
482,
10103,
8644,
861,
14196,
482,
264,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
271,
286,
3146,
15126,
25,
57277,
310,
5354,
2082,
9612,
487,
10344,
4815,
394,
505,
35313,
1039,
35997,
82,
1179,
358,
8653,
198,
394,
4365,
284,
358,
8653,
1021,
504,
1515,
84404,
345,
504,
5110,
73752,
198,
394,
1763,
394,
6587,
861,
284,
4365,
1462,
3261,
43705,
3659,
19573,
50,
746,
286,
3270,
286,
659,
1699,
8042,
1021,
310,
364,
40389,
279,
10103,
62,
3261,
43705,
3659,
19573,
50,
14196,
1749,
4713,
286,
674,
15116,
1905,
3247,
36868,
3083,
3247,
358,
8653,
28545,
198,
286,
1456,
512,
310,
2077,
284,
7540,
673,
1021,
394,
2576,
7822,
16728,
1204,
22589,
66017,
2576,
8257,
310,
1763,
310,
420,
1061,
284,
2077,
5521,
198,
310,
420,
1061,
284,
420,
1061,
5402,
5026,
77,
1158,
310,
2704,
4229,
284,
2077,
4397,
4229,
198,
286,
3734,
7540,
26744,
9856,
1378,
512,
310,
1194,
364,
9412,
6274,
4745,
1270,
310,
5826,
13955,
7,
15,
696,
286,
6587,
861,
284,
4260,
286,
8310,
284,
4482,
609,
498,
330,
969,
46757,
498,
330,
8332,
46757,
498,
330,
89,
27001,
286,
369,
1584,
304,
420,
1061,
512,
310,
420,
13755,
284,
5731,
310,
1584,
284,
1584,
17624,
746,
310,
1584,
284,
1584,
7125,
5026,
83,
498,
330,
14501,
310,
2819,
284,
1584,
5402,
39647,
1158,
310,
422,
2479,
20706,
8,
871,
220,
18,
512,
394,
420,
13755,
1204,
609,
1365,
284,
2819,
58,
15,
948,
13406,
2892,
394,
674,
23276,
1308,
50633,
34,
39302,
68387,
643,
40886,
198,
394,
28157,
284,
5089,
65232,
1021,
504,
1515,
7822,
1699,
198,
394,
1763,
394,
1456,
512,
504,
15473,
46757,
284,
28157,
83414,
83213,
797,
30572,
2401,
75529,
1021,
667,
15473,
28,
3745,
58,
16,
948,
13406,
746,
504,
1763,
504,
420,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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,
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,
9,
32215,
279,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
22242,
286,
3146,
5715,
25,
1035,
310,
482,
10103,
8644,
861,
14196,
482,
264,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
271,
286,
3146,
15126,
25,
57277,
310,
5354,
2082,
9612,
487,
10344,
4815,
394,
505,
35313,
1039,
35997,
82,
1179,
358,
8653,
198,
394,
4365,
284,
358,
8653,
1021,
504,
1515,
84404,
345,
504,
5110,
73752,
198,
394,
1763,
394,
6587,
861,
284,
4365,
1462,
3261,
43705,
3659,
19573,
50,
2892,
14711,
6075,
512,
755,
721,
3261,
43705,
3659,
19573,
50,
1021,
310,
659,
997,
286,
4304,
9,
32215,
279,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
22242,
286,
3146,
5715,
25,
1035,
310,
482,
10103,
8644,
861,
14196,
482,
264,
1160,
315,
58614,
8649,
682,
279,
7123,
304,
279,
358,
8653,
4365,
271,
286,
3146,
15126,
25,
57277,
310,
5354,
2082,
9612,
487,
10344,
4815,
394,
505,
35313,
1039,
35997,
82,
1179,
358,
8653,
198,
394,
4365,
284,
358,
8653,
1021,
504,
1515,
84404,
345,
504,
5110,
73752,
198,
394,
1763,
394,
6587,
861,
284,
4365,
1462,
3261,
43705,
3659,
19573,
50,
746,
286,
3270,
286,
659,
1699,
8042,
1021,
310,
364,
40389,
279,
10103,
62,
3261,
43705,
3659,
19573,
50,
14196,
1749,
4713,
286,
674,
15116,
1905,
3247,
36868,
3083,
3247,
358,
8653,
28545,
198,
286,
1456,
512,
310,
2077,
284,
7540,
673,
1021,
394,
2576,
7822,
16728,
1204,
22589,
66017,
2576,
8257,
310,
1763,
310,
420,
1061,
284,
2077,
5521,
198,
310,
420,
1061,
284,
420,
1061,
5402,
5026,
77,
1158,
310,
2704,
4229,
284,
2077,
4397,
4229,
198,
286,
3734,
7540,
26744,
9856,
1378,
512,
310,
1194,
364,
9412,
6274,
4745,
1270,
310,
5826,
13955,
7,
15,
696,
286,
6587,
861,
284,
4260,
286,
8310,
284,
4482,
609,
498,
330,
969,
46757,
498,
330,
8332,
46757,
498,
330,
89,
27001,
286,
369,
1584,
304,
420,
1061,
512,
310,
420,
13755,
284,
5731,
310,
1584,
284,
1584,
17624,
746,
310,
1584,
284,
1584,
7125,
5026,
83,
498,
330,
14501,
310,
2819,
284,
1584,
5402,
39647,
1158,
310,
422,
2479,
20706,
8,
871,
220,
18,
512,
394,
420,
13755,
1204,
609,
1365,
284,
2819,
58,
15,
948,
13406,
2892,
394,
674,
23276,
1308,
50633,
34,
39302,
68387,
643,
40886,
198,
394,
28157,
284,
5089,
65232,
1021,
504,
1515,
7822,
1699,
198,
394,
1763,
394,
1456,
512,
504,
15473,
46757,
284,
28157,
83414,
83213,
797,
30572,
2401,
75529,
1021,
667,
15473,
28,
3745,
58,
16,
948,
13406,
746,
504,
1763,
504,
420,
13755,
1204,
969,
46757,
1365,
284,
15473,
46757,
198,
504,
1654,
46757,
284,
28157,
29120,
83213,
797,
30572,
2401,
75529,
1021,
667,
1654,
28,
3745,
58,
17,
948,
13406,
746,
504,
1763,
504,
420,
13755,
1204,
8332,
46757,
1365,
284,
1654,
46757,
198,
394
] |
estnltk/estnltk | estnltk/disambiguator.py | Disambiguator.post_disambiguate | def post_disambiguate(self, collections):
""" Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine
toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning
seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1
dokumendikollektsioon);
Sisuliselt kasutatakse ühestamisel "üks tähendus teksti kohta" idee laiendust:
kui mitmeseks jäänud lemma esineb ka mujal (samas kollektsioonis või kõigis
kollektsioonides) ning lõppkokkuvõttes esineb sagedamini kui alternatiivsed
analüüsid, siis tõenäoliselt see ongi õige lemma/analüüs;
"""
#
# I etapp: ühestame ühe dokumendikollektsiooni piires
# (nt üle kõigi samal päeval ilmunud ajaleheartiklite);
#
for docs in collections:
# 1) Eemaldame analüüside seast duplikaadid ja probleemsed
self.__remove_duplicate_and_problematic_analyses(docs)
# 2) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
# (selliseid mitmesusi, mida me ühestamisel ei arvesta);
hiddenWords = self.__find_hidden_analyses(docs)
# 3) Leiame kaks lemmade sagedusleksikoni: üldise lemmade sagedus-
# leksikoni ja mitmeseks jäänud sonade lemmade sagedusleksikoni;
# Mitmeste lemmade leksikoni läheb kirja vastavate lemmade yldine
# sagedus korpuses (kuhu arvatud ka sagedus ühestatud sõnades);
genLemmaLex = dict()
ambLemmaLex = dict()
self.__supplement_lemma_frequency_lexicon(docs, hiddenWords, ambLemmaLex, genLemmaLex)
# 4) Teostame lemmade-p6hise yhestamise: mitmeseks j22nud analyyside
# puhul j2tame alles analyysid, mille lemma esinemisagedus on suurim
# (ja kui k6igi esinemissagedus on v6rdne, siis ei tee midagi)
self.__disambiguate_with_lexicon(docs, ambLemmaLex, hiddenWords)
#
# II etapp: ühestame üle kõikide dokumendikollektsioonide
# (nt üle kõigi ühe aasta ajalehenumbrite, kus
# üks ajalehenumber sisaldab kõiki sama päeva artikleid);
#
if len(collections) > 1:
# Genereerime mitmeste sagedusleksikoni
genLemmaLex = dict()
ambLemmaLex = dict()
for docs in collections:
# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
hiddenWords = self.__find_hidden_analyses(docs)
# *) Täiendame üldist lemmade sagedusleksikoni ja mitmeseks jäänud
# lemmade sagedusleksikoni;
self.__supplement_lemma_frequency_lexicon(docs, hiddenWords, ambLemmaLex, genLemmaLex)
# Teostame järelühestamise
for docs in collections:
# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
hiddenWords = self.__find_hidden_analyses(docs)
# *) Teostame lemmade-p6hise yhestamise;
self.__disambiguate_with_lexicon(docs, ambLemmaLex, hiddenWords)
return collections | python | def post_disambiguate(self, collections):
""" Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine
toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning
seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1
dokumendikollektsioon);
Sisuliselt kasutatakse ühestamisel "üks tähendus teksti kohta" idee laiendust:
kui mitmeseks jäänud lemma esineb ka mujal (samas kollektsioonis või kõigis
kollektsioonides) ning lõppkokkuvõttes esineb sagedamini kui alternatiivsed
analüüsid, siis tõenäoliselt see ongi õige lemma/analüüs;
"""
#
# I etapp: ühestame ühe dokumendikollektsiooni piires
# (nt üle kõigi samal päeval ilmunud ajaleheartiklite);
#
for docs in collections:
# 1) Eemaldame analüüside seast duplikaadid ja probleemsed
self.__remove_duplicate_and_problematic_analyses(docs)
# 2) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
# (selliseid mitmesusi, mida me ühestamisel ei arvesta);
hiddenWords = self.__find_hidden_analyses(docs)
# 3) Leiame kaks lemmade sagedusleksikoni: üldise lemmade sagedus-
# leksikoni ja mitmeseks jäänud sonade lemmade sagedusleksikoni;
# Mitmeste lemmade leksikoni läheb kirja vastavate lemmade yldine
# sagedus korpuses (kuhu arvatud ka sagedus ühestatud sõnades);
genLemmaLex = dict()
ambLemmaLex = dict()
self.__supplement_lemma_frequency_lexicon(docs, hiddenWords, ambLemmaLex, genLemmaLex)
# 4) Teostame lemmade-p6hise yhestamise: mitmeseks j22nud analyyside
# puhul j2tame alles analyysid, mille lemma esinemisagedus on suurim
# (ja kui k6igi esinemissagedus on v6rdne, siis ei tee midagi)
self.__disambiguate_with_lexicon(docs, ambLemmaLex, hiddenWords)
#
# II etapp: ühestame üle kõikide dokumendikollektsioonide
# (nt üle kõigi ühe aasta ajalehenumbrite, kus
# üks ajalehenumber sisaldab kõiki sama päeva artikleid);
#
if len(collections) > 1:
# Genereerime mitmeste sagedusleksikoni
genLemmaLex = dict()
ambLemmaLex = dict()
for docs in collections:
# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
hiddenWords = self.__find_hidden_analyses(docs)
# *) Täiendame üldist lemmade sagedusleksikoni ja mitmeseks jäänud
# lemmade sagedusleksikoni;
self.__supplement_lemma_frequency_lexicon(docs, hiddenWords, ambLemmaLex, genLemmaLex)
# Teostame järelühestamise
for docs in collections:
# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
hiddenWords = self.__find_hidden_analyses(docs)
# *) Teostame lemmade-p6hise yhestamise;
self.__disambiguate_with_lexicon(docs, ambLemmaLex, hiddenWords)
return collections | [
"def",
"post_disambiguate",
"(",
"self",
",",
"collections",
")",
":",
"#",
"# I etapp: ühestame ühe dokumendikollektsiooni piires ",
"# (nt üle kõigi samal päeval ilmunud ajaleheartiklite);",
"#",
"for",
"docs",
"in",
"collections",
":",
"# 1) Eemaldame analüüside seast duplikaadid ja probleemsed",
"self",
".",
"__remove_duplicate_and_problematic_analyses",
"(",
"docs",
")",
"# 2) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi",
"# (selliseid mitmesusi, mida me ühestamisel ei arvesta);",
"hiddenWords",
"=",
"self",
".",
"__find_hidden_analyses",
"(",
"docs",
")",
"# 3) Leiame kaks lemmade sagedusleksikoni: üldise lemmade sagedus-",
"# leksikoni ja mitmeseks jäänud sonade lemmade sagedusleksikoni;",
"# Mitmeste lemmade leksikoni läheb kirja vastavate lemmade yldine ",
"# sagedus korpuses (kuhu arvatud ka sagedus ühestatud sõnades);",
"genLemmaLex",
"=",
"dict",
"(",
")",
"ambLemmaLex",
"=",
"dict",
"(",
")",
"self",
".",
"__supplement_lemma_frequency_lexicon",
"(",
"docs",
",",
"hiddenWords",
",",
"ambLemmaLex",
",",
"genLemmaLex",
")",
"# 4) Teostame lemmade-p6hise yhestamise: mitmeseks j22nud analyyside ",
"# puhul j2tame alles analyysid, mille lemma esinemisagedus on suurim",
"# (ja kui k6igi esinemissagedus on v6rdne, siis ei tee midagi)",
"self",
".",
"__disambiguate_with_lexicon",
"(",
"docs",
",",
"ambLemmaLex",
",",
"hiddenWords",
")",
"#",
"# II etapp: ühestame üle kõikide dokumendikollektsioonide ",
"# (nt üle kõigi ühe aasta ajalehenumbrite, kus",
"# üks ajalehenumber sisaldab kõiki sama päeva artikleid);",
"#",
"if",
"len",
"(",
"collections",
")",
">",
"1",
":",
"# Genereerime mitmeste sagedusleksikoni",
"genLemmaLex",
"=",
"dict",
"(",
")",
"ambLemmaLex",
"=",
"dict",
"(",
")",
"for",
"docs",
"in",
"collections",
":",
"# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi",
"hiddenWords",
"=",
"self",
".",
"__find_hidden_analyses",
"(",
"docs",
")",
"# *) Täiendame üldist lemmade sagedusleksikoni ja mitmeseks jäänud",
"# lemmade sagedusleksikoni;",
"self",
".",
"__supplement_lemma_frequency_lexicon",
"(",
"docs",
",",
"hiddenWords",
",",
"ambLemmaLex",
",",
"genLemmaLex",
")",
"# Teostame järelühestamise",
"for",
"docs",
"in",
"collections",
":",
"# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi",
"hiddenWords",
"=",
"self",
".",
"__find_hidden_analyses",
"(",
"docs",
")",
"# *) Teostame lemmade-p6hise yhestamise;",
"self",
".",
"__disambiguate_with_lexicon",
"(",
"docs",
",",
"ambLemmaLex",
",",
"hiddenWords",
")",
"return",
"collections"
] | Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine
toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning
seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1
dokumendikollektsioon);
Sisuliselt kasutatakse ühestamisel "üks tähendus teksti kohta" idee laiendust:
kui mitmeseks jäänud lemma esineb ka mujal (samas kollektsioonis või kõigis
kollektsioonides) ning lõppkokkuvõttes esineb sagedamini kui alternatiivsed
analüüsid, siis tõenäoliselt see ongi õige lemma/analüüs; | [
"Teostab",
"mitmeste",
"analüüside",
"lemma",
"-",
"põhise",
"järelühestamise",
".",
"Järelühestamine",
"toimub",
"kahes",
"etapis",
":",
"kõigepealt",
"ühe",
"dokumendikollektsiooni",
"piires",
"ning",
"seejärel",
"üle",
"kõigi",
"dokumendikollektsioonide",
"(",
"kui",
"sisendis",
"on",
"rohkem",
"kui",
"1",
"dokumendikollektsioon",
")",
";",
"Sisuliselt",
"kasutatakse",
"ühestamisel",
"üks",
"tähendus",
"teksti",
"kohta",
"idee",
"laiendust",
":",
"kui",
"mitmeseks",
"jäänud",
"lemma",
"esineb",
"ka",
"mujal",
"(",
"samas",
"kollektsioonis",
"või",
"kõigis",
"kollektsioonides",
")",
"ning",
"lõppkokkuvõttes",
"esineb",
"sagedamini",
"kui",
"alternatiivsed",
"analüüsid",
"siis",
"tõenäoliselt",
"see",
"ongi",
"õige",
"lemma",
"/",
"analüüs",
";"
] | train | https://github.com/estnltk/estnltk/blob/28ae334a68a0673072febc318635f04da0dcc54a/estnltk/disambiguator.py#L615-L667 | <|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:
Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine
toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning
seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1
dokumendikollektsioon);
Sisuliselt kasutatakse ühestamisel "üks tähendus teksti kohta" idee laiendust:
kui mitmeseks jäänud lemma esineb ka mujal (samas kollektsioonis või kõigis
kollektsioonides) ning lõppkokkuvõttes esineb sagedamini kui alternatiivsed
analüüsid, siis tõenäoliselt see ongi õige lemma/analüüs;
### Response:
def post_disambiguate(self, collections):
""" Teostab mitmeste analüüside lemma-põhise järelühestamise. Järelühestamine
toimub kahes etapis: kõigepealt ühe dokumendikollektsiooni piires ning
seejärel üle kõigi dokumendikollektsioonide (kui sisendis on rohkem kui 1
dokumendikollektsioon);
Sisuliselt kasutatakse ühestamisel "üks tähendus teksti kohta" idee laiendust:
kui mitmeseks jäänud lemma esineb ka mujal (samas kollektsioonis või kõigis
kollektsioonides) ning lõppkokkuvõttes esineb sagedamini kui alternatiivsed
analüüsid, siis tõenäoliselt see ongi õige lemma/analüüs;
"""
#
# I etapp: ühestame ühe dokumendikollektsiooni piires
# (nt üle kõigi samal päeval ilmunud ajaleheartiklite);
#
for docs in collections:
# 1) Eemaldame analüüside seast duplikaadid ja probleemsed
self.__remove_duplicate_and_problematic_analyses(docs)
# 2) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
# (selliseid mitmesusi, mida me ühestamisel ei arvesta);
hiddenWords = self.__find_hidden_analyses(docs)
# 3) Leiame kaks lemmade sagedusleksikoni: üldise lemmade sagedus-
# leksikoni ja mitmeseks jäänud sonade lemmade sagedusleksikoni;
# Mitmeste lemmade leksikoni läheb kirja vastavate lemmade yldine
# sagedus korpuses (kuhu arvatud ka sagedus ühestatud sõnades);
genLemmaLex = dict()
ambLemmaLex = dict()
self.__supplement_lemma_frequency_lexicon(docs, hiddenWords, ambLemmaLex, genLemmaLex)
# 4) Teostame lemmade-p6hise yhestamise: mitmeseks j22nud analyyside
# puhul j2tame alles analyysid, mille lemma esinemisagedus on suurim
# (ja kui k6igi esinemissagedus on v6rdne, siis ei tee midagi)
self.__disambiguate_with_lexicon(docs, ambLemmaLex, hiddenWords)
#
# II etapp: ühestame üle kõikide dokumendikollektsioonide
# (nt üle kõigi ühe aasta ajalehenumbrite, kus
# üks ajalehenumber sisaldab kõiki sama päeva artikleid);
#
if len(collections) > 1:
# Genereerime mitmeste sagedusleksikoni
genLemmaLex = dict()
ambLemmaLex = dict()
for docs in collections:
# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
hiddenWords = self.__find_hidden_analyses(docs)
# *) Täiendame üldist lemmade sagedusleksikoni ja mitmeseks jäänud
# lemmade sagedusleksikoni;
self.__supplement_lemma_frequency_lexicon(docs, hiddenWords, ambLemmaLex, genLemmaLex)
# Teostame järelühestamise
for docs in collections:
# *) Leiame sõnad, mis sisaldavad nn ignoreeritavaid mitmesusi
hiddenWords = self.__find_hidden_analyses(docs)
# *) Teostame lemmade-p6hise yhestamise;
self.__disambiguate_with_lexicon(docs, ambLemmaLex, hiddenWords)
return collections
<|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,
6777,
537,
370,
5568,
76,
18223,
3260,
2448,
2448,
3002,
19340,
2320,
11399,
71,
1082,
88628,
3833,
2448,
6536,
309,
1082,
13,
622,
2357,
3833,
2448,
6536,
20588,
720,
310,
311,
318,
392,
110929,
288,
1880,
14041,
25,
597,
11399,
7404,
375,
3223,
10709,
383,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
21446,
75130,
417,
46607,
720,
310,
1518,
73,
2357,
3833,
10709,
273,
597,
11399,
30637,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
579,
320,
74,
2005,
53415,
408,
285,
389,
938,
86611,
336,
597,
2005,
220,
16,
198,
310,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
317,
1835,
328,
285,
65130,
3903,
48756,
332,
69828,
325,
10709,
6536,
309,
66394,
330,
2448,
2857,
259,
22243,
408,
355,
73678,
72,
15593,
76909,
1,
2679,
68,
116611,
408,
592,
512,
310,
597,
2005,
5568,
9004,
21854,
503,
60446,
664,
19340,
1560,
483,
65,
16909,
27937,
278,
320,
82,
29189,
48219,
76876,
2641,
822,
97794,
80295,
72,
597,
11399,
343,
285,
198,
310,
48219,
76876,
2641,
822,
263,
3422,
8,
46607,
326,
11399,
604,
46364,
74,
12328,
11399,
83,
2392,
1560,
483,
65,
274,
3359,
309,
6729,
597,
2005,
7064,
9491,
344,
32424,
198,
310,
3260,
2448,
2448,
21703,
11,
4502,
285,
259,
11399,
268,
2357,
69858,
3903,
1518,
389,
8376,
1717,
113,
7404,
19340,
14,
49921,
2448,
101789,
401,
14711,
6075,
512,
755,
1772,
10135,
3042,
343,
6426,
1214,
11,
15661,
997,
286,
4304,
220,
2722,
537,
370,
5568,
76,
18223,
3260,
2448,
2448,
3002,
19340,
2320,
11399,
71,
1082,
88628,
3833,
2448,
6536,
309,
1082,
13,
622,
2357,
3833,
2448,
6536,
20588,
720,
310,
311,
318,
392,
110929,
288,
1880,
14041,
25,
597,
11399,
7404,
375,
3223,
10709,
383,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
21446,
75130,
417,
46607,
720,
310,
1518,
73,
2357,
3833,
10709,
273,
597,
11399,
30637,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
579,
320,
74,
2005,
53415,
408,
285,
389,
938,
86611,
336,
597,
2005,
220,
16,
198,
310,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
317,
1835,
328,
285,
65130,
3903,
48756,
332,
69828,
325,
10709,
6536,
309,
66394,
330,
2448,
2857,
259,
22243,
408,
355,
73678,
72,
15593,
76909,
1,
2679,
68,
116611,
408,
592,
512,
310,
597,
2005,
5568,
9004,
21854,
503,
60446,
664,
19340,
1560,
483,
65,
16909,
27937,
278,
320,
82,
29189,
48219,
76876,
2641,
822,
97794,
80295,
72,
597,
11399,
343,
285,
198,
310,
48219,
76876,
2641,
822,
263,
3422,
8,
46607,
326,
11399,
604,
46364,
74,
12328,
11399,
83,
2392,
1560,
483,
65,
274,
3359,
309,
6729,
597,
2005,
7064,
9491,
344,
32424,
198,
310,
3260,
2448,
2448,
21703,
11,
4502,
285,
259,
11399,
268,
2357,
69858,
3903,
1518,
389,
8376,
1717,
113,
7404,
19340,
14,
49921,
2448,
101789,
280,
286,
3270,
286,
9733,
286,
674,
220,
358,
1880
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
6777,
537,
370,
5568,
76,
18223,
3260,
2448,
2448,
3002,
19340,
2320,
11399,
71,
1082,
88628,
3833,
2448,
6536,
309,
1082,
13,
622,
2357,
3833,
2448,
6536,
20588,
720,
310,
311,
318,
392,
110929,
288,
1880,
14041,
25,
597,
11399,
7404,
375,
3223,
10709,
383,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
21446,
75130,
417,
46607,
720,
310,
1518,
73,
2357,
3833,
10709,
273,
597,
11399,
30637,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
579,
320,
74,
2005,
53415,
408,
285,
389,
938,
86611,
336,
597,
2005,
220,
16,
198,
310,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
317,
1835,
328,
285,
65130,
3903,
48756,
332,
69828,
325,
10709,
6536,
309,
66394,
330,
2448,
2857,
259,
22243,
408,
355,
73678,
72,
15593,
76909,
1,
2679,
68,
116611,
408,
592,
512,
310,
597,
2005,
5568,
9004,
21854,
503,
60446,
664,
19340,
1560,
483,
65,
16909,
27937,
278,
320,
82,
29189,
48219,
76876,
2641,
822,
97794,
80295,
72,
597,
11399,
343,
285,
198,
310,
48219,
76876,
2641,
822,
263,
3422,
8,
46607,
326,
11399,
604,
46364,
74,
12328,
11399,
83,
2392,
1560,
483,
65,
274,
3359,
309,
6729,
597,
2005,
7064,
9491,
344,
32424,
198,
310,
3260,
2448,
2448,
21703,
11,
4502,
285,
259,
11399,
268,
2357,
69858,
3903,
1518,
389,
8376,
1717,
113,
7404,
19340,
14,
49921,
2448,
101789,
401,
14711,
6075,
512,
755,
1772,
10135,
3042,
343,
6426,
1214,
11,
15661,
997,
286,
4304,
220,
2722,
537,
370,
5568,
76,
18223,
3260,
2448,
2448,
3002,
19340,
2320,
11399,
71,
1082,
88628,
3833,
2448,
6536,
309,
1082,
13,
622,
2357,
3833,
2448,
6536,
20588,
720,
310,
311,
318,
392,
110929,
288,
1880,
14041,
25,
597,
11399,
7404,
375,
3223,
10709,
383,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
21446,
75130,
417,
46607,
720,
310,
1518,
73,
2357,
3833,
10709,
273,
597,
11399,
30637,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
579,
320,
74,
2005,
53415,
408,
285,
389,
938,
86611,
336,
597,
2005,
220,
16,
198,
310,
42161,
372,
408,
1609,
55148,
74,
2641,
822,
263,
317,
1835,
328,
285,
65130,
3903,
48756,
332,
69828,
325,
10709,
6536,
309,
66394,
330,
2448,
2857,
259,
22243,
408,
355,
73678,
72,
15593,
76909,
1,
2679,
68,
116611,
408,
592,
512,
310,
597,
2005,
5568,
9004,
21854,
503,
60446,
664,
19340,
1560,
483,
65,
16909,
27937,
278,
320,
82,
29189,
48219,
76876,
2641,
822,
97794,
80295,
72,
597,
11399,
343,
285,
198,
310,
48219,
76876,
2641,
822,
263,
3422,
8,
46607,
326,
11399,
604,
46364,
74,
12328,
11399,
83,
2392,
1560,
483,
65,
274,
3359,
309,
6729,
597,
2005,
7064,
9491,
344,
32424,
198,
310,
3260,
2448,
2448,
21703,
11,
4502,
285,
259,
11399,
268,
2357,
69858,
3903,
1518,
389,
8376,
1717,
113,
7404,
19340,
14,
49921,
2448,
101789,
280,
286,
3270,
286,
9733,
286,
674,
220,
358,
1880
] |
iotile/coretools | iotilesensorgraph/iotile/sg/sensor_log.py | SensorLog.create_walker | def create_walker(self, selector, skip_all=True):
"""Create a stream walker based on the given selector.
This function returns a StreamWalker subclass that will
remain up to date and allow iterating over and popping readings
from the stream(s) specified by the selector.
When the stream walker is done, it should be passed to
destroy_walker so that it is removed from internal lists that
are used to always keep it in sync.
Args:
selector (DataStreamSelector): The selector describing the
streams that we want to iterate over.
skip_all (bool): Whether to start at the beginning of the data
or to skip everything and start at the end. Defaults
to skipping everything. This parameter only has any
effect on buffered stream selectors.
Returns:
StreamWalker: A properly updating stream walker with the given selector.
"""
if selector.buffered:
walker = BufferedStreamWalker(selector, self._engine, skip_all=skip_all)
self._queue_walkers.append(walker)
return walker
if selector.match_type == DataStream.CounterType:
walker = CounterStreamWalker(selector)
else:
walker = VirtualStreamWalker(selector)
self._virtual_walkers.append(walker)
return walker | python | def create_walker(self, selector, skip_all=True):
"""Create a stream walker based on the given selector.
This function returns a StreamWalker subclass that will
remain up to date and allow iterating over and popping readings
from the stream(s) specified by the selector.
When the stream walker is done, it should be passed to
destroy_walker so that it is removed from internal lists that
are used to always keep it in sync.
Args:
selector (DataStreamSelector): The selector describing the
streams that we want to iterate over.
skip_all (bool): Whether to start at the beginning of the data
or to skip everything and start at the end. Defaults
to skipping everything. This parameter only has any
effect on buffered stream selectors.
Returns:
StreamWalker: A properly updating stream walker with the given selector.
"""
if selector.buffered:
walker = BufferedStreamWalker(selector, self._engine, skip_all=skip_all)
self._queue_walkers.append(walker)
return walker
if selector.match_type == DataStream.CounterType:
walker = CounterStreamWalker(selector)
else:
walker = VirtualStreamWalker(selector)
self._virtual_walkers.append(walker)
return walker | [
"def",
"create_walker",
"(",
"self",
",",
"selector",
",",
"skip_all",
"=",
"True",
")",
":",
"if",
"selector",
".",
"buffered",
":",
"walker",
"=",
"BufferedStreamWalker",
"(",
"selector",
",",
"self",
".",
"_engine",
",",
"skip_all",
"=",
"skip_all",
")",
"self",
".",
"_queue_walkers",
".",
"append",
"(",
"walker",
")",
"return",
"walker",
"if",
"selector",
".",
"match_type",
"==",
"DataStream",
".",
"CounterType",
":",
"walker",
"=",
"CounterStreamWalker",
"(",
"selector",
")",
"else",
":",
"walker",
"=",
"VirtualStreamWalker",
"(",
"selector",
")",
"self",
".",
"_virtual_walkers",
".",
"append",
"(",
"walker",
")",
"return",
"walker"
] | Create a stream walker based on the given selector.
This function returns a StreamWalker subclass that will
remain up to date and allow iterating over and popping readings
from the stream(s) specified by the selector.
When the stream walker is done, it should be passed to
destroy_walker so that it is removed from internal lists that
are used to always keep it in sync.
Args:
selector (DataStreamSelector): The selector describing the
streams that we want to iterate over.
skip_all (bool): Whether to start at the beginning of the data
or to skip everything and start at the end. Defaults
to skipping everything. This parameter only has any
effect on buffered stream selectors.
Returns:
StreamWalker: A properly updating stream walker with the given selector. | [
"Create",
"a",
"stream",
"walker",
"based",
"on",
"the",
"given",
"selector",
"."
] | train | https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilesensorgraph/iotile/sg/sensor_log.py#L207-L242 | <|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:
Create a stream walker based on the given selector.
This function returns a StreamWalker subclass that will
remain up to date and allow iterating over and popping readings
from the stream(s) specified by the selector.
When the stream walker is done, it should be passed to
destroy_walker so that it is removed from internal lists that
are used to always keep it in sync.
Args:
selector (DataStreamSelector): The selector describing the
streams that we want to iterate over.
skip_all (bool): Whether to start at the beginning of the data
or to skip everything and start at the end. Defaults
to skipping everything. This parameter only has any
effect on buffered stream selectors.
Returns:
StreamWalker: A properly updating stream walker with the given selector.
### Response:
def create_walker(self, selector, skip_all=True):
"""Create a stream walker based on the given selector.
This function returns a StreamWalker subclass that will
remain up to date and allow iterating over and popping readings
from the stream(s) specified by the selector.
When the stream walker is done, it should be passed to
destroy_walker so that it is removed from internal lists that
are used to always keep it in sync.
Args:
selector (DataStreamSelector): The selector describing the
streams that we want to iterate over.
skip_all (bool): Whether to start at the beginning of the data
or to skip everything and start at the end. Defaults
to skipping everything. This parameter only has any
effect on buffered stream selectors.
Returns:
StreamWalker: A properly updating stream walker with the given selector.
"""
if selector.buffered:
walker = BufferedStreamWalker(selector, self._engine, skip_all=skip_all)
self._queue_walkers.append(walker)
return walker
if selector.match_type == DataStream.CounterType:
walker = CounterStreamWalker(selector)
else:
walker = VirtualStreamWalker(selector)
self._virtual_walkers.append(walker)
return walker
<|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,
4110,
264,
4365,
63624,
3196,
389,
279,
2728,
9551,
382,
286,
1115,
734,
4780,
264,
9384,
85992,
38290,
430,
690,
198,
286,
7293,
709,
311,
2457,
323,
2187,
88335,
927,
323,
50949,
40174,
198,
286,
505,
279,
4365,
1161,
8,
5300,
555,
279,
9551,
382,
286,
3277,
279,
4365,
63624,
374,
2884,
11,
433,
1288,
387,
5946,
311,
198,
286,
7066,
1704,
37908,
779,
430,
433,
374,
7108,
505,
5419,
11725,
430,
198,
286,
527,
1511,
311,
2744,
2567,
433,
304,
13105,
382,
286,
18161,
512,
310,
9551,
320,
89162,
6001,
1680,
578,
9551,
23524,
279,
198,
394,
23914,
430,
584,
1390,
311,
30729,
927,
627,
310,
10936,
5823,
320,
2707,
1680,
13440,
311,
1212,
520,
279,
7314,
315,
279,
828,
198,
394,
477,
311,
10936,
4395,
323,
1212,
520,
279,
842,
13,
220,
37090,
198,
394,
311,
43759,
4395,
13,
220,
1115,
5852,
1193,
706,
904,
198,
394,
2515,
389,
54157,
4365,
57137,
382,
286,
5295,
512,
310,
9384,
85992,
25,
362,
10489,
21686,
4365,
63624,
449,
279,
2728,
9551,
382,
14711,
6075,
512,
755,
1893,
1704,
37908,
1214,
11,
9551,
11,
10936,
5823,
3702,
997,
286,
4304,
4110,
264,
4365,
63624,
3196,
389,
279,
2728,
9551,
382,
286,
1115,
734,
4780,
264,
9384,
85992,
38290,
430,
690,
198,
286,
7293,
709,
311,
2457,
323,
2187,
88335,
927,
323,
50949,
40174,
198,
286,
505,
279,
4365,
1161,
8,
5300,
555,
279,
9551,
382,
286,
3277,
279,
4365,
63624,
374,
2884,
11,
433,
1288,
387,
5946,
311,
198,
286,
7066,
1704,
37908,
779,
430,
433,
374,
7108,
505,
5419,
11725,
430,
198,
286,
527,
1511,
311,
2744,
2567,
433,
304,
13105,
382,
286,
18161,
512,
310,
9551,
320,
89162,
6001,
1680,
578,
9551,
23524,
279,
198,
394,
23914,
430,
584,
1390,
311,
30729,
927,
627,
310,
10936,
5823,
320,
2707,
1680,
13440,
311,
1212,
520,
279,
7314,
315,
279,
828,
198,
394,
477,
311,
10936,
4395,
323,
1212,
520,
279,
842,
13,
220,
37090,
198,
394,
311,
43759,
4395,
13,
220,
1115,
5852,
1193,
706,
904,
198,
394,
2515,
389,
54157,
4365,
57137,
382,
286,
5295,
512,
310,
9384,
85992,
25,
362,
10489,
21686,
4365,
63624,
449,
279,
2728,
9551,
627,
286,
12713,
286,
422,
9551,
25472,
291,
512,
310,
63624,
284,
31802,
3103,
85992,
47518,
11,
659,
1462,
8680,
11,
10936,
5823,
28,
21247,
5823,
340,
310,
659,
1462,
4687,
57231,
388,
2102,
3706,
37908,
340,
310,
471,
63624,
271,
286,
422,
9551,
11319,
1857,
624,
2956,
3103,
87391,
941,
512,
310,
63624,
284,
20315,
3103,
85992,
47518,
340,
286,
775,
512,
310,
63624,
284,
21382,
3103,
85992,
47518,
696,
286,
659,
1462,
26752,
57231,
388,
2102,
3706,
37908,
696,
286,
471,
63624,
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
] | [
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,
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,
4110,
264,
4365,
63624,
3196,
389,
279,
2728,
9551,
382,
286,
1115,
734,
4780,
264,
9384,
85992,
38290,
430,
690,
198,
286,
7293,
709,
311,
2457,
323,
2187,
88335,
927,
323,
50949,
40174,
198,
286,
505,
279,
4365,
1161,
8,
5300,
555,
279,
9551,
382,
286,
3277,
279,
4365,
63624,
374,
2884,
11,
433,
1288,
387,
5946,
311,
198,
286,
7066,
1704,
37908,
779,
430,
433,
374,
7108,
505,
5419,
11725,
430,
198,
286,
527,
1511,
311,
2744,
2567,
433,
304,
13105,
382,
286,
18161,
512,
310,
9551,
320,
89162,
6001,
1680,
578,
9551,
23524,
279,
198,
394,
23914,
430,
584,
1390,
311,
30729,
927,
627,
310,
10936,
5823,
320,
2707,
1680,
13440,
311,
1212,
520,
279,
7314,
315,
279,
828,
198,
394,
477,
311,
10936,
4395,
323,
1212,
520,
279,
842,
13,
220,
37090,
198,
394,
311,
43759,
4395,
13,
220,
1115,
5852,
1193,
706,
904,
198,
394,
2515,
389,
54157,
4365,
57137,
382,
286,
5295,
512,
310,
9384,
85992,
25,
362,
10489,
21686,
4365,
63624,
449,
279,
2728,
9551,
382,
14711,
6075,
512,
755,
1893,
1704,
37908,
1214,
11,
9551,
11,
10936,
5823,
3702,
997,
286,
4304,
4110,
264,
4365,
63624,
3196,
389,
279,
2728,
9551,
382,
286,
1115,
734,
4780,
264,
9384,
85992,
38290,
430,
690,
198,
286,
7293,
709,
311,
2457,
323,
2187,
88335,
927,
323,
50949,
40174,
198,
286,
505,
279,
4365,
1161,
8,
5300,
555,
279,
9551,
382,
286,
3277,
279,
4365,
63624,
374,
2884,
11,
433,
1288,
387,
5946,
311,
198,
286,
7066,
1704,
37908,
779,
430,
433,
374,
7108,
505,
5419,
11725,
430,
198,
286,
527,
1511,
311,
2744,
2567,
433,
304,
13105,
382,
286,
18161,
512,
310,
9551,
320,
89162,
6001,
1680,
578,
9551,
23524,
279,
198,
394,
23914,
430,
584,
1390,
311,
30729,
927,
627,
310,
10936,
5823,
320,
2707,
1680,
13440,
311,
1212,
520,
279,
7314,
315,
279,
828,
198,
394,
477,
311,
10936,
4395,
323,
1212,
520,
279,
842,
13,
220,
37090,
198,
394,
311,
43759,
4395,
13,
220,
1115,
5852,
1193,
706,
904,
198,
394,
2515,
389,
54157,
4365,
57137,
382,
286,
5295,
512,
310,
9384,
85992,
25,
362,
10489,
21686,
4365,
63624,
449,
279,
2728,
9551,
627,
286,
12713,
286,
422,
9551,
25472,
291,
512,
310,
63624,
284,
31802,
3103,
85992,
47518,
11,
659,
1462,
8680,
11,
10936,
5823,
28,
21247,
5823,
340,
310,
659,
1462,
4687,
57231,
388,
2102,
3706,
37908,
340,
310,
471,
63624,
271,
286,
422,
9551,
11319,
1857,
624,
2956,
3103,
87391,
941,
512,
310,
63624,
284,
20315,
3103,
85992,
47518,
340,
286,
775,
512,
310,
63624,
284,
21382,
3103,
85992,
47518,
696,
286,
659,
1462,
26752,
57231,
388,
2102,
3706,
37908,
696,
286,
471,
63624,
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
] |
jaraco/irc | irc/bot.py | SingleServerIRCBot._on_namreply | def _on_namreply(self, connection, event):
"""
event.arguments[0] == "@" for secret channels,
"*" for private channels,
"=" for others (public channels)
event.arguments[1] == channel
event.arguments[2] == nick list
"""
ch_type, channel, nick_list = event.arguments
if channel == '*':
# User is not in any visible channel
# http://tools.ietf.org/html/rfc2812#section-3.2.5
return
for nick in nick_list.split():
nick_modes = []
if nick[0] in self.connection.features.prefix:
nick_modes.append(self.connection.features.prefix[nick[0]])
nick = nick[1:]
for mode in nick_modes:
self.channels[channel].set_mode(mode, nick)
self.channels[channel].add_user(nick) | python | def _on_namreply(self, connection, event):
"""
event.arguments[0] == "@" for secret channels,
"*" for private channels,
"=" for others (public channels)
event.arguments[1] == channel
event.arguments[2] == nick list
"""
ch_type, channel, nick_list = event.arguments
if channel == '*':
# User is not in any visible channel
# http://tools.ietf.org/html/rfc2812#section-3.2.5
return
for nick in nick_list.split():
nick_modes = []
if nick[0] in self.connection.features.prefix:
nick_modes.append(self.connection.features.prefix[nick[0]])
nick = nick[1:]
for mode in nick_modes:
self.channels[channel].set_mode(mode, nick)
self.channels[channel].add_user(nick) | [
"def",
"_on_namreply",
"(",
"self",
",",
"connection",
",",
"event",
")",
":",
"ch_type",
",",
"channel",
",",
"nick_list",
"=",
"event",
".",
"arguments",
"if",
"channel",
"==",
"'*'",
":",
"# User is not in any visible channel",
"# http://tools.ietf.org/html/rfc2812#section-3.2.5",
"return",
"for",
"nick",
"in",
"nick_list",
".",
"split",
"(",
")",
":",
"nick_modes",
"=",
"[",
"]",
"if",
"nick",
"[",
"0",
"]",
"in",
"self",
".",
"connection",
".",
"features",
".",
"prefix",
":",
"nick_modes",
".",
"append",
"(",
"self",
".",
"connection",
".",
"features",
".",
"prefix",
"[",
"nick",
"[",
"0",
"]",
"]",
")",
"nick",
"=",
"nick",
"[",
"1",
":",
"]",
"for",
"mode",
"in",
"nick_modes",
":",
"self",
".",
"channels",
"[",
"channel",
"]",
".",
"set_mode",
"(",
"mode",
",",
"nick",
")",
"self",
".",
"channels",
"[",
"channel",
"]",
".",
"add_user",
"(",
"nick",
")"
] | event.arguments[0] == "@" for secret channels,
"*" for private channels,
"=" for others (public channels)
event.arguments[1] == channel
event.arguments[2] == nick list | [
"event",
".",
"arguments",
"[",
"0",
"]",
"=="
] | train | https://github.com/jaraco/irc/blob/571c1f448d5d5bb92bbe2605c33148bf6e698413/irc/bot.py#L218-L244 | <|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:
event.arguments[0] == "@" for secret channels,
"*" for private channels,
"=" for others (public channels)
event.arguments[1] == channel
event.arguments[2] == nick list
### Response:
def _on_namreply(self, connection, event):
"""
event.arguments[0] == "@" for secret channels,
"*" for private channels,
"=" for others (public channels)
event.arguments[1] == channel
event.arguments[2] == nick list
"""
ch_type, channel, nick_list = event.arguments
if channel == '*':
# User is not in any visible channel
# http://tools.ietf.org/html/rfc2812#section-3.2.5
return
for nick in nick_list.split():
nick_modes = []
if nick[0] in self.connection.features.prefix:
nick_modes.append(self.connection.features.prefix[nick[0]])
nick = nick[1:]
for mode in nick_modes:
self.channels[channel].set_mode(mode, nick)
self.channels[channel].add_user(nick)
<|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,
3163,
53515,
58,
15,
60,
624,
97948,
369,
6367,
12006,
345,
3586,
66993,
369,
879,
12006,
345,
3586,
37334,
369,
3885,
320,
898,
12006,
340,
286,
1567,
53515,
58,
16,
60,
624,
5613,
198,
286,
1567,
53515,
58,
17,
60,
624,
16370,
1160,
271,
14711,
6075,
512,
755,
721,
263,
1107,
309,
21710,
1214,
11,
3717,
11,
1567,
997,
286,
3270,
286,
1567,
53515,
58,
15,
60,
624,
97948,
369,
6367,
12006,
345,
3586,
66993,
369,
879,
12006,
345,
3586,
37334,
369,
3885,
320,
898,
12006,
340,
286,
1567,
53515,
58,
16,
60,
624,
5613,
198,
286,
1567,
53515,
58,
17,
60,
624,
16370,
1160,
198,
286,
12713,
286,
523,
1857,
11,
5613,
11,
16370,
2062,
284,
1567,
53515,
271,
286,
422,
5613,
624,
15224,
3730,
310,
674,
2724,
374,
539,
304,
904,
9621,
5613,
198,
310,
674,
1795,
1129,
16297,
13,
75168,
2726,
14056,
95082,
15282,
17,
2,
2879,
12,
18,
13,
17,
13,
20,
198,
310,
471,
271,
286,
369,
16370,
304,
16370,
2062,
5402,
4019,
310,
16370,
60824,
284,
14941,
310,
422,
16370,
58,
15,
60,
304,
659,
20928,
39410,
39643,
512,
394,
16370,
60824,
2102,
1214,
20928,
39410,
39643,
7824,
875,
58,
15,
27829,
394,
16370,
284,
16370,
58,
16,
65731,
310,
369,
3941,
304,
16370,
60824,
512,
394,
659,
40995,
70424,
948,
751,
7450,
32456,
11,
16370,
696,
310,
659,
40995,
70424,
948,
723,
3398,
1471,
875,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
3163,
53515,
58,
15,
60,
624,
97948,
369,
6367,
12006,
345,
3586,
66993,
369,
879,
12006,
345,
3586,
37334,
369,
3885,
320,
898,
12006,
340,
286,
1567,
53515,
58,
16,
60,
624,
5613,
198,
286,
1567,
53515,
58,
17,
60,
624,
16370,
1160,
271,
14711,
6075,
512,
755,
721,
263,
1107,
309,
21710,
1214,
11,
3717,
11,
1567,
997,
286,
3270,
286,
1567,
53515,
58,
15,
60,
624,
97948,
369,
6367,
12006,
345,
3586,
66993,
369,
879,
12006,
345,
3586,
37334,
369,
3885,
320,
898,
12006,
340,
286,
1567,
53515,
58,
16,
60,
624,
5613,
198,
286,
1567,
53515,
58,
17,
60,
624,
16370,
1160,
198,
286,
12713,
286,
523,
1857,
11,
5613,
11,
16370,
2062,
284,
1567,
53515,
271,
286,
422,
5613,
624,
15224,
3730,
310,
674,
2724,
374,
539,
304,
904,
9621,
5613,
198,
310,
674,
1795,
1129,
16297,
13,
75168,
2726,
14056,
95082,
15282,
17,
2,
2879,
12,
18,
13,
17,
13,
20,
198,
310,
471,
271,
286,
369,
16370,
304,
16370,
2062,
5402,
4019,
310,
16370,
60824,
284,
14941,
310,
422,
16370,
58,
15,
60,
304,
659,
20928,
39410,
39643,
512,
394,
16370,
60824,
2102,
1214,
20928,
39410,
39643,
7824,
875,
58,
15,
27829,
394,
16370,
284,
16370,
58,
16,
65731,
310,
369,
3941,
304,
16370,
60824,
512,
394,
659,
40995,
70424,
948,
751,
7450,
32456,
11,
16370,
696,
310,
659,
40995,
70424,
948,
723,
3398,
1471,
875,
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
] |
dourvaris/nano-python | src/nano/conversion.py | convert | def convert(value, from_unit, to_unit):
"""
Converts a value from `from_unit` units to `to_unit` units
:param value: value to convert
:type value: int or str or decimal.Decimal
:param from_unit: unit to convert from
:type from_unit: str
:param to_unit: unit to convert to
:type to_unit: str
>>> convert(value='1.5', from_unit='xrb', to_unit='krai')
Decimal('0.0015')
"""
if isinstance(value, float):
raise ValueError(
"float values can lead to unexpected precision loss, please use a"
" Decimal or string eg."
" convert('%s', %r, %r)" % (value, from_unit, to_unit)
)
if from_unit not in UNITS_TO_RAW:
raise ValueError('unknown unit: %r' % from_unit)
if to_unit not in UNITS_TO_RAW:
raise ValueError('unknown unit: %r' % to_unit)
try:
value = Decimal(value)
except Exception:
raise ValueError('not a number: %r' % value)
from_value_in_base = UNITS_TO_RAW[from_unit]
to_value_in_base = UNITS_TO_RAW[to_unit]
result = value * (from_value_in_base / to_value_in_base)
return result.normalize() | python | def convert(value, from_unit, to_unit):
"""
Converts a value from `from_unit` units to `to_unit` units
:param value: value to convert
:type value: int or str or decimal.Decimal
:param from_unit: unit to convert from
:type from_unit: str
:param to_unit: unit to convert to
:type to_unit: str
>>> convert(value='1.5', from_unit='xrb', to_unit='krai')
Decimal('0.0015')
"""
if isinstance(value, float):
raise ValueError(
"float values can lead to unexpected precision loss, please use a"
" Decimal or string eg."
" convert('%s', %r, %r)" % (value, from_unit, to_unit)
)
if from_unit not in UNITS_TO_RAW:
raise ValueError('unknown unit: %r' % from_unit)
if to_unit not in UNITS_TO_RAW:
raise ValueError('unknown unit: %r' % to_unit)
try:
value = Decimal(value)
except Exception:
raise ValueError('not a number: %r' % value)
from_value_in_base = UNITS_TO_RAW[from_unit]
to_value_in_base = UNITS_TO_RAW[to_unit]
result = value * (from_value_in_base / to_value_in_base)
return result.normalize() | [
"def",
"convert",
"(",
"value",
",",
"from_unit",
",",
"to_unit",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"float",
")",
":",
"raise",
"ValueError",
"(",
"\"float values can lead to unexpected precision loss, please use a\"",
"\" Decimal or string eg.\"",
"\" convert('%s', %r, %r)\"",
"%",
"(",
"value",
",",
"from_unit",
",",
"to_unit",
")",
")",
"if",
"from_unit",
"not",
"in",
"UNITS_TO_RAW",
":",
"raise",
"ValueError",
"(",
"'unknown unit: %r'",
"%",
"from_unit",
")",
"if",
"to_unit",
"not",
"in",
"UNITS_TO_RAW",
":",
"raise",
"ValueError",
"(",
"'unknown unit: %r'",
"%",
"to_unit",
")",
"try",
":",
"value",
"=",
"Decimal",
"(",
"value",
")",
"except",
"Exception",
":",
"raise",
"ValueError",
"(",
"'not a number: %r'",
"%",
"value",
")",
"from_value_in_base",
"=",
"UNITS_TO_RAW",
"[",
"from_unit",
"]",
"to_value_in_base",
"=",
"UNITS_TO_RAW",
"[",
"to_unit",
"]",
"result",
"=",
"value",
"*",
"(",
"from_value_in_base",
"/",
"to_value_in_base",
")",
"return",
"result",
".",
"normalize",
"(",
")"
] | Converts a value from `from_unit` units to `to_unit` units
:param value: value to convert
:type value: int or str or decimal.Decimal
:param from_unit: unit to convert from
:type from_unit: str
:param to_unit: unit to convert to
:type to_unit: str
>>> convert(value='1.5', from_unit='xrb', to_unit='krai')
Decimal('0.0015') | [
"Converts",
"a",
"value",
"from",
"from_unit",
"units",
"to",
"to_unit",
"units"
] | train | https://github.com/dourvaris/nano-python/blob/f26b8bc895b997067780f925049a70e82c0c2479/src/nano/conversion.py#L45-L85 | <|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:
Converts a value from `from_unit` units to `to_unit` units
:param value: value to convert
:type value: int or str or decimal.Decimal
:param from_unit: unit to convert from
:type from_unit: str
:param to_unit: unit to convert to
:type to_unit: str
>>> convert(value='1.5', from_unit='xrb', to_unit='krai')
Decimal('0.0015')
### Response:
def convert(value, from_unit, to_unit):
"""
Converts a value from `from_unit` units to `to_unit` units
:param value: value to convert
:type value: int or str or decimal.Decimal
:param from_unit: unit to convert from
:type from_unit: str
:param to_unit: unit to convert to
:type to_unit: str
>>> convert(value='1.5', from_unit='xrb', to_unit='krai')
Decimal('0.0015')
"""
if isinstance(value, float):
raise ValueError(
"float values can lead to unexpected precision loss, please use a"
" Decimal or string eg."
" convert('%s', %r, %r)" % (value, from_unit, to_unit)
)
if from_unit not in UNITS_TO_RAW:
raise ValueError('unknown unit: %r' % from_unit)
if to_unit not in UNITS_TO_RAW:
raise ValueError('unknown unit: %r' % to_unit)
try:
value = Decimal(value)
except Exception:
raise ValueError('not a number: %r' % value)
from_value_in_base = UNITS_TO_RAW[from_unit]
to_value_in_base = UNITS_TO_RAW[to_unit]
result = value * (from_value_in_base / to_value_in_base)
return result.normalize()
<|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,
82,
264,
907,
505,
1595,
1527,
15176,
63,
8316,
311,
1595,
998,
15176,
63,
8316,
271,
262,
551,
913,
907,
25,
907,
311,
5625,
198,
262,
551,
1337,
907,
25,
528,
477,
610,
477,
12395,
41775,
271,
262,
551,
913,
505,
15176,
25,
5089,
311,
5625,
505,
198,
262,
551,
1337,
505,
15176,
25,
610,
271,
262,
551,
913,
311,
15176,
25,
5089,
311,
5625,
311,
198,
262,
551,
1337,
311,
15176,
25,
610,
271,
262,
12382,
5625,
3764,
1151,
16,
13,
20,
518,
505,
15176,
1151,
87,
10910,
518,
311,
15176,
1151,
74,
68962,
1329,
262,
27826,
493,
15,
13,
4119,
20,
4713,
14711,
6075,
512,
755,
5625,
3764,
11,
505,
15176,
11,
311,
15176,
997,
262,
3270,
262,
42829,
264,
907,
505,
1595,
1527,
15176,
63,
8316,
311,
1595,
998,
15176,
63,
8316,
271,
262,
551,
913,
907,
25,
907,
311,
5625,
198,
262,
551,
1337,
907,
25,
528,
477,
610,
477,
12395,
41775,
271,
262,
551,
913,
505,
15176,
25,
5089,
311,
5625,
505,
198,
262,
551,
1337,
505,
15176,
25,
610,
271,
262,
551,
913,
311,
15176,
25,
5089,
311,
5625,
311,
198,
262,
551,
1337,
311,
15176,
25,
610,
271,
262,
12382,
5625,
3764,
1151,
16,
13,
20,
518,
505,
15176,
1151,
87,
10910,
518,
311,
15176,
1151,
74,
68962,
1329,
262,
27826,
493,
15,
13,
4119,
20,
1329,
262,
12713,
262,
422,
11656,
3764,
11,
2273,
997,
286,
4933,
15764,
1021,
310,
330,
3733,
2819,
649,
3063,
311,
16907,
16437,
4814,
11,
4587,
1005,
264,
702,
310,
330,
27826,
477,
925,
8866,
10246,
310,
330,
5625,
16428,
82,
518,
1034,
81,
11,
1034,
81,
10143,
1034,
320,
970,
11,
505,
15176,
11,
311,
15176,
340,
286,
5235,
262,
422,
505,
15176,
539,
304,
6781,
14813,
8820,
41022,
512,
286,
4933,
15764,
493,
16476,
5089,
25,
1034,
81,
6,
1034,
505,
15176,
696,
262,
422,
311,
15176,
539,
304,
6781,
14813,
8820,
41022,
512,
286,
4933,
15764,
493,
16476,
5089,
25,
1034,
81,
6,
1034,
311,
15176,
696,
262,
1456,
512,
286,
907,
284,
27826,
3764,
340,
262,
3734,
4204,
512,
286,
4933,
15764,
493,
1962,
264,
1396,
25,
1034,
81,
6,
1034,
907,
696,
262,
505,
3220,
1265,
7806,
284,
6781,
14813,
8820,
41022,
79430,
15176,
933,
262,
311,
3220,
1265,
7806,
284,
6781,
14813,
8820,
41022,
67399,
15176,
2595,
262,
1121,
284,
907,
353,
320,
1527,
3220,
1265,
7806,
611,
311,
3220,
1265,
7806,
696,
262,
471,
1121,
45757,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
82,
264,
907,
505,
1595,
1527,
15176,
63,
8316,
311,
1595,
998,
15176,
63,
8316,
271,
262,
551,
913,
907,
25,
907,
311,
5625,
198,
262,
551,
1337,
907,
25,
528,
477,
610,
477,
12395,
41775,
271,
262,
551,
913,
505,
15176,
25,
5089,
311,
5625,
505,
198,
262,
551,
1337,
505,
15176,
25,
610,
271,
262,
551,
913,
311,
15176,
25,
5089,
311,
5625,
311,
198,
262,
551,
1337,
311,
15176,
25,
610,
271,
262,
12382,
5625,
3764,
1151,
16,
13,
20,
518,
505,
15176,
1151,
87,
10910,
518,
311,
15176,
1151,
74,
68962,
1329,
262,
27826,
493,
15,
13,
4119,
20,
4713,
14711,
6075,
512,
755,
5625,
3764,
11,
505,
15176,
11,
311,
15176,
997,
262,
3270,
262,
42829,
264,
907,
505,
1595,
1527,
15176,
63,
8316,
311,
1595,
998,
15176,
63,
8316,
271,
262,
551,
913,
907,
25,
907,
311,
5625,
198,
262,
551,
1337,
907,
25,
528,
477,
610,
477,
12395,
41775,
271,
262,
551,
913,
505,
15176,
25,
5089,
311,
5625,
505,
198,
262,
551,
1337,
505,
15176,
25,
610,
271,
262,
551,
913,
311,
15176,
25,
5089,
311,
5625,
311,
198,
262,
551,
1337,
311,
15176,
25,
610,
271,
262,
12382,
5625,
3764,
1151,
16,
13,
20,
518,
505,
15176,
1151,
87,
10910,
518,
311,
15176,
1151,
74,
68962,
1329,
262,
27826,
493,
15,
13,
4119,
20,
1329,
262,
12713,
262,
422,
11656,
3764,
11,
2273,
997,
286,
4933,
15764,
1021,
310,
330,
3733,
2819,
649,
3063,
311,
16907,
16437,
4814,
11,
4587,
1005,
264,
702,
310,
330,
27826,
477,
925,
8866,
10246,
310,
330,
5625,
16428,
82,
518,
1034,
81,
11,
1034,
81,
10143,
1034,
320,
970,
11,
505,
15176,
11,
311,
15176,
340,
286,
5235,
262,
422,
505,
15176,
539,
304,
6781,
14813,
8820,
41022,
512,
286,
4933,
15764,
493,
16476,
5089,
25,
1034,
81,
6,
1034,
505,
15176,
696,
262,
422,
311,
15176,
539,
304,
6781,
14813,
8820,
41022,
512,
286,
4933,
15764,
493,
16476,
5089,
25,
1034,
81,
6,
1034,
311,
15176,
696,
262,
1456,
512,
286,
907,
284,
27826,
3764,
340,
262,
3734,
4204,
512,
286,
4933,
15764,
493,
1962,
264,
1396,
25,
1034,
81,
6,
1034,
907,
696,
262,
505,
3220,
1265,
7806,
284,
6781,
14813,
8820,
41022,
79430,
15176,
933,
262,
311,
3220,
1265,
7806,
284,
6781,
14813,
8820,
41022,
67399,
15176,
2595,
262,
1121,
284,
907,
353,
320,
1527,
3220,
1265,
7806,
611,
311,
3220,
1265,
7806,
696,
262,
471,
1121,
45757,
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
] |
thorgate/django-esteid | esteid/config.py | ocsp_responder_certificate_path | def ocsp_responder_certificate_path():
"""Get ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return:
"""
certificate_path = getattr(settings, 'ESTEID_OCSP_RESPONDER_CERTIFICATE_PATH', 'TEST_of_SK_OCSP_RESPONDER_2011.pem')
if certificate_path in ['TEST_of_SK_OCSP_RESPONDER_2011.pem', 'sk-ocsp-responder-certificates.pem']:
return os.path.join(os.path.dirname(__file__), 'certs', certificate_path)
return certificate_path | python | def ocsp_responder_certificate_path():
"""Get ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return:
"""
certificate_path = getattr(settings, 'ESTEID_OCSP_RESPONDER_CERTIFICATE_PATH', 'TEST_of_SK_OCSP_RESPONDER_2011.pem')
if certificate_path in ['TEST_of_SK_OCSP_RESPONDER_2011.pem', 'sk-ocsp-responder-certificates.pem']:
return os.path.join(os.path.dirname(__file__), 'certs', certificate_path)
return certificate_path | [
"def",
"ocsp_responder_certificate_path",
"(",
")",
":",
"certificate_path",
"=",
"getattr",
"(",
"settings",
",",
"'ESTEID_OCSP_RESPONDER_CERTIFICATE_PATH'",
",",
"'TEST_of_SK_OCSP_RESPONDER_2011.pem'",
")",
"if",
"certificate_path",
"in",
"[",
"'TEST_of_SK_OCSP_RESPONDER_2011.pem'",
",",
"'sk-ocsp-responder-certificates.pem'",
"]",
":",
"return",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"dirname",
"(",
"__file__",
")",
",",
"'certs'",
",",
"certificate_path",
")",
"return",
"certificate_path"
] | Get ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return: | [
"Get",
"ocsp",
"responder",
"certificate",
"path"
] | train | https://github.com/thorgate/django-esteid/blob/407ae513e357fedea0e3e42198df8eb9d9ff0646/esteid/config.py#L40-L55 | <|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 ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return:
### Response:
def ocsp_responder_certificate_path():
"""Get ocsp responder certificate path
Test: TEST_of_SK_OCSP_RESPONDER_2011.pem
Live: sk-ocsp-responder-certificates.pem
Note: These files are distributed under esteid/certs
:return:
"""
certificate_path = getattr(settings, 'ESTEID_OCSP_RESPONDER_CERTIFICATE_PATH', 'TEST_of_SK_OCSP_RESPONDER_2011.pem')
if certificate_path in ['TEST_of_SK_OCSP_RESPONDER_2011.pem', 'sk-ocsp-responder-certificates.pem']:
return os.path.join(os.path.dirname(__file__), 'certs', certificate_path)
return certificate_path
<|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,
18274,
2203,
65134,
16125,
1853,
271,
262,
3475,
25,
13916,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
198,
262,
11406,
25,
1940,
12,
511,
2203,
11849,
20949,
62134,
25409,
50473,
271,
262,
7181,
25,
4314,
3626,
527,
4332,
1234,
10566,
307,
2971,
15916,
271,
262,
551,
693,
1473,
14711,
6075,
512,
755,
18274,
2203,
5023,
20949,
64147,
2703,
4019,
262,
4304,
1991,
18274,
2203,
65134,
16125,
1853,
271,
262,
3475,
25,
13916,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
198,
262,
11406,
25,
1940,
12,
511,
2203,
11849,
20949,
62134,
25409,
50473,
271,
262,
7181,
25,
4314,
3626,
527,
4332,
1234,
10566,
307,
2971,
15916,
271,
262,
551,
693,
512,
262,
3270,
262,
16125,
2703,
284,
31097,
24258,
11,
364,
5288,
36,
926,
75763,
4695,
30080,
715,
11645,
56398,
83123,
8103,
518,
364,
10238,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
4713,
262,
422,
16125,
2703,
304,
2570,
10238,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
518,
364,
4991,
12,
511,
2203,
11849,
20949,
62134,
25409,
50473,
18888,
286,
471,
2709,
3960,
5563,
9835,
3960,
21803,
5630,
1213,
56187,
364,
12525,
82,
518,
16125,
2703,
696,
262,
471,
16125,
2703,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
18274,
2203,
65134,
16125,
1853,
271,
262,
3475,
25,
13916,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
198,
262,
11406,
25,
1940,
12,
511,
2203,
11849,
20949,
62134,
25409,
50473,
271,
262,
7181,
25,
4314,
3626,
527,
4332,
1234,
10566,
307,
2971,
15916,
271,
262,
551,
693,
1473,
14711,
6075,
512,
755,
18274,
2203,
5023,
20949,
64147,
2703,
4019,
262,
4304,
1991,
18274,
2203,
65134,
16125,
1853,
271,
262,
3475,
25,
13916,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
198,
262,
11406,
25,
1940,
12,
511,
2203,
11849,
20949,
62134,
25409,
50473,
271,
262,
7181,
25,
4314,
3626,
527,
4332,
1234,
10566,
307,
2971,
15916,
271,
262,
551,
693,
512,
262,
3270,
262,
16125,
2703,
284,
31097,
24258,
11,
364,
5288,
36,
926,
75763,
4695,
30080,
715,
11645,
56398,
83123,
8103,
518,
364,
10238,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
4713,
262,
422,
16125,
2703,
304,
2570,
10238,
3659,
35564,
75763,
4695,
30080,
715,
11645,
62,
679,
16,
50473,
518,
364,
4991,
12,
511,
2203,
11849,
20949,
62134,
25409,
50473,
18888,
286,
471,
2709,
3960,
5563,
9835,
3960,
21803,
5630,
1213,
56187,
364,
12525,
82,
518,
16125,
2703,
696,
262,
471,
16125,
2703,
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
] |
WoLpH/mailjet | mailjet/contrib/django_mailjet/views.py | SubscriptionView.form_valid | def form_valid(self, form):
""" Call `form.save()` and super itself. """
form.save()
return super(SubscriptionView, self).form_valid(form) | python | def form_valid(self, form):
""" Call `form.save()` and super itself. """
form.save()
return super(SubscriptionView, self).form_valid(form) | [
"def",
"form_valid",
"(",
"self",
",",
"form",
")",
":",
"form",
".",
"save",
"(",
")",
"return",
"super",
"(",
"SubscriptionView",
",",
"self",
")",
".",
"form_valid",
"(",
"form",
")"
] | Call `form.save()` and super itself. | [
"Call",
"form",
".",
"save",
"()",
"and",
"super",
"itself",
"."
] | train | https://github.com/WoLpH/mailjet/blob/f7f5102bf52be6a4a9c62afe474387481c806e27/mailjet/contrib/django_mailjet/views.py#L13-L16 | <|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 `form.save()` and super itself.
### Response:
def form_valid(self, form):
""" Call `form.save()` and super itself. """
form.save()
return super(SubscriptionView, self).form_valid(form)
<|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,
1595,
630,
5799,
55358,
323,
2307,
5196,
382,
14711,
6075,
512,
755,
1376,
8501,
1214,
11,
1376,
997,
286,
4304,
7290,
1595,
630,
5799,
55358,
323,
2307,
5196,
13,
3270,
286,
1376,
5799,
746,
286,
471,
2307,
7,
34502,
860,
11,
659,
570,
630,
8501,
17178,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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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,
7368,
1595,
630,
5799,
55358,
323,
2307,
5196,
382,
14711,
6075,
512,
755,
1376,
8501,
1214,
11,
1376,
997,
286,
4304,
7290,
1595,
630,
5799,
55358,
323,
2307,
5196,
13,
3270,
286,
1376,
5799,
746,
286,
471,
2307,
7,
34502,
860,
11,
659,
570,
630,
8501,
17178,
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
] |
brocade/pynos | pynos/versions/ver_7/ver_7_1_0/yang/brocade_arp.py | brocade_arp.get_arp_output_arp_entry_entry_type | def get_arp_output_arp_entry_entry_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_arp = ET.Element("get_arp")
config = get_arp
output = ET.SubElement(get_arp, "output")
arp_entry = ET.SubElement(output, "arp-entry")
ip_address_key = ET.SubElement(arp_entry, "ip-address")
ip_address_key.text = kwargs.pop('ip_address')
entry_type = ET.SubElement(arp_entry, "entry-type")
entry_type.text = kwargs.pop('entry_type')
callback = kwargs.pop('callback', self._callback)
return callback(config) | python | def get_arp_output_arp_entry_entry_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_arp = ET.Element("get_arp")
config = get_arp
output = ET.SubElement(get_arp, "output")
arp_entry = ET.SubElement(output, "arp-entry")
ip_address_key = ET.SubElement(arp_entry, "ip-address")
ip_address_key.text = kwargs.pop('ip_address')
entry_type = ET.SubElement(arp_entry, "entry-type")
entry_type.text = kwargs.pop('entry_type')
callback = kwargs.pop('callback', self._callback)
return callback(config) | [
"def",
"get_arp_output_arp_entry_entry_type",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"config",
"=",
"ET",
".",
"Element",
"(",
"\"config\"",
")",
"get_arp",
"=",
"ET",
".",
"Element",
"(",
"\"get_arp\"",
")",
"config",
"=",
"get_arp",
"output",
"=",
"ET",
".",
"SubElement",
"(",
"get_arp",
",",
"\"output\"",
")",
"arp_entry",
"=",
"ET",
".",
"SubElement",
"(",
"output",
",",
"\"arp-entry\"",
")",
"ip_address_key",
"=",
"ET",
".",
"SubElement",
"(",
"arp_entry",
",",
"\"ip-address\"",
")",
"ip_address_key",
".",
"text",
"=",
"kwargs",
".",
"pop",
"(",
"'ip_address'",
")",
"entry_type",
"=",
"ET",
".",
"SubElement",
"(",
"arp_entry",
",",
"\"entry-type\"",
")",
"entry_type",
".",
"text",
"=",
"kwargs",
".",
"pop",
"(",
"'entry_type'",
")",
"callback",
"=",
"kwargs",
".",
"pop",
"(",
"'callback'",
",",
"self",
".",
"_callback",
")",
"return",
"callback",
"(",
"config",
")"
] | Auto Generated Code | [
"Auto",
"Generated",
"Code"
] | train | https://github.com/brocade/pynos/blob/bd8a34e98f322de3fc06750827d8bbc3a0c00380/pynos/versions/ver_7/ver_7_1_0/yang/brocade_arp.py#L327-L341 | <|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:
Auto Generated Code
### Response:
def get_arp_output_arp_entry_entry_type(self, **kwargs):
"""Auto Generated Code
"""
config = ET.Element("config")
get_arp = ET.Element("get_arp")
config = get_arp
output = ET.SubElement(get_arp, "output")
arp_entry = ET.SubElement(output, "arp-entry")
ip_address_key = ET.SubElement(arp_entry, "ip-address")
ip_address_key.text = kwargs.pop('ip_address')
entry_type = ET.SubElement(arp_entry, "entry-type")
entry_type.text = kwargs.pop('entry_type')
callback = kwargs.pop('callback', self._callback)
return callback(config)
<|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,
13556,
31588,
6247,
271,
14711,
6075,
512,
755,
636,
62,
8035,
7800,
62,
8035,
9255,
9255,
1857,
1214,
11,
3146,
9872,
997,
286,
4304,
13556,
31588,
6247,
198,
286,
3270,
286,
2242,
284,
18241,
20743,
446,
1710,
1158,
286,
636,
62,
8035,
284,
18241,
20743,
446,
456,
62,
8035,
1158,
286,
2242,
284,
636,
62,
8035,
198,
286,
2612,
284,
18241,
93442,
5550,
62,
8035,
11,
330,
3081,
1158,
286,
99698,
9255,
284,
18241,
93442,
11304,
11,
330,
8035,
48344,
1158,
286,
6125,
6886,
3173,
284,
18241,
93442,
7,
8035,
9255,
11,
330,
575,
42733,
1158,
286,
6125,
6886,
3173,
2858,
284,
16901,
8452,
493,
575,
6886,
1329,
286,
4441,
1857,
284,
18241,
93442,
7,
8035,
9255,
11,
330,
4177,
10827,
1158,
286,
4441,
1857,
2858,
284,
16901,
8452,
493,
4177,
1857,
4713,
286,
4927,
284,
16901,
8452,
493,
13802,
518,
659,
1462,
13802,
340,
286,
471,
4927,
8928,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
13556,
31588,
6247,
271,
14711,
6075,
512,
755,
636,
62,
8035,
7800,
62,
8035,
9255,
9255,
1857,
1214,
11,
3146,
9872,
997,
286,
4304,
13556,
31588,
6247,
198,
286,
3270,
286,
2242,
284,
18241,
20743,
446,
1710,
1158,
286,
636,
62,
8035,
284,
18241,
20743,
446,
456,
62,
8035,
1158,
286,
2242,
284,
636,
62,
8035,
198,
286,
2612,
284,
18241,
93442,
5550,
62,
8035,
11,
330,
3081,
1158,
286,
99698,
9255,
284,
18241,
93442,
11304,
11,
330,
8035,
48344,
1158,
286,
6125,
6886,
3173,
284,
18241,
93442,
7,
8035,
9255,
11,
330,
575,
42733,
1158,
286,
6125,
6886,
3173,
2858,
284,
16901,
8452,
493,
575,
6886,
1329,
286,
4441,
1857,
284,
18241,
93442,
7,
8035,
9255,
11,
330,
4177,
10827,
1158,
286,
4441,
1857,
2858,
284,
16901,
8452,
493,
4177,
1857,
4713,
286,
4927,
284,
16901,
8452,
493,
13802,
518,
659,
1462,
13802,
340,
286,
471,
4927,
8928,
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
] |
ska-sa/montblanc | montblanc/impl/rime/tensorflow/sources/cached_source_provider.py | _cache | def _cache(method):
"""
Decorator for caching data source return values
Create a key index for the proxied array in the context.
Iterate over the array shape descriptor e.g. (ntime, nbl, 3)
returning tuples containing the lower and upper extents
of string dimensions. Takes (0, d) in the case of an integer
dimensions.
"""
@functools.wraps(method)
def memoizer(self, context):
# Construct the key for the given index
idx = context.array_extents(context.name)
key = tuple(i for t in idx for i in t)
with self._lock:
# Access the sub-cache for this data source
array_cache = self._cache[context.name]
# Cache miss, call the data source
if key not in array_cache:
array_cache[key] = method(context)
return array_cache[key]
return memoizer | python | def _cache(method):
"""
Decorator for caching data source return values
Create a key index for the proxied array in the context.
Iterate over the array shape descriptor e.g. (ntime, nbl, 3)
returning tuples containing the lower and upper extents
of string dimensions. Takes (0, d) in the case of an integer
dimensions.
"""
@functools.wraps(method)
def memoizer(self, context):
# Construct the key for the given index
idx = context.array_extents(context.name)
key = tuple(i for t in idx for i in t)
with self._lock:
# Access the sub-cache for this data source
array_cache = self._cache[context.name]
# Cache miss, call the data source
if key not in array_cache:
array_cache[key] = method(context)
return array_cache[key]
return memoizer | [
"def",
"_cache",
"(",
"method",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"method",
")",
"def",
"memoizer",
"(",
"self",
",",
"context",
")",
":",
"# Construct the key for the given index",
"idx",
"=",
"context",
".",
"array_extents",
"(",
"context",
".",
"name",
")",
"key",
"=",
"tuple",
"(",
"i",
"for",
"t",
"in",
"idx",
"for",
"i",
"in",
"t",
")",
"with",
"self",
".",
"_lock",
":",
"# Access the sub-cache for this data source",
"array_cache",
"=",
"self",
".",
"_cache",
"[",
"context",
".",
"name",
"]",
"# Cache miss, call the data source",
"if",
"key",
"not",
"in",
"array_cache",
":",
"array_cache",
"[",
"key",
"]",
"=",
"method",
"(",
"context",
")",
"return",
"array_cache",
"[",
"key",
"]",
"return",
"memoizer"
] | Decorator for caching data source return values
Create a key index for the proxied array in the context.
Iterate over the array shape descriptor e.g. (ntime, nbl, 3)
returning tuples containing the lower and upper extents
of string dimensions. Takes (0, d) in the case of an integer
dimensions. | [
"Decorator",
"for",
"caching",
"data",
"source",
"return",
"values"
] | train | https://github.com/ska-sa/montblanc/blob/8a2e742e7500bcc6196489b735f87b233075dd2d/montblanc/impl/rime/tensorflow/sources/cached_source_provider.py#L29-L56 | <|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:
Decorator for caching data source return values
Create a key index for the proxied array in the context.
Iterate over the array shape descriptor e.g. (ntime, nbl, 3)
returning tuples containing the lower and upper extents
of string dimensions. Takes (0, d) in the case of an integer
dimensions.
### Response:
def _cache(method):
"""
Decorator for caching data source return values
Create a key index for the proxied array in the context.
Iterate over the array shape descriptor e.g. (ntime, nbl, 3)
returning tuples containing the lower and upper extents
of string dimensions. Takes (0, d) in the case of an integer
dimensions.
"""
@functools.wraps(method)
def memoizer(self, context):
# Construct the key for the given index
idx = context.array_extents(context.name)
key = tuple(i for t in idx for i in t)
with self._lock:
# Access the sub-cache for this data source
array_cache = self._cache[context.name]
# Cache miss, call the data source
if key not in array_cache:
array_cache[key] = method(context)
return array_cache[key]
return memoizer
<|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,
49051,
369,
48530,
828,
2592,
471,
2819,
271,
262,
4324,
264,
1401,
1963,
369,
279,
22267,
1142,
1358,
304,
279,
2317,
627,
262,
55440,
927,
279,
1358,
6211,
16819,
384,
1326,
13,
320,
406,
547,
11,
308,
2067,
11,
220,
18,
340,
262,
13758,
46325,
8649,
279,
4827,
323,
8582,
92589,
198,
262,
315,
925,
15696,
13,
38707,
320,
15,
11,
294,
8,
304,
279,
1162,
315,
459,
7698,
198,
262,
15696,
382,
14711,
6075,
512,
755,
721,
9544,
17709,
997,
262,
3270,
262,
28069,
859,
369,
48530,
828,
2592,
471,
2819,
271,
262,
4324,
264,
1401,
1963,
369,
279,
22267,
1142,
1358,
304,
279,
2317,
627,
262,
55440,
927,
279,
1358,
6211,
16819,
384,
1326,
13,
320,
406,
547,
11,
308,
2067,
11,
220,
18,
340,
262,
13758,
46325,
8649,
279,
4827,
323,
8582,
92589,
198,
262,
315,
925,
15696,
13,
38707,
320,
15,
11,
294,
8,
304,
279,
1162,
315,
459,
7698,
198,
262,
15696,
627,
262,
12713,
262,
571,
12158,
302,
6309,
82393,
2690,
17709,
340,
262,
711,
22154,
3213,
1214,
11,
2317,
997,
286,
674,
19196,
279,
1401,
369,
279,
2728,
1963,
198,
286,
7335,
284,
2317,
7382,
10129,
812,
5491,
2710,
340,
286,
1401,
284,
14743,
1998,
369,
259,
304,
7335,
369,
602,
304,
259,
696,
286,
449,
659,
1462,
1039,
512,
310,
674,
9742,
279,
1207,
37780,
369,
420,
828,
2592,
198,
310,
1358,
11790,
284,
659,
1462,
9544,
58,
2196,
2710,
2595,
310,
674,
20044,
3194,
11,
1650,
279,
828,
2592,
198,
310,
422,
1401,
539,
304,
1358,
11790,
512,
394,
1358,
11790,
8320,
60,
284,
1749,
5491,
696,
310,
471,
1358,
11790,
8320,
2595,
262,
471,
22154,
3213,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
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,
49051,
369,
48530,
828,
2592,
471,
2819,
271,
262,
4324,
264,
1401,
1963,
369,
279,
22267,
1142,
1358,
304,
279,
2317,
627,
262,
55440,
927,
279,
1358,
6211,
16819,
384,
1326,
13,
320,
406,
547,
11,
308,
2067,
11,
220,
18,
340,
262,
13758,
46325,
8649,
279,
4827,
323,
8582,
92589,
198,
262,
315,
925,
15696,
13,
38707,
320,
15,
11,
294,
8,
304,
279,
1162,
315,
459,
7698,
198,
262,
15696,
382,
14711,
6075,
512,
755,
721,
9544,
17709,
997,
262,
3270,
262,
28069,
859,
369,
48530,
828,
2592,
471,
2819,
271,
262,
4324,
264,
1401,
1963,
369,
279,
22267,
1142,
1358,
304,
279,
2317,
627,
262,
55440,
927,
279,
1358,
6211,
16819,
384,
1326,
13,
320,
406,
547,
11,
308,
2067,
11,
220,
18,
340,
262,
13758,
46325,
8649,
279,
4827,
323,
8582,
92589,
198,
262,
315,
925,
15696,
13,
38707,
320,
15,
11,
294,
8,
304,
279,
1162,
315,
459,
7698,
198,
262,
15696,
627,
262,
12713,
262,
571,
12158,
302,
6309,
82393,
2690,
17709,
340,
262,
711,
22154,
3213,
1214,
11,
2317,
997,
286,
674,
19196,
279,
1401,
369,
279,
2728,
1963,
198,
286,
7335,
284,
2317,
7382,
10129,
812,
5491,
2710,
340,
286,
1401,
284,
14743,
1998,
369,
259,
304,
7335,
369,
602,
304,
259,
696,
286,
449,
659,
1462,
1039,
512,
310,
674,
9742,
279,
1207,
37780,
369,
420,
828,
2592,
198,
310,
1358,
11790,
284,
659,
1462,
9544,
58,
2196,
2710,
2595,
310,
674,
20044,
3194,
11,
1650,
279,
828,
2592,
198,
310,
422,
1401,
539,
304,
1358,
11790,
512,
394,
1358,
11790,
8320,
60,
284,
1749,
5491,
696,
310,
471,
1358,
11790,
8320,
2595,
262,
471,
22154,
3213,
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
] |
openstax/cnx-archive | cnxarchive/events.py | add_cors_headers | def add_cors_headers(request, response):
"""Add cors headers needed for web app implementation."""
response.headerlist.append(('Access-Control-Allow-Origin', '*'))
response.headerlist.append(
('Access-Control-Allow-Methods', 'GET, OPTIONS'))
response.headerlist.append(
('Access-Control-Allow-Headers',
','.join(DEFAULT_ACCESS_CONTROL_ALLOW_HEADERS))) | python | def add_cors_headers(request, response):
"""Add cors headers needed for web app implementation."""
response.headerlist.append(('Access-Control-Allow-Origin', '*'))
response.headerlist.append(
('Access-Control-Allow-Methods', 'GET, OPTIONS'))
response.headerlist.append(
('Access-Control-Allow-Headers',
','.join(DEFAULT_ACCESS_CONTROL_ALLOW_HEADERS))) | [
"def",
"add_cors_headers",
"(",
"request",
",",
"response",
")",
":",
"response",
".",
"headerlist",
".",
"append",
"(",
"(",
"'Access-Control-Allow-Origin'",
",",
"'*'",
")",
")",
"response",
".",
"headerlist",
".",
"append",
"(",
"(",
"'Access-Control-Allow-Methods'",
",",
"'GET, OPTIONS'",
")",
")",
"response",
".",
"headerlist",
".",
"append",
"(",
"(",
"'Access-Control-Allow-Headers'",
",",
"','",
".",
"join",
"(",
"DEFAULT_ACCESS_CONTROL_ALLOW_HEADERS",
")",
")",
")"
] | Add cors headers needed for web app implementation. | [
"Add",
"cors",
"headers",
"needed",
"for",
"web",
"app",
"implementation",
"."
] | train | https://github.com/openstax/cnx-archive/blob/d31d34aa8bbc8a9fde6cd4227a0df92726e8daf4/cnxarchive/events.py#L15-L22 | <|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 cors headers needed for web app implementation.
### Response:
def add_cors_headers(request, response):
"""Add cors headers needed for web app implementation."""
response.headerlist.append(('Access-Control-Allow-Origin', '*'))
response.headerlist.append(
('Access-Control-Allow-Methods', 'GET, OPTIONS'))
response.headerlist.append(
('Access-Control-Allow-Headers',
','.join(DEFAULT_ACCESS_CONTROL_ALLOW_HEADERS)))
<|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,
45011,
7247,
4460,
369,
3566,
917,
8292,
382,
14711,
6075,
512,
755,
923,
669,
1105,
27817,
4980,
11,
2077,
997,
262,
4304,
2261,
45011,
7247,
4460,
369,
3566,
917,
8292,
14781,
262,
2077,
17531,
1638,
2102,
46775,
6182,
26111,
34448,
52736,
518,
15224,
7132,
262,
2077,
17531,
1638,
2102,
1021,
286,
4417,
6182,
26111,
34448,
96590,
518,
364,
3891,
11,
52380,
7132,
262,
2077,
17531,
1638,
2102,
1021,
286,
4417,
6182,
26111,
34448,
77106,
756,
260,
98780,
6115,
44275,
25424,
24607,
45424,
80528,
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,
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,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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
] | [
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,
45011,
7247,
4460,
369,
3566,
917,
8292,
382,
14711,
6075,
512,
755,
923,
669,
1105,
27817,
4980,
11,
2077,
997,
262,
4304,
2261,
45011,
7247,
4460,
369,
3566,
917,
8292,
14781,
262,
2077,
17531,
1638,
2102,
46775,
6182,
26111,
34448,
52736,
518,
15224,
7132,
262,
2077,
17531,
1638,
2102,
1021,
286,
4417,
6182,
26111,
34448,
96590,
518,
364,
3891,
11,
52380,
7132,
262,
2077,
17531,
1638,
2102,
1021,
286,
4417,
6182,
26111,
34448,
77106,
756,
260,
98780,
6115,
44275,
25424,
24607,
45424,
80528,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
coldfix/udiskie | udiskie/mount.py | Mounter.get_device_tree | def get_device_tree(self):
"""Get a tree of all devices."""
root = DevNode(None, None, [], None)
device_nodes = {
dev.object_path: DevNode(dev, dev.parent_object_path, [],
self._ignore_device(dev))
for dev in self.udisks
}
for node in device_nodes.values():
device_nodes.get(node.root, root).children.append(node)
device_nodes['/'] = root
for node in device_nodes.values():
node.children.sort(key=DevNode._sort_key)
# use parent as fallback, update top->down:
def propagate_ignored(node):
for child in node.children:
if child.ignored is None:
child.ignored = node.ignored
propagate_ignored(child)
propagate_ignored(root)
return device_nodes | python | def get_device_tree(self):
"""Get a tree of all devices."""
root = DevNode(None, None, [], None)
device_nodes = {
dev.object_path: DevNode(dev, dev.parent_object_path, [],
self._ignore_device(dev))
for dev in self.udisks
}
for node in device_nodes.values():
device_nodes.get(node.root, root).children.append(node)
device_nodes['/'] = root
for node in device_nodes.values():
node.children.sort(key=DevNode._sort_key)
# use parent as fallback, update top->down:
def propagate_ignored(node):
for child in node.children:
if child.ignored is None:
child.ignored = node.ignored
propagate_ignored(child)
propagate_ignored(root)
return device_nodes | [
"def",
"get_device_tree",
"(",
"self",
")",
":",
"root",
"=",
"DevNode",
"(",
"None",
",",
"None",
",",
"[",
"]",
",",
"None",
")",
"device_nodes",
"=",
"{",
"dev",
".",
"object_path",
":",
"DevNode",
"(",
"dev",
",",
"dev",
".",
"parent_object_path",
",",
"[",
"]",
",",
"self",
".",
"_ignore_device",
"(",
"dev",
")",
")",
"for",
"dev",
"in",
"self",
".",
"udisks",
"}",
"for",
"node",
"in",
"device_nodes",
".",
"values",
"(",
")",
":",
"device_nodes",
".",
"get",
"(",
"node",
".",
"root",
",",
"root",
")",
".",
"children",
".",
"append",
"(",
"node",
")",
"device_nodes",
"[",
"'/'",
"]",
"=",
"root",
"for",
"node",
"in",
"device_nodes",
".",
"values",
"(",
")",
":",
"node",
".",
"children",
".",
"sort",
"(",
"key",
"=",
"DevNode",
".",
"_sort_key",
")",
"# use parent as fallback, update top->down:",
"def",
"propagate_ignored",
"(",
"node",
")",
":",
"for",
"child",
"in",
"node",
".",
"children",
":",
"if",
"child",
".",
"ignored",
"is",
"None",
":",
"child",
".",
"ignored",
"=",
"node",
".",
"ignored",
"propagate_ignored",
"(",
"child",
")",
"propagate_ignored",
"(",
"root",
")",
"return",
"device_nodes"
] | Get a tree of all devices. | [
"Get",
"a",
"tree",
"of",
"all",
"devices",
"."
] | train | https://github.com/coldfix/udiskie/blob/804c9d27df6f7361fec3097c432398f2d702f911/udiskie/mount.py#L713-L734 | <|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 tree of all devices.
### Response:
def get_device_tree(self):
"""Get a tree of all devices."""
root = DevNode(None, None, [], None)
device_nodes = {
dev.object_path: DevNode(dev, dev.parent_object_path, [],
self._ignore_device(dev))
for dev in self.udisks
}
for node in device_nodes.values():
device_nodes.get(node.root, root).children.append(node)
device_nodes['/'] = root
for node in device_nodes.values():
node.children.sort(key=DevNode._sort_key)
# use parent as fallback, update top->down:
def propagate_ignored(node):
for child in node.children:
if child.ignored is None:
child.ignored = node.ignored
propagate_ignored(child)
propagate_ignored(root)
return device_nodes
<|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,
264,
5021,
315,
682,
7766,
382,
14711,
6075,
512,
755,
636,
9385,
11925,
1214,
997,
286,
4304,
1991,
264,
5021,
315,
682,
7766,
14781,
286,
3789,
284,
6168,
1997,
27815,
11,
2290,
11,
10277,
2290,
340,
286,
3756,
15242,
284,
341,
310,
3567,
6163,
2703,
25,
6168,
1997,
18087,
11,
3567,
8829,
5427,
2703,
11,
10450,
10812,
659,
1462,
13431,
9385,
18087,
1192,
310,
369,
3567,
304,
659,
72190,
93934,
198,
286,
457,
286,
369,
2494,
304,
3756,
15242,
10883,
4019,
310,
3756,
15242,
673,
7103,
12861,
11,
3789,
570,
5988,
2102,
7103,
340,
286,
3756,
15242,
681,
14,
663,
284,
3789,
198,
286,
369,
2494,
304,
3756,
15242,
10883,
4019,
310,
2494,
13664,
10838,
4962,
28,
14934,
1997,
1462,
7003,
3173,
696,
286,
674,
1005,
2748,
439,
33872,
11,
2713,
1948,
405,
2996,
512,
286,
711,
58514,
62,
59571,
7103,
997,
310,
369,
1716,
304,
2494,
13664,
512,
394,
422,
1716,
13,
59571,
374,
2290,
512,
504,
1716,
13,
59571,
284,
2494,
13,
59571,
198,
394,
58514,
62,
59571,
18272,
340,
286,
58514,
62,
59571,
9387,
340,
286,
471,
3756,
15242,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
264,
5021,
315,
682,
7766,
382,
14711,
6075,
512,
755,
636,
9385,
11925,
1214,
997,
286,
4304,
1991,
264,
5021,
315,
682,
7766,
14781,
286,
3789,
284,
6168,
1997,
27815,
11,
2290,
11,
10277,
2290,
340,
286,
3756,
15242,
284,
341,
310,
3567,
6163,
2703,
25,
6168,
1997,
18087,
11,
3567,
8829,
5427,
2703,
11,
10450,
10812,
659,
1462,
13431,
9385,
18087,
1192,
310,
369,
3567,
304,
659,
72190,
93934,
198,
286,
457,
286,
369,
2494,
304,
3756,
15242,
10883,
4019,
310,
3756,
15242,
673,
7103,
12861,
11,
3789,
570,
5988,
2102,
7103,
340,
286,
3756,
15242,
681,
14,
663,
284,
3789,
198,
286,
369,
2494,
304,
3756,
15242,
10883,
4019,
310,
2494,
13664,
10838,
4962,
28,
14934,
1997,
1462,
7003,
3173,
696,
286,
674,
1005,
2748,
439,
33872,
11,
2713,
1948,
405,
2996,
512,
286,
711,
58514,
62,
59571,
7103,
997,
310,
369,
1716,
304,
2494,
13664,
512,
394,
422,
1716,
13,
59571,
374,
2290,
512,
504,
1716,
13,
59571,
284,
2494,
13,
59571,
198,
394,
58514,
62,
59571,
18272,
340,
286,
58514,
62,
59571,
9387,
340,
286,
471,
3756,
15242,
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
] |
tensorflow/tensor2tensor | tensor2tensor/trax/layers/base.py | _find_frame | def _find_frame(stack, start=0):
"""Find the frame with the caller on the stack."""
# We want to find the first place where the layer was called
# that is *not* an __init__ function of an inheriting layer.
frame = inspect.getframeinfo(stack[start][0])
# If we are in an init, move on.
if frame.function == '__init__':
return _find_frame(stack, start + 1)
return frame | python | def _find_frame(stack, start=0):
"""Find the frame with the caller on the stack."""
# We want to find the first place where the layer was called
# that is *not* an __init__ function of an inheriting layer.
frame = inspect.getframeinfo(stack[start][0])
# If we are in an init, move on.
if frame.function == '__init__':
return _find_frame(stack, start + 1)
return frame | [
"def",
"_find_frame",
"(",
"stack",
",",
"start",
"=",
"0",
")",
":",
"# We want to find the first place where the layer was called",
"# that is *not* an __init__ function of an inheriting layer.",
"frame",
"=",
"inspect",
".",
"getframeinfo",
"(",
"stack",
"[",
"start",
"]",
"[",
"0",
"]",
")",
"# If we are in an init, move on.",
"if",
"frame",
".",
"function",
"==",
"'__init__'",
":",
"return",
"_find_frame",
"(",
"stack",
",",
"start",
"+",
"1",
")",
"return",
"frame"
] | Find the frame with the caller on the stack. | [
"Find",
"the",
"frame",
"with",
"the",
"caller",
"on",
"the",
"stack",
"."
] | train | https://github.com/tensorflow/tensor2tensor/blob/272500b6efe353aeb638d2745ed56e519462ca31/tensor2tensor/trax/layers/base.py#L189-L197 | <|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 frame with the caller on the stack.
### Response:
def _find_frame(stack, start=0):
"""Find the frame with the caller on the stack."""
# We want to find the first place where the layer was called
# that is *not* an __init__ function of an inheriting layer.
frame = inspect.getframeinfo(stack[start][0])
# If we are in an init, move on.
if frame.function == '__init__':
return _find_frame(stack, start + 1)
return frame
<|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,
4124,
449,
279,
20456,
389,
279,
5729,
382,
14711,
6075,
512,
755,
721,
3990,
9106,
28538,
11,
1212,
28,
15,
997,
220,
4304,
10086,
279,
4124,
449,
279,
20456,
389,
279,
5729,
14781,
220,
674,
1226,
1390,
311,
1505,
279,
1176,
2035,
1405,
279,
6324,
574,
2663,
198,
220,
674,
430,
374,
353,
1962,
9,
459,
1328,
2381,
565,
734,
315,
459,
15517,
5977,
6324,
627,
220,
4124,
284,
25052,
673,
6906,
2801,
28538,
29563,
1483,
15,
2608,
220,
674,
1442,
584,
527,
304,
459,
3003,
11,
3351,
389,
627,
220,
422,
4124,
20687,
624,
12385,
2381,
16575,
262,
471,
721,
3990,
9106,
28538,
11,
1212,
489,
220,
16,
340,
220,
471,
4124,
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
] | [
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,
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,
4124,
449,
279,
20456,
389,
279,
5729,
382,
14711,
6075,
512,
755,
721,
3990,
9106,
28538,
11,
1212,
28,
15,
997,
220,
4304,
10086,
279,
4124,
449,
279,
20456,
389,
279,
5729,
14781,
220,
674,
1226,
1390,
311,
1505,
279,
1176,
2035,
1405,
279,
6324,
574,
2663,
198,
220,
674,
430,
374,
353,
1962,
9,
459,
1328,
2381,
565,
734,
315,
459,
15517,
5977,
6324,
627,
220,
4124,
284,
25052,
673,
6906,
2801,
28538,
29563,
1483,
15,
2608,
220,
674,
1442,
584,
527,
304,
459,
3003,
11,
3351,
389,
627,
220,
422,
4124,
20687,
624,
12385,
2381,
16575,
262,
471,
721,
3990,
9106,
28538,
11,
1212,
489,
220,
16,
340,
220,
471,
4124,
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
] |
inveniosoftware/invenio-openaire | invenio_openaire/minters.py | minter | def minter(record_uuid, data, pid_type, key):
"""Mint PIDs for a record."""
pid = PersistentIdentifier.create(
pid_type,
data[key],
object_type='rec',
object_uuid=record_uuid,
status=PIDStatus.REGISTERED
)
for scheme, identifier in data['identifiers'].items():
if identifier:
PersistentIdentifier.create(
scheme,
identifier,
object_type='rec',
object_uuid=record_uuid,
status=PIDStatus.REGISTERED
)
return pid | python | def minter(record_uuid, data, pid_type, key):
"""Mint PIDs for a record."""
pid = PersistentIdentifier.create(
pid_type,
data[key],
object_type='rec',
object_uuid=record_uuid,
status=PIDStatus.REGISTERED
)
for scheme, identifier in data['identifiers'].items():
if identifier:
PersistentIdentifier.create(
scheme,
identifier,
object_type='rec',
object_uuid=record_uuid,
status=PIDStatus.REGISTERED
)
return pid | [
"def",
"minter",
"(",
"record_uuid",
",",
"data",
",",
"pid_type",
",",
"key",
")",
":",
"pid",
"=",
"PersistentIdentifier",
".",
"create",
"(",
"pid_type",
",",
"data",
"[",
"key",
"]",
",",
"object_type",
"=",
"'rec'",
",",
"object_uuid",
"=",
"record_uuid",
",",
"status",
"=",
"PIDStatus",
".",
"REGISTERED",
")",
"for",
"scheme",
",",
"identifier",
"in",
"data",
"[",
"'identifiers'",
"]",
".",
"items",
"(",
")",
":",
"if",
"identifier",
":",
"PersistentIdentifier",
".",
"create",
"(",
"scheme",
",",
"identifier",
",",
"object_type",
"=",
"'rec'",
",",
"object_uuid",
"=",
"record_uuid",
",",
"status",
"=",
"PIDStatus",
".",
"REGISTERED",
")",
"return",
"pid"
] | Mint PIDs for a record. | [
"Mint",
"PIDs",
"for",
"a",
"record",
"."
] | train | https://github.com/inveniosoftware/invenio-openaire/blob/71860effff6abe7f658d3a11894e064202ef1c36/invenio_openaire/minters.py#L42-L60 | <|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:
Mint PIDs for a record.
### Response:
def minter(record_uuid, data, pid_type, key):
"""Mint PIDs for a record."""
pid = PersistentIdentifier.create(
pid_type,
data[key],
object_type='rec',
object_uuid=record_uuid,
status=PIDStatus.REGISTERED
)
for scheme, identifier in data['identifiers'].items():
if identifier:
PersistentIdentifier.create(
scheme,
identifier,
object_type='rec',
object_uuid=record_uuid,
status=PIDStatus.REGISTERED
)
return pid
<|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,
44,
396,
393,
31566,
369,
264,
3335,
382,
14711,
6075,
512,
755,
296,
2295,
24728,
26621,
11,
828,
11,
15158,
1857,
11,
1401,
997,
262,
4304,
44,
396,
393,
31566,
369,
264,
3335,
14781,
262,
15158,
284,
67644,
8887,
2581,
1021,
286,
15158,
1857,
345,
286,
828,
8320,
1282,
286,
1665,
1857,
1151,
2827,
756,
286,
1665,
26621,
28,
8716,
26621,
345,
286,
2704,
28,
34851,
2583,
13,
47402,
1507,
198,
262,
1763,
262,
369,
13155,
11,
13110,
304,
828,
681,
1748,
12099,
7352,
3699,
4019,
286,
422,
13110,
512,
310,
67644,
8887,
2581,
1021,
394,
13155,
345,
394,
13110,
345,
394,
1665,
1857,
1151,
2827,
756,
394,
1665,
26621,
28,
8716,
26621,
345,
394,
2704,
28,
34851,
2583,
13,
47402,
1507,
198,
310,
1763,
262,
471,
15158,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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,
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,
44,
396,
393,
31566,
369,
264,
3335,
382,
14711,
6075,
512,
755,
296,
2295,
24728,
26621,
11,
828,
11,
15158,
1857,
11,
1401,
997,
262,
4304,
44,
396,
393,
31566,
369,
264,
3335,
14781,
262,
15158,
284,
67644,
8887,
2581,
1021,
286,
15158,
1857,
345,
286,
828,
8320,
1282,
286,
1665,
1857,
1151,
2827,
756,
286,
1665,
26621,
28,
8716,
26621,
345,
286,
2704,
28,
34851,
2583,
13,
47402,
1507,
198,
262,
1763,
262,
369,
13155,
11,
13110,
304,
828,
681,
1748,
12099,
7352,
3699,
4019,
286,
422,
13110,
512,
310,
67644,
8887,
2581,
1021,
394,
13155,
345,
394,
13110,
345,
394,
1665,
1857,
1151,
2827,
756,
394,
1665,
26621,
28,
8716,
26621,
345,
394,
2704,
28,
34851,
2583,
13,
47402,
1507,
198,
310,
1763,
262,
471,
15158,
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
] |
saltstack/salt | salt/modules/xbpspkg.py | list_repos | def list_repos(**kwargs):
'''
List all repos known by XBPS
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos
'''
repos = {}
out = __salt__['cmd.run']('xbps-query -L', output_loglevel='trace')
for line in out.splitlines():
repo = {}
if not line:
continue
try:
nb, url, rsa = line.strip().split(' ', 2)
except ValueError:
log.error(
'Problem parsing xbps-query: '
'Unexpected formatting in line: "%s"', line
)
repo['nbpkg'] = int(nb) if nb.isdigit() else 0
repo['url'] = url
repo['rsasigned'] = True if rsa == '(RSA signed)' else False
repos[repo['url']] = repo
return repos | python | def list_repos(**kwargs):
'''
List all repos known by XBPS
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos
'''
repos = {}
out = __salt__['cmd.run']('xbps-query -L', output_loglevel='trace')
for line in out.splitlines():
repo = {}
if not line:
continue
try:
nb, url, rsa = line.strip().split(' ', 2)
except ValueError:
log.error(
'Problem parsing xbps-query: '
'Unexpected formatting in line: "%s"', line
)
repo['nbpkg'] = int(nb) if nb.isdigit() else 0
repo['url'] = url
repo['rsasigned'] = True if rsa == '(RSA signed)' else False
repos[repo['url']] = repo
return repos | [
"def",
"list_repos",
"(",
"*",
"*",
"kwargs",
")",
":",
"repos",
"=",
"{",
"}",
"out",
"=",
"__salt__",
"[",
"'cmd.run'",
"]",
"(",
"'xbps-query -L'",
",",
"output_loglevel",
"=",
"'trace'",
")",
"for",
"line",
"in",
"out",
".",
"splitlines",
"(",
")",
":",
"repo",
"=",
"{",
"}",
"if",
"not",
"line",
":",
"continue",
"try",
":",
"nb",
",",
"url",
",",
"rsa",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
"' '",
",",
"2",
")",
"except",
"ValueError",
":",
"log",
".",
"error",
"(",
"'Problem parsing xbps-query: '",
"'Unexpected formatting in line: \"%s\"'",
",",
"line",
")",
"repo",
"[",
"'nbpkg'",
"]",
"=",
"int",
"(",
"nb",
")",
"if",
"nb",
".",
"isdigit",
"(",
")",
"else",
"0",
"repo",
"[",
"'url'",
"]",
"=",
"url",
"repo",
"[",
"'rsasigned'",
"]",
"=",
"True",
"if",
"rsa",
"==",
"'(RSA signed)'",
"else",
"False",
"repos",
"[",
"repo",
"[",
"'url'",
"]",
"]",
"=",
"repo",
"return",
"repos"
] | List all repos known by XBPS
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos | [
"List",
"all",
"repos",
"known",
"by",
"XBPS"
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/xbpspkg.py#L487-L514 | <|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:
List all repos known by XBPS
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos
### Response:
def list_repos(**kwargs):
'''
List all repos known by XBPS
CLI Example:
.. code-block:: bash
salt '*' pkg.list_repos
'''
repos = {}
out = __salt__['cmd.run']('xbps-query -L', output_loglevel='trace')
for line in out.splitlines():
repo = {}
if not line:
continue
try:
nb, url, rsa = line.strip().split(' ', 2)
except ValueError:
log.error(
'Problem parsing xbps-query: '
'Unexpected formatting in line: "%s"', line
)
repo['nbpkg'] = int(nb) if nb.isdigit() else 0
repo['url'] = url
repo['rsasigned'] = True if rsa == '(RSA signed)' else False
repos[repo['url']] = repo
return repos
<|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,
861,
682,
46874,
3967,
555,
75760,
5119,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
996,
12290,
31801,
25830,
6556,
1311,
981,
271,
14711,
6075,
512,
755,
1160,
1311,
981,
22551,
9872,
997,
262,
11414,
262,
1796,
682,
46874,
3967,
555,
75760,
5119,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
996,
12290,
31801,
25830,
6556,
1311,
981,
198,
262,
11414,
262,
46874,
284,
5731,
262,
704,
284,
1328,
43326,
565,
681,
8883,
7789,
663,
493,
8088,
1725,
66589,
482,
43,
518,
2612,
5337,
3374,
1151,
15417,
1329,
262,
369,
1584,
304,
704,
5402,
8128,
4019,
286,
16246,
284,
5731,
286,
422,
539,
1584,
512,
310,
3136,
198,
286,
1456,
512,
310,
17062,
11,
2576,
11,
69670,
284,
1584,
17624,
1020,
7105,
493,
6752,
220,
17,
340,
286,
3734,
15764,
512,
310,
1515,
4517,
1021,
394,
364,
32298,
23115,
865,
32280,
66589,
25,
8044,
394,
364,
30530,
37666,
304,
1584,
25,
6090,
82,
49299,
1584,
198,
310,
1763,
286,
16246,
681,
77,
18287,
7501,
663,
284,
528,
62007,
8,
422,
17062,
88863,
368,
775,
220,
15,
198,
286,
16246,
681,
1103,
663,
284,
2576,
198,
286,
16246,
681,
5544,
300,
1571,
663,
284,
3082,
422,
69670,
624,
22796,
74664,
8667,
22367,
775,
3641,
198,
286,
46874,
58,
24373,
681,
1103,
31940,
284,
16246,
198,
262,
471,
46874,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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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,
861,
682,
46874,
3967,
555,
75760,
5119,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
996,
12290,
31801,
25830,
6556,
1311,
981,
271,
14711,
6075,
512,
755,
1160,
1311,
981,
22551,
9872,
997,
262,
11414,
262,
1796,
682,
46874,
3967,
555,
75760,
5119,
271,
262,
40377,
13688,
1473,
262,
5354,
2082,
9612,
487,
28121,
271,
996,
12290,
31801,
25830,
6556,
1311,
981,
198,
262,
11414,
262,
46874,
284,
5731,
262,
704,
284,
1328,
43326,
565,
681,
8883,
7789,
663,
493,
8088,
1725,
66589,
482,
43,
518,
2612,
5337,
3374,
1151,
15417,
1329,
262,
369,
1584,
304,
704,
5402,
8128,
4019,
286,
16246,
284,
5731,
286,
422,
539,
1584,
512,
310,
3136,
198,
286,
1456,
512,
310,
17062,
11,
2576,
11,
69670,
284,
1584,
17624,
1020,
7105,
493,
6752,
220,
17,
340,
286,
3734,
15764,
512,
310,
1515,
4517,
1021,
394,
364,
32298,
23115,
865,
32280,
66589,
25,
8044,
394,
364,
30530,
37666,
304,
1584,
25,
6090,
82,
49299,
1584,
198,
310,
1763,
286,
16246,
681,
77,
18287,
7501,
663,
284,
528,
62007,
8,
422,
17062,
88863,
368,
775,
220,
15,
198,
286,
16246,
681,
1103,
663,
284,
2576,
198,
286,
16246,
681,
5544,
300,
1571,
663,
284,
3082,
422,
69670,
624,
22796,
74664,
8667,
22367,
775,
3641,
198,
286,
46874,
58,
24373,
681,
1103,
31940,
284,
16246,
198,
262,
471,
46874,
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
] |
DataDog/integrations-core | tokumx/datadog_checks/tokumx/vendor/pymongo/command_cursor.py | CommandCursor.batch_size | def batch_size(self, batch_size):
"""Limits the number of documents returned in one batch. Each batch
requires a round trip to the server. It can be adjusted to optimize
performance and limit data transfer.
.. note:: batch_size can not override MongoDB's internal limits on the
amount of data it will return to the client in a single batch (i.e
if you set batch size to 1,000,000,000, MongoDB will currently only
return 4-16MB of results per batch).
Raises :exc:`TypeError` if `batch_size` is not an integer.
Raises :exc:`ValueError` if `batch_size` is less than ``0``.
:Parameters:
- `batch_size`: The size of each batch of results requested.
"""
if not isinstance(batch_size, integer_types):
raise TypeError("batch_size must be an integer")
if batch_size < 0:
raise ValueError("batch_size must be >= 0")
self.__batch_size = batch_size == 1 and 2 or batch_size
return self | python | def batch_size(self, batch_size):
"""Limits the number of documents returned in one batch. Each batch
requires a round trip to the server. It can be adjusted to optimize
performance and limit data transfer.
.. note:: batch_size can not override MongoDB's internal limits on the
amount of data it will return to the client in a single batch (i.e
if you set batch size to 1,000,000,000, MongoDB will currently only
return 4-16MB of results per batch).
Raises :exc:`TypeError` if `batch_size` is not an integer.
Raises :exc:`ValueError` if `batch_size` is less than ``0``.
:Parameters:
- `batch_size`: The size of each batch of results requested.
"""
if not isinstance(batch_size, integer_types):
raise TypeError("batch_size must be an integer")
if batch_size < 0:
raise ValueError("batch_size must be >= 0")
self.__batch_size = batch_size == 1 and 2 or batch_size
return self | [
"def",
"batch_size",
"(",
"self",
",",
"batch_size",
")",
":",
"if",
"not",
"isinstance",
"(",
"batch_size",
",",
"integer_types",
")",
":",
"raise",
"TypeError",
"(",
"\"batch_size must be an integer\"",
")",
"if",
"batch_size",
"<",
"0",
":",
"raise",
"ValueError",
"(",
"\"batch_size must be >= 0\"",
")",
"self",
".",
"__batch_size",
"=",
"batch_size",
"==",
"1",
"and",
"2",
"or",
"batch_size",
"return",
"self"
] | Limits the number of documents returned in one batch. Each batch
requires a round trip to the server. It can be adjusted to optimize
performance and limit data transfer.
.. note:: batch_size can not override MongoDB's internal limits on the
amount of data it will return to the client in a single batch (i.e
if you set batch size to 1,000,000,000, MongoDB will currently only
return 4-16MB of results per batch).
Raises :exc:`TypeError` if `batch_size` is not an integer.
Raises :exc:`ValueError` if `batch_size` is less than ``0``.
:Parameters:
- `batch_size`: The size of each batch of results requested. | [
"Limits",
"the",
"number",
"of",
"documents",
"returned",
"in",
"one",
"batch",
".",
"Each",
"batch",
"requires",
"a",
"round",
"trip",
"to",
"the",
"server",
".",
"It",
"can",
"be",
"adjusted",
"to",
"optimize",
"performance",
"and",
"limit",
"data",
"transfer",
"."
] | train | https://github.com/DataDog/integrations-core/blob/ebd41c873cf9f97a8c51bf9459bc6a7536af8acd/tokumx/datadog_checks/tokumx/vendor/pymongo/command_cursor.py#L70-L92 | <|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:
Limits the number of documents returned in one batch. Each batch
requires a round trip to the server. It can be adjusted to optimize
performance and limit data transfer.
.. note:: batch_size can not override MongoDB's internal limits on the
amount of data it will return to the client in a single batch (i.e
if you set batch size to 1,000,000,000, MongoDB will currently only
return 4-16MB of results per batch).
Raises :exc:`TypeError` if `batch_size` is not an integer.
Raises :exc:`ValueError` if `batch_size` is less than ``0``.
:Parameters:
- `batch_size`: The size of each batch of results requested.
### Response:
def batch_size(self, batch_size):
"""Limits the number of documents returned in one batch. Each batch
requires a round trip to the server. It can be adjusted to optimize
performance and limit data transfer.
.. note:: batch_size can not override MongoDB's internal limits on the
amount of data it will return to the client in a single batch (i.e
if you set batch size to 1,000,000,000, MongoDB will currently only
return 4-16MB of results per batch).
Raises :exc:`TypeError` if `batch_size` is not an integer.
Raises :exc:`ValueError` if `batch_size` is less than ``0``.
:Parameters:
- `batch_size`: The size of each batch of results requested.
"""
if not isinstance(batch_size, integer_types):
raise TypeError("batch_size must be an integer")
if batch_size < 0:
raise ValueError("batch_size must be >= 0")
self.__batch_size = batch_size == 1 and 2 or batch_size
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,
95688,
279,
1396,
315,
9477,
6052,
304,
832,
7309,
13,
9062,
7309,
198,
286,
7612,
264,
4883,
8577,
311,
279,
3622,
13,
1102,
649,
387,
24257,
311,
30536,
198,
286,
5178,
323,
4017,
828,
8481,
382,
286,
5354,
5296,
487,
7309,
2424,
649,
539,
2882,
46428,
596,
5419,
13693,
389,
279,
198,
1881,
3392,
315,
828,
433,
690,
471,
311,
279,
3016,
304,
264,
3254,
7309,
320,
72,
1770,
198,
1881,
422,
499,
743,
7309,
1404,
311,
220,
16,
11,
931,
11,
931,
11,
931,
11,
46428,
690,
5131,
1193,
198,
1881,
471,
220,
19,
12,
845,
8578,
315,
3135,
824,
7309,
3677,
286,
61411,
551,
40541,
19258,
81176,
63,
422,
1595,
14377,
2424,
63,
374,
539,
459,
7698,
627,
286,
61411,
551,
40541,
19258,
1150,
1480,
63,
422,
1595,
14377,
2424,
63,
374,
2753,
1109,
10103,
15,
14196,
382,
286,
551,
9905,
512,
692,
482,
1595,
14377,
2424,
45722,
578,
1404,
315,
1855,
7309,
315,
3135,
11472,
382,
14711,
6075,
512,
755,
7309,
2424,
1214,
11,
7309,
2424,
997,
286,
4304,
95688,
279,
1396,
315,
9477,
6052,
304,
832,
7309,
13,
9062,
7309,
198,
286,
7612,
264,
4883,
8577,
311,
279,
3622,
13,
1102,
649,
387,
24257,
311,
30536,
198,
286,
5178,
323,
4017,
828,
8481,
382,
286,
5354,
5296,
487,
7309,
2424,
649,
539,
2882,
46428,
596,
5419,
13693,
389,
279,
198,
1881,
3392,
315,
828,
433,
690,
471,
311,
279,
3016,
304,
264,
3254,
7309,
320,
72,
1770,
198,
1881,
422,
499,
743,
7309,
1404,
311,
220,
16,
11,
931,
11,
931,
11,
931,
11,
46428,
690,
5131,
1193,
198,
1881,
471,
220,
19,
12,
845,
8578,
315,
3135,
824,
7309,
3677,
286,
61411,
551,
40541,
19258,
81176,
63,
422,
1595,
14377,
2424,
63,
374,
539,
459,
7698,
627,
286,
61411,
551,
40541,
19258,
1150,
1480,
63,
422,
1595,
14377,
2424,
63,
374,
2753,
1109,
10103,
15,
14196,
382,
286,
551,
9905,
512,
692,
482,
1595,
14377,
2424,
45722,
578,
1404,
315,
1855,
7309,
315,
3135,
11472,
627,
286,
3270,
286,
422,
539,
11656,
31239,
2424,
11,
7698,
9962,
997,
310,
4933,
26082,
446,
14377,
2424,
2011,
387,
459,
7698,
1158,
286,
422,
7309,
2424,
366,
220,
15,
512,
310,
4933,
15764,
446,
14377,
2424,
2011,
387,
2669,
220,
15,
5240,
286,
659,
4952,
14377,
2424,
284,
7309,
2424,
624,
220,
16,
323,
220,
17,
477,
7309,
2424,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
95688,
279,
1396,
315,
9477,
6052,
304,
832,
7309,
13,
9062,
7309,
198,
286,
7612,
264,
4883,
8577,
311,
279,
3622,
13,
1102,
649,
387,
24257,
311,
30536,
198,
286,
5178,
323,
4017,
828,
8481,
382,
286,
5354,
5296,
487,
7309,
2424,
649,
539,
2882,
46428,
596,
5419,
13693,
389,
279,
198,
1881,
3392,
315,
828,
433,
690,
471,
311,
279,
3016,
304,
264,
3254,
7309,
320,
72,
1770,
198,
1881,
422,
499,
743,
7309,
1404,
311,
220,
16,
11,
931,
11,
931,
11,
931,
11,
46428,
690,
5131,
1193,
198,
1881,
471,
220,
19,
12,
845,
8578,
315,
3135,
824,
7309,
3677,
286,
61411,
551,
40541,
19258,
81176,
63,
422,
1595,
14377,
2424,
63,
374,
539,
459,
7698,
627,
286,
61411,
551,
40541,
19258,
1150,
1480,
63,
422,
1595,
14377,
2424,
63,
374,
2753,
1109,
10103,
15,
14196,
382,
286,
551,
9905,
512,
692,
482,
1595,
14377,
2424,
45722,
578,
1404,
315,
1855,
7309,
315,
3135,
11472,
382,
14711,
6075,
512,
755,
7309,
2424,
1214,
11,
7309,
2424,
997,
286,
4304,
95688,
279,
1396,
315,
9477,
6052,
304,
832,
7309,
13,
9062,
7309,
198,
286,
7612,
264,
4883,
8577,
311,
279,
3622,
13,
1102,
649,
387,
24257,
311,
30536,
198,
286,
5178,
323,
4017,
828,
8481,
382,
286,
5354,
5296,
487,
7309,
2424,
649,
539,
2882,
46428,
596,
5419,
13693,
389,
279,
198,
1881,
3392,
315,
828,
433,
690,
471,
311,
279,
3016,
304,
264,
3254,
7309,
320,
72,
1770,
198,
1881,
422,
499,
743,
7309,
1404,
311,
220,
16,
11,
931,
11,
931,
11,
931,
11,
46428,
690,
5131,
1193,
198,
1881,
471,
220,
19,
12,
845,
8578,
315,
3135,
824,
7309,
3677,
286,
61411,
551,
40541,
19258,
81176,
63,
422,
1595,
14377,
2424,
63,
374,
539,
459,
7698,
627,
286,
61411,
551,
40541,
19258,
1150,
1480,
63,
422,
1595,
14377,
2424,
63,
374,
2753,
1109,
10103,
15,
14196,
382,
286,
551,
9905,
512,
692,
482,
1595,
14377,
2424,
45722,
578,
1404,
315,
1855,
7309,
315,
3135,
11472,
627,
286,
3270,
286,
422,
539,
11656,
31239,
2424,
11,
7698,
9962,
997,
310,
4933,
26082,
446,
14377,
2424,
2011,
387,
459,
7698,
1158,
286,
422,
7309,
2424,
366,
220,
15,
512,
310,
4933,
15764,
446,
14377,
2424,
2011,
387,
2669,
220,
15,
5240,
286,
659,
4952,
14377,
2424,
284,
7309,
2424,
624,
220,
16,
323,
220,
17,
477,
7309,
2424,
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
] |
GNS3/gns3-server | gns3server/controller/project.py | Project.remove_allocated_node_name | def remove_allocated_node_name(self, name):
"""
Removes an allocated node name
:param name: allocated node name
"""
if name in self._allocated_node_names:
self._allocated_node_names.remove(name) | python | def remove_allocated_node_name(self, name):
"""
Removes an allocated node name
:param name: allocated node name
"""
if name in self._allocated_node_names:
self._allocated_node_names.remove(name) | [
"def",
"remove_allocated_node_name",
"(",
"self",
",",
"name",
")",
":",
"if",
"name",
"in",
"self",
".",
"_allocated_node_names",
":",
"self",
".",
"_allocated_node_names",
".",
"remove",
"(",
"name",
")"
] | Removes an allocated node name
:param name: allocated node name | [
"Removes",
"an",
"allocated",
"node",
"name"
] | train | https://github.com/GNS3/gns3-server/blob/a221678448fb5d24e977ef562f81d56aacc89ab1/gns3server/controller/project.py#L349-L357 | <|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:
Removes an allocated node name
:param name: allocated node name
### Response:
def remove_allocated_node_name(self, name):
"""
Removes an allocated node name
:param name: allocated node name
"""
if name in self._allocated_node_names:
self._allocated_node_names.remove(name)
<|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,
6728,
10296,
459,
20816,
2494,
836,
271,
286,
551,
913,
836,
25,
20816,
2494,
836,
271,
14711,
6075,
512,
755,
4148,
83442,
5194,
1292,
1214,
11,
836,
997,
286,
3270,
286,
39875,
459,
20816,
2494,
836,
271,
286,
551,
913,
836,
25,
20816,
2494,
836,
198,
286,
12713,
286,
422,
836,
304,
659,
1462,
58472,
5194,
9366,
512,
310,
659,
1462,
58472,
5194,
9366,
4955,
3232,
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,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,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
6728,
10296,
459,
20816,
2494,
836,
271,
286,
551,
913,
836,
25,
20816,
2494,
836,
271,
14711,
6075,
512,
755,
4148,
83442,
5194,
1292,
1214,
11,
836,
997,
286,
3270,
286,
39875,
459,
20816,
2494,
836,
271,
286,
551,
913,
836,
25,
20816,
2494,
836,
198,
286,
12713,
286,
422,
836,
304,
659,
1462,
58472,
5194,
9366,
512,
310,
659,
1462,
58472,
5194,
9366,
4955,
3232,
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
] |
IrvKalb/pygwidgets | pygwidgets/pygwidgets.py | DisplayText.setValue | def setValue(self, newText):
"""Sets a text value (string) into the text field."""
newText = str(newText) # attempt to convert to string (might be int or float ...)
if self.text == newText:
return # nothing to change
self.text = newText # save the new text
textLines = self.text.splitlines()
nLines = len(textLines)
surfacesList = [] # build up a list of surfaces, one for each line of original text
actualWidth = 0 # will eventually be set the width of longest line
for line in textLines:
lineSurface = self.font.render(line, True, self.textColor)
surfacesList.append(lineSurface)
thisRect = lineSurface.get_rect()
if thisRect.width > actualWidth:
actualWidth = thisRect.width
heightOfOneLine = self.fontHeight
actualHeight = nLines * heightOfOneLine
self.rect = pygame.Rect(self.loc[0], self.loc[1], actualWidth, actualHeight)
# Create one larger surface, then blit all line surfaces into it
# Special flags are needed to set the background alpha as transparent
self.textImage = pygame.Surface((actualWidth, actualHeight), flags=SRCALPHA)
if self.backgroundColor is not None:
self.textImage.fill(self.backgroundColor)
thisLineTop = 0
for lineSurface in surfacesList:
if self.justified == 'left':
self.textImage.blit(lineSurface, (0, thisLineTop))
else:
thisSurfaceWidth = lineSurface.get_rect()[2] # element 2 is the width
if self.justified == 'center':
theLeft = (actualWidth - thisSurfaceWidth) / 2
elif self.justified == 'right': # right justified
theLeft = actualWidth - thisSurfaceWidth
else:
raise Exception('Value of justified was: ' + self.justified + '. Must be left, center, or right')
self.textImage.blit(lineSurface, (theLeft, thisLineTop))
thisLineTop = thisLineTop + heightOfOneLine
if self.useSpecifiedArea:
# Fit the text image into a user specified area, may truncate the text off left, right, or bottom
textRect = self.textImage.get_rect()
if self.userWidth is None:
theWidth = textRect.width
else:
theWidth = self.userWidth
if self.userHeight is None:
theHeight = textRect.height
else:
theHeight = self.userHeight
# Create a surface that is the size that the user asked for
userSizedImage = pygame.Surface((theWidth, theHeight), flags=SRCALPHA)
self.rect = pygame.Rect(self.loc[0], self.loc[1], theWidth, theHeight)
if self.backgroundColor is not None:
userSizedImage.fill(self.backgroundColor)
# Figure out the appropriate left edge within the userSizedImage
if self.justified == 'left':
theLeft = 0
elif self.justified == 'center':
theLeft = (theWidth - textRect.width) / 2
else: # right justified
theLeft = theWidth - textRect.width
# Copy the appropriate part from the text image into the user sized image
# Then re-name it to the textImage so it can be drawn later
userSizedImage.blit(self.textImage, (theLeft, 0))
self.textImage = userSizedImage
self.textImage = pygame.Surface.convert_alpha(self.textImage) | python | def setValue(self, newText):
"""Sets a text value (string) into the text field."""
newText = str(newText) # attempt to convert to string (might be int or float ...)
if self.text == newText:
return # nothing to change
self.text = newText # save the new text
textLines = self.text.splitlines()
nLines = len(textLines)
surfacesList = [] # build up a list of surfaces, one for each line of original text
actualWidth = 0 # will eventually be set the width of longest line
for line in textLines:
lineSurface = self.font.render(line, True, self.textColor)
surfacesList.append(lineSurface)
thisRect = lineSurface.get_rect()
if thisRect.width > actualWidth:
actualWidth = thisRect.width
heightOfOneLine = self.fontHeight
actualHeight = nLines * heightOfOneLine
self.rect = pygame.Rect(self.loc[0], self.loc[1], actualWidth, actualHeight)
# Create one larger surface, then blit all line surfaces into it
# Special flags are needed to set the background alpha as transparent
self.textImage = pygame.Surface((actualWidth, actualHeight), flags=SRCALPHA)
if self.backgroundColor is not None:
self.textImage.fill(self.backgroundColor)
thisLineTop = 0
for lineSurface in surfacesList:
if self.justified == 'left':
self.textImage.blit(lineSurface, (0, thisLineTop))
else:
thisSurfaceWidth = lineSurface.get_rect()[2] # element 2 is the width
if self.justified == 'center':
theLeft = (actualWidth - thisSurfaceWidth) / 2
elif self.justified == 'right': # right justified
theLeft = actualWidth - thisSurfaceWidth
else:
raise Exception('Value of justified was: ' + self.justified + '. Must be left, center, or right')
self.textImage.blit(lineSurface, (theLeft, thisLineTop))
thisLineTop = thisLineTop + heightOfOneLine
if self.useSpecifiedArea:
# Fit the text image into a user specified area, may truncate the text off left, right, or bottom
textRect = self.textImage.get_rect()
if self.userWidth is None:
theWidth = textRect.width
else:
theWidth = self.userWidth
if self.userHeight is None:
theHeight = textRect.height
else:
theHeight = self.userHeight
# Create a surface that is the size that the user asked for
userSizedImage = pygame.Surface((theWidth, theHeight), flags=SRCALPHA)
self.rect = pygame.Rect(self.loc[0], self.loc[1], theWidth, theHeight)
if self.backgroundColor is not None:
userSizedImage.fill(self.backgroundColor)
# Figure out the appropriate left edge within the userSizedImage
if self.justified == 'left':
theLeft = 0
elif self.justified == 'center':
theLeft = (theWidth - textRect.width) / 2
else: # right justified
theLeft = theWidth - textRect.width
# Copy the appropriate part from the text image into the user sized image
# Then re-name it to the textImage so it can be drawn later
userSizedImage.blit(self.textImage, (theLeft, 0))
self.textImage = userSizedImage
self.textImage = pygame.Surface.convert_alpha(self.textImage) | [
"def",
"setValue",
"(",
"self",
",",
"newText",
")",
":",
"newText",
"=",
"str",
"(",
"newText",
")",
"# attempt to convert to string (might be int or float ...)\r",
"if",
"self",
".",
"text",
"==",
"newText",
":",
"return",
"# nothing to change\r",
"self",
".",
"text",
"=",
"newText",
"# save the new text\r",
"textLines",
"=",
"self",
".",
"text",
".",
"splitlines",
"(",
")",
"nLines",
"=",
"len",
"(",
"textLines",
")",
"surfacesList",
"=",
"[",
"]",
"# build up a list of surfaces, one for each line of original text\r",
"actualWidth",
"=",
"0",
"# will eventually be set the width of longest line\r",
"for",
"line",
"in",
"textLines",
":",
"lineSurface",
"=",
"self",
".",
"font",
".",
"render",
"(",
"line",
",",
"True",
",",
"self",
".",
"textColor",
")",
"surfacesList",
".",
"append",
"(",
"lineSurface",
")",
"thisRect",
"=",
"lineSurface",
".",
"get_rect",
"(",
")",
"if",
"thisRect",
".",
"width",
">",
"actualWidth",
":",
"actualWidth",
"=",
"thisRect",
".",
"width",
"heightOfOneLine",
"=",
"self",
".",
"fontHeight",
"actualHeight",
"=",
"nLines",
"*",
"heightOfOneLine",
"self",
".",
"rect",
"=",
"pygame",
".",
"Rect",
"(",
"self",
".",
"loc",
"[",
"0",
"]",
",",
"self",
".",
"loc",
"[",
"1",
"]",
",",
"actualWidth",
",",
"actualHeight",
")",
"# Create one larger surface, then blit all line surfaces into it\r",
"# Special flags are needed to set the background alpha as transparent\r",
"self",
".",
"textImage",
"=",
"pygame",
".",
"Surface",
"(",
"(",
"actualWidth",
",",
"actualHeight",
")",
",",
"flags",
"=",
"SRCALPHA",
")",
"if",
"self",
".",
"backgroundColor",
"is",
"not",
"None",
":",
"self",
".",
"textImage",
".",
"fill",
"(",
"self",
".",
"backgroundColor",
")",
"thisLineTop",
"=",
"0",
"for",
"lineSurface",
"in",
"surfacesList",
":",
"if",
"self",
".",
"justified",
"==",
"'left'",
":",
"self",
".",
"textImage",
".",
"blit",
"(",
"lineSurface",
",",
"(",
"0",
",",
"thisLineTop",
")",
")",
"else",
":",
"thisSurfaceWidth",
"=",
"lineSurface",
".",
"get_rect",
"(",
")",
"[",
"2",
"]",
"# element 2 is the width\r",
"if",
"self",
".",
"justified",
"==",
"'center'",
":",
"theLeft",
"=",
"(",
"actualWidth",
"-",
"thisSurfaceWidth",
")",
"/",
"2",
"elif",
"self",
".",
"justified",
"==",
"'right'",
":",
"# right justified\r",
"theLeft",
"=",
"actualWidth",
"-",
"thisSurfaceWidth",
"else",
":",
"raise",
"Exception",
"(",
"'Value of justified was: '",
"+",
"self",
".",
"justified",
"+",
"'. Must be left, center, or right'",
")",
"self",
".",
"textImage",
".",
"blit",
"(",
"lineSurface",
",",
"(",
"theLeft",
",",
"thisLineTop",
")",
")",
"thisLineTop",
"=",
"thisLineTop",
"+",
"heightOfOneLine",
"if",
"self",
".",
"useSpecifiedArea",
":",
"# Fit the text image into a user specified area, may truncate the text off left, right, or bottom\r",
"textRect",
"=",
"self",
".",
"textImage",
".",
"get_rect",
"(",
")",
"if",
"self",
".",
"userWidth",
"is",
"None",
":",
"theWidth",
"=",
"textRect",
".",
"width",
"else",
":",
"theWidth",
"=",
"self",
".",
"userWidth",
"if",
"self",
".",
"userHeight",
"is",
"None",
":",
"theHeight",
"=",
"textRect",
".",
"height",
"else",
":",
"theHeight",
"=",
"self",
".",
"userHeight",
"# Create a surface that is the size that the user asked for\r",
"userSizedImage",
"=",
"pygame",
".",
"Surface",
"(",
"(",
"theWidth",
",",
"theHeight",
")",
",",
"flags",
"=",
"SRCALPHA",
")",
"self",
".",
"rect",
"=",
"pygame",
".",
"Rect",
"(",
"self",
".",
"loc",
"[",
"0",
"]",
",",
"self",
".",
"loc",
"[",
"1",
"]",
",",
"theWidth",
",",
"theHeight",
")",
"if",
"self",
".",
"backgroundColor",
"is",
"not",
"None",
":",
"userSizedImage",
".",
"fill",
"(",
"self",
".",
"backgroundColor",
")",
"# Figure out the appropriate left edge within the userSizedImage\r",
"if",
"self",
".",
"justified",
"==",
"'left'",
":",
"theLeft",
"=",
"0",
"elif",
"self",
".",
"justified",
"==",
"'center'",
":",
"theLeft",
"=",
"(",
"theWidth",
"-",
"textRect",
".",
"width",
")",
"/",
"2",
"else",
":",
"# right justified\r",
"theLeft",
"=",
"theWidth",
"-",
"textRect",
".",
"width",
"# Copy the appropriate part from the text image into the user sized image\r",
"# Then re-name it to the textImage so it can be drawn later\r",
"userSizedImage",
".",
"blit",
"(",
"self",
".",
"textImage",
",",
"(",
"theLeft",
",",
"0",
")",
")",
"self",
".",
"textImage",
"=",
"userSizedImage",
"self",
".",
"textImage",
"=",
"pygame",
".",
"Surface",
".",
"convert_alpha",
"(",
"self",
".",
"textImage",
")"
] | Sets a text value (string) into the text field. | [
"Sets",
"a",
"text",
"value",
"(",
"string",
")",
"into",
"the",
"text",
"field",
"."
] | train | https://github.com/IrvKalb/pygwidgets/blob/a830d8885d4d209e471cb53816277d30db56273c/pygwidgets/pygwidgets.py#L1585-L1661 | <|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:
Sets a text value (string) into the text field.
### Response:
def setValue(self, newText):
"""Sets a text value (string) into the text field."""
newText = str(newText) # attempt to convert to string (might be int or float ...)
if self.text == newText:
return # nothing to change
self.text = newText # save the new text
textLines = self.text.splitlines()
nLines = len(textLines)
surfacesList = [] # build up a list of surfaces, one for each line of original text
actualWidth = 0 # will eventually be set the width of longest line
for line in textLines:
lineSurface = self.font.render(line, True, self.textColor)
surfacesList.append(lineSurface)
thisRect = lineSurface.get_rect()
if thisRect.width > actualWidth:
actualWidth = thisRect.width
heightOfOneLine = self.fontHeight
actualHeight = nLines * heightOfOneLine
self.rect = pygame.Rect(self.loc[0], self.loc[1], actualWidth, actualHeight)
# Create one larger surface, then blit all line surfaces into it
# Special flags are needed to set the background alpha as transparent
self.textImage = pygame.Surface((actualWidth, actualHeight), flags=SRCALPHA)
if self.backgroundColor is not None:
self.textImage.fill(self.backgroundColor)
thisLineTop = 0
for lineSurface in surfacesList:
if self.justified == 'left':
self.textImage.blit(lineSurface, (0, thisLineTop))
else:
thisSurfaceWidth = lineSurface.get_rect()[2] # element 2 is the width
if self.justified == 'center':
theLeft = (actualWidth - thisSurfaceWidth) / 2
elif self.justified == 'right': # right justified
theLeft = actualWidth - thisSurfaceWidth
else:
raise Exception('Value of justified was: ' + self.justified + '. Must be left, center, or right')
self.textImage.blit(lineSurface, (theLeft, thisLineTop))
thisLineTop = thisLineTop + heightOfOneLine
if self.useSpecifiedArea:
# Fit the text image into a user specified area, may truncate the text off left, right, or bottom
textRect = self.textImage.get_rect()
if self.userWidth is None:
theWidth = textRect.width
else:
theWidth = self.userWidth
if self.userHeight is None:
theHeight = textRect.height
else:
theHeight = self.userHeight
# Create a surface that is the size that the user asked for
userSizedImage = pygame.Surface((theWidth, theHeight), flags=SRCALPHA)
self.rect = pygame.Rect(self.loc[0], self.loc[1], theWidth, theHeight)
if self.backgroundColor is not None:
userSizedImage.fill(self.backgroundColor)
# Figure out the appropriate left edge within the userSizedImage
if self.justified == 'left':
theLeft = 0
elif self.justified == 'center':
theLeft = (theWidth - textRect.width) / 2
else: # right justified
theLeft = theWidth - textRect.width
# Copy the appropriate part from the text image into the user sized image
# Then re-name it to the textImage so it can be drawn later
userSizedImage.blit(self.textImage, (theLeft, 0))
self.textImage = userSizedImage
self.textImage = pygame.Surface.convert_alpha(self.textImage)
<|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,
31275,
264,
1495,
907,
320,
928,
8,
1139,
279,
1495,
2115,
382,
14711,
6075,
512,
755,
29152,
1214,
11,
95753,
5903,
286,
4304,
31275,
264,
1495,
907,
320,
928,
8,
1139,
279,
1495,
2115,
75100,
319,
286,
95753,
284,
610,
1792,
1199,
8,
220,
674,
220,
4879,
311,
5625,
311,
925,
320,
46068,
387,
528,
477,
2273,
2564,
1240,
286,
422,
659,
2858,
624,
95753,
2904,
310,
471,
220,
674,
4400,
311,
2349,
881,
286,
659,
2858,
284,
95753,
220,
674,
3665,
279,
502,
1495,
881,
286,
1495,
17213,
284,
659,
2858,
5402,
8128,
3652,
286,
308,
17213,
284,
2479,
7383,
17213,
1240,
286,
27529,
861,
284,
3132,
220,
674,
1977,
709,
264,
1160,
315,
27529,
11,
832,
369,
1855,
1584,
315,
4113,
1495,
319,
286,
5150,
3408,
284,
220,
15,
220,
674,
690,
9778,
387,
743,
279,
2430,
315,
22807,
1584,
881,
286,
369,
1584,
304,
1495,
17213,
2904,
310,
1584,
24627,
284,
659,
14317,
8914,
8973,
11,
3082,
11,
659,
31060,
1240,
310,
27529,
861,
2102,
8973,
24627,
1240,
310,
420,
4515,
284,
1584,
24627,
673,
17410,
3652,
310,
422,
420,
4515,
5558,
871,
5150,
3408,
2904,
394,
5150,
3408,
284,
420,
4515,
5558,
881,
286,
2673,
2173,
4054,
2519,
284,
659,
14317,
3724,
319,
286,
5150,
3724,
284,
308,
17213,
353,
2673,
2173,
4054,
2519,
319,
286,
659,
19293,
284,
15041,
33253,
1214,
15006,
58,
15,
1145,
659,
15006,
58,
16,
1145,
5150,
3408,
11,
5150,
3724,
7377,
286,
674,
4324,
832,
8294,
7479,
11,
1243,
1529,
275,
682,
1584,
27529,
1139,
433,
319,
286,
674,
9984,
8202,
527,
4460,
311,
743,
279,
4092,
8451,
439,
18300,
319,
286,
659,
2858,
1945,
284,
15041,
82074,
1209,
12210,
3408,
11,
5150,
3724,
705,
8202,
28,
57117,
984,
29322,
1240,
286,
422,
659,
15815,
374,
539,
2290,
2904,
310,
659,
2858,
1945,
12749,
1214,
15815,
7377,
286,
420,
2519,
5479,
284,
220,
15,
319,
286,
369,
1584,
24627,
304,
27529,
861,
2904,
310,
422,
659,
63310,
1908,
624,
364,
2414,
18928,
394,
659,
2858,
1945,
39636,
8973,
24627,
11,
320,
15,
11,
420,
2519,
5479,
5904,
310,
775,
2904,
394,
420,
24627,
3408,
284,
1584,
24627,
673,
17410,
10324,
17,
60,
220,
674,
2449,
220,
17,
374,
279,
2430,
319,
394,
422,
659,
63310,
1908,
624,
364,
3133,
18928,
504,
279,
5530,
284,
320,
12210,
3408,
482,
420,
24627,
3408,
8,
611,
220,
17,
319,
394,
4508,
659,
63310,
1908,
624,
364,
1315,
1232,
220,
674,
1314,
35516,
319,
504,
279,
5530,
284,
5150,
3408,
482,
420,
24627,
3408,
319,
394,
775,
2904,
504,
4933,
4204,
493,
1150,
315,
35516,
574,
25,
364,
489,
659,
63310,
1908,
489,
6389,
15832,
387,
2163,
11,
4219,
11,
477,
1314,
7849,
394,
659,
2858,
1945,
39636,
8973,
24627,
11,
320,
1820,
5530,
11,
420,
2519,
5479,
5904,
310,
420,
2519,
5479,
284,
420,
2519,
5479
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
31275,
264,
1495,
907,
320,
928,
8,
1139,
279,
1495,
2115,
382,
14711,
6075,
512,
755,
29152,
1214,
11,
95753,
5903,
286,
4304,
31275,
264,
1495,
907,
320,
928,
8,
1139,
279,
1495,
2115,
75100,
319,
286,
95753,
284,
610,
1792,
1199,
8,
220,
674,
220,
4879,
311,
5625,
311,
925,
320,
46068,
387,
528,
477,
2273,
2564,
1240,
286,
422,
659,
2858,
624,
95753,
2904,
310,
471,
220,
674,
4400,
311,
2349,
881,
286,
659,
2858,
284,
95753,
220,
674,
3665,
279,
502,
1495,
881,
286,
1495,
17213,
284,
659,
2858,
5402,
8128,
3652,
286,
308,
17213,
284,
2479,
7383,
17213,
1240,
286,
27529,
861,
284,
3132,
220,
674,
1977,
709,
264,
1160,
315,
27529,
11,
832,
369,
1855,
1584,
315,
4113,
1495,
319,
286,
5150,
3408,
284,
220,
15,
220,
674,
690,
9778,
387,
743,
279,
2430,
315,
22807,
1584,
881,
286,
369,
1584,
304,
1495,
17213,
2904,
310,
1584,
24627,
284,
659,
14317,
8914,
8973,
11,
3082,
11,
659,
31060,
1240,
310,
27529,
861,
2102,
8973,
24627,
1240,
310,
420,
4515,
284,
1584,
24627,
673,
17410,
3652,
310,
422,
420,
4515,
5558,
871,
5150,
3408,
2904,
394,
5150,
3408,
284,
420,
4515,
5558,
881,
286,
2673,
2173,
4054,
2519,
284,
659,
14317,
3724,
319,
286,
5150,
3724,
284,
308,
17213,
353,
2673,
2173,
4054,
2519,
319,
286,
659,
19293,
284,
15041,
33253,
1214,
15006,
58,
15,
1145,
659,
15006,
58,
16,
1145,
5150,
3408,
11,
5150,
3724,
7377,
286,
674,
4324,
832,
8294,
7479,
11,
1243,
1529,
275,
682,
1584,
27529,
1139,
433,
319,
286,
674,
9984,
8202,
527,
4460,
311,
743,
279,
4092,
8451,
439,
18300,
319,
286,
659,
2858,
1945,
284,
15041,
82074,
1209,
12210,
3408,
11,
5150,
3724,
705,
8202,
28,
57117,
984,
29322,
1240,
286,
422,
659,
15815,
374,
539,
2290,
2904,
310,
659,
2858,
1945,
12749,
1214,
15815,
7377,
286,
420,
2519,
5479,
284,
220,
15,
319,
286,
369,
1584,
24627,
304,
27529,
861,
2904,
310,
422,
659,
63310,
1908,
624,
364,
2414,
18928,
394,
659,
2858,
1945,
39636,
8973,
24627,
11,
320,
15,
11,
420,
2519,
5479,
5904,
310,
775,
2904,
394,
420,
24627,
3408,
284,
1584,
24627,
673,
17410,
10324,
17,
60,
220,
674,
2449,
220,
17,
374,
279,
2430,
319,
394,
422,
659,
63310,
1908,
624,
364,
3133,
18928,
504,
279,
5530,
284,
320,
12210,
3408,
482,
420,
24627,
3408,
8,
611,
220,
17,
319,
394,
4508,
659,
63310,
1908,
624,
364,
1315,
1232,
220,
674,
1314,
35516,
319,
504,
279,
5530,
284,
5150,
3408,
482,
420,
24627,
3408,
319,
394,
775,
2904,
504,
4933,
4204,
493,
1150,
315,
35516,
574,
25,
364,
489,
659,
63310,
1908,
489,
6389,
15832,
387,
2163,
11,
4219,
11,
477,
1314,
7849,
394,
659,
2858,
1945,
39636,
8973,
24627,
11,
320,
1820,
5530,
11,
420,
2519,
5479,
5904,
310,
420,
2519,
5479,
284,
420,
2519,
5479
] |
django-fluent/django-fluent-contents | fluent_contents/models/fields.py | PlaceholderField.formfield | def formfield(self, **kwargs):
"""
Returns a :class:`PlaceholderFormField` instance for this database Field.
"""
defaults = {
'label': capfirst(self.verbose_name),
'help_text': self.help_text,
'required': not self.blank,
}
defaults.update(kwargs)
return PlaceholderFormField(slot=self.slot, plugins=self._plugins, **defaults) | python | def formfield(self, **kwargs):
"""
Returns a :class:`PlaceholderFormField` instance for this database Field.
"""
defaults = {
'label': capfirst(self.verbose_name),
'help_text': self.help_text,
'required': not self.blank,
}
defaults.update(kwargs)
return PlaceholderFormField(slot=self.slot, plugins=self._plugins, **defaults) | [
"def",
"formfield",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"defaults",
"=",
"{",
"'label'",
":",
"capfirst",
"(",
"self",
".",
"verbose_name",
")",
",",
"'help_text'",
":",
"self",
".",
"help_text",
",",
"'required'",
":",
"not",
"self",
".",
"blank",
",",
"}",
"defaults",
".",
"update",
"(",
"kwargs",
")",
"return",
"PlaceholderFormField",
"(",
"slot",
"=",
"self",
".",
"slot",
",",
"plugins",
"=",
"self",
".",
"_plugins",
",",
"*",
"*",
"defaults",
")"
] | Returns a :class:`PlaceholderFormField` instance for this database Field. | [
"Returns",
"a",
":",
"class",
":",
"PlaceholderFormField",
"instance",
"for",
"this",
"database",
"Field",
"."
] | train | https://github.com/django-fluent/django-fluent-contents/blob/896f14add58471b98d7aa295b2c9e6abedec9003/fluent_contents/models/fields.py#L175-L185 | <|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 :class:`PlaceholderFormField` instance for this database Field.
### Response:
def formfield(self, **kwargs):
"""
Returns a :class:`PlaceholderFormField` instance for this database Field.
"""
defaults = {
'label': capfirst(self.verbose_name),
'help_text': self.help_text,
'required': not self.blank,
}
defaults.update(kwargs)
return PlaceholderFormField(slot=self.slot, plugins=self._plugins, **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,
551,
1058,
19258,
49405,
46457,
63,
2937,
369,
420,
4729,
8771,
382,
14711,
6075,
512,
755,
1376,
2630,
1214,
11,
3146,
9872,
997,
286,
3270,
286,
5295,
264,
551,
1058,
19258,
49405,
46457,
63,
2937,
369,
420,
4729,
8771,
627,
286,
3270,
286,
17088,
284,
341,
310,
364,
1530,
1232,
2107,
3983,
1214,
45749,
1292,
1350,
310,
364,
8823,
4424,
1232,
659,
46566,
4424,
345,
310,
364,
6413,
1232,
539,
659,
56059,
345,
286,
457,
286,
17088,
5430,
71706,
340,
286,
471,
87821,
46457,
44824,
7822,
70743,
11,
17658,
7822,
1462,
19237,
11,
3146,
27854,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
551,
1058,
19258,
49405,
46457,
63,
2937,
369,
420,
4729,
8771,
382,
14711,
6075,
512,
755,
1376,
2630,
1214,
11,
3146,
9872,
997,
286,
3270,
286,
5295,
264,
551,
1058,
19258,
49405,
46457,
63,
2937,
369,
420,
4729,
8771,
627,
286,
3270,
286,
17088,
284,
341,
310,
364,
1530,
1232,
2107,
3983,
1214,
45749,
1292,
1350,
310,
364,
8823,
4424,
1232,
659,
46566,
4424,
345,
310,
364,
6413,
1232,
539,
659,
56059,
345,
286,
457,
286,
17088,
5430,
71706,
340,
286,
471,
87821,
46457,
44824,
7822,
70743,
11,
17658,
7822,
1462,
19237,
11,
3146,
27854,
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
] |
codelv/enaml-native | src/enamlnative/android/android_view_pager.py | AndroidViewPager.create_widget | def create_widget(self):
""" Create the underlying widget.
"""
self.widget = ViewPager(self.get_context())
self.adapter = BridgedFragmentStatePagerAdapter() | python | def create_widget(self):
""" Create the underlying widget.
"""
self.widget = ViewPager(self.get_context())
self.adapter = BridgedFragmentStatePagerAdapter() | [
"def",
"create_widget",
"(",
"self",
")",
":",
"self",
".",
"widget",
"=",
"ViewPager",
"(",
"self",
".",
"get_context",
"(",
")",
")",
"self",
".",
"adapter",
"=",
"BridgedFragmentStatePagerAdapter",
"(",
")"
] | Create the underlying widget. | [
"Create",
"the",
"underlying",
"widget",
"."
] | train | https://github.com/codelv/enaml-native/blob/c33986e9eda468c508806e0a3e73c771401e5718/src/enamlnative/android/android_view_pager.py#L143-L148 | <|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:
Create the underlying widget.
### Response:
def create_widget(self):
""" Create the underlying widget.
"""
self.widget = ViewPager(self.get_context())
self.adapter = BridgedFragmentStatePagerAdapter()
<|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,
4110,
279,
16940,
9264,
382,
14711,
6075,
512,
755,
1893,
13899,
1214,
997,
286,
4304,
4324,
279,
16940,
9264,
382,
286,
3270,
286,
659,
5917,
284,
91285,
1214,
673,
8634,
2455,
286,
659,
27419,
284,
32437,
3640,
9677,
1423,
60467,
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,
128009,
128009,
128009,
128009,
128009,
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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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
] | [
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,
4110,
279,
16940,
9264,
382,
14711,
6075,
512,
755,
1893,
13899,
1214,
997,
286,
4304,
4324,
279,
16940,
9264,
382,
286,
3270,
286,
659,
5917,
284,
91285,
1214,
673,
8634,
2455,
286,
659,
27419,
284,
32437,
3640,
9677,
1423,
60467,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
Spinmob/spinmob | _functions.py | replace_lines_in_files | def replace_lines_in_files(search_string, replacement_line):
"""
Finds lines containing the search string and replaces the whole line with
the specified replacement string.
"""
# have the user select some files
paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*')
if paths == []: return
for path in paths:
_shutil.copy(path, path+".backup")
lines = read_lines(path)
for n in range(0,len(lines)):
if lines[n].find(search_string) >= 0:
print(lines[n])
lines[n] = replacement_line.strip() + "\n"
write_to_file(path, join(lines, ''))
return | python | def replace_lines_in_files(search_string, replacement_line):
"""
Finds lines containing the search string and replaces the whole line with
the specified replacement string.
"""
# have the user select some files
paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*')
if paths == []: return
for path in paths:
_shutil.copy(path, path+".backup")
lines = read_lines(path)
for n in range(0,len(lines)):
if lines[n].find(search_string) >= 0:
print(lines[n])
lines[n] = replacement_line.strip() + "\n"
write_to_file(path, join(lines, ''))
return | [
"def",
"replace_lines_in_files",
"(",
"search_string",
",",
"replacement_line",
")",
":",
"# have the user select some files",
"paths",
"=",
"_s",
".",
"dialogs",
".",
"MultipleFiles",
"(",
"'DIS AND DAT|*.*'",
")",
"if",
"paths",
"==",
"[",
"]",
":",
"return",
"for",
"path",
"in",
"paths",
":",
"_shutil",
".",
"copy",
"(",
"path",
",",
"path",
"+",
"\".backup\"",
")",
"lines",
"=",
"read_lines",
"(",
"path",
")",
"for",
"n",
"in",
"range",
"(",
"0",
",",
"len",
"(",
"lines",
")",
")",
":",
"if",
"lines",
"[",
"n",
"]",
".",
"find",
"(",
"search_string",
")",
">=",
"0",
":",
"print",
"(",
"lines",
"[",
"n",
"]",
")",
"lines",
"[",
"n",
"]",
"=",
"replacement_line",
".",
"strip",
"(",
")",
"+",
"\"\\n\"",
"write_to_file",
"(",
"path",
",",
"join",
"(",
"lines",
",",
"''",
")",
")",
"return"
] | Finds lines containing the search string and replaces the whole line with
the specified replacement string. | [
"Finds",
"lines",
"containing",
"the",
"search",
"string",
"and",
"replaces",
"the",
"whole",
"line",
"with",
"the",
"specified",
"replacement",
"string",
"."
] | train | https://github.com/Spinmob/spinmob/blob/f037f5df07f194bcd4a01f4d9916e57b9e8fb45a/_functions.py#L1264-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:
Finds lines containing the search string and replaces the whole line with
the specified replacement string.
### Response:
def replace_lines_in_files(search_string, replacement_line):
"""
Finds lines containing the search string and replaces the whole line with
the specified replacement string.
"""
# have the user select some files
paths = _s.dialogs.MultipleFiles('DIS AND DAT|*.*')
if paths == []: return
for path in paths:
_shutil.copy(path, path+".backup")
lines = read_lines(path)
for n in range(0,len(lines)):
if lines[n].find(search_string) >= 0:
print(lines[n])
lines[n] = replacement_line.strip() + "\n"
write_to_file(path, join(lines, ''))
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,
37,
8843,
5238,
8649,
279,
2778,
925,
323,
41800,
279,
4459,
1584,
449,
198,
262,
279,
5300,
14039,
925,
382,
14711,
6075,
512,
755,
8454,
18828,
1265,
11171,
21079,
3991,
11,
14039,
6665,
997,
262,
3270,
262,
51730,
5238,
8649,
279,
2778,
925,
323,
41800,
279,
4459,
1584,
449,
198,
262,
279,
5300,
14039,
925,
627,
262,
4304,
1432,
262,
674,
617,
279,
1217,
3373,
1063,
3626,
198,
262,
13006,
284,
721,
82,
25978,
82,
1345,
12508,
11043,
493,
21894,
3651,
40462,
91,
9,
5013,
1329,
262,
422,
13006,
624,
3132,
25,
471,
271,
262,
369,
1853,
304,
13006,
512,
286,
721,
939,
1338,
12511,
5698,
11,
1853,
42549,
32471,
1158,
286,
5238,
284,
1373,
18828,
5698,
340,
286,
369,
308,
304,
2134,
7,
15,
30719,
34252,
10162,
310,
422,
5238,
7824,
948,
3990,
21079,
3991,
8,
2669,
220,
15,
512,
394,
1194,
34252,
7824,
2608,
394,
5238,
7824,
60,
284,
14039,
6665,
17624,
368,
489,
2990,
77,
702,
286,
3350,
2401,
2517,
5698,
11,
5249,
34252,
11,
3436,
4489,
262,
471,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
5238,
8649,
279,
2778,
925,
323,
41800,
279,
4459,
1584,
449,
198,
262,
279,
5300,
14039,
925,
382,
14711,
6075,
512,
755,
8454,
18828,
1265,
11171,
21079,
3991,
11,
14039,
6665,
997,
262,
3270,
262,
51730,
5238,
8649,
279,
2778,
925,
323,
41800,
279,
4459,
1584,
449,
198,
262,
279,
5300,
14039,
925,
627,
262,
4304,
1432,
262,
674,
617,
279,
1217,
3373,
1063,
3626,
198,
262,
13006,
284,
721,
82,
25978,
82,
1345,
12508,
11043,
493,
21894,
3651,
40462,
91,
9,
5013,
1329,
262,
422,
13006,
624,
3132,
25,
471,
271,
262,
369,
1853,
304,
13006,
512,
286,
721,
939,
1338,
12511,
5698,
11,
1853,
42549,
32471,
1158,
286,
5238,
284,
1373,
18828,
5698,
340,
286,
369,
308,
304,
2134,
7,
15,
30719,
34252,
10162,
310,
422,
5238,
7824,
948,
3990,
21079,
3991,
8,
2669,
220,
15,
512,
394,
1194,
34252,
7824,
2608,
394,
5238,
7824,
60,
284,
14039,
6665,
17624,
368,
489,
2990,
77,
702,
286,
3350,
2401,
2517,
5698,
11,
5249,
34252,
11,
3436,
4489,
262,
471,
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
] |
jmcgeheeiv/pyfakefs | pyfakefs/helpers.py | FakeStatResult.st_atime | def st_atime(self):
"""Return the access time in seconds."""
atime = self._st_atime_ns / 1e9
return atime if self.use_float else int(atime) | python | def st_atime(self):
"""Return the access time in seconds."""
atime = self._st_atime_ns / 1e9
return atime if self.use_float else int(atime) | [
"def",
"st_atime",
"(",
"self",
")",
":",
"atime",
"=",
"self",
".",
"_st_atime_ns",
"/",
"1e9",
"return",
"atime",
"if",
"self",
".",
"use_float",
"else",
"int",
"(",
"atime",
")"
] | Return the access time in seconds. | [
"Return",
"the",
"access",
"time",
"in",
"seconds",
"."
] | train | https://github.com/jmcgeheeiv/pyfakefs/blob/6c36fb8987108107fc861fc3013620d46c7d2f9c/pyfakefs/helpers.py#L169-L172 | <|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 access time in seconds.
### Response:
def st_atime(self):
"""Return the access time in seconds."""
atime = self._st_atime_ns / 1e9
return atime if self.use_float else int(atime)
<|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,
2680,
892,
304,
6622,
382,
14711,
6075,
512,
755,
357,
3837,
547,
1214,
997,
286,
4304,
5715,
279,
2680,
892,
304,
6622,
14781,
286,
520,
547,
284,
659,
1462,
267,
3837,
547,
35828,
611,
220,
16,
68,
24,
198,
286,
471,
520,
547,
422,
659,
7549,
18047,
775,
528,
19917,
547,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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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,
5715,
279,
2680,
892,
304,
6622,
382,
14711,
6075,
512,
755,
357,
3837,
547,
1214,
997,
286,
4304,
5715,
279,
2680,
892,
304,
6622,
14781,
286,
520,
547,
284,
659,
1462,
267,
3837,
547,
35828,
611,
220,
16,
68,
24,
198,
286,
471,
520,
547,
422,
659,
7549,
18047,
775,
528,
19917,
547,
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
] |
klen/makesite | makesite/core.py | get_base_templates | def get_base_templates():
" Get list of installed templates. "
return sorted(filter(
lambda x: op.isdir(op.join(TPL_DIR, x)),
listdir(TPL_DIR))) | python | def get_base_templates():
" Get list of installed templates. "
return sorted(filter(
lambda x: op.isdir(op.join(TPL_DIR, x)),
listdir(TPL_DIR))) | [
"def",
"get_base_templates",
"(",
")",
":",
"return",
"sorted",
"(",
"filter",
"(",
"lambda",
"x",
":",
"op",
".",
"isdir",
"(",
"op",
".",
"join",
"(",
"TPL_DIR",
",",
"x",
")",
")",
",",
"listdir",
"(",
"TPL_DIR",
")",
")",
")"
] | Get list of installed templates. | [
"Get",
"list",
"of",
"installed",
"templates",
"."
] | train | https://github.com/klen/makesite/blob/f6f77a43a04a256189e8fffbeac1ffd63f35a10c/makesite/core.py#L117-L122 | <|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 list of installed templates.
### Response:
def get_base_templates():
" Get list of installed templates. "
return sorted(filter(
lambda x: op.isdir(op.join(TPL_DIR, x)),
listdir(TPL_DIR)))
<|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,
1160,
315,
10487,
20506,
382,
14711,
6075,
512,
755,
636,
7806,
50626,
4019,
262,
330,
2175,
1160,
315,
10487,
20506,
13,
23584,
262,
471,
10839,
20283,
1021,
1733,
12741,
865,
25,
1200,
49261,
17534,
5563,
4233,
2989,
8455,
11,
865,
7110,
1733,
1160,
3826,
4233,
2989,
8455,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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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190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
1991,
1160,
315,
10487,
20506,
382,
14711,
6075,
512,
755,
636,
7806,
50626,
4019,
262,
330,
2175,
1160,
315,
10487,
20506,
13,
23584,
262,
471,
10839,
20283,
1021,
1733,
12741,
865,
25,
1200,
49261,
17534,
5563,
4233,
2989,
8455,
11,
865,
7110,
1733,
1160,
3826,
4233,
2989,
8455,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pymc-devs/pymc | pymc/distributions.py | exponweib_like | def exponweib_like(x, alpha, k, loc=0, scale=1):
R"""
Exponentiated Weibull log-likelihood.
The exponentiated Weibull distribution is a generalization of the Weibull
family. Its value lies in being able to model monotone and non-monotone
failure rates.
.. math::
f(x \mid \alpha,k,loc,scale) & = \frac{\alpha k}{scale} (1-e^{-z^k})^{\alpha-1} e^{-z^k} z^{k-1} \\
z & = \frac{x-loc}{scale}
:Parameters:
- `x` : x > 0
- `alpha` : Shape parameter
- `k` : k > 0
- `loc` : Location parameter
- `scale` : Scale parameter (scale > 0).
"""
return flib.exponweib(x, alpha, k, loc, scale) | python | def exponweib_like(x, alpha, k, loc=0, scale=1):
R"""
Exponentiated Weibull log-likelihood.
The exponentiated Weibull distribution is a generalization of the Weibull
family. Its value lies in being able to model monotone and non-monotone
failure rates.
.. math::
f(x \mid \alpha,k,loc,scale) & = \frac{\alpha k}{scale} (1-e^{-z^k})^{\alpha-1} e^{-z^k} z^{k-1} \\
z & = \frac{x-loc}{scale}
:Parameters:
- `x` : x > 0
- `alpha` : Shape parameter
- `k` : k > 0
- `loc` : Location parameter
- `scale` : Scale parameter (scale > 0).
"""
return flib.exponweib(x, alpha, k, loc, scale) | [
"def",
"exponweib_like",
"(",
"x",
",",
"alpha",
",",
"k",
",",
"loc",
"=",
"0",
",",
"scale",
"=",
"1",
")",
":",
"return",
"flib",
".",
"exponweib",
"(",
"x",
",",
"alpha",
",",
"k",
",",
"loc",
",",
"scale",
")"
] | R"""
Exponentiated Weibull log-likelihood.
The exponentiated Weibull distribution is a generalization of the Weibull
family. Its value lies in being able to model monotone and non-monotone
failure rates.
.. math::
f(x \mid \alpha,k,loc,scale) & = \frac{\alpha k}{scale} (1-e^{-z^k})^{\alpha-1} e^{-z^k} z^{k-1} \\
z & = \frac{x-loc}{scale}
:Parameters:
- `x` : x > 0
- `alpha` : Shape parameter
- `k` : k > 0
- `loc` : Location parameter
- `scale` : Scale parameter (scale > 0). | [
"R",
"Exponentiated",
"Weibull",
"log",
"-",
"likelihood",
"."
] | train | https://github.com/pymc-devs/pymc/blob/c6e530210bff4c0d7189b35b2c971bc53f93f7cd/pymc/distributions.py#L1241-L1261 | <|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:
R"""
Exponentiated Weibull log-likelihood.
The exponentiated Weibull distribution is a generalization of the Weibull
family. Its value lies in being able to model monotone and non-monotone
failure rates.
.. math::
f(x \mid \alpha,k,loc,scale) & = \frac{\alpha k}{scale} (1-e^{-z^k})^{\alpha-1} e^{-z^k} z^{k-1} \\
z & = \frac{x-loc}{scale}
:Parameters:
- `x` : x > 0
- `alpha` : Shape parameter
- `k` : k > 0
- `loc` : Location parameter
- `scale` : Scale parameter (scale > 0).
### Response:
def exponweib_like(x, alpha, k, loc=0, scale=1):
R"""
Exponentiated Weibull log-likelihood.
The exponentiated Weibull distribution is a generalization of the Weibull
family. Its value lies in being able to model monotone and non-monotone
failure rates.
.. math::
f(x \mid \alpha,k,loc,scale) & = \frac{\alpha k}{scale} (1-e^{-z^k})^{\alpha-1} e^{-z^k} z^{k-1} \\
z & = \frac{x-loc}{scale}
:Parameters:
- `x` : x > 0
- `alpha` : Shape parameter
- `k` : k > 0
- `loc` : Location parameter
- `scale` : Scale parameter (scale > 0).
"""
return flib.exponweib(x, alpha, k, loc, scale)
<|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,
7275,
262,
1398,
1166,
10234,
1226,
581,
620,
1515,
12,
62230,
382,
262,
578,
28790,
10234,
1226,
581,
620,
8141,
374,
264,
4689,
2065,
315,
279,
1226,
581,
620,
198,
262,
3070,
13,
11699,
907,
15812,
304,
1694,
3025,
311,
1646,
78316,
606,
323,
2536,
78396,
354,
606,
198,
262,
8060,
7969,
382,
262,
5354,
7033,
50677,
286,
282,
2120,
1144,
16497,
1144,
7288,
16539,
11,
1092,
10900,
2296,
8,
220,
612,
284,
1144,
38118,
36802,
7288,
597,
15523,
12727,
92,
320,
16,
5773,
88310,
89,
61,
74,
5525,
61,
36802,
7288,
12,
16,
92,
384,
88310,
89,
61,
74,
92,
1167,
48922,
74,
12,
16,
92,
91255,
286,
1167,
612,
284,
1144,
38118,
46440,
12,
1092,
15523,
12727,
633,
262,
551,
9905,
512,
415,
482,
1595,
87,
63,
551,
865,
871,
220,
15,
198,
415,
482,
1595,
7288,
63,
551,
23342,
5852,
198,
415,
482,
1595,
74,
63,
551,
597,
871,
220,
15,
198,
415,
482,
1595,
1092,
63,
551,
10067,
5852,
198,
415,
482,
1595,
12727,
63,
551,
25635,
5852,
320,
12727,
871,
220,
15,
3677,
14711,
6075,
512,
755,
506,
621,
906,
581,
26616,
2120,
11,
8451,
11,
597,
11,
1353,
28,
15,
11,
5569,
28,
16,
997,
262,
432,
7275,
262,
1398,
1166,
10234,
1226,
581,
620,
1515,
12,
62230,
382,
262,
578,
28790,
10234,
1226,
581,
620,
8141,
374,
264,
4689,
2065,
315,
279,
1226,
581,
620,
198,
262,
3070,
13,
11699,
907,
15812,
304,
1694,
3025,
311,
1646,
78316,
606,
323,
2536,
78396,
354,
606,
198,
262,
8060,
7969,
382,
262,
5354,
7033,
50677,
286,
282,
2120,
1144,
16497,
1144,
7288,
16539,
11,
1092,
10900,
2296,
8,
220,
612,
284,
1144,
38118,
36802,
7288,
597,
15523,
12727,
92,
320,
16,
5773,
88310,
89,
61,
74,
5525,
61,
36802,
7288,
12,
16,
92,
384,
88310,
89,
61,
74,
92,
1167,
48922,
74,
12,
16,
92,
91255,
286,
1167,
612,
284,
1144,
38118,
46440,
12,
1092,
15523,
12727,
633,
262,
551,
9905,
512,
415,
482,
1595,
87,
63,
551,
865,
871,
220,
15,
198,
415,
482,
1595,
7288,
63,
551,
23342,
5852,
198,
415,
482,
1595,
74,
63,
551,
597,
871,
220,
15,
198,
415,
482,
1595,
1092,
63,
551,
10067,
5852,
198,
415,
482,
1595,
12727,
63,
551,
25635,
5852,
320,
12727,
871,
220,
15,
3677,
262,
3270,
262,
471,
1344,
581,
2272,
621,
906,
581,
2120,
11,
8451,
11,
597,
11,
1353,
11,
5569,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
262,
1398,
1166,
10234,
1226,
581,
620,
1515,
12,
62230,
382,
262,
578,
28790,
10234,
1226,
581,
620,
8141,
374,
264,
4689,
2065,
315,
279,
1226,
581,
620,
198,
262,
3070,
13,
11699,
907,
15812,
304,
1694,
3025,
311,
1646,
78316,
606,
323,
2536,
78396,
354,
606,
198,
262,
8060,
7969,
382,
262,
5354,
7033,
50677,
286,
282,
2120,
1144,
16497,
1144,
7288,
16539,
11,
1092,
10900,
2296,
8,
220,
612,
284,
1144,
38118,
36802,
7288,
597,
15523,
12727,
92,
320,
16,
5773,
88310,
89,
61,
74,
5525,
61,
36802,
7288,
12,
16,
92,
384,
88310,
89,
61,
74,
92,
1167,
48922,
74,
12,
16,
92,
91255,
286,
1167,
612,
284,
1144,
38118,
46440,
12,
1092,
15523,
12727,
633,
262,
551,
9905,
512,
415,
482,
1595,
87,
63,
551,
865,
871,
220,
15,
198,
415,
482,
1595,
7288,
63,
551,
23342,
5852,
198,
415,
482,
1595,
74,
63,
551,
597,
871,
220,
15,
198,
415,
482,
1595,
1092,
63,
551,
10067,
5852,
198,
415,
482,
1595,
12727,
63,
551,
25635,
5852,
320,
12727,
871,
220,
15,
3677,
14711,
6075,
512,
755,
506,
621,
906,
581,
26616,
2120,
11,
8451,
11,
597,
11,
1353,
28,
15,
11,
5569,
28,
16,
997,
262,
432,
7275,
262,
1398,
1166,
10234,
1226,
581,
620,
1515,
12,
62230,
382,
262,
578,
28790,
10234,
1226,
581,
620,
8141,
374,
264,
4689,
2065,
315,
279,
1226,
581,
620,
198,
262,
3070,
13,
11699,
907,
15812,
304,
1694,
3025,
311,
1646,
78316,
606,
323,
2536,
78396,
354,
606,
198,
262,
8060,
7969,
382,
262,
5354,
7033,
50677,
286,
282,
2120,
1144,
16497,
1144,
7288,
16539,
11,
1092,
10900,
2296,
8,
220,
612,
284,
1144,
38118,
36802,
7288,
597,
15523,
12727,
92,
320,
16,
5773,
88310,
89,
61,
74,
5525,
61,
36802,
7288,
12,
16,
92,
384,
88310,
89,
61,
74,
92,
1167,
48922,
74,
12,
16,
92,
91255,
286,
1167,
612,
284,
1144,
38118,
46440,
12,
1092,
15523,
12727,
633,
262,
551,
9905,
512,
415,
482,
1595,
87,
63,
551,
865,
871,
220,
15,
198,
415,
482,
1595,
7288,
63,
551,
23342,
5852,
198,
415,
482,
1595,
74,
63,
551,
597,
871,
220,
15,
198,
415,
482,
1595,
1092,
63,
551,
10067,
5852,
198,
415,
482,
1595,
12727,
63,
551,
25635,
5852,
320,
12727,
871,
220,
15,
3677,
262,
3270,
262,
471,
1344,
581,
2272,
621,
906,
581,
2120,
11,
8451,
11,
597,
11,
1353,
11,
5569,
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
] |
IntegralDefense/critsapi | critsapi/critsapi.py | CRITsAPI.forge_relationship | def forge_relationship(self, left_id, left_type, right_id, right_type,
rel_type='Related To', rel_date=None,
rel_confidence='high', rel_reason=''):
"""
Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
right_id: The CRITs ID of the second indicator
right_type: The CRITs TLO type of the second indicator
rel_type: The relationships type ("Related To", etc)
rel_date: datetime.datetime object for the date of the
relationship. If left blank, it will be datetime.datetime.now()
rel_confidence: The relationship confidence (high, medium, low)
rel_reason: Reason for the relationship.
Returns:
True if the relationship was created. False otherwise.
"""
if not rel_date:
rel_date = datetime.datetime.now()
type_trans = self._type_translation(left_type)
submit_url = '{}/{}/{}/'.format(self.url, type_trans, left_id)
params = {
'api_key': self.api_key,
'username': self.username,
}
data = {
'action': 'forge_relationship',
'right_type': right_type,
'right_id': right_id,
'rel_type': rel_type,
'rel_date': rel_date,
'rel_confidence': rel_confidence,
'rel_reason': rel_reason
}
r = requests.patch(submit_url, params=params, data=data,
proxies=self.proxies, verify=self.verify)
if r.status_code == 200:
log.debug('Relationship built successfully: {0} <-> '
'{1}'.format(left_id, right_id))
return True
else:
log.error('Error with status code {0} and message {1} between '
'these indicators: {2} <-> '
'{3}'.format(r.status_code, r.text, left_id, right_id))
return False | python | def forge_relationship(self, left_id, left_type, right_id, right_type,
rel_type='Related To', rel_date=None,
rel_confidence='high', rel_reason=''):
"""
Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
right_id: The CRITs ID of the second indicator
right_type: The CRITs TLO type of the second indicator
rel_type: The relationships type ("Related To", etc)
rel_date: datetime.datetime object for the date of the
relationship. If left blank, it will be datetime.datetime.now()
rel_confidence: The relationship confidence (high, medium, low)
rel_reason: Reason for the relationship.
Returns:
True if the relationship was created. False otherwise.
"""
if not rel_date:
rel_date = datetime.datetime.now()
type_trans = self._type_translation(left_type)
submit_url = '{}/{}/{}/'.format(self.url, type_trans, left_id)
params = {
'api_key': self.api_key,
'username': self.username,
}
data = {
'action': 'forge_relationship',
'right_type': right_type,
'right_id': right_id,
'rel_type': rel_type,
'rel_date': rel_date,
'rel_confidence': rel_confidence,
'rel_reason': rel_reason
}
r = requests.patch(submit_url, params=params, data=data,
proxies=self.proxies, verify=self.verify)
if r.status_code == 200:
log.debug('Relationship built successfully: {0} <-> '
'{1}'.format(left_id, right_id))
return True
else:
log.error('Error with status code {0} and message {1} between '
'these indicators: {2} <-> '
'{3}'.format(r.status_code, r.text, left_id, right_id))
return False | [
"def",
"forge_relationship",
"(",
"self",
",",
"left_id",
",",
"left_type",
",",
"right_id",
",",
"right_type",
",",
"rel_type",
"=",
"'Related To'",
",",
"rel_date",
"=",
"None",
",",
"rel_confidence",
"=",
"'high'",
",",
"rel_reason",
"=",
"''",
")",
":",
"if",
"not",
"rel_date",
":",
"rel_date",
"=",
"datetime",
".",
"datetime",
".",
"now",
"(",
")",
"type_trans",
"=",
"self",
".",
"_type_translation",
"(",
"left_type",
")",
"submit_url",
"=",
"'{}/{}/{}/'",
".",
"format",
"(",
"self",
".",
"url",
",",
"type_trans",
",",
"left_id",
")",
"params",
"=",
"{",
"'api_key'",
":",
"self",
".",
"api_key",
",",
"'username'",
":",
"self",
".",
"username",
",",
"}",
"data",
"=",
"{",
"'action'",
":",
"'forge_relationship'",
",",
"'right_type'",
":",
"right_type",
",",
"'right_id'",
":",
"right_id",
",",
"'rel_type'",
":",
"rel_type",
",",
"'rel_date'",
":",
"rel_date",
",",
"'rel_confidence'",
":",
"rel_confidence",
",",
"'rel_reason'",
":",
"rel_reason",
"}",
"r",
"=",
"requests",
".",
"patch",
"(",
"submit_url",
",",
"params",
"=",
"params",
",",
"data",
"=",
"data",
",",
"proxies",
"=",
"self",
".",
"proxies",
",",
"verify",
"=",
"self",
".",
"verify",
")",
"if",
"r",
".",
"status_code",
"==",
"200",
":",
"log",
".",
"debug",
"(",
"'Relationship built successfully: {0} <-> '",
"'{1}'",
".",
"format",
"(",
"left_id",
",",
"right_id",
")",
")",
"return",
"True",
"else",
":",
"log",
".",
"error",
"(",
"'Error with status code {0} and message {1} between '",
"'these indicators: {2} <-> '",
"'{3}'",
".",
"format",
"(",
"r",
".",
"status_code",
",",
"r",
".",
"text",
",",
"left_id",
",",
"right_id",
")",
")",
"return",
"False"
] | Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
right_id: The CRITs ID of the second indicator
right_type: The CRITs TLO type of the second indicator
rel_type: The relationships type ("Related To", etc)
rel_date: datetime.datetime object for the date of the
relationship. If left blank, it will be datetime.datetime.now()
rel_confidence: The relationship confidence (high, medium, low)
rel_reason: Reason for the relationship.
Returns:
True if the relationship was created. False otherwise. | [
"Forges",
"a",
"relationship",
"between",
"two",
"TLOs",
"."
] | train | https://github.com/IntegralDefense/critsapi/blob/e770bd81e124eaaeb5f1134ba95f4a35ff345c5a/critsapi/critsapi.py#L631-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:
Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
right_id: The CRITs ID of the second indicator
right_type: The CRITs TLO type of the second indicator
rel_type: The relationships type ("Related To", etc)
rel_date: datetime.datetime object for the date of the
relationship. If left blank, it will be datetime.datetime.now()
rel_confidence: The relationship confidence (high, medium, low)
rel_reason: Reason for the relationship.
Returns:
True if the relationship was created. False otherwise.
### Response:
def forge_relationship(self, left_id, left_type, right_id, right_type,
rel_type='Related To', rel_date=None,
rel_confidence='high', rel_reason=''):
"""
Forges a relationship between two TLOs.
Args:
left_id: The CRITs ID of the first indicator
left_type: The CRITs TLO type of the first indicator
right_id: The CRITs ID of the second indicator
right_type: The CRITs TLO type of the second indicator
rel_type: The relationships type ("Related To", etc)
rel_date: datetime.datetime object for the date of the
relationship. If left blank, it will be datetime.datetime.now()
rel_confidence: The relationship confidence (high, medium, low)
rel_reason: Reason for the relationship.
Returns:
True if the relationship was created. False otherwise.
"""
if not rel_date:
rel_date = datetime.datetime.now()
type_trans = self._type_translation(left_type)
submit_url = '{}/{}/{}/'.format(self.url, type_trans, left_id)
params = {
'api_key': self.api_key,
'username': self.username,
}
data = {
'action': 'forge_relationship',
'right_type': right_type,
'right_id': right_id,
'rel_type': rel_type,
'rel_date': rel_date,
'rel_confidence': rel_confidence,
'rel_reason': rel_reason
}
r = requests.patch(submit_url, params=params, data=data,
proxies=self.proxies, verify=self.verify)
if r.status_code == 200:
log.debug('Relationship built successfully: {0} <-> '
'{1}'.format(left_id, right_id))
return True
else:
log.error('Error with status code {0} and message {1} between '
'these indicators: {2} <-> '
'{3}'.format(r.status_code, r.text, left_id, right_id))
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,
34635,
288,
264,
5133,
1990,
1403,
350,
1623,
82,
382,
286,
18161,
512,
310,
2163,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
1176,
21070,
198,
310,
2163,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
1176,
21070,
198,
310,
1314,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
2132,
21070,
198,
310,
1314,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
2132,
21070,
198,
310,
1375,
1857,
25,
578,
12135,
955,
3573,
11948,
2057,
498,
5099,
340,
310,
1375,
4257,
25,
9050,
20296,
1665,
369,
279,
2457,
315,
279,
198,
394,
5133,
13,
1442,
2163,
10321,
11,
433,
690,
387,
9050,
20296,
10930,
746,
310,
1375,
16445,
7232,
25,
578,
5133,
12410,
320,
12156,
11,
11298,
11,
3428,
340,
310,
1375,
39329,
25,
27857,
369,
279,
5133,
627,
286,
5295,
512,
310,
3082,
422,
279,
5133,
574,
3549,
13,
3641,
6062,
382,
14711,
6075,
512,
755,
57728,
70131,
1214,
11,
2163,
851,
11,
2163,
1857,
11,
1314,
851,
11,
1314,
1857,
345,
6096,
1375,
1857,
1151,
11948,
2057,
518,
1375,
4257,
5980,
345,
6096,
1375,
16445,
7232,
1151,
12156,
518,
1375,
39329,
95227,
286,
3270,
286,
1789,
4282,
264,
5133,
1990,
1403,
350,
1623,
82,
382,
286,
18161,
512,
310,
2163,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
1176,
21070,
198,
310,
2163,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
1176,
21070,
198,
310,
1314,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
2132,
21070,
198,
310,
1314,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
2132,
21070,
198,
310,
1375,
1857,
25,
578,
12135,
955,
3573,
11948,
2057,
498,
5099,
340,
310,
1375,
4257,
25,
9050,
20296,
1665,
369,
279,
2457,
315,
279,
198,
394,
5133,
13,
1442,
2163,
10321,
11,
433,
690,
387,
9050,
20296,
10930,
746,
310,
1375,
16445,
7232,
25,
578,
5133,
12410,
320,
12156,
11,
11298,
11,
3428,
340,
310,
1375,
39329,
25,
27857,
369,
279,
5133,
627,
286,
5295,
512,
310,
3082,
422,
279,
5133,
574,
3549,
13,
3641,
6062,
627,
286,
3270,
286,
422,
539,
1375,
4257,
512,
310,
1375,
4257,
284,
9050,
20296,
10930,
746,
286,
955,
8124,
284,
659,
1462,
1337,
50373,
18139,
1857,
340,
286,
9502,
2975,
284,
11834,
23284,
23284,
4572,
4527,
2293,
1214,
7464,
11,
955,
8124,
11,
2163,
851,
696,
286,
3712,
284,
341,
310,
364,
2113,
3173,
1232,
659,
6314,
3173,
345,
310,
364,
5223,
1232,
659,
12664,
345,
310,
557,
286,
828,
284,
341,
310,
364,
1335,
1232,
364,
25081,
70131,
756,
310,
364,
1315,
1857,
1232,
1314,
1857,
345,
310,
364,
1315,
851,
1232,
1314,
851,
345,
310,
364,
3833,
1857,
1232,
1375,
1857,
345,
310,
364,
3833,
4257,
1232,
1375,
4257,
345,
310,
364,
3833,
16445,
7232,
1232,
1375,
16445,
7232,
345,
310,
364,
3833,
39329,
1232
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
34635,
288,
264,
5133,
1990,
1403,
350,
1623,
82,
382,
286,
18161,
512,
310,
2163,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
1176,
21070,
198,
310,
2163,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
1176,
21070,
198,
310,
1314,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
2132,
21070,
198,
310,
1314,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
2132,
21070,
198,
310,
1375,
1857,
25,
578,
12135,
955,
3573,
11948,
2057,
498,
5099,
340,
310,
1375,
4257,
25,
9050,
20296,
1665,
369,
279,
2457,
315,
279,
198,
394,
5133,
13,
1442,
2163,
10321,
11,
433,
690,
387,
9050,
20296,
10930,
746,
310,
1375,
16445,
7232,
25,
578,
5133,
12410,
320,
12156,
11,
11298,
11,
3428,
340,
310,
1375,
39329,
25,
27857,
369,
279,
5133,
627,
286,
5295,
512,
310,
3082,
422,
279,
5133,
574,
3549,
13,
3641,
6062,
382,
14711,
6075,
512,
755,
57728,
70131,
1214,
11,
2163,
851,
11,
2163,
1857,
11,
1314,
851,
11,
1314,
1857,
345,
6096,
1375,
1857,
1151,
11948,
2057,
518,
1375,
4257,
5980,
345,
6096,
1375,
16445,
7232,
1151,
12156,
518,
1375,
39329,
95227,
286,
3270,
286,
1789,
4282,
264,
5133,
1990,
1403,
350,
1623,
82,
382,
286,
18161,
512,
310,
2163,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
1176,
21070,
198,
310,
2163,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
1176,
21070,
198,
310,
1314,
851,
25,
578,
12904,
964,
82,
3110,
315,
279,
2132,
21070,
198,
310,
1314,
1857,
25,
578,
12904,
964,
82,
350,
1623,
955,
315,
279,
2132,
21070,
198,
310,
1375,
1857,
25,
578,
12135,
955,
3573,
11948,
2057,
498,
5099,
340,
310,
1375,
4257,
25,
9050,
20296,
1665,
369,
279,
2457,
315,
279,
198,
394,
5133,
13,
1442,
2163,
10321,
11,
433,
690,
387,
9050,
20296,
10930,
746,
310,
1375,
16445,
7232,
25,
578,
5133,
12410,
320,
12156,
11,
11298,
11,
3428,
340,
310,
1375,
39329,
25,
27857,
369,
279,
5133,
627,
286,
5295,
512,
310,
3082,
422,
279,
5133,
574,
3549,
13,
3641,
6062,
627,
286,
3270,
286,
422,
539,
1375,
4257,
512,
310,
1375,
4257,
284,
9050,
20296,
10930,
746,
286,
955,
8124,
284,
659,
1462,
1337,
50373,
18139,
1857,
340,
286,
9502,
2975,
284,
11834,
23284,
23284,
4572,
4527,
2293,
1214,
7464,
11,
955,
8124,
11,
2163,
851,
696,
286,
3712,
284,
341,
310,
364,
2113,
3173,
1232,
659,
6314,
3173,
345,
310,
364,
5223,
1232,
659,
12664,
345,
310,
557,
286,
828,
284,
341,
310,
364,
1335,
1232,
364,
25081,
70131,
756,
310,
364,
1315,
1857,
1232,
1314,
1857,
345,
310,
364,
1315,
851,
1232,
1314,
851,
345,
310,
364,
3833,
1857,
1232,
1375,
1857,
345,
310,
364,
3833,
4257,
1232,
1375,
4257,
345,
310,
364,
3833,
16445,
7232,
1232,
1375,
16445,
7232,
345,
310,
364,
3833,
39329,
1232
] |
GoogleCloudPlatform/appengine-mapreduce | python/src/mapreduce/model.py | MapreduceControl.abort | def abort(cls, mapreduce_id, **kwargs):
"""Causes a job to abort.
Args:
mapreduce_id: The job to abort. Not verified as a valid job.
"""
cls(key_name="%s:%s" % (mapreduce_id, cls._KEY_NAME),
command=cls.ABORT).put(**kwargs) | python | def abort(cls, mapreduce_id, **kwargs):
"""Causes a job to abort.
Args:
mapreduce_id: The job to abort. Not verified as a valid job.
"""
cls(key_name="%s:%s" % (mapreduce_id, cls._KEY_NAME),
command=cls.ABORT).put(**kwargs) | [
"def",
"abort",
"(",
"cls",
",",
"mapreduce_id",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
"(",
"key_name",
"=",
"\"%s:%s\"",
"%",
"(",
"mapreduce_id",
",",
"cls",
".",
"_KEY_NAME",
")",
",",
"command",
"=",
"cls",
".",
"ABORT",
")",
".",
"put",
"(",
"*",
"*",
"kwargs",
")"
] | Causes a job to abort.
Args:
mapreduce_id: The job to abort. Not verified as a valid job. | [
"Causes",
"a",
"job",
"to",
"abort",
"."
] | train | https://github.com/GoogleCloudPlatform/appengine-mapreduce/blob/2045eb3605b6ecb40c83d11dd5442a89fe5c5dd6/python/src/mapreduce/model.py#L1200-L1207 | <|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 a job to abort.
Args:
mapreduce_id: The job to abort. Not verified as a valid job.
### Response:
def abort(cls, mapreduce_id, **kwargs):
"""Causes a job to abort.
Args:
mapreduce_id: The job to abort. Not verified as a valid job.
"""
cls(key_name="%s:%s" % (mapreduce_id, cls._KEY_NAME),
command=cls.ABORT).put(**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,
23389,
4881,
264,
2683,
311,
11578,
382,
262,
18161,
512,
415,
2472,
27369,
851,
25,
578,
2683,
311,
11578,
13,
2876,
24884,
439,
264,
2764,
2683,
382,
14711,
6075,
512,
755,
11578,
21024,
11,
2472,
27369,
851,
11,
3146,
9872,
997,
262,
4304,
23389,
4881,
264,
2683,
311,
11578,
382,
262,
18161,
512,
415,
2472,
27369,
851,
25,
578,
2683,
311,
11578,
13,
2876,
24884,
439,
264,
2764,
2683,
627,
262,
3270,
262,
13082,
4962,
1292,
36320,
82,
7685,
82,
1,
1034,
320,
2235,
27369,
851,
11,
13082,
1462,
4889,
4813,
1350,
286,
3290,
28,
18565,
885,
33,
2938,
570,
631,
22551,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
264,
2683,
311,
11578,
382,
262,
18161,
512,
415,
2472,
27369,
851,
25,
578,
2683,
311,
11578,
13,
2876,
24884,
439,
264,
2764,
2683,
382,
14711,
6075,
512,
755,
11578,
21024,
11,
2472,
27369,
851,
11,
3146,
9872,
997,
262,
4304,
23389,
4881,
264,
2683,
311,
11578,
382,
262,
18161,
512,
415,
2472,
27369,
851,
25,
578,
2683,
311,
11578,
13,
2876,
24884,
439,
264,
2764,
2683,
627,
262,
3270,
262,
13082,
4962,
1292,
36320,
82,
7685,
82,
1,
1034,
320,
2235,
27369,
851,
11,
13082,
1462,
4889,
4813,
1350,
286,
3290,
28,
18565,
885,
33,
2938,
570,
631,
22551,
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
] |
EconForge/dolo | dolo/misc/decorators.py | deprecated | def deprecated(func):
'''This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.'''
import warnings
@functools.wraps(func)
def new_func(*args, **kwargs):
if is_python_3:
code = func.__code__
else:
code = func.func_code
warnings.warn_explicit(
"Call to deprecated function {}.".format(func.__name__),
category=Warning,
filename=code.co_filename,
lineno=code.co_firstlineno + 1
)
return func(*args, **kwargs)
return new_func | python | def deprecated(func):
'''This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.'''
import warnings
@functools.wraps(func)
def new_func(*args, **kwargs):
if is_python_3:
code = func.__code__
else:
code = func.func_code
warnings.warn_explicit(
"Call to deprecated function {}.".format(func.__name__),
category=Warning,
filename=code.co_filename,
lineno=code.co_firstlineno + 1
)
return func(*args, **kwargs)
return new_func | [
"def",
"deprecated",
"(",
"func",
")",
":",
"import",
"warnings",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"new_func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"is_python_3",
":",
"code",
"=",
"func",
".",
"__code__",
"else",
":",
"code",
"=",
"func",
".",
"func_code",
"warnings",
".",
"warn_explicit",
"(",
"\"Call to deprecated function {}.\"",
".",
"format",
"(",
"func",
".",
"__name__",
")",
",",
"category",
"=",
"Warning",
",",
"filename",
"=",
"code",
".",
"co_filename",
",",
"lineno",
"=",
"code",
".",
"co_firstlineno",
"+",
"1",
")",
"return",
"func",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"return",
"new_func"
] | This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used. | [
"This",
"is",
"a",
"decorator",
"which",
"can",
"be",
"used",
"to",
"mark",
"functions",
"as",
"deprecated",
".",
"It",
"will",
"result",
"in",
"a",
"warning",
"being",
"emitted",
"when",
"the",
"function",
"is",
"used",
"."
] | train | https://github.com/EconForge/dolo/blob/d91ddf148b009bf79852d9aec70f3a1877e0f79a/dolo/misc/decorators.py#L8-L28 | <|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 a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.
### Response:
def deprecated(func):
'''This is a decorator which can be used to mark functions
as deprecated. It will result in a warning being emitted
when the function is used.'''
import warnings
@functools.wraps(func)
def new_func(*args, **kwargs):
if is_python_3:
code = func.__code__
else:
code = func.func_code
warnings.warn_explicit(
"Call to deprecated function {}.".format(func.__name__),
category=Warning,
filename=code.co_filename,
lineno=code.co_firstlineno + 1
)
return func(*args, **kwargs)
return new_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,
2028,
374,
264,
51778,
902,
649,
387,
1511,
311,
1906,
5865,
198,
262,
439,
32690,
13,
1102,
690,
1121,
304,
264,
10163,
1694,
48042,
198,
262,
994,
279,
734,
374,
1511,
382,
14711,
6075,
512,
755,
32690,
19062,
997,
262,
11712,
2028,
374,
264,
51778,
902,
649,
387,
1511,
311,
1906,
5865,
198,
262,
439,
32690,
13,
1102,
690,
1121,
304,
264,
10163,
1694,
48042,
198,
262,
994,
279,
734,
374,
1511,
43584,
3961,
262,
1179,
19530,
271,
262,
571,
12158,
302,
6309,
82393,
2690,
19062,
340,
262,
711,
502,
9791,
4163,
2164,
11,
3146,
9872,
997,
286,
422,
374,
56969,
62,
18,
512,
310,
2082,
284,
2988,
4952,
1889,
12423,
286,
775,
512,
310,
2082,
284,
2988,
20014,
4229,
198,
286,
19530,
22123,
14548,
6154,
1021,
310,
330,
7368,
311,
32690,
734,
4792,
38011,
2293,
19062,
4952,
609,
565,
1350,
310,
5699,
28,
12358,
345,
310,
3986,
28,
1889,
6973,
13626,
345,
310,
86195,
28,
1889,
6973,
13275,
81083,
489,
220,
16,
198,
286,
1763,
286,
471,
2988,
4163,
2164,
11,
3146,
9872,
340,
262,
471,
502,
9791,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
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,
374,
264,
51778,
902,
649,
387,
1511,
311,
1906,
5865,
198,
262,
439,
32690,
13,
1102,
690,
1121,
304,
264,
10163,
1694,
48042,
198,
262,
994,
279,
734,
374,
1511,
382,
14711,
6075,
512,
755,
32690,
19062,
997,
262,
11712,
2028,
374,
264,
51778,
902,
649,
387,
1511,
311,
1906,
5865,
198,
262,
439,
32690,
13,
1102,
690,
1121,
304,
264,
10163,
1694,
48042,
198,
262,
994,
279,
734,
374,
1511,
43584,
3961,
262,
1179,
19530,
271,
262,
571,
12158,
302,
6309,
82393,
2690,
19062,
340,
262,
711,
502,
9791,
4163,
2164,
11,
3146,
9872,
997,
286,
422,
374,
56969,
62,
18,
512,
310,
2082,
284,
2988,
4952,
1889,
12423,
286,
775,
512,
310,
2082,
284,
2988,
20014,
4229,
198,
286,
19530,
22123,
14548,
6154,
1021,
310,
330,
7368,
311,
32690,
734,
4792,
38011,
2293,
19062,
4952,
609,
565,
1350,
310,
5699,
28,
12358,
345,
310,
3986,
28,
1889,
6973,
13626,
345,
310,
86195,
28,
1889,
6973,
13275,
81083,
489,
220,
16,
198,
286,
1763,
286,
471,
2988,
4163,
2164,
11,
3146,
9872,
340,
262,
471,
502,
9791,
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
] |
python-rope/rope | rope/base/prefs.py | Prefs.set | def set(self, key, value):
"""Set the value of `key` preference to `value`."""
if key in self.callbacks:
self.callbacks[key](value)
else:
self.prefs[key] = value | python | def set(self, key, value):
"""Set the value of `key` preference to `value`."""
if key in self.callbacks:
self.callbacks[key](value)
else:
self.prefs[key] = value | [
"def",
"set",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"if",
"key",
"in",
"self",
".",
"callbacks",
":",
"self",
".",
"callbacks",
"[",
"key",
"]",
"(",
"value",
")",
"else",
":",
"self",
".",
"prefs",
"[",
"key",
"]",
"=",
"value"
] | Set the value of `key` preference to `value`. | [
"Set",
"the",
"value",
"of",
"key",
"preference",
"to",
"value",
"."
] | train | https://github.com/python-rope/rope/blob/1c9f9cd5964b099a99a9111e998f0dc728860688/rope/base/prefs.py#L7-L12 | <|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 value of `key` preference to `value`.
### Response:
def set(self, key, value):
"""Set the value of `key` preference to `value`."""
if key in self.callbacks:
self.callbacks[key](value)
else:
self.prefs[key] = 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,
1681,
279,
907,
315,
1595,
798,
63,
22698,
311,
1595,
970,
63438,
14711,
6075,
512,
755,
743,
1214,
11,
1401,
11,
907,
997,
286,
4304,
1681,
279,
907,
315,
1595,
798,
63,
22698,
311,
1595,
970,
63,
14781,
286,
422,
1401,
304,
659,
72134,
512,
310,
659,
72134,
8320,
9725,
970,
340,
286,
775,
512,
310,
659,
558,
16541,
8320,
60,
284,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,
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,
6498,
382,
14711,
5546,
512,
1681,
279,
907,
315,
1595,
798,
63,
22698,
311,
1595,
970,
63438,
14711,
6075,
512,
755,
743,
1214,
11,
1401,
11,
907,
997,
286,
4304,
1681,
279,
907,
315,
1595,
798,
63,
22698,
311,
1595,
970,
63,
14781,
286,
422,
1401,
304,
659,
72134,
512,
310,
659,
72134,
8320,
9725,
970,
340,
286,
775,
512,
310,
659,
558,
16541,
8320,
60,
284,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
mwhooker/jones | jones/jones.py | Jones.get_config | def get_config(self, hostname):
"""
Returns a configuration for hostname.
"""
version, config = self._get(
self.associations.get(hostname)
)
return config | python | def get_config(self, hostname):
"""
Returns a configuration for hostname.
"""
version, config = self._get(
self.associations.get(hostname)
)
return config | [
"def",
"get_config",
"(",
"self",
",",
"hostname",
")",
":",
"version",
",",
"config",
"=",
"self",
".",
"_get",
"(",
"self",
".",
"associations",
".",
"get",
"(",
"hostname",
")",
")",
"return",
"config"
] | Returns a configuration for hostname. | [
"Returns",
"a",
"configuration",
"for",
"hostname",
"."
] | train | https://github.com/mwhooker/jones/blob/121e89572ca063f456b8e94cbb8cbee26c307a8f/jones/jones.py#L183-L191 | <|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 configuration for hostname.
### Response:
def get_config(self, hostname):
"""
Returns a configuration for hostname.
"""
version, config = self._get(
self.associations.get(hostname)
)
return config
<|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,
6683,
369,
29215,
382,
14711,
6075,
512,
755,
636,
5445,
1214,
11,
29215,
997,
286,
3270,
286,
5295,
264,
6683,
369,
29215,
382,
286,
3270,
286,
2373,
11,
2242,
284,
659,
1462,
456,
1021,
310,
659,
13,
25304,
811,
673,
86986,
340,
286,
1763,
286,
471,
2242,
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,
128009,
128009,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
6683,
369,
29215,
382,
14711,
6075,
512,
755,
636,
5445,
1214,
11,
29215,
997,
286,
3270,
286,
5295,
264,
6683,
369,
29215,
382,
286,
3270,
286,
2373,
11,
2242,
284,
659,
1462,
456,
1021,
310,
659,
13,
25304,
811,
673,
86986,
340,
286,
1763,
286,
471,
2242,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
pyviz/holoviews | holoviews/core/boundingregion.py | BoundingBox.contains_exclusive | def contains_exclusive(self, x, y):
"""
Return True if the given point is contained within the
bounding box, where the bottom and right boundaries are
considered exclusive.
"""
left, bottom, right, top = self._aarect.lbrt()
return (left <= x < right) and (bottom < y <= top) | python | def contains_exclusive(self, x, y):
"""
Return True if the given point is contained within the
bounding box, where the bottom and right boundaries are
considered exclusive.
"""
left, bottom, right, top = self._aarect.lbrt()
return (left <= x < right) and (bottom < y <= top) | [
"def",
"contains_exclusive",
"(",
"self",
",",
"x",
",",
"y",
")",
":",
"left",
",",
"bottom",
",",
"right",
",",
"top",
"=",
"self",
".",
"_aarect",
".",
"lbrt",
"(",
")",
"return",
"(",
"left",
"<=",
"x",
"<",
"right",
")",
"and",
"(",
"bottom",
"<",
"y",
"<=",
"top",
")"
] | Return True if the given point is contained within the
bounding box, where the bottom and right boundaries are
considered exclusive. | [
"Return",
"True",
"if",
"the",
"given",
"point",
"is",
"contained",
"within",
"the",
"bounding",
"box",
"where",
"the",
"bottom",
"and",
"right",
"boundaries",
"are",
"considered",
"exclusive",
"."
] | train | https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/boundingregion.py#L157-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:
Return True if the given point is contained within the
bounding box, where the bottom and right boundaries are
considered exclusive.
### Response:
def contains_exclusive(self, x, y):
"""
Return True if the given point is contained within the
bounding box, where the bottom and right boundaries are
considered exclusive.
"""
left, bottom, right, top = self._aarect.lbrt()
return (left <= x < right) and (bottom < y <= top)
<|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,
3082,
422,
279,
2728,
1486,
374,
13282,
2949,
279,
198,
286,
31718,
3830,
11,
1405,
279,
5740,
323,
1314,
23546,
527,
198,
286,
6646,
14079,
382,
14711,
6075,
512,
755,
5727,
2769,
8500,
1214,
11,
865,
11,
379,
997,
286,
3270,
286,
3494,
3082,
422,
279,
2728,
1486,
374,
13282,
2949,
279,
198,
286,
31718,
3830,
11,
1405,
279,
5740,
323,
1314,
23546,
527,
198,
286,
6646,
14079,
627,
286,
3270,
286,
2163,
11,
5740,
11,
1314,
11,
1948,
284,
659,
1462,
64,
548,
302,
929,
1347,
83,
746,
286,
471,
320,
2414,
2717,
865,
366,
1314,
8,
323,
320,
15205,
366,
379,
2717,
1948,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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
] | [
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,
3082,
422,
279,
2728,
1486,
374,
13282,
2949,
279,
198,
286,
31718,
3830,
11,
1405,
279,
5740,
323,
1314,
23546,
527,
198,
286,
6646,
14079,
382,
14711,
6075,
512,
755,
5727,
2769,
8500,
1214,
11,
865,
11,
379,
997,
286,
3270,
286,
3494,
3082,
422,
279,
2728,
1486,
374,
13282,
2949,
279,
198,
286,
31718,
3830,
11,
1405,
279,
5740,
323,
1314,
23546,
527,
198,
286,
6646,
14079,
627,
286,
3270,
286,
2163,
11,
5740,
11,
1314,
11,
1948,
284,
659,
1462,
64,
548,
302,
929,
1347,
83,
746,
286,
471,
320,
2414,
2717,
865,
366,
1314,
8,
323,
320,
15205,
366,
379,
2717,
1948,
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
] |
NoneGG/aredis | aredis/commands/extra.py | ExtraCommandMixin.cache | def cache(self, name, cache_class=Cache,
identity_generator_class=IdentityGenerator,
compressor_class=Compressor,
serializer_class=Serializer, *args, **kwargs):
"""
Return a cache object using default identity generator,
serializer and compressor.
``name`` is used to identify the series of your cache
``cache_class`` Cache is for normal use and HerdCache
is used in case of Thundering Herd Problem
``identity_generator_class`` is the class used to generate
the real unique key in cache, can be overwritten to
meet your special needs. It should provide `generate` API
``compressor_class`` is the class used to compress cache in redis,
can be overwritten with API `compress` and `decompress` retained.
``serializer_class`` is the class used to serialize
content before compress, can be overwritten with API
`serialize` and `deserialize` retained.
"""
return cache_class(self, app=name,
identity_generator_class=identity_generator_class,
compressor_class=compressor_class,
serializer_class=serializer_class,
*args, **kwargs) | python | def cache(self, name, cache_class=Cache,
identity_generator_class=IdentityGenerator,
compressor_class=Compressor,
serializer_class=Serializer, *args, **kwargs):
"""
Return a cache object using default identity generator,
serializer and compressor.
``name`` is used to identify the series of your cache
``cache_class`` Cache is for normal use and HerdCache
is used in case of Thundering Herd Problem
``identity_generator_class`` is the class used to generate
the real unique key in cache, can be overwritten to
meet your special needs. It should provide `generate` API
``compressor_class`` is the class used to compress cache in redis,
can be overwritten with API `compress` and `decompress` retained.
``serializer_class`` is the class used to serialize
content before compress, can be overwritten with API
`serialize` and `deserialize` retained.
"""
return cache_class(self, app=name,
identity_generator_class=identity_generator_class,
compressor_class=compressor_class,
serializer_class=serializer_class,
*args, **kwargs) | [
"def",
"cache",
"(",
"self",
",",
"name",
",",
"cache_class",
"=",
"Cache",
",",
"identity_generator_class",
"=",
"IdentityGenerator",
",",
"compressor_class",
"=",
"Compressor",
",",
"serializer_class",
"=",
"Serializer",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"cache_class",
"(",
"self",
",",
"app",
"=",
"name",
",",
"identity_generator_class",
"=",
"identity_generator_class",
",",
"compressor_class",
"=",
"compressor_class",
",",
"serializer_class",
"=",
"serializer_class",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Return a cache object using default identity generator,
serializer and compressor.
``name`` is used to identify the series of your cache
``cache_class`` Cache is for normal use and HerdCache
is used in case of Thundering Herd Problem
``identity_generator_class`` is the class used to generate
the real unique key in cache, can be overwritten to
meet your special needs. It should provide `generate` API
``compressor_class`` is the class used to compress cache in redis,
can be overwritten with API `compress` and `decompress` retained.
``serializer_class`` is the class used to serialize
content before compress, can be overwritten with API
`serialize` and `deserialize` retained. | [
"Return",
"a",
"cache",
"object",
"using",
"default",
"identity",
"generator",
"serializer",
"and",
"compressor",
"."
] | train | https://github.com/NoneGG/aredis/blob/204caad740ac13e5760d46444a2ba7632982a046/aredis/commands/extra.py#L11-L35 | <|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 a cache object using default identity generator,
serializer and compressor.
``name`` is used to identify the series of your cache
``cache_class`` Cache is for normal use and HerdCache
is used in case of Thundering Herd Problem
``identity_generator_class`` is the class used to generate
the real unique key in cache, can be overwritten to
meet your special needs. It should provide `generate` API
``compressor_class`` is the class used to compress cache in redis,
can be overwritten with API `compress` and `decompress` retained.
``serializer_class`` is the class used to serialize
content before compress, can be overwritten with API
`serialize` and `deserialize` retained.
### Response:
def cache(self, name, cache_class=Cache,
identity_generator_class=IdentityGenerator,
compressor_class=Compressor,
serializer_class=Serializer, *args, **kwargs):
"""
Return a cache object using default identity generator,
serializer and compressor.
``name`` is used to identify the series of your cache
``cache_class`` Cache is for normal use and HerdCache
is used in case of Thundering Herd Problem
``identity_generator_class`` is the class used to generate
the real unique key in cache, can be overwritten to
meet your special needs. It should provide `generate` API
``compressor_class`` is the class used to compress cache in redis,
can be overwritten with API `compress` and `decompress` retained.
``serializer_class`` is the class used to serialize
content before compress, can be overwritten with API
`serialize` and `deserialize` retained.
"""
return cache_class(self, app=name,
identity_generator_class=identity_generator_class,
compressor_class=compressor_class,
serializer_class=serializer_class,
*args, **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,
5715,
264,
6636,
1665,
1701,
1670,
9764,
14143,
345,
286,
22508,
323,
59977,
382,
286,
10103,
609,
14196,
374,
1511,
311,
10765,
279,
4101,
315,
701,
6636,
198,
286,
10103,
9544,
4895,
14196,
20044,
374,
369,
4725,
1005,
323,
6385,
67,
8397,
198,
286,
374,
1511,
304,
1162,
315,
27789,
287,
6385,
67,
22854,
198,
286,
10103,
17341,
26898,
4895,
14196,
374,
279,
538,
1511,
311,
7068,
198,
286,
279,
1972,
5016,
1401,
304,
6636,
11,
649,
387,
60273,
311,
198,
286,
3449,
701,
3361,
3966,
13,
1102,
1288,
3493,
1595,
19927,
63,
5446,
198,
286,
10103,
39460,
269,
4895,
14196,
374,
279,
538,
1511,
311,
25633,
6636,
304,
21540,
345,
286,
649,
387,
60273,
449,
5446,
1595,
39460,
63,
323,
1595,
451,
39460,
63,
35363,
627,
286,
10103,
53818,
4895,
14196,
374,
279,
538,
1511,
311,
25217,
198,
286,
2262,
1603,
25633,
11,
649,
387,
60273,
449,
5446,
198,
286,
1595,
25140,
63,
323,
1595,
67877,
63,
35363,
382,
14711,
6075,
512,
755,
6636,
1214,
11,
836,
11,
6636,
4895,
28,
8397,
345,
1078,
9764,
26898,
4895,
28,
19069,
12846,
345,
1078,
59977,
4895,
28,
1110,
57320,
345,
1078,
22508,
4895,
28,
14233,
11,
353,
2164,
11,
3146,
9872,
997,
286,
3270,
286,
3494,
264,
6636,
1665,
1701,
1670,
9764,
14143,
345,
286,
22508,
323,
59977,
382,
286,
10103,
609,
14196,
374,
1511,
311,
10765,
279,
4101,
315,
701,
6636,
198,
286,
10103,
9544,
4895,
14196,
20044,
374,
369,
4725,
1005,
323,
6385,
67,
8397,
198,
286,
374,
1511,
304,
1162,
315,
27789,
287,
6385,
67,
22854,
198,
286,
10103,
17341,
26898,
4895,
14196,
374,
279,
538,
1511,
311,
7068,
198,
286,
279,
1972,
5016,
1401,
304,
6636,
11,
649,
387,
60273,
311,
198,
286,
3449,
701,
3361,
3966,
13,
1102,
1288,
3493,
1595,
19927,
63,
5446,
198,
286,
10103,
39460,
269,
4895,
14196,
374,
279,
538,
1511,
311,
25633,
6636,
304,
21540,
345,
286,
649,
387,
60273,
449,
5446,
1595,
39460,
63,
323,
1595,
451,
39460,
63,
35363,
627,
286,
10103,
53818,
4895,
14196,
374,
279,
538,
1511,
311,
25217,
198,
286,
2262,
1603,
25633,
11,
649,
387,
60273,
449,
5446,
198,
286,
1595,
25140,
63,
323,
1595,
67877,
63,
35363,
627,
286,
3270,
286,
471,
6636,
4895,
1214,
11,
917,
40341,
345,
6096,
9764,
26898,
4895,
28,
17341,
26898,
4895,
345,
6096,
59977,
4895,
28,
39460,
269,
4895,
345,
6096,
22508,
4895,
28,
53818,
4895,
345,
6096,
353,
2164,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
264,
6636,
1665,
1701,
1670,
9764,
14143,
345,
286,
22508,
323,
59977,
382,
286,
10103,
609,
14196,
374,
1511,
311,
10765,
279,
4101,
315,
701,
6636,
198,
286,
10103,
9544,
4895,
14196,
20044,
374,
369,
4725,
1005,
323,
6385,
67,
8397,
198,
286,
374,
1511,
304,
1162,
315,
27789,
287,
6385,
67,
22854,
198,
286,
10103,
17341,
26898,
4895,
14196,
374,
279,
538,
1511,
311,
7068,
198,
286,
279,
1972,
5016,
1401,
304,
6636,
11,
649,
387,
60273,
311,
198,
286,
3449,
701,
3361,
3966,
13,
1102,
1288,
3493,
1595,
19927,
63,
5446,
198,
286,
10103,
39460,
269,
4895,
14196,
374,
279,
538,
1511,
311,
25633,
6636,
304,
21540,
345,
286,
649,
387,
60273,
449,
5446,
1595,
39460,
63,
323,
1595,
451,
39460,
63,
35363,
627,
286,
10103,
53818,
4895,
14196,
374,
279,
538,
1511,
311,
25217,
198,
286,
2262,
1603,
25633,
11,
649,
387,
60273,
449,
5446,
198,
286,
1595,
25140,
63,
323,
1595,
67877,
63,
35363,
382,
14711,
6075,
512,
755,
6636,
1214,
11,
836,
11,
6636,
4895,
28,
8397,
345,
1078,
9764,
26898,
4895,
28,
19069,
12846,
345,
1078,
59977,
4895,
28,
1110,
57320,
345,
1078,
22508,
4895,
28,
14233,
11,
353,
2164,
11,
3146,
9872,
997,
286,
3270,
286,
3494,
264,
6636,
1665,
1701,
1670,
9764,
14143,
345,
286,
22508,
323,
59977,
382,
286,
10103,
609,
14196,
374,
1511,
311,
10765,
279,
4101,
315,
701,
6636,
198,
286,
10103,
9544,
4895,
14196,
20044,
374,
369,
4725,
1005,
323,
6385,
67,
8397,
198,
286,
374,
1511,
304,
1162,
315,
27789,
287,
6385,
67,
22854,
198,
286,
10103,
17341,
26898,
4895,
14196,
374,
279,
538,
1511,
311,
7068,
198,
286,
279,
1972,
5016,
1401,
304,
6636,
11,
649,
387,
60273,
311,
198,
286,
3449,
701,
3361,
3966,
13,
1102,
1288,
3493,
1595,
19927,
63,
5446,
198,
286,
10103,
39460,
269,
4895,
14196,
374,
279,
538,
1511,
311,
25633,
6636,
304,
21540,
345,
286,
649,
387,
60273,
449,
5446,
1595,
39460,
63,
323,
1595,
451,
39460,
63,
35363,
627,
286,
10103,
53818,
4895,
14196,
374,
279,
538,
1511,
311,
25217,
198,
286,
2262,
1603,
25633,
11,
649,
387,
60273,
449,
5446,
198,
286,
1595,
25140,
63,
323,
1595,
67877,
63,
35363,
627,
286,
3270,
286,
471,
6636,
4895,
1214,
11,
917,
40341,
345,
6096,
9764,
26898,
4895,
28,
17341,
26898,
4895,
345,
6096,
59977,
4895,
28,
39460,
269,
4895,
345,
6096,
22508,
4895,
28,
53818,
4895,
345,
6096,
353,
2164,
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
] |
quantopian/zipline | zipline/lib/normalize.py | naive_grouped_rowwise_apply | def naive_grouped_rowwise_apply(data,
group_labels,
func,
func_args=(),
out=None):
"""
Simple implementation of grouped row-wise function application.
Parameters
----------
data : ndarray[ndim=2]
Input array over which to apply a grouped function.
group_labels : ndarray[ndim=2, dtype=int64]
Labels to use to bucket inputs from array.
Should be the same shape as array.
func : function[ndarray[ndim=1]] -> function[ndarray[ndim=1]]
Function to apply to pieces of each row in array.
func_args : tuple
Additional positional arguments to provide to each row in array.
out : ndarray, optional
Array into which to write output. If not supplied, a new array of the
same shape as ``data`` is allocated and returned.
Examples
--------
>>> data = np.array([[1., 2., 3.],
... [2., 3., 4.],
... [5., 6., 7.]])
>>> labels = np.array([[0, 0, 1],
... [0, 1, 0],
... [1, 0, 2]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row - row.min())
array([[ 0., 1., 0.],
[ 0., 0., 2.],
[ 0., 0., 0.]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row / row.sum())
array([[ 0.33333333, 0.66666667, 1. ],
[ 0.33333333, 1. , 0.66666667],
[ 1. , 1. , 1. ]])
"""
if out is None:
out = np.empty_like(data)
for (row, label_row, out_row) in zip(data, group_labels, out):
for label in np.unique(label_row):
locs = (label_row == label)
out_row[locs] = func(row[locs], *func_args)
return out | python | def naive_grouped_rowwise_apply(data,
group_labels,
func,
func_args=(),
out=None):
"""
Simple implementation of grouped row-wise function application.
Parameters
----------
data : ndarray[ndim=2]
Input array over which to apply a grouped function.
group_labels : ndarray[ndim=2, dtype=int64]
Labels to use to bucket inputs from array.
Should be the same shape as array.
func : function[ndarray[ndim=1]] -> function[ndarray[ndim=1]]
Function to apply to pieces of each row in array.
func_args : tuple
Additional positional arguments to provide to each row in array.
out : ndarray, optional
Array into which to write output. If not supplied, a new array of the
same shape as ``data`` is allocated and returned.
Examples
--------
>>> data = np.array([[1., 2., 3.],
... [2., 3., 4.],
... [5., 6., 7.]])
>>> labels = np.array([[0, 0, 1],
... [0, 1, 0],
... [1, 0, 2]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row - row.min())
array([[ 0., 1., 0.],
[ 0., 0., 2.],
[ 0., 0., 0.]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row / row.sum())
array([[ 0.33333333, 0.66666667, 1. ],
[ 0.33333333, 1. , 0.66666667],
[ 1. , 1. , 1. ]])
"""
if out is None:
out = np.empty_like(data)
for (row, label_row, out_row) in zip(data, group_labels, out):
for label in np.unique(label_row):
locs = (label_row == label)
out_row[locs] = func(row[locs], *func_args)
return out | [
"def",
"naive_grouped_rowwise_apply",
"(",
"data",
",",
"group_labels",
",",
"func",
",",
"func_args",
"=",
"(",
")",
",",
"out",
"=",
"None",
")",
":",
"if",
"out",
"is",
"None",
":",
"out",
"=",
"np",
".",
"empty_like",
"(",
"data",
")",
"for",
"(",
"row",
",",
"label_row",
",",
"out_row",
")",
"in",
"zip",
"(",
"data",
",",
"group_labels",
",",
"out",
")",
":",
"for",
"label",
"in",
"np",
".",
"unique",
"(",
"label_row",
")",
":",
"locs",
"=",
"(",
"label_row",
"==",
"label",
")",
"out_row",
"[",
"locs",
"]",
"=",
"func",
"(",
"row",
"[",
"locs",
"]",
",",
"*",
"func_args",
")",
"return",
"out"
] | Simple implementation of grouped row-wise function application.
Parameters
----------
data : ndarray[ndim=2]
Input array over which to apply a grouped function.
group_labels : ndarray[ndim=2, dtype=int64]
Labels to use to bucket inputs from array.
Should be the same shape as array.
func : function[ndarray[ndim=1]] -> function[ndarray[ndim=1]]
Function to apply to pieces of each row in array.
func_args : tuple
Additional positional arguments to provide to each row in array.
out : ndarray, optional
Array into which to write output. If not supplied, a new array of the
same shape as ``data`` is allocated and returned.
Examples
--------
>>> data = np.array([[1., 2., 3.],
... [2., 3., 4.],
... [5., 6., 7.]])
>>> labels = np.array([[0, 0, 1],
... [0, 1, 0],
... [1, 0, 2]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row - row.min())
array([[ 0., 1., 0.],
[ 0., 0., 2.],
[ 0., 0., 0.]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row / row.sum())
array([[ 0.33333333, 0.66666667, 1. ],
[ 0.33333333, 1. , 0.66666667],
[ 1. , 1. , 1. ]]) | [
"Simple",
"implementation",
"of",
"grouped",
"row",
"-",
"wise",
"function",
"application",
"."
] | train | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/lib/normalize.py#L4-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:
Simple implementation of grouped row-wise function application.
Parameters
----------
data : ndarray[ndim=2]
Input array over which to apply a grouped function.
group_labels : ndarray[ndim=2, dtype=int64]
Labels to use to bucket inputs from array.
Should be the same shape as array.
func : function[ndarray[ndim=1]] -> function[ndarray[ndim=1]]
Function to apply to pieces of each row in array.
func_args : tuple
Additional positional arguments to provide to each row in array.
out : ndarray, optional
Array into which to write output. If not supplied, a new array of the
same shape as ``data`` is allocated and returned.
Examples
--------
>>> data = np.array([[1., 2., 3.],
... [2., 3., 4.],
... [5., 6., 7.]])
>>> labels = np.array([[0, 0, 1],
... [0, 1, 0],
... [1, 0, 2]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row - row.min())
array([[ 0., 1., 0.],
[ 0., 0., 2.],
[ 0., 0., 0.]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row / row.sum())
array([[ 0.33333333, 0.66666667, 1. ],
[ 0.33333333, 1. , 0.66666667],
[ 1. , 1. , 1. ]])
### Response:
def naive_grouped_rowwise_apply(data,
group_labels,
func,
func_args=(),
out=None):
"""
Simple implementation of grouped row-wise function application.
Parameters
----------
data : ndarray[ndim=2]
Input array over which to apply a grouped function.
group_labels : ndarray[ndim=2, dtype=int64]
Labels to use to bucket inputs from array.
Should be the same shape as array.
func : function[ndarray[ndim=1]] -> function[ndarray[ndim=1]]
Function to apply to pieces of each row in array.
func_args : tuple
Additional positional arguments to provide to each row in array.
out : ndarray, optional
Array into which to write output. If not supplied, a new array of the
same shape as ``data`` is allocated and returned.
Examples
--------
>>> data = np.array([[1., 2., 3.],
... [2., 3., 4.],
... [5., 6., 7.]])
>>> labels = np.array([[0, 0, 1],
... [0, 1, 0],
... [1, 0, 2]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row - row.min())
array([[ 0., 1., 0.],
[ 0., 0., 2.],
[ 0., 0., 0.]])
>>> naive_grouped_rowwise_apply(data, labels, lambda row: row / row.sum())
array([[ 0.33333333, 0.66666667, 1. ],
[ 0.33333333, 1. , 0.66666667],
[ 1. , 1. , 1. ]])
"""
if out is None:
out = np.empty_like(data)
for (row, label_row, out_row) in zip(data, group_labels, out):
for label in np.unique(label_row):
locs = (label_row == label)
out_row[locs] = func(row[locs], *func_args)
return out
<|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,
16778,
8292,
315,
41141,
2872,
45539,
734,
3851,
382,
262,
13831,
198,
262,
31423,
262,
828,
551,
67983,
58,
303,
318,
28,
17,
933,
286,
5688,
1358,
927,
902,
311,
3881,
264,
41141,
734,
627,
262,
1912,
14889,
551,
67983,
58,
303,
318,
28,
17,
11,
13534,
16972,
1227,
933,
286,
62096,
311,
1005,
311,
15994,
11374,
505,
1358,
627,
286,
12540,
387,
279,
1890,
6211,
439,
1358,
627,
262,
2988,
551,
734,
58,
303,
1686,
58,
303,
318,
28,
16,
5163,
1492,
734,
58,
303,
1686,
58,
303,
318,
28,
16,
14623,
286,
5830,
311,
3881,
311,
9863,
315,
1855,
2872,
304,
1358,
627,
262,
2988,
8550,
551,
14743,
198,
286,
24086,
68647,
6105,
311,
3493,
311,
1855,
2872,
304,
1358,
627,
262,
704,
551,
67983,
11,
10309,
198,
286,
2982,
1139,
902,
311,
3350,
2612,
13,
220,
1442,
539,
17665,
11,
264,
502,
1358,
315,
279,
198,
286,
1890,
6211,
439,
10103,
695,
14196,
374,
20816,
323,
6052,
382,
262,
26379,
198,
262,
90238,
262,
12382,
828,
284,
2660,
7382,
28218,
16,
2637,
220,
17,
2637,
220,
18,
13,
1282,
262,
2564,
1733,
510,
17,
2637,
220,
18,
2637,
220,
19,
13,
1282,
262,
2564,
1733,
510,
20,
2637,
220,
21,
2637,
220,
22,
25750,
2608,
262,
12382,
9382,
284,
2660,
7382,
28218,
15,
11,
220,
15,
11,
220,
16,
1282,
262,
2564,
504,
510,
15,
11,
220,
16,
11,
220,
15,
1282,
262,
2564,
504,
510,
16,
11,
220,
15,
11,
220,
17,
27829,
262,
12382,
50765,
6422,
291,
8698,
4583,
37651,
2657,
11,
9382,
11,
12741,
2872,
25,
2872,
482,
2872,
4456,
2455,
262,
1358,
28218,
220,
15,
2637,
220,
220,
16,
2637,
220,
220,
15,
13,
1282,
1881,
510,
220,
15,
2637,
220,
220,
15,
2637,
220,
220,
17,
13,
1282,
1881,
510,
220,
15,
2637,
220,
220,
15,
2637,
220,
220,
15,
25750,
2608,
262,
12382,
50765,
6422,
291,
8698,
4583,
37651,
2657,
11,
9382,
11,
12741,
2872,
25,
2872,
611,
2872,
13485,
2455,
262,
1358,
28218,
220,
15,
13,
8765,
8765,
1644,
11,
220,
220,
15,
13,
10943,
10943,
3080,
11,
220,
220,
16,
13,
286,
3291,
1881,
510,
220,
15,
13,
8765,
8765,
1644,
11,
220,
220,
16,
13,
286,
1174,
220,
220,
15,
13,
10943,
10943,
3080,
1282,
1881,
510,
220,
16,
13,
286,
1174,
220,
220,
16,
13,
286,
1174,
220,
220,
16,
13,
286,
2331,
9801,
14711,
6075,
512,
755,
50765,
6422,
291,
8698,
4583,
37651,
2657,
345,
1408,
1912,
14889,
345,
1408,
2988,
345,
1408,
2988,
8550,
28,
3227,
1408,
704,
5980,
997,
262,
3270,
262,
9170,
8292,
315,
41141,
2872,
45539,
734,
3851,
382,
262,
13831,
198,
262,
31423,
262,
828,
551,
67983,
58,
303,
318,
28,
17,
933,
286,
5688,
1358,
927,
902,
311,
3881,
264,
41141,
734,
627,
262,
1912,
14889,
551,
67983,
58,
303,
318,
28,
17
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
16778,
8292,
315,
41141,
2872,
45539,
734,
3851,
382,
262,
13831,
198,
262,
31423,
262,
828,
551,
67983,
58,
303,
318,
28,
17,
933,
286,
5688,
1358,
927,
902,
311,
3881,
264,
41141,
734,
627,
262,
1912,
14889,
551,
67983,
58,
303,
318,
28,
17,
11,
13534,
16972,
1227,
933,
286,
62096,
311,
1005,
311,
15994,
11374,
505,
1358,
627,
286,
12540,
387,
279,
1890,
6211,
439,
1358,
627,
262,
2988,
551,
734,
58,
303,
1686,
58,
303,
318,
28,
16,
5163,
1492,
734,
58,
303,
1686,
58,
303,
318,
28,
16,
14623,
286,
5830,
311,
3881,
311,
9863,
315,
1855,
2872,
304,
1358,
627,
262,
2988,
8550,
551,
14743,
198,
286,
24086,
68647,
6105,
311,
3493,
311,
1855,
2872,
304,
1358,
627,
262,
704,
551,
67983,
11,
10309,
198,
286,
2982,
1139,
902,
311,
3350,
2612,
13,
220,
1442,
539,
17665,
11,
264,
502,
1358,
315,
279,
198,
286,
1890,
6211,
439,
10103,
695,
14196,
374,
20816,
323,
6052,
382,
262,
26379,
198,
262,
90238,
262,
12382,
828,
284,
2660,
7382,
28218,
16,
2637,
220,
17,
2637,
220,
18,
13,
1282,
262,
2564,
1733,
510,
17,
2637,
220,
18,
2637,
220,
19,
13,
1282,
262,
2564,
1733,
510,
20,
2637,
220,
21,
2637,
220,
22,
25750,
2608,
262,
12382,
9382,
284,
2660,
7382,
28218,
15,
11,
220,
15,
11,
220,
16,
1282,
262,
2564,
504,
510,
15,
11,
220,
16,
11,
220,
15,
1282,
262,
2564,
504,
510,
16,
11,
220,
15,
11,
220,
17,
27829,
262,
12382,
50765,
6422,
291,
8698,
4583,
37651,
2657,
11,
9382,
11,
12741,
2872,
25,
2872,
482,
2872,
4456,
2455,
262,
1358,
28218,
220,
15,
2637,
220,
220,
16,
2637,
220,
220,
15,
13,
1282,
1881,
510,
220,
15,
2637,
220,
220,
15,
2637,
220,
220,
17,
13,
1282,
1881,
510,
220,
15,
2637,
220,
220,
15,
2637,
220,
220,
15,
25750,
2608,
262,
12382,
50765,
6422,
291,
8698,
4583,
37651,
2657,
11,
9382,
11,
12741,
2872,
25,
2872,
611,
2872,
13485,
2455,
262,
1358,
28218,
220,
15,
13,
8765,
8765,
1644,
11,
220,
220,
15,
13,
10943,
10943,
3080,
11,
220,
220,
16,
13,
286,
3291,
1881,
510,
220,
15,
13,
8765,
8765,
1644,
11,
220,
220,
16,
13,
286,
1174,
220,
220,
15,
13,
10943,
10943,
3080,
1282,
1881,
510,
220,
16,
13,
286,
1174,
220,
220,
16,
13,
286,
1174,
220,
220,
16,
13,
286,
2331,
9801,
14711,
6075,
512,
755,
50765,
6422,
291,
8698,
4583,
37651,
2657,
345,
1408,
1912,
14889,
345,
1408,
2988,
345,
1408,
2988,
8550,
28,
3227,
1408,
704,
5980,
997,
262,
3270,
262,
9170,
8292,
315,
41141,
2872,
45539,
734,
3851,
382,
262,
13831,
198,
262,
31423,
262,
828,
551,
67983,
58,
303,
318,
28,
17,
933,
286,
5688,
1358,
927,
902,
311,
3881,
264,
41141,
734,
627,
262,
1912,
14889,
551,
67983,
58,
303,
318,
28,
17
] |
PX4/pyulog | pyulog/core.py | ULog.get_version_info | def get_version_info(self, key_name='ver_sw_release'):
"""
get the (major, minor, patch, type) version information as tuple.
Returns None if not found
definition of type is:
>= 0: development
>= 64: alpha version
>= 128: beta version
>= 192: RC version
== 255: release version
"""
if key_name in self._msg_info_dict:
val = self._msg_info_dict[key_name]
return ((val >> 24) & 0xff, (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff)
return None | python | def get_version_info(self, key_name='ver_sw_release'):
"""
get the (major, minor, patch, type) version information as tuple.
Returns None if not found
definition of type is:
>= 0: development
>= 64: alpha version
>= 128: beta version
>= 192: RC version
== 255: release version
"""
if key_name in self._msg_info_dict:
val = self._msg_info_dict[key_name]
return ((val >> 24) & 0xff, (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff)
return None | [
"def",
"get_version_info",
"(",
"self",
",",
"key_name",
"=",
"'ver_sw_release'",
")",
":",
"if",
"key_name",
"in",
"self",
".",
"_msg_info_dict",
":",
"val",
"=",
"self",
".",
"_msg_info_dict",
"[",
"key_name",
"]",
"return",
"(",
"(",
"val",
">>",
"24",
")",
"&",
"0xff",
",",
"(",
"val",
">>",
"16",
")",
"&",
"0xff",
",",
"(",
"val",
">>",
"8",
")",
"&",
"0xff",
",",
"val",
"&",
"0xff",
")",
"return",
"None"
] | get the (major, minor, patch, type) version information as tuple.
Returns None if not found
definition of type is:
>= 0: development
>= 64: alpha version
>= 128: beta version
>= 192: RC version
== 255: release version | [
"get",
"the",
"(",
"major",
"minor",
"patch",
"type",
")",
"version",
"information",
"as",
"tuple",
".",
"Returns",
"None",
"if",
"not",
"found",
"definition",
"of",
"type",
"is",
":",
">",
"=",
"0",
":",
"development",
">",
"=",
"64",
":",
"alpha",
"version",
">",
"=",
"128",
":",
"beta",
"version",
">",
"=",
"192",
":",
"RC",
"version",
"==",
"255",
":",
"release",
"version"
] | train | https://github.com/PX4/pyulog/blob/3bc4f9338d30e2e0a0dfbed58f54d200967e5056/pyulog/core.py#L614-L628 | <|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 (major, minor, patch, type) version information as tuple.
Returns None if not found
definition of type is:
>= 0: development
>= 64: alpha version
>= 128: beta version
>= 192: RC version
== 255: release version
### Response:
def get_version_info(self, key_name='ver_sw_release'):
"""
get the (major, minor, patch, type) version information as tuple.
Returns None if not found
definition of type is:
>= 0: development
>= 64: alpha version
>= 128: beta version
>= 192: RC version
== 255: release version
"""
if key_name in self._msg_info_dict:
val = self._msg_info_dict[key_name]
return ((val >> 24) & 0xff, (val >> 16) & 0xff, (val >> 8) & 0xff, val & 0xff)
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,
456,
279,
320,
37605,
11,
9099,
11,
11140,
11,
955,
8,
2373,
2038,
439,
14743,
627,
286,
5295,
2290,
422,
539,
1766,
198,
286,
7419,
315,
955,
374,
512,
260,
2669,
220,
15,
25,
4500,
198,
260,
2669,
220,
1227,
25,
8451,
2373,
198,
260,
2669,
220,
4386,
25,
13746,
2373,
198,
260,
2669,
220,
5926,
25,
22322,
2373,
198,
260,
624,
220,
3192,
25,
4984,
2373,
271,
14711,
6075,
512,
755,
636,
9625,
3186,
1214,
11,
1401,
1292,
1151,
424,
33681,
25596,
11290,
286,
3270,
286,
636,
279,
320,
37605,
11,
9099,
11,
11140,
11,
955,
8,
2373,
2038,
439,
14743,
627,
286,
5295,
2290,
422,
539,
1766,
198,
286,
7419,
315,
955,
374,
512,
260,
2669,
220,
15,
25,
4500,
198,
260,
2669,
220,
1227,
25,
8451,
2373,
198,
260,
2669,
220,
4386,
25,
13746,
2373,
198,
260,
2669,
220,
5926,
25,
22322,
2373,
198,
260,
624,
220,
3192,
25,
4984,
2373,
198,
286,
3270,
286,
422,
1401,
1292,
304,
659,
1462,
3316,
3186,
5356,
512,
310,
1062,
284,
659,
1462,
3316,
3186,
5356,
8320,
1292,
933,
310,
471,
1819,
838,
3662,
220,
1187,
8,
612,
220,
15,
9197,
11,
320,
838,
3662,
220,
845,
8,
612,
220,
15,
9197,
11,
320,
838,
3662,
220,
23,
8,
612,
220,
15,
9197,
11,
1062,
612,
220,
15,
9197,
340,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
279,
320,
37605,
11,
9099,
11,
11140,
11,
955,
8,
2373,
2038,
439,
14743,
627,
286,
5295,
2290,
422,
539,
1766,
198,
286,
7419,
315,
955,
374,
512,
260,
2669,
220,
15,
25,
4500,
198,
260,
2669,
220,
1227,
25,
8451,
2373,
198,
260,
2669,
220,
4386,
25,
13746,
2373,
198,
260,
2669,
220,
5926,
25,
22322,
2373,
198,
260,
624,
220,
3192,
25,
4984,
2373,
271,
14711,
6075,
512,
755,
636,
9625,
3186,
1214,
11,
1401,
1292,
1151,
424,
33681,
25596,
11290,
286,
3270,
286,
636,
279,
320,
37605,
11,
9099,
11,
11140,
11,
955,
8,
2373,
2038,
439,
14743,
627,
286,
5295,
2290,
422,
539,
1766,
198,
286,
7419,
315,
955,
374,
512,
260,
2669,
220,
15,
25,
4500,
198,
260,
2669,
220,
1227,
25,
8451,
2373,
198,
260,
2669,
220,
4386,
25,
13746,
2373,
198,
260,
2669,
220,
5926,
25,
22322,
2373,
198,
260,
624,
220,
3192,
25,
4984,
2373,
198,
286,
3270,
286,
422,
1401,
1292,
304,
659,
1462,
3316,
3186,
5356,
512,
310,
1062,
284,
659,
1462,
3316,
3186,
5356,
8320,
1292,
933,
310,
471,
1819,
838,
3662,
220,
1187,
8,
612,
220,
15,
9197,
11,
320,
838,
3662,
220,
845,
8,
612,
220,
15,
9197,
11,
320,
838,
3662,
220,
23,
8,
612,
220,
15,
9197,
11,
1062,
612,
220,
15,
9197,
340,
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
] |
apple/turicreate | src/external/coremltools_wrap/coremltools/coremltools/models/utils.py | load_spec | def load_spec(filename):
"""
Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of the model
Examples
--------
.. sourcecode:: python
>>> spec = coremltools.utils.load_spec('HousePricer.mlmodel')
See Also
--------
save_spec
"""
from ..proto import Model_pb2
spec = Model_pb2.Model()
with open(filename, 'rb') as f:
contents = f.read()
spec.ParseFromString(contents)
return spec | python | def load_spec(filename):
"""
Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of the model
Examples
--------
.. sourcecode:: python
>>> spec = coremltools.utils.load_spec('HousePricer.mlmodel')
See Also
--------
save_spec
"""
from ..proto import Model_pb2
spec = Model_pb2.Model()
with open(filename, 'rb') as f:
contents = f.read()
spec.ParseFromString(contents)
return spec | [
"def",
"load_spec",
"(",
"filename",
")",
":",
"from",
".",
".",
"proto",
"import",
"Model_pb2",
"spec",
"=",
"Model_pb2",
".",
"Model",
"(",
")",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"f",
":",
"contents",
"=",
"f",
".",
"read",
"(",
")",
"spec",
".",
"ParseFromString",
"(",
"contents",
")",
"return",
"spec"
] | Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of the model
Examples
--------
.. sourcecode:: python
>>> spec = coremltools.utils.load_spec('HousePricer.mlmodel')
See Also
--------
save_spec | [
"Load",
"a",
"protobuf",
"model",
"specification",
"from",
"file"
] | train | https://github.com/apple/turicreate/blob/74514c3f99e25b46f22c6e02977fe3da69221c2e/src/external/coremltools_wrap/coremltools/coremltools/models/utils.py#L62-L93 | <|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:
Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of the model
Examples
--------
.. sourcecode:: python
>>> spec = coremltools.utils.load_spec('HousePricer.mlmodel')
See Also
--------
save_spec
### Response:
def load_spec(filename):
"""
Load a protobuf model specification from file
Parameters
----------
filename: str
Location on disk (a valid filepath) from which the file is loaded
as a protobuf spec.
Returns
-------
model_spec: Model_pb
Protobuf representation of the model
Examples
--------
.. sourcecode:: python
>>> spec = coremltools.utils.load_spec('HousePricer.mlmodel')
See Also
--------
save_spec
"""
from ..proto import Model_pb2
spec = Model_pb2.Model()
with open(filename, 'rb') as f:
contents = f.read()
spec.ParseFromString(contents)
return spec
<|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,
6003,
264,
70734,
1646,
26185,
505,
1052,
271,
262,
13831,
198,
262,
31423,
262,
3986,
25,
610,
198,
286,
10067,
389,
13668,
320,
64,
2764,
27146,
8,
505,
902,
279,
1052,
374,
6799,
198,
286,
439,
264,
70734,
1424,
382,
262,
5295,
198,
262,
39707,
262,
1646,
13908,
25,
5008,
32509,
198,
286,
11970,
18971,
13340,
315,
279,
1646,
271,
262,
26379,
198,
262,
90238,
262,
5354,
2592,
1889,
487,
10344,
271,
286,
12382,
1424,
284,
6332,
1029,
16297,
8576,
5214,
13908,
493,
29707,
47,
2265,
261,
58509,
2590,
4713,
262,
3580,
7429,
198,
262,
90238,
262,
3665,
13908,
271,
14711,
6075,
512,
755,
2865,
13908,
11202,
997,
262,
3270,
262,
9069,
264,
70734,
1646,
26185,
505,
1052,
271,
262,
13831,
198,
262,
31423,
262,
3986,
25,
610,
198,
286,
10067,
389,
13668,
320,
64,
2764,
27146,
8,
505,
902,
279,
1052,
374,
6799,
198,
286,
439,
264,
70734,
1424,
382,
262,
5295,
198,
262,
39707,
262,
1646,
13908,
25,
5008,
32509,
198,
286,
11970,
18971,
13340,
315,
279,
1646,
271,
262,
26379,
198,
262,
90238,
262,
5354,
2592,
1889,
487,
10344,
271,
286,
12382,
1424,
284,
6332,
1029,
16297,
8576,
5214,
13908,
493,
29707,
47,
2265,
261,
58509,
2590,
4713,
262,
3580,
7429,
198,
262,
90238,
262,
3665,
13908,
198,
262,
3270,
262,
505,
5354,
15461,
1179,
5008,
32509,
17,
198,
262,
1424,
284,
5008,
32509,
17,
5777,
2892,
262,
449,
1825,
11202,
11,
364,
10910,
873,
439,
282,
512,
286,
8970,
284,
282,
4217,
746,
286,
1424,
9114,
45591,
48064,
340,
286,
471,
1424,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
6003,
264,
70734,
1646,
26185,
505,
1052,
271,
262,
13831,
198,
262,
31423,
262,
3986,
25,
610,
198,
286,
10067,
389,
13668,
320,
64,
2764,
27146,
8,
505,
902,
279,
1052,
374,
6799,
198,
286,
439,
264,
70734,
1424,
382,
262,
5295,
198,
262,
39707,
262,
1646,
13908,
25,
5008,
32509,
198,
286,
11970,
18971,
13340,
315,
279,
1646,
271,
262,
26379,
198,
262,
90238,
262,
5354,
2592,
1889,
487,
10344,
271,
286,
12382,
1424,
284,
6332,
1029,
16297,
8576,
5214,
13908,
493,
29707,
47,
2265,
261,
58509,
2590,
4713,
262,
3580,
7429,
198,
262,
90238,
262,
3665,
13908,
271,
14711,
6075,
512,
755,
2865,
13908,
11202,
997,
262,
3270,
262,
9069,
264,
70734,
1646,
26185,
505,
1052,
271,
262,
13831,
198,
262,
31423,
262,
3986,
25,
610,
198,
286,
10067,
389,
13668,
320,
64,
2764,
27146,
8,
505,
902,
279,
1052,
374,
6799,
198,
286,
439,
264,
70734,
1424,
382,
262,
5295,
198,
262,
39707,
262,
1646,
13908,
25,
5008,
32509,
198,
286,
11970,
18971,
13340,
315,
279,
1646,
271,
262,
26379,
198,
262,
90238,
262,
5354,
2592,
1889,
487,
10344,
271,
286,
12382,
1424,
284,
6332,
1029,
16297,
8576,
5214,
13908,
493,
29707,
47,
2265,
261,
58509,
2590,
4713,
262,
3580,
7429,
198,
262,
90238,
262,
3665,
13908,
198,
262,
3270,
262,
505,
5354,
15461,
1179,
5008,
32509,
17,
198,
262,
1424,
284,
5008,
32509,
17,
5777,
2892,
262,
449,
1825,
11202,
11,
364,
10910,
873,
439,
282,
512,
286,
8970,
284,
282,
4217,
746,
286,
1424,
9114,
45591,
48064,
340,
286,
471,
1424,
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
] |
watson-developer-cloud/python-sdk | ibm_watson/text_to_speech_v1.py | VoiceModel._from_dict | def _from_dict(cls, _dict):
"""Initialize a VoiceModel object from a json dictionary."""
args = {}
if 'customization_id' in _dict:
args['customization_id'] = _dict.get('customization_id')
else:
raise ValueError(
'Required property \'customization_id\' not present in VoiceModel JSON'
)
if 'name' in _dict:
args['name'] = _dict.get('name')
if 'language' in _dict:
args['language'] = _dict.get('language')
if 'owner' in _dict:
args['owner'] = _dict.get('owner')
if 'created' in _dict:
args['created'] = _dict.get('created')
if 'last_modified' in _dict:
args['last_modified'] = _dict.get('last_modified')
if 'description' in _dict:
args['description'] = _dict.get('description')
if 'words' in _dict:
args['words'] = [Word._from_dict(x) for x in (_dict.get('words'))]
return cls(**args) | python | def _from_dict(cls, _dict):
"""Initialize a VoiceModel object from a json dictionary."""
args = {}
if 'customization_id' in _dict:
args['customization_id'] = _dict.get('customization_id')
else:
raise ValueError(
'Required property \'customization_id\' not present in VoiceModel JSON'
)
if 'name' in _dict:
args['name'] = _dict.get('name')
if 'language' in _dict:
args['language'] = _dict.get('language')
if 'owner' in _dict:
args['owner'] = _dict.get('owner')
if 'created' in _dict:
args['created'] = _dict.get('created')
if 'last_modified' in _dict:
args['last_modified'] = _dict.get('last_modified')
if 'description' in _dict:
args['description'] = _dict.get('description')
if 'words' in _dict:
args['words'] = [Word._from_dict(x) for x in (_dict.get('words'))]
return cls(**args) | [
"def",
"_from_dict",
"(",
"cls",
",",
"_dict",
")",
":",
"args",
"=",
"{",
"}",
"if",
"'customization_id'",
"in",
"_dict",
":",
"args",
"[",
"'customization_id'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'customization_id'",
")",
"else",
":",
"raise",
"ValueError",
"(",
"'Required property \\'customization_id\\' not present in VoiceModel JSON'",
")",
"if",
"'name'",
"in",
"_dict",
":",
"args",
"[",
"'name'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'name'",
")",
"if",
"'language'",
"in",
"_dict",
":",
"args",
"[",
"'language'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'language'",
")",
"if",
"'owner'",
"in",
"_dict",
":",
"args",
"[",
"'owner'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'owner'",
")",
"if",
"'created'",
"in",
"_dict",
":",
"args",
"[",
"'created'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'created'",
")",
"if",
"'last_modified'",
"in",
"_dict",
":",
"args",
"[",
"'last_modified'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'last_modified'",
")",
"if",
"'description'",
"in",
"_dict",
":",
"args",
"[",
"'description'",
"]",
"=",
"_dict",
".",
"get",
"(",
"'description'",
")",
"if",
"'words'",
"in",
"_dict",
":",
"args",
"[",
"'words'",
"]",
"=",
"[",
"Word",
".",
"_from_dict",
"(",
"x",
")",
"for",
"x",
"in",
"(",
"_dict",
".",
"get",
"(",
"'words'",
")",
")",
"]",
"return",
"cls",
"(",
"*",
"*",
"args",
")"
] | Initialize a VoiceModel object from a json dictionary. | [
"Initialize",
"a",
"VoiceModel",
"object",
"from",
"a",
"json",
"dictionary",
"."
] | train | https://github.com/watson-developer-cloud/python-sdk/blob/4c2c9df4466fcde88975da9ecd834e6ba95eb353/ibm_watson/text_to_speech_v1.py#L1306-L1329 | <|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 a VoiceModel object from a json dictionary.
### Response:
def _from_dict(cls, _dict):
"""Initialize a VoiceModel object from a json dictionary."""
args = {}
if 'customization_id' in _dict:
args['customization_id'] = _dict.get('customization_id')
else:
raise ValueError(
'Required property \'customization_id\' not present in VoiceModel JSON'
)
if 'name' in _dict:
args['name'] = _dict.get('name')
if 'language' in _dict:
args['language'] = _dict.get('language')
if 'owner' in _dict:
args['owner'] = _dict.get('owner')
if 'created' in _dict:
args['created'] = _dict.get('created')
if 'last_modified' in _dict:
args['last_modified'] = _dict.get('last_modified')
if 'description' in _dict:
args['description'] = _dict.get('description')
if 'words' in _dict:
args['words'] = [Word._from_dict(x) for x in (_dict.get('words'))]
return cls(**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,
10130,
264,
29030,
1747,
1665,
505,
264,
3024,
11240,
382,
14711,
6075,
512,
755,
721,
1527,
5356,
21024,
11,
721,
8644,
997,
286,
4304,
10130,
264,
29030,
1747,
1665,
505,
264,
3024,
11240,
14781,
286,
2897,
284,
5731,
286,
422,
364,
9342,
2065,
851,
6,
304,
721,
8644,
512,
310,
2897,
681,
9342,
2065,
851,
663,
284,
721,
8644,
673,
493,
9342,
2065,
851,
1329,
286,
775,
512,
310,
4933,
15764,
1021,
394,
364,
8327,
3424,
28251,
9342,
2065,
851,
10379,
539,
3118,
304,
29030,
1747,
4823,
1270,
310,
1763,
286,
422,
364,
609,
6,
304,
721,
8644,
512,
310,
2897,
681,
609,
663,
284,
721,
8644,
673,
493,
609,
1329,
286,
422,
364,
11789,
6,
304,
721,
8644,
512,
310,
2897,
681,
11789,
663,
284,
721,
8644,
673,
493,
11789,
1329,
286,
422,
364,
8281,
6,
304,
721,
8644,
512,
310,
2897,
681,
8281,
663,
284,
721,
8644,
673,
493,
8281,
1329,
286,
422,
364,
7266,
6,
304,
721,
8644,
512,
310,
2897,
681,
7266,
663,
284,
721,
8644,
673,
493,
7266,
1329,
286,
422,
364,
4354,
38849,
6,
304,
721,
8644,
512,
310,
2897,
681,
4354,
38849,
663,
284,
721,
8644,
673,
493,
4354,
38849,
1329,
286,
422,
364,
4789,
6,
304,
721,
8644,
512,
310,
2897,
681,
4789,
663,
284,
721,
8644,
673,
493,
4789,
1329,
286,
422,
364,
5880,
6,
304,
721,
8644,
512,
310,
2897,
681,
5880,
663,
284,
510,
11116,
1462,
1527,
5356,
2120,
8,
369,
865,
304,
5570,
8644,
673,
493,
5880,
3874,
933,
286,
471,
13082,
22551,
2164,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
10130,
264,
29030,
1747,
1665,
505,
264,
3024,
11240,
382,
14711,
6075,
512,
755,
721,
1527,
5356,
21024,
11,
721,
8644,
997,
286,
4304,
10130,
264,
29030,
1747,
1665,
505,
264,
3024,
11240,
14781,
286,
2897,
284,
5731,
286,
422,
364,
9342,
2065,
851,
6,
304,
721,
8644,
512,
310,
2897,
681,
9342,
2065,
851,
663,
284,
721,
8644,
673,
493,
9342,
2065,
851,
1329,
286,
775,
512,
310,
4933,
15764,
1021,
394,
364,
8327,
3424,
28251,
9342,
2065,
851,
10379,
539,
3118,
304,
29030,
1747,
4823,
1270,
310,
1763,
286,
422,
364,
609,
6,
304,
721,
8644,
512,
310,
2897,
681,
609,
663,
284,
721,
8644,
673,
493,
609,
1329,
286,
422,
364,
11789,
6,
304,
721,
8644,
512,
310,
2897,
681,
11789,
663,
284,
721,
8644,
673,
493,
11789,
1329,
286,
422,
364,
8281,
6,
304,
721,
8644,
512,
310,
2897,
681,
8281,
663,
284,
721,
8644,
673,
493,
8281,
1329,
286,
422,
364,
7266,
6,
304,
721,
8644,
512,
310,
2897,
681,
7266,
663,
284,
721,
8644,
673,
493,
7266,
1329,
286,
422,
364,
4354,
38849,
6,
304,
721,
8644,
512,
310,
2897,
681,
4354,
38849,
663,
284,
721,
8644,
673,
493,
4354,
38849,
1329,
286,
422,
364,
4789,
6,
304,
721,
8644,
512,
310,
2897,
681,
4789,
663,
284,
721,
8644,
673,
493,
4789,
1329,
286,
422,
364,
5880,
6,
304,
721,
8644,
512,
310,
2897,
681,
5880,
663,
284,
510,
11116,
1462,
1527,
5356,
2120,
8,
369,
865,
304,
5570,
8644,
673,
493,
5880,
3874,
933,
286,
471,
13082,
22551,
2164,
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
] |
totalgood/pugnlp | src/pugnlp/detector_morse.py | Detector.candidates | def candidates(text):
"""
Given a `text` string, get candidates and context for feature
extraction and classification
"""
for Pmatch in finditer(TARGET, text):
# the punctuation mark itself
P = Pmatch.group(1)
# is it a boundary?
B = bool(match(NEWLINE, Pmatch.group(5)))
# L & R
start = Pmatch.start()
end = Pmatch.end()
Lmatch = search(LTOKEN, text[max(0, start - BUFSIZE):start])
if not Lmatch: # this happens when a line begins with '.'
continue
L = word_tokenize(" " + Lmatch.group(1))[-1]
Rmatch = search(RTOKEN, text[end:end + BUFSIZE])
if not Rmatch: # this happens at the end of the file, usually
continue
R = word_tokenize(Rmatch.group(1) + " ")[0]
# complete observation
yield Observation(L, P, R, B, end) | python | def candidates(text):
"""
Given a `text` string, get candidates and context for feature
extraction and classification
"""
for Pmatch in finditer(TARGET, text):
# the punctuation mark itself
P = Pmatch.group(1)
# is it a boundary?
B = bool(match(NEWLINE, Pmatch.group(5)))
# L & R
start = Pmatch.start()
end = Pmatch.end()
Lmatch = search(LTOKEN, text[max(0, start - BUFSIZE):start])
if not Lmatch: # this happens when a line begins with '.'
continue
L = word_tokenize(" " + Lmatch.group(1))[-1]
Rmatch = search(RTOKEN, text[end:end + BUFSIZE])
if not Rmatch: # this happens at the end of the file, usually
continue
R = word_tokenize(Rmatch.group(1) + " ")[0]
# complete observation
yield Observation(L, P, R, B, end) | [
"def",
"candidates",
"(",
"text",
")",
":",
"for",
"Pmatch",
"in",
"finditer",
"(",
"TARGET",
",",
"text",
")",
":",
"# the punctuation mark itself",
"P",
"=",
"Pmatch",
".",
"group",
"(",
"1",
")",
"# is it a boundary?",
"B",
"=",
"bool",
"(",
"match",
"(",
"NEWLINE",
",",
"Pmatch",
".",
"group",
"(",
"5",
")",
")",
")",
"# L & R",
"start",
"=",
"Pmatch",
".",
"start",
"(",
")",
"end",
"=",
"Pmatch",
".",
"end",
"(",
")",
"Lmatch",
"=",
"search",
"(",
"LTOKEN",
",",
"text",
"[",
"max",
"(",
"0",
",",
"start",
"-",
"BUFSIZE",
")",
":",
"start",
"]",
")",
"if",
"not",
"Lmatch",
":",
"# this happens when a line begins with '.'",
"continue",
"L",
"=",
"word_tokenize",
"(",
"\" \"",
"+",
"Lmatch",
".",
"group",
"(",
"1",
")",
")",
"[",
"-",
"1",
"]",
"Rmatch",
"=",
"search",
"(",
"RTOKEN",
",",
"text",
"[",
"end",
":",
"end",
"+",
"BUFSIZE",
"]",
")",
"if",
"not",
"Rmatch",
":",
"# this happens at the end of the file, usually",
"continue",
"R",
"=",
"word_tokenize",
"(",
"Rmatch",
".",
"group",
"(",
"1",
")",
"+",
"\" \"",
")",
"[",
"0",
"]",
"# complete observation",
"yield",
"Observation",
"(",
"L",
",",
"P",
",",
"R",
",",
"B",
",",
"end",
")"
] | Given a `text` string, get candidates and context for feature
extraction and classification | [
"Given",
"a",
"text",
"string",
"get",
"candidates",
"and",
"context",
"for",
"feature",
"extraction",
"and",
"classification"
] | train | https://github.com/totalgood/pugnlp/blob/c43445b14afddfdeadc5f3076675c9e8fc1ee67c/src/pugnlp/detector_morse.py#L105-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:
Given a `text` string, get candidates and context for feature
extraction and classification
### Response:
def candidates(text):
"""
Given a `text` string, get candidates and context for feature
extraction and classification
"""
for Pmatch in finditer(TARGET, text):
# the punctuation mark itself
P = Pmatch.group(1)
# is it a boundary?
B = bool(match(NEWLINE, Pmatch.group(5)))
# L & R
start = Pmatch.start()
end = Pmatch.end()
Lmatch = search(LTOKEN, text[max(0, start - BUFSIZE):start])
if not Lmatch: # this happens when a line begins with '.'
continue
L = word_tokenize(" " + Lmatch.group(1))[-1]
Rmatch = search(RTOKEN, text[end:end + BUFSIZE])
if not Rmatch: # this happens at the end of the file, usually
continue
R = word_tokenize(Rmatch.group(1) + " ")[0]
# complete observation
yield Observation(L, P, R, B, end)
<|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,
22818,
264,
1595,
1342,
63,
925,
11,
636,
11426,
323,
2317,
369,
4668,
198,
286,
33289,
323,
24790,
271,
14711,
6075,
512,
755,
11426,
7383,
997,
286,
3270,
286,
16644,
264,
1595,
1342,
63,
925,
11,
636,
11426,
323,
2317,
369,
4668,
198,
286,
33289,
323,
24790,
198,
286,
3270,
286,
369,
393,
6481,
304,
1505,
2058,
4233,
16880,
11,
1495,
997,
310,
674,
279,
62603,
1906,
5196,
198,
310,
393,
284,
393,
6481,
6306,
7,
16,
340,
310,
674,
374,
433,
264,
19254,
5380,
310,
426,
284,
1845,
26473,
7,
21242,
8429,
11,
393,
6481,
6306,
7,
20,
6054,
310,
674,
445,
612,
432,
198,
310,
1212,
284,
393,
6481,
5069,
746,
310,
842,
284,
393,
6481,
5183,
746,
310,
445,
6481,
284,
2778,
5063,
63953,
11,
1495,
38823,
7,
15,
11,
1212,
482,
55129,
79267,
1680,
2527,
2608,
310,
422,
539,
445,
6481,
25,
220,
674,
420,
8741,
994,
264,
1584,
12302,
449,
6389,
1270,
394,
3136,
198,
310,
445,
284,
3492,
87608,
446,
330,
489,
445,
6481,
6306,
7,
16,
595,
7764,
16,
933,
310,
432,
6481,
284,
2778,
2855,
63953,
11,
1495,
58308,
26874,
489,
55129,
79267,
2608,
310,
422,
539,
432,
6481,
25,
220,
674,
420,
8741,
520,
279,
842,
315,
279,
1052,
11,
6118,
198,
394,
3136,
198,
310,
432,
284,
3492,
87608,
2855,
6481,
6306,
7,
16,
8,
489,
330,
69400,
15,
933,
310,
674,
4686,
22695,
198,
310,
7692,
87529,
5063,
11,
393,
11,
432,
11,
426,
11,
842,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
22818,
264,
1595,
1342,
63,
925,
11,
636,
11426,
323,
2317,
369,
4668,
198,
286,
33289,
323,
24790,
271,
14711,
6075,
512,
755,
11426,
7383,
997,
286,
3270,
286,
16644,
264,
1595,
1342,
63,
925,
11,
636,
11426,
323,
2317,
369,
4668,
198,
286,
33289,
323,
24790,
198,
286,
3270,
286,
369,
393,
6481,
304,
1505,
2058,
4233,
16880,
11,
1495,
997,
310,
674,
279,
62603,
1906,
5196,
198,
310,
393,
284,
393,
6481,
6306,
7,
16,
340,
310,
674,
374,
433,
264,
19254,
5380,
310,
426,
284,
1845,
26473,
7,
21242,
8429,
11,
393,
6481,
6306,
7,
20,
6054,
310,
674,
445,
612,
432,
198,
310,
1212,
284,
393,
6481,
5069,
746,
310,
842,
284,
393,
6481,
5183,
746,
310,
445,
6481,
284,
2778,
5063,
63953,
11,
1495,
38823,
7,
15,
11,
1212,
482,
55129,
79267,
1680,
2527,
2608,
310,
422,
539,
445,
6481,
25,
220,
674,
420,
8741,
994,
264,
1584,
12302,
449,
6389,
1270,
394,
3136,
198,
310,
445,
284,
3492,
87608,
446,
330,
489,
445,
6481,
6306,
7,
16,
595,
7764,
16,
933,
310,
432,
6481,
284,
2778,
2855,
63953,
11,
1495,
58308,
26874,
489,
55129,
79267,
2608,
310,
422,
539,
432,
6481,
25,
220,
674,
420,
8741,
520,
279,
842,
315,
279,
1052,
11,
6118,
198,
394,
3136,
198,
310,
432,
284,
3492,
87608,
2855,
6481,
6306,
7,
16,
8,
489,
330,
69400,
15,
933,
310,
674,
4686,
22695,
198,
310,
7692,
87529,
5063,
11,
393,
11,
432,
11,
426,
11,
842,
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
] |
ljcooke/see | see/tools.py | char_width | def char_width(char):
"""
Get the display length of a unicode character.
"""
if ord(char) < 128:
return 1
elif unicodedata.east_asian_width(char) in ('F', 'W'):
return 2
elif unicodedata.category(char) in ('Mn',):
return 0
else:
return 1 | python | def char_width(char):
"""
Get the display length of a unicode character.
"""
if ord(char) < 128:
return 1
elif unicodedata.east_asian_width(char) in ('F', 'W'):
return 2
elif unicodedata.category(char) in ('Mn',):
return 0
else:
return 1 | [
"def",
"char_width",
"(",
"char",
")",
":",
"if",
"ord",
"(",
"char",
")",
"<",
"128",
":",
"return",
"1",
"elif",
"unicodedata",
".",
"east_asian_width",
"(",
"char",
")",
"in",
"(",
"'F'",
",",
"'W'",
")",
":",
"return",
"2",
"elif",
"unicodedata",
".",
"category",
"(",
"char",
")",
"in",
"(",
"'Mn'",
",",
")",
":",
"return",
"0",
"else",
":",
"return",
"1"
] | Get the display length of a unicode character. | [
"Get",
"the",
"display",
"length",
"of",
"a",
"unicode",
"character",
"."
] | train | https://github.com/ljcooke/see/blob/4cbc67a31c92367977ecb4bbb1f0736fa688a6ba/see/tools.py#L16-L27 | <|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 display length of a unicode character.
### Response:
def char_width(char):
"""
Get the display length of a unicode character.
"""
if ord(char) < 128:
return 1
elif unicodedata.east_asian_width(char) in ('F', 'W'):
return 2
elif unicodedata.category(char) in ('Mn',):
return 0
else:
return 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,
1991,
279,
3113,
3160,
315,
264,
27169,
3752,
382,
14711,
6075,
512,
755,
1181,
8086,
7078,
997,
262,
3270,
262,
2175,
279,
3113,
3160,
315,
264,
27169,
3752,
627,
262,
3270,
262,
422,
6141,
7078,
8,
366,
220,
4386,
512,
286,
471,
220,
16,
198,
262,
4508,
88649,
6879,
460,
1770,
561,
12162,
1122,
8086,
7078,
8,
304,
4417,
37,
518,
364,
54,
11290,
286,
471,
220,
17,
198,
262,
4508,
88649,
6879,
460,
18898,
7078,
8,
304,
4417,
44,
77,
518,
997,
286,
471,
220,
15,
198,
262,
775,
512,
286,
471,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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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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
] | [
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,
3113,
3160,
315,
264,
27169,
3752,
382,
14711,
6075,
512,
755,
1181,
8086,
7078,
997,
262,
3270,
262,
2175,
279,
3113,
3160,
315,
264,
27169,
3752,
627,
262,
3270,
262,
422,
6141,
7078,
8,
366,
220,
4386,
512,
286,
471,
220,
16,
198,
262,
4508,
88649,
6879,
460,
1770,
561,
12162,
1122,
8086,
7078,
8,
304,
4417,
37,
518,
364,
54,
11290,
286,
471,
220,
17,
198,
262,
4508,
88649,
6879,
460,
18898,
7078,
8,
304,
4417,
44,
77,
518,
997,
286,
471,
220,
15,
198,
262,
775,
512,
286,
471,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
BlueBrain/NeuroM | examples/density_plot.py | plot_neuron_on_density | def plot_neuron_on_density(population, # pylint: disable=too-many-arguments
bins=100, new_fig=True, subplot=111, levels=None, plane='xy',
colorlabel='Nodes per unit area', labelfontsize=16,
color_map='Reds', no_colorbar=False, threshold=0.01,
neurite_type=NeuriteType.basal_dendrite, **kwargs):
'''Plots the 2d histogram of the center
coordinates of segments in the selected plane
and superimposes the view of the first neurite of the collection.
'''
_, ax = common.get_figure(new_fig=new_fig)
view.plot_tree(ax, population.neurites[0])
return plot_density(population, plane=plane, bins=bins, new_fig=False, subplot=subplot,
colorlabel=colorlabel, labelfontsize=labelfontsize, levels=levels,
color_map=color_map, no_colorbar=no_colorbar, threshold=threshold,
neurite_type=neurite_type, **kwargs) | python | def plot_neuron_on_density(population, # pylint: disable=too-many-arguments
bins=100, new_fig=True, subplot=111, levels=None, plane='xy',
colorlabel='Nodes per unit area', labelfontsize=16,
color_map='Reds', no_colorbar=False, threshold=0.01,
neurite_type=NeuriteType.basal_dendrite, **kwargs):
'''Plots the 2d histogram of the center
coordinates of segments in the selected plane
and superimposes the view of the first neurite of the collection.
'''
_, ax = common.get_figure(new_fig=new_fig)
view.plot_tree(ax, population.neurites[0])
return plot_density(population, plane=plane, bins=bins, new_fig=False, subplot=subplot,
colorlabel=colorlabel, labelfontsize=labelfontsize, levels=levels,
color_map=color_map, no_colorbar=no_colorbar, threshold=threshold,
neurite_type=neurite_type, **kwargs) | [
"def",
"plot_neuron_on_density",
"(",
"population",
",",
"# pylint: disable=too-many-arguments",
"bins",
"=",
"100",
",",
"new_fig",
"=",
"True",
",",
"subplot",
"=",
"111",
",",
"levels",
"=",
"None",
",",
"plane",
"=",
"'xy'",
",",
"colorlabel",
"=",
"'Nodes per unit area'",
",",
"labelfontsize",
"=",
"16",
",",
"color_map",
"=",
"'Reds'",
",",
"no_colorbar",
"=",
"False",
",",
"threshold",
"=",
"0.01",
",",
"neurite_type",
"=",
"NeuriteType",
".",
"basal_dendrite",
",",
"*",
"*",
"kwargs",
")",
":",
"_",
",",
"ax",
"=",
"common",
".",
"get_figure",
"(",
"new_fig",
"=",
"new_fig",
")",
"view",
".",
"plot_tree",
"(",
"ax",
",",
"population",
".",
"neurites",
"[",
"0",
"]",
")",
"return",
"plot_density",
"(",
"population",
",",
"plane",
"=",
"plane",
",",
"bins",
"=",
"bins",
",",
"new_fig",
"=",
"False",
",",
"subplot",
"=",
"subplot",
",",
"colorlabel",
"=",
"colorlabel",
",",
"labelfontsize",
"=",
"labelfontsize",
",",
"levels",
"=",
"levels",
",",
"color_map",
"=",
"color_map",
",",
"no_colorbar",
"=",
"no_colorbar",
",",
"threshold",
"=",
"threshold",
",",
"neurite_type",
"=",
"neurite_type",
",",
"*",
"*",
"kwargs",
")"
] | Plots the 2d histogram of the center
coordinates of segments in the selected plane
and superimposes the view of the first neurite of the collection. | [
"Plots",
"the",
"2d",
"histogram",
"of",
"the",
"center",
"coordinates",
"of",
"segments",
"in",
"the",
"selected",
"plane",
"and",
"superimposes",
"the",
"view",
"of",
"the",
"first",
"neurite",
"of",
"the",
"collection",
"."
] | train | https://github.com/BlueBrain/NeuroM/blob/254bb73535b20053d175bc4725bade662177d12b/examples/density_plot.py#L83-L99 | <|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:
Plots the 2d histogram of the center
coordinates of segments in the selected plane
and superimposes the view of the first neurite of the collection.
### Response:
def plot_neuron_on_density(population, # pylint: disable=too-many-arguments
bins=100, new_fig=True, subplot=111, levels=None, plane='xy',
colorlabel='Nodes per unit area', labelfontsize=16,
color_map='Reds', no_colorbar=False, threshold=0.01,
neurite_type=NeuriteType.basal_dendrite, **kwargs):
'''Plots the 2d histogram of the center
coordinates of segments in the selected plane
and superimposes the view of the first neurite of the collection.
'''
_, ax = common.get_figure(new_fig=new_fig)
view.plot_tree(ax, population.neurites[0])
return plot_density(population, plane=plane, bins=bins, new_fig=False, subplot=subplot,
colorlabel=colorlabel, labelfontsize=labelfontsize, levels=levels,
color_map=color_map, no_colorbar=no_colorbar, threshold=threshold,
neurite_type=neurite_type, **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,
2169,
2469,
279,
220,
17,
67,
31381,
315,
279,
4219,
198,
996,
14259,
315,
21282,
304,
279,
4183,
11277,
198,
996,
323,
2307,
318,
8449,
279,
1684,
315,
279,
1176,
21850,
635,
315,
279,
4526,
382,
14711,
6075,
512,
755,
7234,
14250,
37190,
4570,
54449,
41248,
2987,
11,
674,
51471,
25,
11404,
28,
37227,
81288,
12,
16774,
198,
6096,
29618,
28,
1041,
11,
502,
63241,
3702,
11,
47726,
28,
5037,
11,
5990,
5980,
11,
11277,
1151,
4223,
756,
6096,
1933,
1530,
1151,
12568,
824,
5089,
3158,
518,
10278,
491,
546,
2190,
28,
845,
345,
6096,
1933,
5489,
1151,
6161,
82,
518,
912,
6855,
2308,
5725,
11,
12447,
28,
15,
13,
1721,
345,
6096,
21850,
635,
1857,
28,
8989,
324,
635,
941,
960,
116607,
821,
408,
1269,
11,
3146,
9872,
997,
262,
11712,
2169,
2469,
279,
220,
17,
67,
31381,
315,
279,
4219,
198,
996,
14259,
315,
21282,
304,
279,
4183,
11277,
198,
996,
323,
2307,
318,
8449,
279,
1684,
315,
279,
1176,
21850,
635,
315,
279,
4526,
627,
262,
11414,
262,
8523,
3944,
284,
4279,
673,
83831,
1792,
63241,
8507,
63241,
696,
262,
1684,
12683,
11925,
43022,
11,
7187,
23456,
324,
3695,
58,
15,
9801,
262,
471,
7234,
54449,
41248,
2987,
11,
11277,
28,
19563,
11,
29618,
22861,
1354,
11,
502,
63241,
5725,
11,
47726,
46499,
4569,
345,
667,
1933,
1530,
64892,
1530,
11,
10278,
491,
546,
2190,
28,
14717,
491,
546,
2190,
11,
5990,
28,
43664,
345,
667,
1933,
5489,
64892,
5489,
11,
912,
6855,
2308,
31415,
6855,
2308,
11,
12447,
28,
30002,
345,
667,
21850,
635,
1857,
28,
818,
324,
635,
1857,
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
] | [
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,
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,
2169,
2469,
279,
220,
17,
67,
31381,
315,
279,
4219,
198,
996,
14259,
315,
21282,
304,
279,
4183,
11277,
198,
996,
323,
2307,
318,
8449,
279,
1684,
315,
279,
1176,
21850,
635,
315,
279,
4526,
382,
14711,
6075,
512,
755,
7234,
14250,
37190,
4570,
54449,
41248,
2987,
11,
674,
51471,
25,
11404,
28,
37227,
81288,
12,
16774,
198,
6096,
29618,
28,
1041,
11,
502,
63241,
3702,
11,
47726,
28,
5037,
11,
5990,
5980,
11,
11277,
1151,
4223,
756,
6096,
1933,
1530,
1151,
12568,
824,
5089,
3158,
518,
10278,
491,
546,
2190,
28,
845,
345,
6096,
1933,
5489,
1151,
6161,
82,
518,
912,
6855,
2308,
5725,
11,
12447,
28,
15,
13,
1721,
345,
6096,
21850,
635,
1857,
28,
8989,
324,
635,
941,
960,
116607,
821,
408,
1269,
11,
3146,
9872,
997,
262,
11712,
2169,
2469,
279,
220,
17,
67,
31381,
315,
279,
4219,
198,
996,
14259,
315,
21282,
304,
279,
4183,
11277,
198,
996,
323,
2307,
318,
8449,
279,
1684,
315,
279,
1176,
21850,
635,
315,
279,
4526,
627,
262,
11414,
262,
8523,
3944,
284,
4279,
673,
83831,
1792,
63241,
8507,
63241,
696,
262,
1684,
12683,
11925,
43022,
11,
7187,
23456,
324,
3695,
58,
15,
9801,
262,
471,
7234,
54449,
41248,
2987,
11,
11277,
28,
19563,
11,
29618,
22861,
1354,
11,
502,
63241,
5725,
11,
47726,
46499,
4569,
345,
667,
1933,
1530,
64892,
1530,
11,
10278,
491,
546,
2190,
28,
14717,
491,
546,
2190,
11,
5990,
28,
43664,
345,
667,
1933,
5489,
64892,
5489,
11,
912,
6855,
2308,
31415,
6855,
2308,
11,
12447,
28,
30002,
345,
667,
21850,
635,
1857,
28,
818,
324,
635,
1857,
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
] |
codeinn/vcs | vcs/backends/hg/changeset.py | MercurialChangeset.get_file_annotate | def get_file_annotate(self, path):
"""
Returns a generator of four element tuples with
lineno, sha, changeset lazy loader and line
"""
fctx = self._get_filectx(path)
for i, annotate_data in enumerate(fctx.annotate()):
ln_no = i + 1
sha = hex(annotate_data[0].node())
yield (ln_no, sha, lambda: self.repository.get_changeset(sha), annotate_data[1],) | python | def get_file_annotate(self, path):
"""
Returns a generator of four element tuples with
lineno, sha, changeset lazy loader and line
"""
fctx = self._get_filectx(path)
for i, annotate_data in enumerate(fctx.annotate()):
ln_no = i + 1
sha = hex(annotate_data[0].node())
yield (ln_no, sha, lambda: self.repository.get_changeset(sha), annotate_data[1],) | [
"def",
"get_file_annotate",
"(",
"self",
",",
"path",
")",
":",
"fctx",
"=",
"self",
".",
"_get_filectx",
"(",
"path",
")",
"for",
"i",
",",
"annotate_data",
"in",
"enumerate",
"(",
"fctx",
".",
"annotate",
"(",
")",
")",
":",
"ln_no",
"=",
"i",
"+",
"1",
"sha",
"=",
"hex",
"(",
"annotate_data",
"[",
"0",
"]",
".",
"node",
"(",
")",
")",
"yield",
"(",
"ln_no",
",",
"sha",
",",
"lambda",
":",
"self",
".",
"repository",
".",
"get_changeset",
"(",
"sha",
")",
",",
"annotate_data",
"[",
"1",
"]",
",",
")"
] | Returns a generator of four element tuples with
lineno, sha, changeset lazy loader and line | [
"Returns",
"a",
"generator",
"of",
"four",
"element",
"tuples",
"with",
"lineno",
"sha",
"changeset",
"lazy",
"loader",
"and",
"line"
] | train | https://github.com/codeinn/vcs/blob/e6cd94188e9c36d273411bf3adc0584ac6ab92a0/vcs/backends/hg/changeset.py#L242-L252 | <|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 generator of four element tuples with
lineno, sha, changeset lazy loader and line
### Response:
def get_file_annotate(self, path):
"""
Returns a generator of four element tuples with
lineno, sha, changeset lazy loader and line
"""
fctx = self._get_filectx(path)
for i, annotate_data in enumerate(fctx.annotate()):
ln_no = i + 1
sha = hex(annotate_data[0].node())
yield (ln_no, sha, lambda: self.repository.get_changeset(sha), annotate_data[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,
16851,
264,
14143,
315,
3116,
2449,
46325,
449,
198,
310,
86195,
11,
16249,
11,
4442,
295,
16053,
16432,
323,
1584,
271,
14711,
6075,
512,
755,
636,
2517,
62,
92450,
1214,
11,
1853,
997,
286,
3270,
286,
5295,
264,
14143,
315,
3116,
2449,
46325,
449,
198,
310,
86195,
11,
16249,
11,
4442,
295,
16053,
16432,
323,
1584,
198,
286,
12713,
286,
282,
3858,
284,
659,
1462,
456,
2517,
3858,
5698,
340,
286,
369,
602,
11,
89498,
1807,
304,
13555,
968,
3858,
93232,
34257,
310,
30490,
6673,
284,
602,
489,
220,
16,
198,
310,
16249,
284,
12651,
7,
92450,
1807,
58,
15,
948,
3593,
2455,
310,
7692,
320,
2312,
6673,
11,
16249,
11,
12741,
25,
659,
15311,
673,
48626,
295,
7,
15605,
705,
89498,
1807,
58,
16,
1145,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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
315,
3116,
2449,
46325,
449,
198,
310,
86195,
11,
16249,
11,
4442,
295,
16053,
16432,
323,
1584,
271,
14711,
6075,
512,
755,
636,
2517,
62,
92450,
1214,
11,
1853,
997,
286,
3270,
286,
5295,
264,
14143,
315,
3116,
2449,
46325,
449,
198,
310,
86195,
11,
16249,
11,
4442,
295,
16053,
16432,
323,
1584,
198,
286,
12713,
286,
282,
3858,
284,
659,
1462,
456,
2517,
3858,
5698,
340,
286,
369,
602,
11,
89498,
1807,
304,
13555,
968,
3858,
93232,
34257,
310,
30490,
6673,
284,
602,
489,
220,
16,
198,
310,
16249,
284,
12651,
7,
92450,
1807,
58,
15,
948,
3593,
2455,
310,
7692,
320,
2312,
6673,
11,
16249,
11,
12741,
25,
659,
15311,
673,
48626,
295,
7,
15605,
705,
89498,
1807,
58,
16,
1145,
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
] |
markchil/gptools | gptools/kernel/matern.py | MaternKernel._compute_dk_dy | def _compute_dk_dy(self, y, n):
r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int.
Order of derivative to compute.
Returns
-------
dk_dy : :py:class:`Array`, (`M`,)
Specified derivative at specified locations.
"""
return 2.0**(1 - self.nu) / (scipy.special.gamma(self.nu)) * yn2Kn2Der(self.nu, y, n=n) | python | def _compute_dk_dy(self, y, n):
r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int.
Order of derivative to compute.
Returns
-------
dk_dy : :py:class:`Array`, (`M`,)
Specified derivative at specified locations.
"""
return 2.0**(1 - self.nu) / (scipy.special.gamma(self.nu)) * yn2Kn2Der(self.nu, y, n=n) | [
"def",
"_compute_dk_dy",
"(",
"self",
",",
"y",
",",
"n",
")",
":",
"return",
"2.0",
"**",
"(",
"1",
"-",
"self",
".",
"nu",
")",
"/",
"(",
"scipy",
".",
"special",
".",
"gamma",
"(",
"self",
".",
"nu",
")",
")",
"*",
"yn2Kn2Der",
"(",
"self",
".",
"nu",
",",
"y",
",",
"n",
"=",
"n",
")"
] | r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int.
Order of derivative to compute.
Returns
-------
dk_dy : :py:class:`Array`, (`M`,)
Specified derivative at specified locations. | [
"r",
"Evaluate",
"the",
"derivative",
"of",
"the",
"outer",
"form",
"of",
"the",
"Matern",
"kernel",
".",
"Uses",
"the",
"general",
"Leibniz",
"rule",
"to",
"compute",
"the",
"n",
"-",
"th",
"derivative",
"of",
":",
"..",
"math",
"::",
"f",
"(",
"y",
")",
"=",
"\\",
"frac",
"{",
"2^",
"{",
"1",
"-",
"\\",
"nu",
"}}",
"{",
"\\",
"Gamma",
"(",
"\\",
"nu",
")",
"}",
"y^",
"{",
"\\",
"nu",
"/",
"2",
"}",
"K_",
"\\",
"nu",
"(",
"y^",
"{",
"1",
"/",
"2",
"}",
")",
"Parameters",
"----------",
"y",
":",
":",
"py",
":",
"class",
":",
"Array",
"(",
"M",
")",
"M",
"inputs",
"to",
"evaluate",
"at",
".",
"n",
":",
"non",
"-",
"negative",
"scalar",
"int",
".",
"Order",
"of",
"derivative",
"to",
"compute",
".",
"Returns",
"-------",
"dk_dy",
":",
":",
"py",
":",
"class",
":",
"Array",
"(",
"M",
")",
"Specified",
"derivative",
"at",
"specified",
"locations",
"."
] | train | https://github.com/markchil/gptools/blob/225db52bfe6baef1516529ad22177aa2cf7b71e4/gptools/kernel/matern.py#L357-L378 | <|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:
r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int.
Order of derivative to compute.
Returns
-------
dk_dy : :py:class:`Array`, (`M`,)
Specified derivative at specified locations.
### Response:
def _compute_dk_dy(self, y, n):
r"""Evaluate the derivative of the outer form of the Matern kernel.
Uses the general Leibniz rule to compute the n-th derivative of:
.. math::
f(y) = \frac{2^{1-\nu}}{\Gamma(\nu)} y^{\nu/2} K_\nu(y^{1/2})
Parameters
----------
y : :py:class:`Array`, (`M`,)
`M` inputs to evaluate at.
n : non-negative scalar int.
Order of derivative to compute.
Returns
-------
dk_dy : :py:class:`Array`, (`M`,)
Specified derivative at specified locations.
"""
return 2.0**(1 - self.nu) / (scipy.special.gamma(self.nu)) * yn2Kn2Der(self.nu, y, n=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,
81,
12885,
83445,
279,
32905,
315,
279,
16335,
1376,
315,
279,
7011,
944,
10206,
627,
1827,
286,
39923,
279,
4689,
2009,
581,
77,
450,
6037,
311,
12849,
279,
308,
7716,
32905,
315,
512,
1827,
286,
5354,
7033,
50677,
1827,
310,
282,
7166,
8,
284,
1144,
38118,
90,
17,
48922,
16,
31629,
9110,
3500,
36802,
41557,
11781,
9110,
9317,
379,
61,
36802,
9110,
14,
17,
92,
735,
57114,
9110,
7166,
48922,
16,
14,
17,
3602,
1827,
286,
13831,
198,
286,
31423,
286,
379,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
1595,
44,
63,
11374,
311,
15806,
520,
627,
286,
308,
551,
2536,
62035,
17722,
528,
627,
310,
7365,
315,
32905,
311,
12849,
627,
1827,
286,
5295,
198,
286,
39707,
286,
41304,
83735,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
11197,
1908,
32905,
520,
5300,
10687,
382,
14711,
6075,
512,
755,
721,
28806,
821,
74,
83735,
1214,
11,
379,
11,
308,
997,
286,
436,
12885,
83445,
279,
32905,
315,
279,
16335,
1376,
315,
279,
7011,
944,
10206,
627,
1827,
286,
39923,
279,
4689,
2009,
581,
77,
450,
6037,
311,
12849,
279,
308,
7716,
32905,
315,
512,
1827,
286,
5354,
7033,
50677,
1827,
310,
282,
7166,
8,
284,
1144,
38118,
90,
17,
48922,
16,
31629,
9110,
3500,
36802,
41557,
11781,
9110,
9317,
379,
61,
36802,
9110,
14,
17,
92,
735,
57114,
9110,
7166,
48922,
16,
14,
17,
3602,
1827,
286,
13831,
198,
286,
31423,
286,
379,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
1595,
44,
63,
11374,
311,
15806,
520,
627,
286,
308,
551,
2536,
62035,
17722,
528,
627,
310,
7365,
315,
32905,
311,
12849,
627,
1827,
286,
5295,
198,
286,
39707,
286,
41304,
83735,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
11197,
1908,
32905,
520,
5300,
10687,
627,
286,
3270,
286,
471,
220,
17,
13,
15,
84825,
16,
482,
659,
1276,
84,
8,
611,
320,
2445,
23799,
64308,
74401,
1214,
1276,
84,
595,
353,
81861,
17,
37353,
17,
22960,
1214,
1276,
84,
11,
379,
11,
308,
22495,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
81,
12885,
83445,
279,
32905,
315,
279,
16335,
1376,
315,
279,
7011,
944,
10206,
627,
1827,
286,
39923,
279,
4689,
2009,
581,
77,
450,
6037,
311,
12849,
279,
308,
7716,
32905,
315,
512,
1827,
286,
5354,
7033,
50677,
1827,
310,
282,
7166,
8,
284,
1144,
38118,
90,
17,
48922,
16,
31629,
9110,
3500,
36802,
41557,
11781,
9110,
9317,
379,
61,
36802,
9110,
14,
17,
92,
735,
57114,
9110,
7166,
48922,
16,
14,
17,
3602,
1827,
286,
13831,
198,
286,
31423,
286,
379,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
1595,
44,
63,
11374,
311,
15806,
520,
627,
286,
308,
551,
2536,
62035,
17722,
528,
627,
310,
7365,
315,
32905,
311,
12849,
627,
1827,
286,
5295,
198,
286,
39707,
286,
41304,
83735,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
11197,
1908,
32905,
520,
5300,
10687,
382,
14711,
6075,
512,
755,
721,
28806,
821,
74,
83735,
1214,
11,
379,
11,
308,
997,
286,
436,
12885,
83445,
279,
32905,
315,
279,
16335,
1376,
315,
279,
7011,
944,
10206,
627,
1827,
286,
39923,
279,
4689,
2009,
581,
77,
450,
6037,
311,
12849,
279,
308,
7716,
32905,
315,
512,
1827,
286,
5354,
7033,
50677,
1827,
310,
282,
7166,
8,
284,
1144,
38118,
90,
17,
48922,
16,
31629,
9110,
3500,
36802,
41557,
11781,
9110,
9317,
379,
61,
36802,
9110,
14,
17,
92,
735,
57114,
9110,
7166,
48922,
16,
14,
17,
3602,
1827,
286,
13831,
198,
286,
31423,
286,
379,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
1595,
44,
63,
11374,
311,
15806,
520,
627,
286,
308,
551,
2536,
62035,
17722,
528,
627,
310,
7365,
315,
32905,
311,
12849,
627,
1827,
286,
5295,
198,
286,
39707,
286,
41304,
83735,
551,
551,
3368,
93064,
19258,
1895,
7964,
29754,
44,
7964,
340,
310,
11197,
1908,
32905,
520,
5300,
10687,
627,
286,
3270,
286,
471,
220,
17,
13,
15,
84825,
16,
482,
659,
1276,
84,
8,
611,
320,
2445,
23799,
64308,
74401,
1214,
1276,
84,
595,
353,
81861,
17,
37353,
17,
22960,
1214,
1276,
84,
11,
379,
11,
308,
22495,
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
] |
drj11/pypng | code/png.py | is_natural | def is_natural(x):
"""A non-negative integer."""
try:
is_integer = int(x) == x
except (TypeError, ValueError):
return False
return is_integer and x >= 0 | python | def is_natural(x):
"""A non-negative integer."""
try:
is_integer = int(x) == x
except (TypeError, ValueError):
return False
return is_integer and x >= 0 | [
"def",
"is_natural",
"(",
"x",
")",
":",
"try",
":",
"is_integer",
"=",
"int",
"(",
"x",
")",
"==",
"x",
"except",
"(",
"TypeError",
",",
"ValueError",
")",
":",
"return",
"False",
"return",
"is_integer",
"and",
"x",
">=",
"0"
] | A non-negative integer. | [
"A",
"non",
"-",
"negative",
"integer",
"."
] | train | https://github.com/drj11/pypng/blob/b8220ca9f58e4c5bc1d507e713744fcb8c049225/code/png.py#L2203-L2209 | <|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 non-negative integer.
### Response:
def is_natural(x):
"""A non-negative integer."""
try:
is_integer = int(x) == x
except (TypeError, ValueError):
return False
return is_integer and x >= 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,
32,
2536,
62035,
7698,
382,
14711,
6075,
512,
755,
374,
1107,
4688,
2120,
997,
262,
4304,
32,
2536,
62035,
7698,
14781,
262,
1456,
512,
286,
374,
32825,
284,
528,
2120,
8,
624,
865,
198,
262,
3734,
320,
81176,
11,
15764,
997,
286,
471,
3641,
198,
262,
471,
374,
32825,
323,
865,
2669,
220,
15,
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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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,
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,
2536,
62035,
7698,
382,
14711,
6075,
512,
755,
374,
1107,
4688,
2120,
997,
262,
4304,
32,
2536,
62035,
7698,
14781,
262,
1456,
512,
286,
374,
32825,
284,
528,
2120,
8,
624,
865,
198,
262,
3734,
320,
81176,
11,
15764,
997,
286,
471,
3641,
198,
262,
471,
374,
32825,
323,
865,
2669,
220,
15,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
vertexproject/synapse | synapse/cortex.py | Cortex.addLayer | async def addLayer(self, **info):
'''
Add a Layer to the cortex.
Notes:
The addLayer ``**info`` arg is expected to be shaped like the following::
info = {
'iden': <str>, ( optional iden. default guid() )
'type': <str>, ( optional type. default lmdb )
'owner': <str>, ( optional owner. default root )
'config': {}, # type specific config options.
}
'''
iden = info.pop('iden', None)
if iden is None:
iden = s_common.guid()
node = await self.hive.open(('cortex', 'layers', iden))
layrinfo = await node.dict()
layrconf = await (await node.open(('config',))).dict()
await layrinfo.set('type', info.get('type', 'lmdb'))
await layrinfo.set('owner', info.get('owner', 'root'))
await layrinfo.set('name', info.get('name', '??'))
for name, valu in info.get('config', {}).items():
await layrconf.set(name, valu)
return await self._layrFromNode(node) | python | async def addLayer(self, **info):
'''
Add a Layer to the cortex.
Notes:
The addLayer ``**info`` arg is expected to be shaped like the following::
info = {
'iden': <str>, ( optional iden. default guid() )
'type': <str>, ( optional type. default lmdb )
'owner': <str>, ( optional owner. default root )
'config': {}, # type specific config options.
}
'''
iden = info.pop('iden', None)
if iden is None:
iden = s_common.guid()
node = await self.hive.open(('cortex', 'layers', iden))
layrinfo = await node.dict()
layrconf = await (await node.open(('config',))).dict()
await layrinfo.set('type', info.get('type', 'lmdb'))
await layrinfo.set('owner', info.get('owner', 'root'))
await layrinfo.set('name', info.get('name', '??'))
for name, valu in info.get('config', {}).items():
await layrconf.set(name, valu)
return await self._layrFromNode(node) | [
"async",
"def",
"addLayer",
"(",
"self",
",",
"*",
"*",
"info",
")",
":",
"iden",
"=",
"info",
".",
"pop",
"(",
"'iden'",
",",
"None",
")",
"if",
"iden",
"is",
"None",
":",
"iden",
"=",
"s_common",
".",
"guid",
"(",
")",
"node",
"=",
"await",
"self",
".",
"hive",
".",
"open",
"(",
"(",
"'cortex'",
",",
"'layers'",
",",
"iden",
")",
")",
"layrinfo",
"=",
"await",
"node",
".",
"dict",
"(",
")",
"layrconf",
"=",
"await",
"(",
"await",
"node",
".",
"open",
"(",
"(",
"'config'",
",",
")",
")",
")",
".",
"dict",
"(",
")",
"await",
"layrinfo",
".",
"set",
"(",
"'type'",
",",
"info",
".",
"get",
"(",
"'type'",
",",
"'lmdb'",
")",
")",
"await",
"layrinfo",
".",
"set",
"(",
"'owner'",
",",
"info",
".",
"get",
"(",
"'owner'",
",",
"'root'",
")",
")",
"await",
"layrinfo",
".",
"set",
"(",
"'name'",
",",
"info",
".",
"get",
"(",
"'name'",
",",
"'??'",
")",
")",
"for",
"name",
",",
"valu",
"in",
"info",
".",
"get",
"(",
"'config'",
",",
"{",
"}",
")",
".",
"items",
"(",
")",
":",
"await",
"layrconf",
".",
"set",
"(",
"name",
",",
"valu",
")",
"return",
"await",
"self",
".",
"_layrFromNode",
"(",
"node",
")"
] | Add a Layer to the cortex.
Notes:
The addLayer ``**info`` arg is expected to be shaped like the following::
info = {
'iden': <str>, ( optional iden. default guid() )
'type': <str>, ( optional type. default lmdb )
'owner': <str>, ( optional owner. default root )
'config': {}, # type specific config options.
} | [
"Add",
"a",
"Layer",
"to",
"the",
"cortex",
"."
] | train | https://github.com/vertexproject/synapse/blob/22e67c5a8f6d7caddbcf34b39ab1bd2d6c4a6e0b/synapse/cortex.py#L1070-L1102 | <|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 Layer to the cortex.
Notes:
The addLayer ``**info`` arg is expected to be shaped like the following::
info = {
'iden': <str>, ( optional iden. default guid() )
'type': <str>, ( optional type. default lmdb )
'owner': <str>, ( optional owner. default root )
'config': {}, # type specific config options.
}
### Response:
async def addLayer(self, **info):
'''
Add a Layer to the cortex.
Notes:
The addLayer ``**info`` arg is expected to be shaped like the following::
info = {
'iden': <str>, ( optional iden. default guid() )
'type': <str>, ( optional type. default lmdb )
'owner': <str>, ( optional owner. default root )
'config': {}, # type specific config options.
}
'''
iden = info.pop('iden', None)
if iden is None:
iden = s_common.guid()
node = await self.hive.open(('cortex', 'layers', iden))
layrinfo = await node.dict()
layrconf = await (await node.open(('config',))).dict()
await layrinfo.set('type', info.get('type', 'lmdb'))
await layrinfo.set('owner', info.get('owner', 'root'))
await layrinfo.set('name', info.get('name', '??'))
for name, valu in info.get('config', {}).items():
await layrconf.set(name, valu)
return await self._layrFromNode(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,
2261,
264,
23570,
311,
279,
49370,
382,
286,
18559,
1473,
310,
578,
923,
9368,
10103,
334,
2801,
14196,
1417,
374,
3685,
311,
387,
27367,
1093,
279,
2768,
66152,
394,
3630,
284,
341,
504,
364,
12770,
1232,
366,
496,
8226,
320,
10309,
887,
268,
13,
1670,
9840,
368,
1763,
504,
364,
1337,
1232,
366,
496,
8226,
320,
10309,
955,
13,
1670,
41338,
2042,
1763,
504,
364,
8281,
1232,
366,
496,
8226,
320,
10309,
6506,
13,
1670,
3789,
1763,
504,
364,
1710,
1232,
16857,
674,
955,
3230,
2242,
2671,
627,
394,
557,
14711,
6075,
512,
7847,
711,
923,
9368,
1214,
11,
3146,
2801,
997,
286,
11414,
286,
2758,
264,
23570,
311,
279,
49370,
382,
286,
18559,
1473,
310,
578,
923,
9368,
10103,
334,
2801,
14196,
1417,
374,
3685,
311,
387,
27367,
1093,
279,
2768,
66152,
394,
3630,
284,
341,
504,
364,
12770,
1232,
366,
496,
8226,
320,
10309,
887,
268,
13,
1670,
9840,
368,
1763,
504,
364,
1337,
1232,
366,
496,
8226,
320,
10309,
955,
13,
1670,
41338,
2042,
1763,
504,
364,
8281,
1232,
366,
496,
8226,
320,
10309,
6506,
13,
1670,
3789,
1763,
504,
364,
1710,
1232,
16857,
674,
955,
3230,
2242,
2671,
627,
394,
557,
286,
11414,
286,
887,
268,
284,
3630,
8452,
493,
12770,
518,
2290,
340,
286,
422,
887,
268,
374,
2290,
512,
310,
887,
268,
284,
274,
21790,
63994,
2892,
286,
2494,
284,
2597,
659,
870,
535,
5949,
46775,
66,
45692,
518,
364,
45298,
518,
887,
268,
4489,
286,
11203,
81,
2801,
284,
2597,
2494,
55877,
746,
286,
11203,
81,
6263,
284,
2597,
320,
11675,
2494,
5949,
46775,
1710,
518,
37434,
8644,
2892,
286,
2597,
11203,
81,
2801,
995,
493,
1337,
518,
3630,
673,
493,
1337,
518,
364,
18244,
2042,
7132,
286,
2597,
11203,
81,
2801,
995,
493,
8281,
518,
3630,
673,
493,
8281,
518,
364,
2959,
7132,
286,
2597,
11203,
81,
2801,
995,
493,
609,
518,
3630,
673,
493,
609,
518,
364,
7801,
25863,
286,
369,
836,
11,
94031,
304,
3630,
673,
493,
1710,
518,
73827,
3699,
4019,
310,
2597,
11203,
81,
6263,
995,
3232,
11,
94031,
696,
286,
471,
2597,
659,
1462,
6789,
81,
3915,
1997,
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
] | [
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
2261,
264,
23570,
311,
279,
49370,
382,
286,
18559,
1473,
310,
578,
923,
9368,
10103,
334,
2801,
14196,
1417,
374,
3685,
311,
387,
27367,
1093,
279,
2768,
66152,
394,
3630,
284,
341,
504,
364,
12770,
1232,
366,
496,
8226,
320,
10309,
887,
268,
13,
1670,
9840,
368,
1763,
504,
364,
1337,
1232,
366,
496,
8226,
320,
10309,
955,
13,
1670,
41338,
2042,
1763,
504,
364,
8281,
1232,
366,
496,
8226,
320,
10309,
6506,
13,
1670,
3789,
1763,
504,
364,
1710,
1232,
16857,
674,
955,
3230,
2242,
2671,
627,
394,
557,
14711,
6075,
512,
7847,
711,
923,
9368,
1214,
11,
3146,
2801,
997,
286,
11414,
286,
2758,
264,
23570,
311,
279,
49370,
382,
286,
18559,
1473,
310,
578,
923,
9368,
10103,
334,
2801,
14196,
1417,
374,
3685,
311,
387,
27367,
1093,
279,
2768,
66152,
394,
3630,
284,
341,
504,
364,
12770,
1232,
366,
496,
8226,
320,
10309,
887,
268,
13,
1670,
9840,
368,
1763,
504,
364,
1337,
1232,
366,
496,
8226,
320,
10309,
955,
13,
1670,
41338,
2042,
1763,
504,
364,
8281,
1232,
366,
496,
8226,
320,
10309,
6506,
13,
1670,
3789,
1763,
504,
364,
1710,
1232,
16857,
674,
955,
3230,
2242,
2671,
627,
394,
557,
286,
11414,
286,
887,
268,
284,
3630,
8452,
493,
12770,
518,
2290,
340,
286,
422,
887,
268,
374,
2290,
512,
310,
887,
268,
284,
274,
21790,
63994,
2892,
286,
2494,
284,
2597,
659,
870,
535,
5949,
46775,
66,
45692,
518,
364,
45298,
518,
887,
268,
4489,
286,
11203,
81,
2801,
284,
2597,
2494,
55877,
746,
286,
11203,
81,
6263,
284,
2597,
320,
11675,
2494,
5949,
46775,
1710,
518,
37434,
8644,
2892,
286,
2597,
11203,
81,
2801,
995,
493,
1337,
518,
3630,
673,
493,
1337,
518,
364,
18244,
2042,
7132,
286,
2597,
11203,
81,
2801,
995,
493,
8281,
518,
3630,
673,
493,
8281,
518,
364,
2959,
7132,
286,
2597,
11203,
81,
2801,
995,
493,
609,
518,
3630,
673,
493,
609,
518,
364,
7801,
25863,
286,
369,
836,
11,
94031,
304,
3630,
673,
493,
1710,
518,
73827,
3699,
4019,
310,
2597,
11203,
81,
6263,
995,
3232,
11,
94031,
696,
286,
471,
2597,
659,
1462,
6789,
81,
3915,
1997,
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
] |
linkhub-sdk/popbill.py | popbill/htCashbillService.py | HTCashbillService.requestJob | def requestJob(self, CorpNum, Type, SDate, EDate, UserID=None):
""" 수집 요청
args
CorpNum : 팝빌회원 사업자번호
Type : 문서형태, SELL-매출, BUY-매입,
SDate : 시작일자, 표시형식(yyyyMMdd)
EDate : 종료일자, 표시형식(yyyyMMdd)
UserID : 팝빌회원 아이디
return
작업아이디 (jobID)
raise
PopbillException
"""
if Type == None or Type == '':
raise PopbillException(-99999999, "문서형태이 입력되지 않았습니다.")
if SDate == None or SDate == '':
raise PopbillException(-99999999, "시작일자가 입력되지 않았습니다.")
if EDate == None or EDate == '':
raise PopbillException(-99999999, "종료일자가 입력되지 않았습니다.")
uri = '/HomeTax/Cashbill/' + Type
uri += '?SDate=' + SDate
uri += '&EDate=' + EDate
return self._httppost(uri, "", CorpNum, UserID).jobID | python | def requestJob(self, CorpNum, Type, SDate, EDate, UserID=None):
""" 수집 요청
args
CorpNum : 팝빌회원 사업자번호
Type : 문서형태, SELL-매출, BUY-매입,
SDate : 시작일자, 표시형식(yyyyMMdd)
EDate : 종료일자, 표시형식(yyyyMMdd)
UserID : 팝빌회원 아이디
return
작업아이디 (jobID)
raise
PopbillException
"""
if Type == None or Type == '':
raise PopbillException(-99999999, "문서형태이 입력되지 않았습니다.")
if SDate == None or SDate == '':
raise PopbillException(-99999999, "시작일자가 입력되지 않았습니다.")
if EDate == None or EDate == '':
raise PopbillException(-99999999, "종료일자가 입력되지 않았습니다.")
uri = '/HomeTax/Cashbill/' + Type
uri += '?SDate=' + SDate
uri += '&EDate=' + EDate
return self._httppost(uri, "", CorpNum, UserID).jobID | [
"def",
"requestJob",
"(",
"self",
",",
"CorpNum",
",",
"Type",
",",
"SDate",
",",
"EDate",
",",
"UserID",
"=",
"None",
")",
":",
"if",
"Type",
"==",
"None",
"or",
"Type",
"==",
"''",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
",",
"\"문서형태이 입력되지 않았습니다.\")",
"",
"if",
"SDate",
"==",
"None",
"or",
"SDate",
"==",
"''",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
",",
"\"시작일자가 입력되지 않았습니다.\")",
"",
"if",
"EDate",
"==",
"None",
"or",
"EDate",
"==",
"''",
":",
"raise",
"PopbillException",
"(",
"-",
"99999999",
",",
"\"종료일자가 입력되지 않았습니다.\")",
"",
"uri",
"=",
"'/HomeTax/Cashbill/'",
"+",
"Type",
"uri",
"+=",
"'?SDate='",
"+",
"SDate",
"uri",
"+=",
"'&EDate='",
"+",
"EDate",
"return",
"self",
".",
"_httppost",
"(",
"uri",
",",
"\"\"",
",",
"CorpNum",
",",
"UserID",
")",
".",
"jobID"
] | 수집 요청
args
CorpNum : 팝빌회원 사업자번호
Type : 문서형태, SELL-매출, BUY-매입,
SDate : 시작일자, 표시형식(yyyyMMdd)
EDate : 종료일자, 표시형식(yyyyMMdd)
UserID : 팝빌회원 아이디
return
작업아이디 (jobID)
raise
PopbillException | [
"수집",
"요청",
"args",
"CorpNum",
":",
"팝빌회원",
"사업자번호",
"Type",
":",
"문서형태",
"SELL",
"-",
"매출",
"BUY",
"-",
"매입",
"SDate",
":",
"시작일자",
"표시형식",
"(",
"yyyyMMdd",
")",
"EDate",
":",
"종료일자",
"표시형식",
"(",
"yyyyMMdd",
")",
"UserID",
":",
"팝빌회원",
"아이디",
"return",
"작업아이디",
"(",
"jobID",
")",
"raise",
"PopbillException"
] | train | https://github.com/linkhub-sdk/popbill.py/blob/68a0dd7f7a937603318e93be321fde73c50b96cc/popbill/htCashbillService.py#L41-L68 | <|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
CorpNum : 팝빌회원 사업자번호
Type : 문서형태, SELL-매출, BUY-매입,
SDate : 시작일자, 표시형식(yyyyMMdd)
EDate : 종료일자, 표시형식(yyyyMMdd)
UserID : 팝빌회원 아이디
return
작업아이디 (jobID)
raise
PopbillException
### Response:
def requestJob(self, CorpNum, Type, SDate, EDate, UserID=None):
""" 수집 요청
args
CorpNum : 팝빌회원 사업자번호
Type : 문서형태, SELL-매출, BUY-매입,
SDate : 시작일자, 표시형식(yyyyMMdd)
EDate : 종료일자, 표시형식(yyyyMMdd)
UserID : 팝빌회원 아이디
return
작업아이디 (jobID)
raise
PopbillException
"""
if Type == None or Type == '':
raise PopbillException(-99999999, "문서형태이 입력되지 않았습니다.")
if SDate == None or SDate == '':
raise PopbillException(-99999999, "시작일자가 입력되지 않았습니다.")
if EDate == None or EDate == '':
raise PopbillException(-99999999, "종료일자가 입력되지 않았습니다.")
uri = '/HomeTax/Cashbill/' + Type
uri += '?SDate=' + SDate
uri += '&EDate=' + EDate
return self._httppost(uri, "", CorpNum, UserID).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,
24140,
102201,
127296,
198,
310,
2897,
198,
394,
22621,
4755,
551,
46204,
251,
116964,
62841,
55421,
115888,
26799,
73148,
198,
394,
4078,
551,
117294,
102193,
87472,
11,
328,
19659,
12,
101518,
71023,
11,
52862,
12,
101518,
44966,
345,
394,
328,
1956,
551,
94821,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
469,
1956,
551,
99458,
64356,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
69667,
551,
46204,
251,
116964,
62841,
55421,
125998,
198,
310,
471,
198,
394,
121002,
114714,
90335,
320,
8975,
926,
340,
310,
4933,
198,
394,
10466,
30742,
1378,
271,
14711,
6075,
512,
755,
1715,
12524,
1214,
11,
22621,
4755,
11,
4078,
11,
328,
1956,
11,
469,
1956,
11,
69667,
5980,
997,
286,
4304,
29833,
102201,
127296,
198,
310,
2897,
198,
394,
22621,
4755,
551,
46204,
251,
116964,
62841,
55421,
115888,
26799,
73148,
198,
394,
4078,
551,
117294,
102193,
87472,
11,
328,
19659,
12,
101518,
71023,
11,
52862,
12,
101518,
44966,
345,
394,
328,
1956,
551,
94821,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
469,
1956,
551,
99458,
64356,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
69667,
551,
46204,
251,
116964,
62841,
55421,
125998,
198,
310,
471,
198,
394,
121002,
114714,
90335,
320,
8975,
926,
340,
310,
4933,
198,
394,
10466,
30742,
1378,
198,
286,
12713,
286,
422,
4078,
624,
2290,
477,
4078,
624,
49215,
310,
4933,
10466,
30742,
1378,
4172,
5500,
5500,
1484,
11,
330,
52688,
27796,
102193,
87472,
13094,
43449,
119222,
116154,
39331,
32325,
286,
422,
328,
1956,
624,
2290,
477,
328,
1956,
624,
49215,
310,
4933,
10466,
30742,
1378,
4172,
5500,
5500,
1484,
11,
330,
30426,
68611,
33177,
108181,
43449,
119222,
116154,
39331,
32325,
286,
422,
469,
1956,
624,
2290,
477,
469,
1956,
624,
49215,
310,
4933,
10466,
30742,
1378,
4172,
5500,
5500,
1484,
11,
330,
102757,
64356,
33177,
108181,
43449,
119222,
116154,
39331,
32325,
286,
13371,
284,
3434,
7778,
32449,
11547,
1003,
30742,
11576,
489,
4078,
198,
286,
13371,
1447,
32167,
50,
1956,
1151,
489,
328,
1956,
198,
286,
13371,
1447,
15065,
1507,
349,
1151,
489,
469,
1956,
271,
286,
471,
659,
1462,
97436,
604,
537,
26882,
11,
7492,
22621,
4755,
11,
69667,
570,
8975,
926,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
24140,
102201,
127296,
198,
310,
2897,
198,
394,
22621,
4755,
551,
46204,
251,
116964,
62841,
55421,
115888,
26799,
73148,
198,
394,
4078,
551,
117294,
102193,
87472,
11,
328,
19659,
12,
101518,
71023,
11,
52862,
12,
101518,
44966,
345,
394,
328,
1956,
551,
94821,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
469,
1956,
551,
99458,
64356,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
69667,
551,
46204,
251,
116964,
62841,
55421,
125998,
198,
310,
471,
198,
394,
121002,
114714,
90335,
320,
8975,
926,
340,
310,
4933,
198,
394,
10466,
30742,
1378,
271,
14711,
6075,
512,
755,
1715,
12524,
1214,
11,
22621,
4755,
11,
4078,
11,
328,
1956,
11,
469,
1956,
11,
69667,
5980,
997,
286,
4304,
29833,
102201,
127296,
198,
310,
2897,
198,
394,
22621,
4755,
551,
46204,
251,
116964,
62841,
55421,
115888,
26799,
73148,
198,
394,
4078,
551,
117294,
102193,
87472,
11,
328,
19659,
12,
101518,
71023,
11,
52862,
12,
101518,
44966,
345,
394,
328,
1956,
551,
94821,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
469,
1956,
551,
99458,
64356,
33177,
26799,
11,
125538,
102193,
77437,
7,
79331,
340,
394,
69667,
551,
46204,
251,
116964,
62841,
55421,
125998,
198,
310,
471,
198,
394,
121002,
114714,
90335,
320,
8975,
926,
340,
310,
4933,
198,
394,
10466,
30742,
1378,
198,
286,
12713,
286,
422,
4078,
624,
2290,
477,
4078,
624,
49215,
310,
4933,
10466,
30742,
1378,
4172,
5500,
5500,
1484,
11,
330,
52688,
27796,
102193,
87472,
13094,
43449,
119222,
116154,
39331,
32325,
286,
422,
328,
1956,
624,
2290,
477,
328,
1956,
624,
49215,
310,
4933,
10466,
30742,
1378,
4172,
5500,
5500,
1484,
11,
330,
30426,
68611,
33177,
108181,
43449,
119222,
116154,
39331,
32325,
286,
422,
469,
1956,
624,
2290,
477,
469,
1956,
624,
49215,
310,
4933,
10466,
30742,
1378,
4172,
5500,
5500,
1484,
11,
330,
102757,
64356,
33177,
108181,
43449,
119222,
116154,
39331,
32325,
286,
13371,
284,
3434,
7778,
32449,
11547,
1003,
30742,
11576,
489,
4078,
198,
286,
13371,
1447,
32167,
50,
1956,
1151,
489,
328,
1956,
198,
286,
13371,
1447,
15065,
1507,
349,
1151,
489,
469,
1956,
271,
286,
471,
659,
1462,
97436,
604,
537,
26882,
11,
7492,
22621,
4755,
11,
69667,
570,
8975,
926,
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
] |
ralphbean/taskw | taskw/warrior.py | TaskWarriorDirect.task_delete | def task_delete(self, **kw):
"""
Marks a task as deleted, optionally specifying a completion
date with the 'end' argument.
"""
def validate(task):
if task['status'] == Status.DELETED:
raise ValueError("Task is already deleted.")
return self._task_change_status(Status.DELETED, validate, **kw) | python | def task_delete(self, **kw):
"""
Marks a task as deleted, optionally specifying a completion
date with the 'end' argument.
"""
def validate(task):
if task['status'] == Status.DELETED:
raise ValueError("Task is already deleted.")
return self._task_change_status(Status.DELETED, validate, **kw) | [
"def",
"task_delete",
"(",
"self",
",",
"*",
"*",
"kw",
")",
":",
"def",
"validate",
"(",
"task",
")",
":",
"if",
"task",
"[",
"'status'",
"]",
"==",
"Status",
".",
"DELETED",
":",
"raise",
"ValueError",
"(",
"\"Task is already deleted.\"",
")",
"return",
"self",
".",
"_task_change_status",
"(",
"Status",
".",
"DELETED",
",",
"validate",
",",
"*",
"*",
"kw",
")"
] | Marks a task as deleted, optionally specifying a completion
date with the 'end' argument. | [
"Marks",
"a",
"task",
"as",
"deleted",
"optionally",
"specifying",
"a",
"completion",
"date",
"with",
"the",
"end",
"argument",
"."
] | train | https://github.com/ralphbean/taskw/blob/11e2f9132eaedd157f514538de9b5f3b69c30a52/taskw/warrior.py#L319-L328 | <|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:
Marks a task as deleted, optionally specifying a completion
date with the 'end' argument.
### Response:
def task_delete(self, **kw):
"""
Marks a task as deleted, optionally specifying a completion
date with the 'end' argument.
"""
def validate(task):
if task['status'] == Status.DELETED:
raise ValueError("Task is already deleted.")
return self._task_change_status(Status.DELETED, validate, **kw)
<|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,
90470,
264,
3465,
439,
11309,
11,
46624,
38938,
264,
9954,
198,
286,
2457,
449,
279,
364,
408,
6,
5811,
382,
14711,
6075,
512,
755,
3465,
11607,
1214,
11,
3146,
29700,
997,
286,
3270,
286,
49195,
264,
3465,
439,
11309,
11,
46624,
38938,
264,
9954,
198,
286,
2457,
449,
279,
364,
408,
6,
5811,
627,
286,
3270,
286,
711,
9788,
17941,
997,
310,
422,
3465,
681,
2899,
663,
624,
8266,
10813,
57586,
512,
394,
4933,
15764,
446,
6396,
374,
2736,
11309,
32325,
286,
471,
659,
1462,
8366,
16326,
4878,
39966,
10813,
57586,
11,
9788,
11,
3146,
29700,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
90470,
264,
3465,
439,
11309,
11,
46624,
38938,
264,
9954,
198,
286,
2457,
449,
279,
364,
408,
6,
5811,
382,
14711,
6075,
512,
755,
3465,
11607,
1214,
11,
3146,
29700,
997,
286,
3270,
286,
49195,
264,
3465,
439,
11309,
11,
46624,
38938,
264,
9954,
198,
286,
2457,
449,
279,
364,
408,
6,
5811,
627,
286,
3270,
286,
711,
9788,
17941,
997,
310,
422,
3465,
681,
2899,
663,
624,
8266,
10813,
57586,
512,
394,
4933,
15764,
446,
6396,
374,
2736,
11309,
32325,
286,
471,
659,
1462,
8366,
16326,
4878,
39966,
10813,
57586,
11,
9788,
11,
3146,
29700,
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
] |
pytroll/pyspectral | rsr_convert_scripts/oli_reader.py | OliRSR._load | def _load(self, scale=0.001):
"""Load the Landsat OLI relative spectral responses
"""
with open_workbook(self.path) as wb_:
for sheet in wb_.sheets():
if sheet.name in ['Plot of AllBands', ]:
continue
ch_name = OLI_BAND_NAMES.get(sheet.name.strip())
if ch_name != self.bandname:
continue
wvl = sheet.col_values(0, 2)
resp = sheet.col_values(1, 2)
self.rsr = {'wavelength': np.array(wvl) / 1000.,
'response': np.array(resp)}
break | python | def _load(self, scale=0.001):
"""Load the Landsat OLI relative spectral responses
"""
with open_workbook(self.path) as wb_:
for sheet in wb_.sheets():
if sheet.name in ['Plot of AllBands', ]:
continue
ch_name = OLI_BAND_NAMES.get(sheet.name.strip())
if ch_name != self.bandname:
continue
wvl = sheet.col_values(0, 2)
resp = sheet.col_values(1, 2)
self.rsr = {'wavelength': np.array(wvl) / 1000.,
'response': np.array(resp)}
break | [
"def",
"_load",
"(",
"self",
",",
"scale",
"=",
"0.001",
")",
":",
"with",
"open_workbook",
"(",
"self",
".",
"path",
")",
"as",
"wb_",
":",
"for",
"sheet",
"in",
"wb_",
".",
"sheets",
"(",
")",
":",
"if",
"sheet",
".",
"name",
"in",
"[",
"'Plot of AllBands'",
",",
"]",
":",
"continue",
"ch_name",
"=",
"OLI_BAND_NAMES",
".",
"get",
"(",
"sheet",
".",
"name",
".",
"strip",
"(",
")",
")",
"if",
"ch_name",
"!=",
"self",
".",
"bandname",
":",
"continue",
"wvl",
"=",
"sheet",
".",
"col_values",
"(",
"0",
",",
"2",
")",
"resp",
"=",
"sheet",
".",
"col_values",
"(",
"1",
",",
"2",
")",
"self",
".",
"rsr",
"=",
"{",
"'wavelength'",
":",
"np",
".",
"array",
"(",
"wvl",
")",
"/",
"1000.",
",",
"'response'",
":",
"np",
".",
"array",
"(",
"resp",
")",
"}",
"break"
] | Load the Landsat OLI relative spectral responses | [
"Load",
"the",
"Landsat",
"OLI",
"relative",
"spectral",
"responses"
] | train | https://github.com/pytroll/pyspectral/blob/fd296c0e0bdf5364fa180134a1292665d6bc50a3/rsr_convert_scripts/oli_reader.py#L67-L85 | <|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:
Load the Landsat OLI relative spectral responses
### Response:
def _load(self, scale=0.001):
"""Load the Landsat OLI relative spectral responses
"""
with open_workbook(self.path) as wb_:
for sheet in wb_.sheets():
if sheet.name in ['Plot of AllBands', ]:
continue
ch_name = OLI_BAND_NAMES.get(sheet.name.strip())
if ch_name != self.bandname:
continue
wvl = sheet.col_values(0, 2)
resp = sheet.col_values(1, 2)
self.rsr = {'wavelength': np.array(wvl) / 1000.,
'response': np.array(resp)}
break
<|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,
6003,
279,
38523,
266,
507,
19046,
8844,
57077,
14847,
271,
14711,
6075,
512,
755,
721,
1096,
1214,
11,
5569,
28,
15,
13,
4119,
997,
286,
4304,
6003,
279,
38523,
266,
507,
19046,
8844,
57077,
14847,
198,
286,
12713,
286,
449,
1825,
11757,
2239,
1214,
3960,
8,
439,
38958,
62,
512,
310,
369,
11071,
304,
38958,
5056,
92537,
4019,
394,
422,
11071,
2710,
304,
2570,
26687,
315,
2052,
33,
2914,
518,
2331,
512,
504,
3136,
198,
394,
523,
1292,
284,
507,
19046,
79368,
25872,
673,
62780,
2710,
17624,
12647,
394,
422,
523,
1292,
976,
659,
75339,
609,
512,
504,
3136,
271,
394,
289,
14878,
284,
11071,
13720,
9324,
7,
15,
11,
220,
17,
340,
394,
9216,
284,
11071,
13720,
9324,
7,
16,
11,
220,
17,
696,
394,
659,
1783,
15444,
284,
5473,
86,
35961,
1232,
2660,
7382,
3706,
14878,
8,
611,
220,
1041,
15,
39188,
1014,
364,
2376,
1232,
2660,
7382,
20882,
10792,
394,
1464,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
266,
507,
19046,
8844,
57077,
14847,
271,
14711,
6075,
512,
755,
721,
1096,
1214,
11,
5569,
28,
15,
13,
4119,
997,
286,
4304,
6003,
279,
38523,
266,
507,
19046,
8844,
57077,
14847,
198,
286,
12713,
286,
449,
1825,
11757,
2239,
1214,
3960,
8,
439,
38958,
62,
512,
310,
369,
11071,
304,
38958,
5056,
92537,
4019,
394,
422,
11071,
2710,
304,
2570,
26687,
315,
2052,
33,
2914,
518,
2331,
512,
504,
3136,
198,
394,
523,
1292,
284,
507,
19046,
79368,
25872,
673,
62780,
2710,
17624,
12647,
394,
422,
523,
1292,
976,
659,
75339,
609,
512,
504,
3136,
271,
394,
289,
14878,
284,
11071,
13720,
9324,
7,
15,
11,
220,
17,
340,
394,
9216,
284,
11071,
13720,
9324,
7,
16,
11,
220,
17,
696,
394,
659,
1783,
15444,
284,
5473,
86,
35961,
1232,
2660,
7382,
3706,
14878,
8,
611,
220,
1041,
15,
39188,
1014,
364,
2376,
1232,
2660,
7382,
20882,
10792,
394,
1464,
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
] |
mlperf/training | image_classification/tensorflow/official/resnet/imagenet_main.py | _get_block_sizes | def _get_block_sizes(resnet_size):
"""Retrieve the size of each block_layer in the ResNet model.
The number of block layers used for the Resnet model varies according
to the size of the model. This helper grabs the layer set we want, throwing
an error if a non-standard size has been selected.
Args:
resnet_size: The number of convolutional layers needed in the model.
Returns:
A list of block sizes to use in building the model.
Raises:
KeyError: if invalid resnet_size is received.
"""
choices = {
18: [2, 2, 2, 2],
34: [3, 4, 6, 3],
50: [3, 4, 6, 3],
101: [3, 4, 23, 3],
152: [3, 8, 36, 3],
200: [3, 24, 36, 3]
}
try:
return choices[resnet_size]
except KeyError:
err = ('Could not find layers for selected Resnet size.\n'
'Size received: {}; sizes allowed: {}.'.format(
resnet_size, choices.keys()))
raise ValueError(err) | python | def _get_block_sizes(resnet_size):
"""Retrieve the size of each block_layer in the ResNet model.
The number of block layers used for the Resnet model varies according
to the size of the model. This helper grabs the layer set we want, throwing
an error if a non-standard size has been selected.
Args:
resnet_size: The number of convolutional layers needed in the model.
Returns:
A list of block sizes to use in building the model.
Raises:
KeyError: if invalid resnet_size is received.
"""
choices = {
18: [2, 2, 2, 2],
34: [3, 4, 6, 3],
50: [3, 4, 6, 3],
101: [3, 4, 23, 3],
152: [3, 8, 36, 3],
200: [3, 24, 36, 3]
}
try:
return choices[resnet_size]
except KeyError:
err = ('Could not find layers for selected Resnet size.\n'
'Size received: {}; sizes allowed: {}.'.format(
resnet_size, choices.keys()))
raise ValueError(err) | [
"def",
"_get_block_sizes",
"(",
"resnet_size",
")",
":",
"choices",
"=",
"{",
"18",
":",
"[",
"2",
",",
"2",
",",
"2",
",",
"2",
"]",
",",
"34",
":",
"[",
"3",
",",
"4",
",",
"6",
",",
"3",
"]",
",",
"50",
":",
"[",
"3",
",",
"4",
",",
"6",
",",
"3",
"]",
",",
"101",
":",
"[",
"3",
",",
"4",
",",
"23",
",",
"3",
"]",
",",
"152",
":",
"[",
"3",
",",
"8",
",",
"36",
",",
"3",
"]",
",",
"200",
":",
"[",
"3",
",",
"24",
",",
"36",
",",
"3",
"]",
"}",
"try",
":",
"return",
"choices",
"[",
"resnet_size",
"]",
"except",
"KeyError",
":",
"err",
"=",
"(",
"'Could not find layers for selected Resnet size.\\n'",
"'Size received: {}; sizes allowed: {}.'",
".",
"format",
"(",
"resnet_size",
",",
"choices",
".",
"keys",
"(",
")",
")",
")",
"raise",
"ValueError",
"(",
"err",
")"
] | Retrieve the size of each block_layer in the ResNet model.
The number of block layers used for the Resnet model varies according
to the size of the model. This helper grabs the layer set we want, throwing
an error if a non-standard size has been selected.
Args:
resnet_size: The number of convolutional layers needed in the model.
Returns:
A list of block sizes to use in building the model.
Raises:
KeyError: if invalid resnet_size is received. | [
"Retrieve",
"the",
"size",
"of",
"each",
"block_layer",
"in",
"the",
"ResNet",
"model",
"."
] | train | https://github.com/mlperf/training/blob/1c6ae725a81d15437a2b2df05cac0673fde5c3a4/image_classification/tensorflow/official/resnet/imagenet_main.py#L242-L273 | <|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 the size of each block_layer in the ResNet model.
The number of block layers used for the Resnet model varies according
to the size of the model. This helper grabs the layer set we want, throwing
an error if a non-standard size has been selected.
Args:
resnet_size: The number of convolutional layers needed in the model.
Returns:
A list of block sizes to use in building the model.
Raises:
KeyError: if invalid resnet_size is received.
### Response:
def _get_block_sizes(resnet_size):
"""Retrieve the size of each block_layer in the ResNet model.
The number of block layers used for the Resnet model varies according
to the size of the model. This helper grabs the layer set we want, throwing
an error if a non-standard size has been selected.
Args:
resnet_size: The number of convolutional layers needed in the model.
Returns:
A list of block sizes to use in building the model.
Raises:
KeyError: if invalid resnet_size is received.
"""
choices = {
18: [2, 2, 2, 2],
34: [3, 4, 6, 3],
50: [3, 4, 6, 3],
101: [3, 4, 23, 3],
152: [3, 8, 36, 3],
200: [3, 24, 36, 3]
}
try:
return choices[resnet_size]
except KeyError:
err = ('Could not find layers for selected Resnet size.\n'
'Size received: {}; sizes allowed: {}.'.format(
resnet_size, choices.keys()))
raise ValueError(err)
<|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,
279,
1404,
315,
1855,
2565,
12969,
304,
279,
1838,
7099,
1646,
382,
220,
578,
1396,
315,
2565,
13931,
1511,
369,
279,
1838,
4816,
1646,
35327,
4184,
198,
220,
311,
279,
1404,
315,
279,
1646,
13,
1115,
13438,
49155,
279,
6324,
743,
584,
1390,
11,
21939,
198,
220,
459,
1493,
422,
264,
2536,
54920,
1404,
706,
1027,
4183,
382,
220,
18161,
512,
262,
594,
4816,
2424,
25,
578,
1396,
315,
56812,
278,
13931,
4460,
304,
279,
1646,
382,
220,
5295,
512,
262,
362,
1160,
315,
2565,
12562,
311,
1005,
304,
4857,
279,
1646,
382,
220,
61411,
512,
262,
39194,
25,
422,
8482,
594,
4816,
2424,
374,
4036,
382,
14711,
6075,
512,
755,
721,
456,
7258,
33259,
4693,
4816,
2424,
997,
220,
4304,
88765,
279,
1404,
315,
1855,
2565,
12969,
304,
279,
1838,
7099,
1646,
382,
220,
578,
1396,
315,
2565,
13931,
1511,
369,
279,
1838,
4816,
1646,
35327,
4184,
198,
220,
311,
279,
1404,
315,
279,
1646,
13,
1115,
13438,
49155,
279,
6324,
743,
584,
1390,
11,
21939,
198,
220,
459,
1493,
422,
264,
2536,
54920,
1404,
706,
1027,
4183,
382,
220,
18161,
512,
262,
594,
4816,
2424,
25,
578,
1396,
315,
56812,
278,
13931,
4460,
304,
279,
1646,
382,
220,
5295,
512,
262,
362,
1160,
315,
2565,
12562,
311,
1005,
304,
4857,
279,
1646,
382,
220,
61411,
512,
262,
39194,
25,
422,
8482,
594,
4816,
2424,
374,
4036,
627,
220,
3270,
220,
11709,
284,
341,
415,
220,
972,
25,
510,
17,
11,
220,
17,
11,
220,
17,
11,
220,
17,
1282,
415,
220,
1958,
25,
510,
18,
11,
220,
19,
11,
220,
21,
11,
220,
18,
1282,
415,
220,
1135,
25,
510,
18,
11,
220,
19,
11,
220,
21,
11,
220,
18,
1282,
415,
220,
4645,
25,
510,
18,
11,
220,
19,
11,
220,
1419,
11,
220,
18,
1282,
415,
220,
9756,
25,
510,
18,
11,
220,
23,
11,
220,
1927,
11,
220,
18,
1282,
415,
220,
1049,
25,
510,
18,
11,
220,
1187,
11,
220,
1927,
11,
220,
18,
933,
220,
557,
220,
1456,
512,
262,
471,
11709,
95490,
4816,
2424,
933,
220,
3734,
39194,
512,
262,
1886,
284,
4417,
13191,
539,
1505,
13931,
369,
4183,
1838,
4816,
1404,
7255,
77,
1270,
1881,
364,
1730,
4036,
25,
53266,
12562,
5535,
25,
4792,
37049,
2293,
1021,
2342,
594,
4816,
2424,
11,
11709,
9301,
12419,
262,
4933,
15764,
4052,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
279,
1404,
315,
1855,
2565,
12969,
304,
279,
1838,
7099,
1646,
382,
220,
578,
1396,
315,
2565,
13931,
1511,
369,
279,
1838,
4816,
1646,
35327,
4184,
198,
220,
311,
279,
1404,
315,
279,
1646,
13,
1115,
13438,
49155,
279,
6324,
743,
584,
1390,
11,
21939,
198,
220,
459,
1493,
422,
264,
2536,
54920,
1404,
706,
1027,
4183,
382,
220,
18161,
512,
262,
594,
4816,
2424,
25,
578,
1396,
315,
56812,
278,
13931,
4460,
304,
279,
1646,
382,
220,
5295,
512,
262,
362,
1160,
315,
2565,
12562,
311,
1005,
304,
4857,
279,
1646,
382,
220,
61411,
512,
262,
39194,
25,
422,
8482,
594,
4816,
2424,
374,
4036,
382,
14711,
6075,
512,
755,
721,
456,
7258,
33259,
4693,
4816,
2424,
997,
220,
4304,
88765,
279,
1404,
315,
1855,
2565,
12969,
304,
279,
1838,
7099,
1646,
382,
220,
578,
1396,
315,
2565,
13931,
1511,
369,
279,
1838,
4816,
1646,
35327,
4184,
198,
220,
311,
279,
1404,
315,
279,
1646,
13,
1115,
13438,
49155,
279,
6324,
743,
584,
1390,
11,
21939,
198,
220,
459,
1493,
422,
264,
2536,
54920,
1404,
706,
1027,
4183,
382,
220,
18161,
512,
262,
594,
4816,
2424,
25,
578,
1396,
315,
56812,
278,
13931,
4460,
304,
279,
1646,
382,
220,
5295,
512,
262,
362,
1160,
315,
2565,
12562,
311,
1005,
304,
4857,
279,
1646,
382,
220,
61411,
512,
262,
39194,
25,
422,
8482,
594,
4816,
2424,
374,
4036,
627,
220,
3270,
220,
11709,
284,
341,
415,
220,
972,
25,
510,
17,
11,
220,
17,
11,
220,
17,
11,
220,
17,
1282,
415,
220,
1958,
25,
510,
18,
11,
220,
19,
11,
220,
21,
11,
220,
18,
1282,
415,
220,
1135,
25,
510,
18,
11,
220,
19,
11,
220,
21,
11,
220,
18,
1282,
415,
220,
4645,
25,
510,
18,
11,
220,
19,
11,
220,
1419,
11,
220,
18,
1282,
415,
220,
9756,
25,
510,
18,
11,
220,
23,
11,
220,
1927,
11,
220,
18,
1282,
415,
220,
1049,
25,
510,
18,
11,
220,
1187,
11,
220,
1927,
11,
220,
18,
933,
220,
557,
220,
1456,
512,
262,
471,
11709,
95490,
4816,
2424,
933,
220,
3734,
39194,
512,
262,
1886,
284,
4417,
13191,
539,
1505,
13931,
369,
4183,
1838,
4816,
1404,
7255,
77,
1270,
1881,
364,
1730,
4036,
25,
53266,
12562,
5535,
25,
4792,
37049,
2293,
1021,
2342,
594,
4816,
2424,
11,
11709,
9301,
12419,
262,
4933,
15764,
4052,
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
] |
opendatateam/udata | udata/core/user/commands.py | delete | def delete():
'''Delete an existing user'''
email = click.prompt('Email')
user = User.objects(email=email).first()
if not user:
exit_with_error('Invalid user')
user.delete()
success('User deleted successfully') | python | def delete():
'''Delete an existing user'''
email = click.prompt('Email')
user = User.objects(email=email).first()
if not user:
exit_with_error('Invalid user')
user.delete()
success('User deleted successfully') | [
"def",
"delete",
"(",
")",
":",
"email",
"=",
"click",
".",
"prompt",
"(",
"'Email'",
")",
"user",
"=",
"User",
".",
"objects",
"(",
"email",
"=",
"email",
")",
".",
"first",
"(",
")",
"if",
"not",
"user",
":",
"exit_with_error",
"(",
"'Invalid user'",
")",
"user",
".",
"delete",
"(",
")",
"success",
"(",
"'User deleted successfully'",
")"
] | Delete an existing user | [
"Delete",
"an",
"existing",
"user"
] | train | https://github.com/opendatateam/udata/blob/f016585af94b0ff6bd73738c700324adc8ba7f8f/udata/core/user/commands.py#L66-L73 | <|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 an existing user
### Response:
def delete():
'''Delete an existing user'''
email = click.prompt('Email')
user = User.objects(email=email).first()
if not user:
exit_with_error('Invalid user')
user.delete()
success('User deleted successfully')
<|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,
459,
6484,
1217,
271,
14711,
6075,
512,
755,
3783,
4019,
262,
11712,
6571,
459,
6484,
1217,
15029,
262,
2613,
284,
4299,
66499,
493,
4886,
1329,
262,
1217,
284,
2724,
8549,
18411,
77471,
570,
3983,
746,
262,
422,
539,
1217,
512,
286,
4974,
6753,
4188,
493,
8087,
1217,
1329,
262,
1217,
7592,
746,
262,
2450,
493,
1502,
11309,
7946,
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,
128009,
128009,
128009,
128009,
128009,
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,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323,
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
6571,
459,
6484,
1217,
271,
14711,
6075,
512,
755,
3783,
4019,
262,
11712,
6571,
459,
6484,
1217,
15029,
262,
2613,
284,
4299,
66499,
493,
4886,
1329,
262,
1217,
284,
2724,
8549,
18411,
77471,
570,
3983,
746,
262,
422,
539,
1217,
512,
286,
4974,
6753,
4188,
493,
8087,
1217,
1329,
262,
1217,
7592,
746,
262,
2450,
493,
1502,
11309,
7946,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
geophysics-ubonn/reda | lib/reda/utils/geom_fac_crtomo.py | compute_K | def compute_K(dataframe, settings, keep_dir=False):
"""
Parameters
----------
dataframe: pandas.DataFrame
dataframe that contains the data
settings: dict
with required settings, see below
keep_dir: path
if not None, copy modeling dir here
settings = {
'rho': 100, # resistivity to use for homogeneous model, [Ohm m]
'elem'
'elec'
'2D' : True|False
'sink_node': '100',
}
"""
if settings is None:
print('using default settings')
settings = get_default_settings()
if not os.path.isfile(settings['elem']):
raise IOError(
'elem file not found: {0}'.format(settings['elem'])
)
if not os.path.isfile(settings['elec']):
raise IOError(
'elec file not found: {0}'.format(settings['elec'])
)
# read grid file and determine nr of cells
with open(settings['elem'], 'r') as fid:
fid.readline()
cell_type, cell_number, edge_number = np.fromstring(
fid.readline().strip(),
sep=' ',
dtype=int,
)
# generate forward model as a string
forward_model = '{0}\n'.format(cell_number)
forward_model += '{0} {1}\n'.format(settings['rho'], 0) * cell_number
full_path_elem = os.path.abspath(settings['elem'])
full_path_elec = os.path.abspath(settings['elec'])
pwd = os.getcwd()
with tempfile.TemporaryDirectory() as invdir:
os.chdir(invdir)
# create tomodir directory structure
for dir in [
'exe',
'mod',
'config',
'inv',
'grid',
'rho',
]:
os.makedirs(dir)
# save forward model
with open('rho/rho.dat', 'w') as fid:
fid.write(forward_model)
shutil.copy(full_path_elem, 'grid/elem.dat')
shutil.copy(full_path_elec, 'grid/elec.dat')
print('SETTINGS')
print(settings)
cfg = CRcfg.crmod_config()
if settings.get('2D', False):
# activate 2D mode
print('2D modeling')
cfg['2D'] = '0'
cfg['fictitious_sink'] = 'T'
cfg['sink_node'] = settings.get('sink_node')
else:
cfg['2D'] = 1
cfg.write_to_file('exe/crmod.cfg')
subprocess.call('cat exe/crmod.cfg', shell=True)
config_orig = _write_config_file('config/config.dat', dataframe)
os.chdir('exe')
binary = CRbinaries.get('CRMod')
subprocess.call(binary, shell=True)
os.chdir('..')
# read in results
modeled_resistances = np.loadtxt(
'mod/volt.dat',
skiprows=1,
)
# now we have to make sure CRMod didn't change the signs
changed_sign = (config_orig[:, 1] == modeled_resistances[:, 1])
modeled_resistances[~changed_sign, 2] *= -1
if settings.get('norm_factor', None) is not None:
modeled_resistances[:, 2] /= settings.get('norm_factor')
K = settings['rho'] / modeled_resistances[:, 2]
if isinstance(dataframe, pd.DataFrame):
dataframe['k'] = K
if keep_dir is not None and not os.path.isdir(keep_dir):
shutil.copytree('.', keep_dir)
print('Copy of modeling dir stored here: {}'.format(keep_dir))
os.chdir(pwd)
return K | python | def compute_K(dataframe, settings, keep_dir=False):
"""
Parameters
----------
dataframe: pandas.DataFrame
dataframe that contains the data
settings: dict
with required settings, see below
keep_dir: path
if not None, copy modeling dir here
settings = {
'rho': 100, # resistivity to use for homogeneous model, [Ohm m]
'elem'
'elec'
'2D' : True|False
'sink_node': '100',
}
"""
if settings is None:
print('using default settings')
settings = get_default_settings()
if not os.path.isfile(settings['elem']):
raise IOError(
'elem file not found: {0}'.format(settings['elem'])
)
if not os.path.isfile(settings['elec']):
raise IOError(
'elec file not found: {0}'.format(settings['elec'])
)
# read grid file and determine nr of cells
with open(settings['elem'], 'r') as fid:
fid.readline()
cell_type, cell_number, edge_number = np.fromstring(
fid.readline().strip(),
sep=' ',
dtype=int,
)
# generate forward model as a string
forward_model = '{0}\n'.format(cell_number)
forward_model += '{0} {1}\n'.format(settings['rho'], 0) * cell_number
full_path_elem = os.path.abspath(settings['elem'])
full_path_elec = os.path.abspath(settings['elec'])
pwd = os.getcwd()
with tempfile.TemporaryDirectory() as invdir:
os.chdir(invdir)
# create tomodir directory structure
for dir in [
'exe',
'mod',
'config',
'inv',
'grid',
'rho',
]:
os.makedirs(dir)
# save forward model
with open('rho/rho.dat', 'w') as fid:
fid.write(forward_model)
shutil.copy(full_path_elem, 'grid/elem.dat')
shutil.copy(full_path_elec, 'grid/elec.dat')
print('SETTINGS')
print(settings)
cfg = CRcfg.crmod_config()
if settings.get('2D', False):
# activate 2D mode
print('2D modeling')
cfg['2D'] = '0'
cfg['fictitious_sink'] = 'T'
cfg['sink_node'] = settings.get('sink_node')
else:
cfg['2D'] = 1
cfg.write_to_file('exe/crmod.cfg')
subprocess.call('cat exe/crmod.cfg', shell=True)
config_orig = _write_config_file('config/config.dat', dataframe)
os.chdir('exe')
binary = CRbinaries.get('CRMod')
subprocess.call(binary, shell=True)
os.chdir('..')
# read in results
modeled_resistances = np.loadtxt(
'mod/volt.dat',
skiprows=1,
)
# now we have to make sure CRMod didn't change the signs
changed_sign = (config_orig[:, 1] == modeled_resistances[:, 1])
modeled_resistances[~changed_sign, 2] *= -1
if settings.get('norm_factor', None) is not None:
modeled_resistances[:, 2] /= settings.get('norm_factor')
K = settings['rho'] / modeled_resistances[:, 2]
if isinstance(dataframe, pd.DataFrame):
dataframe['k'] = K
if keep_dir is not None and not os.path.isdir(keep_dir):
shutil.copytree('.', keep_dir)
print('Copy of modeling dir stored here: {}'.format(keep_dir))
os.chdir(pwd)
return K | [
"def",
"compute_K",
"(",
"dataframe",
",",
"settings",
",",
"keep_dir",
"=",
"False",
")",
":",
"if",
"settings",
"is",
"None",
":",
"print",
"(",
"'using default settings'",
")",
"settings",
"=",
"get_default_settings",
"(",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"settings",
"[",
"'elem'",
"]",
")",
":",
"raise",
"IOError",
"(",
"'elem file not found: {0}'",
".",
"format",
"(",
"settings",
"[",
"'elem'",
"]",
")",
")",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"settings",
"[",
"'elec'",
"]",
")",
":",
"raise",
"IOError",
"(",
"'elec file not found: {0}'",
".",
"format",
"(",
"settings",
"[",
"'elec'",
"]",
")",
")",
"# read grid file and determine nr of cells",
"with",
"open",
"(",
"settings",
"[",
"'elem'",
"]",
",",
"'r'",
")",
"as",
"fid",
":",
"fid",
".",
"readline",
"(",
")",
"cell_type",
",",
"cell_number",
",",
"edge_number",
"=",
"np",
".",
"fromstring",
"(",
"fid",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
",",
"sep",
"=",
"' '",
",",
"dtype",
"=",
"int",
",",
")",
"# generate forward model as a string",
"forward_model",
"=",
"'{0}\\n'",
".",
"format",
"(",
"cell_number",
")",
"forward_model",
"+=",
"'{0} {1}\\n'",
".",
"format",
"(",
"settings",
"[",
"'rho'",
"]",
",",
"0",
")",
"*",
"cell_number",
"full_path_elem",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"settings",
"[",
"'elem'",
"]",
")",
"full_path_elec",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"settings",
"[",
"'elec'",
"]",
")",
"pwd",
"=",
"os",
".",
"getcwd",
"(",
")",
"with",
"tempfile",
".",
"TemporaryDirectory",
"(",
")",
"as",
"invdir",
":",
"os",
".",
"chdir",
"(",
"invdir",
")",
"# create tomodir directory structure",
"for",
"dir",
"in",
"[",
"'exe'",
",",
"'mod'",
",",
"'config'",
",",
"'inv'",
",",
"'grid'",
",",
"'rho'",
",",
"]",
":",
"os",
".",
"makedirs",
"(",
"dir",
")",
"# save forward model",
"with",
"open",
"(",
"'rho/rho.dat'",
",",
"'w'",
")",
"as",
"fid",
":",
"fid",
".",
"write",
"(",
"forward_model",
")",
"shutil",
".",
"copy",
"(",
"full_path_elem",
",",
"'grid/elem.dat'",
")",
"shutil",
".",
"copy",
"(",
"full_path_elec",
",",
"'grid/elec.dat'",
")",
"print",
"(",
"'SETTINGS'",
")",
"print",
"(",
"settings",
")",
"cfg",
"=",
"CRcfg",
".",
"crmod_config",
"(",
")",
"if",
"settings",
".",
"get",
"(",
"'2D'",
",",
"False",
")",
":",
"# activate 2D mode",
"print",
"(",
"'2D modeling'",
")",
"cfg",
"[",
"'2D'",
"]",
"=",
"'0'",
"cfg",
"[",
"'fictitious_sink'",
"]",
"=",
"'T'",
"cfg",
"[",
"'sink_node'",
"]",
"=",
"settings",
".",
"get",
"(",
"'sink_node'",
")",
"else",
":",
"cfg",
"[",
"'2D'",
"]",
"=",
"1",
"cfg",
".",
"write_to_file",
"(",
"'exe/crmod.cfg'",
")",
"subprocess",
".",
"call",
"(",
"'cat exe/crmod.cfg'",
",",
"shell",
"=",
"True",
")",
"config_orig",
"=",
"_write_config_file",
"(",
"'config/config.dat'",
",",
"dataframe",
")",
"os",
".",
"chdir",
"(",
"'exe'",
")",
"binary",
"=",
"CRbinaries",
".",
"get",
"(",
"'CRMod'",
")",
"subprocess",
".",
"call",
"(",
"binary",
",",
"shell",
"=",
"True",
")",
"os",
".",
"chdir",
"(",
"'..'",
")",
"# read in results",
"modeled_resistances",
"=",
"np",
".",
"loadtxt",
"(",
"'mod/volt.dat'",
",",
"skiprows",
"=",
"1",
",",
")",
"# now we have to make sure CRMod didn't change the signs",
"changed_sign",
"=",
"(",
"config_orig",
"[",
":",
",",
"1",
"]",
"==",
"modeled_resistances",
"[",
":",
",",
"1",
"]",
")",
"modeled_resistances",
"[",
"~",
"changed_sign",
",",
"2",
"]",
"*=",
"-",
"1",
"if",
"settings",
".",
"get",
"(",
"'norm_factor'",
",",
"None",
")",
"is",
"not",
"None",
":",
"modeled_resistances",
"[",
":",
",",
"2",
"]",
"/=",
"settings",
".",
"get",
"(",
"'norm_factor'",
")",
"K",
"=",
"settings",
"[",
"'rho'",
"]",
"/",
"modeled_resistances",
"[",
":",
",",
"2",
"]",
"if",
"isinstance",
"(",
"dataframe",
",",
"pd",
".",
"DataFrame",
")",
":",
"dataframe",
"[",
"'k'",
"]",
"=",
"K",
"if",
"keep_dir",
"is",
"not",
"None",
"and",
"not",
"os",
".",
"path",
".",
"isdir",
"(",
"keep_dir",
")",
":",
"shutil",
".",
"copytree",
"(",
"'.'",
",",
"keep_dir",
")",
"print",
"(",
"'Copy of modeling dir stored here: {}'",
".",
"format",
"(",
"keep_dir",
")",
")",
"os",
".",
"chdir",
"(",
"pwd",
")",
"return",
"K"
] | Parameters
----------
dataframe: pandas.DataFrame
dataframe that contains the data
settings: dict
with required settings, see below
keep_dir: path
if not None, copy modeling dir here
settings = {
'rho': 100, # resistivity to use for homogeneous model, [Ohm m]
'elem'
'elec'
'2D' : True|False
'sink_node': '100',
} | [
"Parameters",
"----------",
"dataframe",
":",
"pandas",
".",
"DataFrame",
"dataframe",
"that",
"contains",
"the",
"data",
"settings",
":",
"dict",
"with",
"required",
"settings",
"see",
"below",
"keep_dir",
":",
"path",
"if",
"not",
"None",
"copy",
"modeling",
"dir",
"here"
] | train | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/geom_fac_crtomo.py#L78-L194 | <|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:
Parameters
----------
dataframe: pandas.DataFrame
dataframe that contains the data
settings: dict
with required settings, see below
keep_dir: path
if not None, copy modeling dir here
settings = {
'rho': 100, # resistivity to use for homogeneous model, [Ohm m]
'elem'
'elec'
'2D' : True|False
'sink_node': '100',
}
### Response:
def compute_K(dataframe, settings, keep_dir=False):
"""
Parameters
----------
dataframe: pandas.DataFrame
dataframe that contains the data
settings: dict
with required settings, see below
keep_dir: path
if not None, copy modeling dir here
settings = {
'rho': 100, # resistivity to use for homogeneous model, [Ohm m]
'elem'
'elec'
'2D' : True|False
'sink_node': '100',
}
"""
if settings is None:
print('using default settings')
settings = get_default_settings()
if not os.path.isfile(settings['elem']):
raise IOError(
'elem file not found: {0}'.format(settings['elem'])
)
if not os.path.isfile(settings['elec']):
raise IOError(
'elec file not found: {0}'.format(settings['elec'])
)
# read grid file and determine nr of cells
with open(settings['elem'], 'r') as fid:
fid.readline()
cell_type, cell_number, edge_number = np.fromstring(
fid.readline().strip(),
sep=' ',
dtype=int,
)
# generate forward model as a string
forward_model = '{0}\n'.format(cell_number)
forward_model += '{0} {1}\n'.format(settings['rho'], 0) * cell_number
full_path_elem = os.path.abspath(settings['elem'])
full_path_elec = os.path.abspath(settings['elec'])
pwd = os.getcwd()
with tempfile.TemporaryDirectory() as invdir:
os.chdir(invdir)
# create tomodir directory structure
for dir in [
'exe',
'mod',
'config',
'inv',
'grid',
'rho',
]:
os.makedirs(dir)
# save forward model
with open('rho/rho.dat', 'w') as fid:
fid.write(forward_model)
shutil.copy(full_path_elem, 'grid/elem.dat')
shutil.copy(full_path_elec, 'grid/elec.dat')
print('SETTINGS')
print(settings)
cfg = CRcfg.crmod_config()
if settings.get('2D', False):
# activate 2D mode
print('2D modeling')
cfg['2D'] = '0'
cfg['fictitious_sink'] = 'T'
cfg['sink_node'] = settings.get('sink_node')
else:
cfg['2D'] = 1
cfg.write_to_file('exe/crmod.cfg')
subprocess.call('cat exe/crmod.cfg', shell=True)
config_orig = _write_config_file('config/config.dat', dataframe)
os.chdir('exe')
binary = CRbinaries.get('CRMod')
subprocess.call(binary, shell=True)
os.chdir('..')
# read in results
modeled_resistances = np.loadtxt(
'mod/volt.dat',
skiprows=1,
)
# now we have to make sure CRMod didn't change the signs
changed_sign = (config_orig[:, 1] == modeled_resistances[:, 1])
modeled_resistances[~changed_sign, 2] *= -1
if settings.get('norm_factor', None) is not None:
modeled_resistances[:, 2] /= settings.get('norm_factor')
K = settings['rho'] / modeled_resistances[:, 2]
if isinstance(dataframe, pd.DataFrame):
dataframe['k'] = K
if keep_dir is not None and not os.path.isdir(keep_dir):
shutil.copytree('.', keep_dir)
print('Copy of modeling dir stored here: {}'.format(keep_dir))
os.chdir(pwd)
return K
<|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,
9905,
198,
262,
31423,
262,
39328,
25,
19130,
21756,
198,
286,
39328,
430,
5727,
279,
828,
198,
262,
5110,
25,
6587,
198,
286,
449,
2631,
5110,
11,
1518,
3770,
198,
262,
2567,
4432,
25,
1853,
198,
286,
422,
539,
2290,
11,
3048,
34579,
5534,
1618,
1432,
262,
5110,
284,
341,
286,
364,
41422,
1232,
220,
1041,
11,
220,
674,
22884,
1968,
311,
1005,
369,
87282,
1646,
11,
510,
12174,
76,
296,
933,
286,
364,
19403,
1270,
286,
364,
10274,
66,
1270,
286,
364,
17,
35,
6,
551,
3082,
91,
4139,
198,
286,
364,
67838,
5194,
1232,
364,
1041,
756,
262,
557,
14711,
6075,
512,
755,
12849,
10310,
2657,
6906,
11,
5110,
11,
2567,
4432,
5725,
997,
262,
3270,
262,
13831,
198,
262,
31423,
262,
39328,
25,
19130,
21756,
198,
286,
39328,
430,
5727,
279,
828,
198,
262,
5110,
25,
6587,
198,
286,
449,
2631,
5110,
11,
1518,
3770,
198,
262,
2567,
4432,
25,
1853,
198,
286,
422,
539,
2290,
11,
3048,
34579,
5534,
1618,
1432,
262,
5110,
284,
341,
286,
364,
41422,
1232,
220,
1041,
11,
220,
674,
22884,
1968,
311,
1005,
369,
87282,
1646,
11,
510,
12174,
76,
296,
933,
286,
364,
19403,
1270,
286,
364,
10274,
66,
1270,
286,
364,
17,
35,
6,
551,
3082,
91,
4139,
198,
286,
364,
67838,
5194,
1232,
364,
1041,
756,
262,
557,
262,
3270,
262,
422,
5110,
374,
2290,
512,
286,
1194,
493,
985,
1670,
5110,
1329,
286,
5110,
284,
636,
10198,
11090,
2892,
262,
422,
539,
2709,
3960,
40047,
24258,
681,
19403,
55802,
286,
4933,
62061,
1021,
310,
364,
19403,
1052,
539,
1766,
25,
314,
15,
24398,
2293,
24258,
681,
19403,
7519,
286,
5235,
262,
422,
539,
2709,
3960,
40047,
24258,
681,
10274,
66,
55802,
286,
4933,
62061,
1021,
310,
364,
10274,
66,
1052,
539,
1766,
25,
314,
15,
24398,
2293,
24258,
681,
10274,
66,
7519,
286,
5235,
262,
674,
1373,
5950,
1052,
323,
8417,
20877,
315,
7917,
198,
262,
449,
1825,
24258,
681,
19403,
4181,
364,
81,
873,
439,
33204,
512,
286,
33204,
32900,
746,
286,
2849,
1857,
11,
2849,
5617,
11,
6964,
5617,
284,
2660,
6521,
928,
1021,
310,
33204,
32900,
1020,
13406,
3227,
310,
21693,
1151,
32518,
310,
13534,
16972,
345,
286,
5235,
262,
674,
7068,
4741,
1646,
439,
264,
925,
198,
262,
4741,
5156,
284,
11834,
15,
11281,
77,
4527,
2293,
23521,
5617,
340,
262,
4741,
5156,
1447,
11834,
15,
92,
314,
16,
11281,
77,
4527,
2293,
24258,
681,
41422,
4181,
220,
15,
8,
353,
2849,
5617,
271,
262,
2539,
2703,
29279,
284,
2709,
3960,
36652,
24258,
681,
19403,
7519,
262,
2539,
2703,
2253,
35853,
284,
2709,
3960,
36652,
24258,
681,
10274,
66,
24287,
262,
33806,
284,
2709,
47574,
746,
262,
449,
55919,
844,
14084,
9494,
368,
439,
1558,
3826,
512,
286,
2709,
52110,
57069,
3826,
340,
286,
674,
1893,
311,
2658,
404,
6352,
6070,
198,
286,
369,
5534,
304
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
39328,
25,
19130,
21756,
198,
286,
39328,
430,
5727,
279,
828,
198,
262,
5110,
25,
6587,
198,
286,
449,
2631,
5110,
11,
1518,
3770,
198,
262,
2567,
4432,
25,
1853,
198,
286,
422,
539,
2290,
11,
3048,
34579,
5534,
1618,
1432,
262,
5110,
284,
341,
286,
364,
41422,
1232,
220,
1041,
11,
220,
674,
22884,
1968,
311,
1005,
369,
87282,
1646,
11,
510,
12174,
76,
296,
933,
286,
364,
19403,
1270,
286,
364,
10274,
66,
1270,
286,
364,
17,
35,
6,
551,
3082,
91,
4139,
198,
286,
364,
67838,
5194,
1232,
364,
1041,
756,
262,
557,
14711,
6075,
512,
755,
12849,
10310,
2657,
6906,
11,
5110,
11,
2567,
4432,
5725,
997,
262,
3270,
262,
13831,
198,
262,
31423,
262,
39328,
25,
19130,
21756,
198,
286,
39328,
430,
5727,
279,
828,
198,
262,
5110,
25,
6587,
198,
286,
449,
2631,
5110,
11,
1518,
3770,
198,
262,
2567,
4432,
25,
1853,
198,
286,
422,
539,
2290,
11,
3048,
34579,
5534,
1618,
1432,
262,
5110,
284,
341,
286,
364,
41422,
1232,
220,
1041,
11,
220,
674,
22884,
1968,
311,
1005,
369,
87282,
1646,
11,
510,
12174,
76,
296,
933,
286,
364,
19403,
1270,
286,
364,
10274,
66,
1270,
286,
364,
17,
35,
6,
551,
3082,
91,
4139,
198,
286,
364,
67838,
5194,
1232,
364,
1041,
756,
262,
557,
262,
3270,
262,
422,
5110,
374,
2290,
512,
286,
1194,
493,
985,
1670,
5110,
1329,
286,
5110,
284,
636,
10198,
11090,
2892,
262,
422,
539,
2709,
3960,
40047,
24258,
681,
19403,
55802,
286,
4933,
62061,
1021,
310,
364,
19403,
1052,
539,
1766,
25,
314,
15,
24398,
2293,
24258,
681,
19403,
7519,
286,
5235,
262,
422,
539,
2709,
3960,
40047,
24258,
681,
10274,
66,
55802,
286,
4933,
62061,
1021,
310,
364,
10274,
66,
1052,
539,
1766,
25,
314,
15,
24398,
2293,
24258,
681,
10274,
66,
7519,
286,
5235,
262,
674,
1373,
5950,
1052,
323,
8417,
20877,
315,
7917,
198,
262,
449,
1825,
24258,
681,
19403,
4181,
364,
81,
873,
439,
33204,
512,
286,
33204,
32900,
746,
286,
2849,
1857,
11,
2849,
5617,
11,
6964,
5617,
284,
2660,
6521,
928,
1021,
310,
33204,
32900,
1020,
13406,
3227,
310,
21693,
1151,
32518,
310,
13534,
16972,
345,
286,
5235,
262,
674,
7068,
4741,
1646,
439,
264,
925,
198,
262,
4741,
5156,
284,
11834,
15,
11281,
77,
4527,
2293,
23521,
5617,
340,
262,
4741,
5156,
1447,
11834,
15,
92,
314,
16,
11281,
77,
4527,
2293,
24258,
681,
41422,
4181,
220,
15,
8,
353,
2849,
5617,
271,
262,
2539,
2703,
29279,
284,
2709,
3960,
36652,
24258,
681,
19403,
7519,
262,
2539,
2703,
2253,
35853,
284,
2709,
3960,
36652,
24258,
681,
10274,
66,
24287,
262,
33806,
284,
2709,
47574,
746,
262,
449,
55919,
844,
14084,
9494,
368,
439,
1558,
3826,
512,
286,
2709,
52110,
57069,
3826,
340,
286,
674,
1893,
311,
2658,
404,
6352,
6070,
198,
286,
369,
5534,
304
] |
LeKono/pyhgnc | src/pyhgnc/manager/query.py | QueryManager._one_to_many_query | def _one_to_many_query(cls, query_obj, search4, model_attrib):
"""extends and returns a SQLAlchemy query object to allow one-to-many queries
:param query_obj: SQL Alchemy query object
:param str search4: search string
:param model_attrib: attribute in model
"""
model = model_attrib.parent.class_
already_joined_tables = [mapper.class_ for mapper in query_obj._join_entities]
if isinstance(search4, (str, int, Iterable)) and model not in already_joined_tables:
query_obj = query_obj.join(model)
if isinstance(search4, str):
query_obj = query_obj.filter(model_attrib.like(search4))
elif isinstance(search4, int):
query_obj = query_obj.filter(model_attrib == search4)
elif isinstance(search4, Iterable):
query_obj = query_obj.filter(model_attrib.in_(search4))
return query_obj | python | def _one_to_many_query(cls, query_obj, search4, model_attrib):
"""extends and returns a SQLAlchemy query object to allow one-to-many queries
:param query_obj: SQL Alchemy query object
:param str search4: search string
:param model_attrib: attribute in model
"""
model = model_attrib.parent.class_
already_joined_tables = [mapper.class_ for mapper in query_obj._join_entities]
if isinstance(search4, (str, int, Iterable)) and model not in already_joined_tables:
query_obj = query_obj.join(model)
if isinstance(search4, str):
query_obj = query_obj.filter(model_attrib.like(search4))
elif isinstance(search4, int):
query_obj = query_obj.filter(model_attrib == search4)
elif isinstance(search4, Iterable):
query_obj = query_obj.filter(model_attrib.in_(search4))
return query_obj | [
"def",
"_one_to_many_query",
"(",
"cls",
",",
"query_obj",
",",
"search4",
",",
"model_attrib",
")",
":",
"model",
"=",
"model_attrib",
".",
"parent",
".",
"class_",
"already_joined_tables",
"=",
"[",
"mapper",
".",
"class_",
"for",
"mapper",
"in",
"query_obj",
".",
"_join_entities",
"]",
"if",
"isinstance",
"(",
"search4",
",",
"(",
"str",
",",
"int",
",",
"Iterable",
")",
")",
"and",
"model",
"not",
"in",
"already_joined_tables",
":",
"query_obj",
"=",
"query_obj",
".",
"join",
"(",
"model",
")",
"if",
"isinstance",
"(",
"search4",
",",
"str",
")",
":",
"query_obj",
"=",
"query_obj",
".",
"filter",
"(",
"model_attrib",
".",
"like",
"(",
"search4",
")",
")",
"elif",
"isinstance",
"(",
"search4",
",",
"int",
")",
":",
"query_obj",
"=",
"query_obj",
".",
"filter",
"(",
"model_attrib",
"==",
"search4",
")",
"elif",
"isinstance",
"(",
"search4",
",",
"Iterable",
")",
":",
"query_obj",
"=",
"query_obj",
".",
"filter",
"(",
"model_attrib",
".",
"in_",
"(",
"search4",
")",
")",
"return",
"query_obj"
] | extends and returns a SQLAlchemy query object to allow one-to-many queries
:param query_obj: SQL Alchemy query object
:param str search4: search string
:param model_attrib: attribute in model | [
"extends",
"and",
"returns",
"a",
"SQLAlchemy",
"query",
"object",
"to",
"allow",
"one",
"-",
"to",
"-",
"many",
"queries"
] | train | https://github.com/LeKono/pyhgnc/blob/1cae20c40874bfb51581b7c5c1481707e942b5d0/src/pyhgnc/manager/query.py#L65-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:
extends and returns a SQLAlchemy query object to allow one-to-many queries
:param query_obj: SQL Alchemy query object
:param str search4: search string
:param model_attrib: attribute in model
### Response:
def _one_to_many_query(cls, query_obj, search4, model_attrib):
"""extends and returns a SQLAlchemy query object to allow one-to-many queries
:param query_obj: SQL Alchemy query object
:param str search4: search string
:param model_attrib: attribute in model
"""
model = model_attrib.parent.class_
already_joined_tables = [mapper.class_ for mapper in query_obj._join_entities]
if isinstance(search4, (str, int, Iterable)) and model not in already_joined_tables:
query_obj = query_obj.join(model)
if isinstance(search4, str):
query_obj = query_obj.filter(model_attrib.like(search4))
elif isinstance(search4, int):
query_obj = query_obj.filter(model_attrib == search4)
elif isinstance(search4, Iterable):
query_obj = query_obj.filter(model_attrib.in_(search4))
return query_obj
<|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,
15588,
323,
4780,
264,
85829,
3319,
1665,
311,
2187,
832,
4791,
81288,
20126,
271,
286,
551,
913,
3319,
7478,
25,
8029,
1708,
25055,
3319,
1665,
198,
286,
551,
913,
610,
2778,
19,
25,
2778,
925,
198,
286,
551,
913,
1646,
69887,
25,
7180,
304,
1646,
271,
14711,
6075,
512,
755,
721,
606,
2401,
22879,
5857,
21024,
11,
3319,
7478,
11,
2778,
19,
11,
1646,
69887,
997,
286,
4304,
15588,
323,
4780,
264,
85829,
3319,
1665,
311,
2187,
832,
4791,
81288,
20126,
271,
286,
551,
913,
3319,
7478,
25,
8029,
1708,
25055,
3319,
1665,
198,
286,
551,
913,
610,
2778,
19,
25,
2778,
925,
198,
286,
551,
913,
1646,
69887,
25,
7180,
304,
1646,
198,
286,
3270,
286,
1646,
284,
1646,
69887,
8829,
3150,
19327,
286,
2736,
5487,
74606,
36732,
284,
510,
39176,
3150,
62,
369,
25514,
304,
3319,
7478,
1462,
6115,
48477,
2595,
286,
422,
11656,
21079,
19,
11,
320,
496,
11,
528,
11,
39116,
595,
323,
1646,
539,
304,
2736,
5487,
74606,
36732,
512,
310,
3319,
7478,
284,
3319,
7478,
5563,
7790,
696,
286,
422,
11656,
21079,
19,
11,
610,
997,
310,
3319,
7478,
284,
3319,
7478,
7081,
7790,
69887,
67418,
21079,
19,
4489,
286,
4508,
11656,
21079,
19,
11,
528,
997,
310,
3319,
7478,
284,
3319,
7478,
7081,
7790,
69887,
624,
2778,
19,
696,
286,
4508,
11656,
21079,
19,
11,
39116,
997,
310,
3319,
7478,
284,
3319,
7478,
7081,
7790,
69887,
1896,
8526,
1874,
19,
4489,
286,
471,
3319,
7478,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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4780,
264,
85829,
3319,
1665,
311,
2187,
832,
4791,
81288,
20126,
271,
286,
551,
913,
3319,
7478,
25,
8029,
1708,
25055,
3319,
1665,
198,
286,
551,
913,
610,
2778,
19,
25,
2778,
925,
198,
286,
551,
913,
1646,
69887,
25,
7180,
304,
1646,
271,
14711,
6075,
512,
755,
721,
606,
2401,
22879,
5857,
21024,
11,
3319,
7478,
11,
2778,
19,
11,
1646,
69887,
997,
286,
4304,
15588,
323,
4780,
264,
85829,
3319,
1665,
311,
2187,
832,
4791,
81288,
20126,
271,
286,
551,
913,
3319,
7478,
25,
8029,
1708,
25055,
3319,
1665,
198,
286,
551,
913,
610,
2778,
19,
25,
2778,
925,
198,
286,
551,
913,
1646,
69887,
25,
7180,
304,
1646,
198,
286,
3270,
286,
1646,
284,
1646,
69887,
8829,
3150,
19327,
286,
2736,
5487,
74606,
36732,
284,
510,
39176,
3150,
62,
369,
25514,
304,
3319,
7478,
1462,
6115,
48477,
2595,
286,
422,
11656,
21079,
19,
11,
320,
496,
11,
528,
11,
39116,
595,
323,
1646,
539,
304,
2736,
5487,
74606,
36732,
512,
310,
3319,
7478,
284,
3319,
7478,
5563,
7790,
696,
286,
422,
11656,
21079,
19,
11,
610,
997,
310,
3319,
7478,
284,
3319,
7478,
7081,
7790,
69887,
67418,
21079,
19,
4489,
286,
4508,
11656,
21079,
19,
11,
528,
997,
310,
3319,
7478,
284,
3319,
7478,
7081,
7790,
69887,
624,
2778,
19,
696,
286,
4508,
11656,
21079,
19,
11,
39116,
997,
310,
3319,
7478,
284,
3319,
7478,
7081,
7790,
69887,
1896,
8526,
1874,
19,
4489,
286,
471,
3319,
7478,
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
] |
etcher-be/emiz | emiz/avwx/service.py | NOAA._extract | def _extract(self, raw: str, station: str = None) -> str:
"""
Extracts the raw_report element from XML response
"""
resp = parsexml(raw)
try:
report = resp['response']['data'][self.rtype.upper()]
except KeyError:
raise self.make_err(raw)
# Find report string
if isinstance(report, dict):
report = report['raw_text']
elif isinstance(report, list) and report:
report = report[0]['raw_text']
else:
raise self.make_err(raw, '"raw_text"')
# Remove excess leading and trailing data
for item in (self.rtype.upper(), 'SPECI'):
if report.startswith(item + ' '):
report = report[len(item) + 1:]
return report | python | def _extract(self, raw: str, station: str = None) -> str:
"""
Extracts the raw_report element from XML response
"""
resp = parsexml(raw)
try:
report = resp['response']['data'][self.rtype.upper()]
except KeyError:
raise self.make_err(raw)
# Find report string
if isinstance(report, dict):
report = report['raw_text']
elif isinstance(report, list) and report:
report = report[0]['raw_text']
else:
raise self.make_err(raw, '"raw_text"')
# Remove excess leading and trailing data
for item in (self.rtype.upper(), 'SPECI'):
if report.startswith(item + ' '):
report = report[len(item) + 1:]
return report | [
"def",
"_extract",
"(",
"self",
",",
"raw",
":",
"str",
",",
"station",
":",
"str",
"=",
"None",
")",
"->",
"str",
":",
"resp",
"=",
"parsexml",
"(",
"raw",
")",
"try",
":",
"report",
"=",
"resp",
"[",
"'response'",
"]",
"[",
"'data'",
"]",
"[",
"self",
".",
"rtype",
".",
"upper",
"(",
")",
"]",
"except",
"KeyError",
":",
"raise",
"self",
".",
"make_err",
"(",
"raw",
")",
"# Find report string",
"if",
"isinstance",
"(",
"report",
",",
"dict",
")",
":",
"report",
"=",
"report",
"[",
"'raw_text'",
"]",
"elif",
"isinstance",
"(",
"report",
",",
"list",
")",
"and",
"report",
":",
"report",
"=",
"report",
"[",
"0",
"]",
"[",
"'raw_text'",
"]",
"else",
":",
"raise",
"self",
".",
"make_err",
"(",
"raw",
",",
"'\"raw_text\"'",
")",
"# Remove excess leading and trailing data",
"for",
"item",
"in",
"(",
"self",
".",
"rtype",
".",
"upper",
"(",
")",
",",
"'SPECI'",
")",
":",
"if",
"report",
".",
"startswith",
"(",
"item",
"+",
"' '",
")",
":",
"report",
"=",
"report",
"[",
"len",
"(",
"item",
")",
"+",
"1",
":",
"]",
"return",
"report"
] | Extracts the raw_report element from XML response | [
"Extracts",
"the",
"raw_report",
"element",
"from",
"XML",
"response"
] | train | https://github.com/etcher-be/emiz/blob/1c3e32711921d7e600e85558ffe5d337956372de/emiz/avwx/service.py#L70-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:
Extracts the raw_report element from XML response
### Response:
def _extract(self, raw: str, station: str = None) -> str:
"""
Extracts the raw_report element from XML response
"""
resp = parsexml(raw)
try:
report = resp['response']['data'][self.rtype.upper()]
except KeyError:
raise self.make_err(raw)
# Find report string
if isinstance(report, dict):
report = report['raw_text']
elif isinstance(report, list) and report:
report = report[0]['raw_text']
else:
raise self.make_err(raw, '"raw_text"')
# Remove excess leading and trailing data
for item in (self.rtype.upper(), 'SPECI'):
if report.startswith(item + ' '):
report = report[len(item) + 1:]
return report
<|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,
30059,
82,
279,
7257,
15157,
2449,
505,
12138,
2077,
271,
14711,
6075,
512,
755,
721,
24396,
1214,
11,
7257,
25,
610,
11,
8216,
25,
610,
284,
2290,
8,
1492,
610,
512,
286,
3270,
286,
23673,
82,
279,
7257,
15157,
2449,
505,
12138,
2077,
198,
286,
3270,
286,
9216,
284,
4820,
6591,
23269,
340,
286,
1456,
512,
310,
1934,
284,
9216,
681,
2376,
4274,
695,
10136,
726,
1783,
1337,
34764,
28866,
286,
3734,
39194,
512,
310,
4933,
659,
10325,
9450,
23269,
340,
286,
674,
7531,
1934,
925,
198,
286,
422,
11656,
46275,
11,
6587,
997,
310,
1934,
284,
1934,
681,
1059,
4424,
4532,
286,
4508,
11656,
46275,
11,
1160,
8,
323,
1934,
512,
310,
1934,
284,
1934,
58,
15,
5465,
1059,
4424,
4532,
286,
775,
512,
310,
4933,
659,
10325,
9450,
23269,
11,
7273,
1059,
4424,
1,
1329,
286,
674,
11016,
13937,
6522,
323,
28848,
828,
198,
286,
369,
1537,
304,
320,
726,
1783,
1337,
34764,
1535,
364,
57581,
40,
11290,
310,
422,
1934,
27249,
5508,
489,
364,
364,
997,
394,
1934,
284,
1934,
25721,
5508,
8,
489,
220,
16,
25106,
286,
471,
1934,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
30059,
82,
279,
7257,
15157,
2449,
505,
12138,
2077,
271,
14711,
6075,
512,
755,
721,
24396,
1214,
11,
7257,
25,
610,
11,
8216,
25,
610,
284,
2290,
8,
1492,
610,
512,
286,
3270,
286,
23673,
82,
279,
7257,
15157,
2449,
505,
12138,
2077,
198,
286,
3270,
286,
9216,
284,
4820,
6591,
23269,
340,
286,
1456,
512,
310,
1934,
284,
9216,
681,
2376,
4274,
695,
10136,
726,
1783,
1337,
34764,
28866,
286,
3734,
39194,
512,
310,
4933,
659,
10325,
9450,
23269,
340,
286,
674,
7531,
1934,
925,
198,
286,
422,
11656,
46275,
11,
6587,
997,
310,
1934,
284,
1934,
681,
1059,
4424,
4532,
286,
4508,
11656,
46275,
11,
1160,
8,
323,
1934,
512,
310,
1934,
284,
1934,
58,
15,
5465,
1059,
4424,
4532,
286,
775,
512,
310,
4933,
659,
10325,
9450,
23269,
11,
7273,
1059,
4424,
1,
1329,
286,
674,
11016,
13937,
6522,
323,
28848,
828,
198,
286,
369,
1537,
304,
320,
726,
1783,
1337,
34764,
1535,
364,
57581,
40,
11290,
310,
422,
1934,
27249,
5508,
489,
364,
364,
997,
394,
1934,
284,
1934,
25721,
5508,
8,
489,
220,
16,
25106,
286,
471,
1934,
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
] |
sammchardy/python-kucoin | kucoin/client.py | Client.get_deposit_address | def get_deposit_address(self, currency):
"""Get deposit address for a currency
https://docs.kucoin.com/#get-deposit-address
:param currency: Name of currency
:type currency: string
.. code:: python
address = client.get_deposit_address('NEO')
:returns: ApiResponse
.. code:: python
{
"address": "0x78d3ad1c0aa1bf068e19c94a2d7b16c9c0fcd8b1",
"memo": "5c247c8a03aa677cea2a251d"
}
:raises: KucoinResponseException, KucoinAPIException
"""
data = {
'currency': currency
}
return self._get('deposit-addresses', True, data=data) | python | def get_deposit_address(self, currency):
"""Get deposit address for a currency
https://docs.kucoin.com/#get-deposit-address
:param currency: Name of currency
:type currency: string
.. code:: python
address = client.get_deposit_address('NEO')
:returns: ApiResponse
.. code:: python
{
"address": "0x78d3ad1c0aa1bf068e19c94a2d7b16c9c0fcd8b1",
"memo": "5c247c8a03aa677cea2a251d"
}
:raises: KucoinResponseException, KucoinAPIException
"""
data = {
'currency': currency
}
return self._get('deposit-addresses', True, data=data) | [
"def",
"get_deposit_address",
"(",
"self",
",",
"currency",
")",
":",
"data",
"=",
"{",
"'currency'",
":",
"currency",
"}",
"return",
"self",
".",
"_get",
"(",
"'deposit-addresses'",
",",
"True",
",",
"data",
"=",
"data",
")"
] | Get deposit address for a currency
https://docs.kucoin.com/#get-deposit-address
:param currency: Name of currency
:type currency: string
.. code:: python
address = client.get_deposit_address('NEO')
:returns: ApiResponse
.. code:: python
{
"address": "0x78d3ad1c0aa1bf068e19c94a2d7b16c9c0fcd8b1",
"memo": "5c247c8a03aa677cea2a251d"
}
:raises: KucoinResponseException, KucoinAPIException | [
"Get",
"deposit",
"address",
"for",
"a",
"currency"
] | train | https://github.com/sammchardy/python-kucoin/blob/a4cacde413804784bd313f27a0ad37234888be29/kucoin/client.py#L592-L621 | <|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 deposit address for a currency
https://docs.kucoin.com/#get-deposit-address
:param currency: Name of currency
:type currency: string
.. code:: python
address = client.get_deposit_address('NEO')
:returns: ApiResponse
.. code:: python
{
"address": "0x78d3ad1c0aa1bf068e19c94a2d7b16c9c0fcd8b1",
"memo": "5c247c8a03aa677cea2a251d"
}
:raises: KucoinResponseException, KucoinAPIException
### Response:
def get_deposit_address(self, currency):
"""Get deposit address for a currency
https://docs.kucoin.com/#get-deposit-address
:param currency: Name of currency
:type currency: string
.. code:: python
address = client.get_deposit_address('NEO')
:returns: ApiResponse
.. code:: python
{
"address": "0x78d3ad1c0aa1bf068e19c94a2d7b16c9c0fcd8b1",
"memo": "5c247c8a03aa677cea2a251d"
}
:raises: KucoinResponseException, KucoinAPIException
"""
data = {
'currency': currency
}
return self._get('deposit-addresses', True, data=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,
1991,
16946,
2686,
369,
264,
11667,
271,
286,
3788,
1129,
14452,
5314,
84,
7307,
916,
27657,
456,
6953,
2792,
42733,
271,
286,
551,
913,
11667,
25,
4076,
315,
11667,
198,
286,
551,
1337,
11667,
25,
925,
271,
286,
5354,
2082,
487,
10344,
271,
310,
2686,
284,
3016,
673,
86898,
6886,
493,
4031,
46,
4713,
286,
551,
4310,
25,
72400,
271,
286,
5354,
2082,
487,
10344,
271,
310,
341,
394,
330,
5102,
794,
330,
15,
87,
2495,
67,
18,
329,
16,
66,
15,
5418,
16,
13536,
26661,
68,
777,
66,
6281,
64,
17,
67,
22,
65,
845,
66,
24,
66,
15,
69,
4484,
23,
65,
16,
761,
394,
330,
56509,
794,
330,
20,
66,
14125,
66,
23,
64,
2839,
5418,
24375,
74038,
17,
64,
13860,
67,
702,
310,
557,
286,
551,
33371,
25,
33479,
7307,
2647,
1378,
11,
33479,
7307,
7227,
1378,
271,
14711,
6075,
512,
755,
636,
86898,
6886,
1214,
11,
11667,
997,
286,
4304,
1991,
16946,
2686,
369,
264,
11667,
271,
286,
3788,
1129,
14452,
5314,
84,
7307,
916,
27657,
456,
6953,
2792,
42733,
271,
286,
551,
913,
11667,
25,
4076,
315,
11667,
198,
286,
551,
1337,
11667,
25,
925,
271,
286,
5354,
2082,
487,
10344,
271,
310,
2686,
284,
3016,
673,
86898,
6886,
493,
4031,
46,
4713,
286,
551,
4310,
25,
72400,
271,
286,
5354,
2082,
487,
10344,
271,
310,
341,
394,
330,
5102,
794,
330,
15,
87,
2495,
67,
18,
329,
16,
66,
15,
5418,
16,
13536,
26661,
68,
777,
66,
6281,
64,
17,
67,
22,
65,
845,
66,
24,
66,
15,
69,
4484,
23,
65,
16,
761,
394,
330,
56509,
794,
330,
20,
66,
14125,
66,
23,
64,
2839,
5418,
24375,
74038,
17,
64,
13860,
67,
702,
310,
557,
286,
551,
33371,
25,
33479,
7307,
2647,
1378,
11,
33479,
7307,
7227,
1378,
271,
286,
12713,
286,
828,
284,
341,
310,
364,
16353,
1232,
11667,
198,
286,
557,
286,
471,
659,
1462,
456,
493,
61614,
42733,
288,
518,
3082,
11,
828,
23686,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
16946,
2686,
369,
264,
11667,
271,
286,
3788,
1129,
14452,
5314,
84,
7307,
916,
27657,
456,
6953,
2792,
42733,
271,
286,
551,
913,
11667,
25,
4076,
315,
11667,
198,
286,
551,
1337,
11667,
25,
925,
271,
286,
5354,
2082,
487,
10344,
271,
310,
2686,
284,
3016,
673,
86898,
6886,
493,
4031,
46,
4713,
286,
551,
4310,
25,
72400,
271,
286,
5354,
2082,
487,
10344,
271,
310,
341,
394,
330,
5102,
794,
330,
15,
87,
2495,
67,
18,
329,
16,
66,
15,
5418,
16,
13536,
26661,
68,
777,
66,
6281,
64,
17,
67,
22,
65,
845,
66,
24,
66,
15,
69,
4484,
23,
65,
16,
761,
394,
330,
56509,
794,
330,
20,
66,
14125,
66,
23,
64,
2839,
5418,
24375,
74038,
17,
64,
13860,
67,
702,
310,
557,
286,
551,
33371,
25,
33479,
7307,
2647,
1378,
11,
33479,
7307,
7227,
1378,
271,
14711,
6075,
512,
755,
636,
86898,
6886,
1214,
11,
11667,
997,
286,
4304,
1991,
16946,
2686,
369,
264,
11667,
271,
286,
3788,
1129,
14452,
5314,
84,
7307,
916,
27657,
456,
6953,
2792,
42733,
271,
286,
551,
913,
11667,
25,
4076,
315,
11667,
198,
286,
551,
1337,
11667,
25,
925,
271,
286,
5354,
2082,
487,
10344,
271,
310,
2686,
284,
3016,
673,
86898,
6886,
493,
4031,
46,
4713,
286,
551,
4310,
25,
72400,
271,
286,
5354,
2082,
487,
10344,
271,
310,
341,
394,
330,
5102,
794,
330,
15,
87,
2495,
67,
18,
329,
16,
66,
15,
5418,
16,
13536,
26661,
68,
777,
66,
6281,
64,
17,
67,
22,
65,
845,
66,
24,
66,
15,
69,
4484,
23,
65,
16,
761,
394,
330,
56509,
794,
330,
20,
66,
14125,
66,
23,
64,
2839,
5418,
24375,
74038,
17,
64,
13860,
67,
702,
310,
557,
286,
551,
33371,
25,
33479,
7307,
2647,
1378,
11,
33479,
7307,
7227,
1378,
271,
286,
12713,
286,
828,
284,
341,
310,
364,
16353,
1232,
11667,
198,
286,
557,
286,
471,
659,
1462,
456,
493,
61614,
42733,
288,
518,
3082,
11,
828,
23686,
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
] |
classam/silly | silly/main.py | a_thing | def a_thing(random=random, *args, **kwargs):
"""
Return a ... thing.
>>> mock_random.seed(0)
>>> a_thing(random=mock_random)
'two secrets'
>>> mock_random.seed(1)
>>> a_thing(random=mock_random, capitalize=True)
'A Mighty Poop'
>>> mock_random.seed(2)
>>> a_thing(random=mock_random, slugify=True)
'a-poop'
>>> mock_random.seed(4)
>>> a_thing(random=mock_random, slugify=True)
'two-chimps'
"""
return thing(random=random, an=True, *args, **kwargs) | python | def a_thing(random=random, *args, **kwargs):
"""
Return a ... thing.
>>> mock_random.seed(0)
>>> a_thing(random=mock_random)
'two secrets'
>>> mock_random.seed(1)
>>> a_thing(random=mock_random, capitalize=True)
'A Mighty Poop'
>>> mock_random.seed(2)
>>> a_thing(random=mock_random, slugify=True)
'a-poop'
>>> mock_random.seed(4)
>>> a_thing(random=mock_random, slugify=True)
'two-chimps'
"""
return thing(random=random, an=True, *args, **kwargs) | [
"def",
"a_thing",
"(",
"random",
"=",
"random",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"thing",
"(",
"random",
"=",
"random",
",",
"an",
"=",
"True",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | Return a ... thing.
>>> mock_random.seed(0)
>>> a_thing(random=mock_random)
'two secrets'
>>> mock_random.seed(1)
>>> a_thing(random=mock_random, capitalize=True)
'A Mighty Poop'
>>> mock_random.seed(2)
>>> a_thing(random=mock_random, slugify=True)
'a-poop'
>>> mock_random.seed(4)
>>> a_thing(random=mock_random, slugify=True)
'two-chimps' | [
"Return",
"a",
"...",
"thing",
"."
] | train | https://github.com/classam/silly/blob/f3202e997d5ebc9e4f98370b08665fd1178a9556/silly/main.py#L1069-L1087 | <|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 a ... thing.
>>> mock_random.seed(0)
>>> a_thing(random=mock_random)
'two secrets'
>>> mock_random.seed(1)
>>> a_thing(random=mock_random, capitalize=True)
'A Mighty Poop'
>>> mock_random.seed(2)
>>> a_thing(random=mock_random, slugify=True)
'a-poop'
>>> mock_random.seed(4)
>>> a_thing(random=mock_random, slugify=True)
'two-chimps'
### Response:
def a_thing(random=random, *args, **kwargs):
"""
Return a ... thing.
>>> mock_random.seed(0)
>>> a_thing(random=mock_random)
'two secrets'
>>> mock_random.seed(1)
>>> a_thing(random=mock_random, capitalize=True)
'A Mighty Poop'
>>> mock_random.seed(2)
>>> a_thing(random=mock_random, slugify=True)
'a-poop'
>>> mock_random.seed(4)
>>> a_thing(random=mock_random, slugify=True)
'two-chimps'
"""
return thing(random=random, an=True, *args, **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,
5715,
264,
2564,
3245,
382,
262,
12382,
8018,
23471,
37425,
7,
15,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
340,
262,
364,
20375,
24511,
1270,
262,
12382,
8018,
23471,
37425,
7,
16,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
53825,
3702,
340,
262,
364,
32,
75268,
14128,
454,
1270,
262,
12382,
8018,
23471,
37425,
7,
17,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
64,
2320,
48406,
1270,
262,
12382,
8018,
23471,
37425,
7,
19,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
20375,
11843,
67758,
3961,
14711,
6075,
512,
755,
264,
62,
1626,
26167,
80917,
11,
353,
2164,
11,
3146,
9872,
997,
262,
3270,
262,
3494,
264,
2564,
3245,
382,
262,
12382,
8018,
23471,
37425,
7,
15,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
340,
262,
364,
20375,
24511,
1270,
262,
12382,
8018,
23471,
37425,
7,
16,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
53825,
3702,
340,
262,
364,
32,
75268,
14128,
454,
1270,
262,
12382,
8018,
23471,
37425,
7,
17,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
64,
2320,
48406,
1270,
262,
12382,
8018,
23471,
37425,
7,
19,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
20375,
11843,
67758,
3961,
262,
3270,
262,
471,
3245,
26167,
80917,
11,
459,
3702,
11,
353,
2164,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
264,
2564,
3245,
382,
262,
12382,
8018,
23471,
37425,
7,
15,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
340,
262,
364,
20375,
24511,
1270,
262,
12382,
8018,
23471,
37425,
7,
16,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
53825,
3702,
340,
262,
364,
32,
75268,
14128,
454,
1270,
262,
12382,
8018,
23471,
37425,
7,
17,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
64,
2320,
48406,
1270,
262,
12382,
8018,
23471,
37425,
7,
19,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
20375,
11843,
67758,
3961,
14711,
6075,
512,
755,
264,
62,
1626,
26167,
80917,
11,
353,
2164,
11,
3146,
9872,
997,
262,
3270,
262,
3494,
264,
2564,
3245,
382,
262,
12382,
8018,
23471,
37425,
7,
15,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
340,
262,
364,
20375,
24511,
1270,
262,
12382,
8018,
23471,
37425,
7,
16,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
53825,
3702,
340,
262,
364,
32,
75268,
14128,
454,
1270,
262,
12382,
8018,
23471,
37425,
7,
17,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
64,
2320,
48406,
1270,
262,
12382,
8018,
23471,
37425,
7,
19,
340,
262,
12382,
264,
62,
1626,
26167,
28,
17127,
23471,
11,
25478,
1463,
3702,
340,
262,
364,
20375,
11843,
67758,
3961,
262,
3270,
262,
471,
3245,
26167,
80917,
11,
459,
3702,
11,
353,
2164,
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
] |
openego/eDisGo | edisgo/grid/network.py | StorageControl._check_nominal_power | def _check_nominal_power(self, storage_parameters, timeseries):
"""
Tries to assign a nominal power to the storage.
Checks if nominal power is provided through `storage_parameters`,
otherwise tries to return the absolute maximum of `timeseries`. Raises
an error if it cannot assign a nominal power.
Parameters
----------
timeseries : :obj:`str` or :pandas:`pandas.Series<series>`
See parameter `timeseries` in class definition for more
information.
storage_parameters : :obj:`dict`
See parameter `parameters` in class definition for more
information.
Returns
--------
:obj:`dict`
The given `storage_parameters` is returned extended by an entry for
'nominal_power', if it didn't already have that key.
"""
if storage_parameters.get('nominal_power', None) is None:
try:
storage_parameters['nominal_power'] = max(abs(timeseries))
except:
raise ValueError("Could not assign a nominal power to the "
"storage. Please provide either a nominal "
"power or an active power time series.")
return storage_parameters | python | def _check_nominal_power(self, storage_parameters, timeseries):
"""
Tries to assign a nominal power to the storage.
Checks if nominal power is provided through `storage_parameters`,
otherwise tries to return the absolute maximum of `timeseries`. Raises
an error if it cannot assign a nominal power.
Parameters
----------
timeseries : :obj:`str` or :pandas:`pandas.Series<series>`
See parameter `timeseries` in class definition for more
information.
storage_parameters : :obj:`dict`
See parameter `parameters` in class definition for more
information.
Returns
--------
:obj:`dict`
The given `storage_parameters` is returned extended by an entry for
'nominal_power', if it didn't already have that key.
"""
if storage_parameters.get('nominal_power', None) is None:
try:
storage_parameters['nominal_power'] = max(abs(timeseries))
except:
raise ValueError("Could not assign a nominal power to the "
"storage. Please provide either a nominal "
"power or an active power time series.")
return storage_parameters | [
"def",
"_check_nominal_power",
"(",
"self",
",",
"storage_parameters",
",",
"timeseries",
")",
":",
"if",
"storage_parameters",
".",
"get",
"(",
"'nominal_power'",
",",
"None",
")",
"is",
"None",
":",
"try",
":",
"storage_parameters",
"[",
"'nominal_power'",
"]",
"=",
"max",
"(",
"abs",
"(",
"timeseries",
")",
")",
"except",
":",
"raise",
"ValueError",
"(",
"\"Could not assign a nominal power to the \"",
"\"storage. Please provide either a nominal \"",
"\"power or an active power time series.\"",
")",
"return",
"storage_parameters"
] | Tries to assign a nominal power to the storage.
Checks if nominal power is provided through `storage_parameters`,
otherwise tries to return the absolute maximum of `timeseries`. Raises
an error if it cannot assign a nominal power.
Parameters
----------
timeseries : :obj:`str` or :pandas:`pandas.Series<series>`
See parameter `timeseries` in class definition for more
information.
storage_parameters : :obj:`dict`
See parameter `parameters` in class definition for more
information.
Returns
--------
:obj:`dict`
The given `storage_parameters` is returned extended by an entry for
'nominal_power', if it didn't already have that key. | [
"Tries",
"to",
"assign",
"a",
"nominal",
"power",
"to",
"the",
"storage",
"."
] | train | https://github.com/openego/eDisGo/blob/e6245bdaf236f9c49dbda5a18c1c458290f41e2b/edisgo/grid/network.py#L2002-L2033 | <|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:
Tries to assign a nominal power to the storage.
Checks if nominal power is provided through `storage_parameters`,
otherwise tries to return the absolute maximum of `timeseries`. Raises
an error if it cannot assign a nominal power.
Parameters
----------
timeseries : :obj:`str` or :pandas:`pandas.Series<series>`
See parameter `timeseries` in class definition for more
information.
storage_parameters : :obj:`dict`
See parameter `parameters` in class definition for more
information.
Returns
--------
:obj:`dict`
The given `storage_parameters` is returned extended by an entry for
'nominal_power', if it didn't already have that key.
### Response:
def _check_nominal_power(self, storage_parameters, timeseries):
"""
Tries to assign a nominal power to the storage.
Checks if nominal power is provided through `storage_parameters`,
otherwise tries to return the absolute maximum of `timeseries`. Raises
an error if it cannot assign a nominal power.
Parameters
----------
timeseries : :obj:`str` or :pandas:`pandas.Series<series>`
See parameter `timeseries` in class definition for more
information.
storage_parameters : :obj:`dict`
See parameter `parameters` in class definition for more
information.
Returns
--------
:obj:`dict`
The given `storage_parameters` is returned extended by an entry for
'nominal_power', if it didn't already have that key.
"""
if storage_parameters.get('nominal_power', None) is None:
try:
storage_parameters['nominal_power'] = max(abs(timeseries))
except:
raise ValueError("Could not assign a nominal power to the "
"storage. Please provide either a nominal "
"power or an active power time series.")
return storage_parameters
<|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,
51,
4108,
311,
9993,
264,
47855,
2410,
311,
279,
5942,
382,
286,
25884,
422,
47855,
2410,
374,
3984,
1555,
1595,
16568,
18764,
13188,
286,
6062,
16696,
311,
471,
279,
10973,
7340,
315,
1595,
15487,
4804,
29687,
61411,
198,
286,
459,
1493,
422,
433,
4250,
9993,
264,
47855,
2410,
382,
286,
13831,
198,
286,
31423,
286,
3115,
4804,
551,
551,
2347,
19258,
496,
63,
477,
551,
79,
56533,
19258,
79,
56533,
38228,
27,
20473,
54822,
310,
3580,
5852,
1595,
15487,
4804,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
627,
286,
5942,
18764,
551,
551,
2347,
19258,
8644,
4077,
310,
3580,
5852,
1595,
14105,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
382,
286,
5295,
198,
286,
90238,
286,
551,
2347,
19258,
8644,
4077,
310,
578,
2728,
1595,
16568,
18764,
63,
374,
6052,
11838,
555,
459,
4441,
369,
198,
310,
364,
17101,
992,
21052,
518,
422,
433,
3287,
956,
2736,
617,
430,
1401,
382,
14711,
6075,
512,
755,
721,
2071,
54575,
992,
21052,
1214,
11,
5942,
18764,
11,
3115,
4804,
997,
286,
3270,
286,
350,
4108,
311,
9993,
264,
47855,
2410,
311,
279,
5942,
382,
286,
25884,
422,
47855,
2410,
374,
3984,
1555,
1595,
16568,
18764,
13188,
286,
6062,
16696,
311,
471,
279,
10973,
7340,
315,
1595,
15487,
4804,
29687,
61411,
198,
286,
459,
1493,
422,
433,
4250,
9993,
264,
47855,
2410,
382,
286,
13831,
198,
286,
31423,
286,
3115,
4804,
551,
551,
2347,
19258,
496,
63,
477,
551,
79,
56533,
19258,
79,
56533,
38228,
27,
20473,
54822,
310,
3580,
5852,
1595,
15487,
4804,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
627,
286,
5942,
18764,
551,
551,
2347,
19258,
8644,
4077,
310,
3580,
5852,
1595,
14105,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
382,
286,
5295,
198,
286,
90238,
286,
551,
2347,
19258,
8644,
4077,
310,
578,
2728,
1595,
16568,
18764,
63,
374,
6052,
11838,
555,
459,
4441,
369,
198,
310,
364,
17101,
992,
21052,
518,
422,
433,
3287,
956,
2736,
617,
430,
1401,
382,
286,
3270,
286,
422,
5942,
18764,
673,
493,
17101,
992,
21052,
518,
2290,
8,
374,
2290,
512,
310,
1456,
512,
394,
5942,
18764,
681,
17101,
992,
21052,
663,
284,
1973,
31623,
62218,
4804,
1192,
310,
3734,
512,
394,
4933,
15764,
446,
13191,
539,
9993,
264,
47855,
2410,
311,
279,
6360,
792,
330,
16568,
13,
5321,
3493,
3060,
264,
47855,
6360,
792,
330,
13477,
477,
459,
4642,
2410,
892,
4101,
13352,
286,
471,
5942,
18764,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
51,
4108,
311,
9993,
264,
47855,
2410,
311,
279,
5942,
382,
286,
25884,
422,
47855,
2410,
374,
3984,
1555,
1595,
16568,
18764,
13188,
286,
6062,
16696,
311,
471,
279,
10973,
7340,
315,
1595,
15487,
4804,
29687,
61411,
198,
286,
459,
1493,
422,
433,
4250,
9993,
264,
47855,
2410,
382,
286,
13831,
198,
286,
31423,
286,
3115,
4804,
551,
551,
2347,
19258,
496,
63,
477,
551,
79,
56533,
19258,
79,
56533,
38228,
27,
20473,
54822,
310,
3580,
5852,
1595,
15487,
4804,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
627,
286,
5942,
18764,
551,
551,
2347,
19258,
8644,
4077,
310,
3580,
5852,
1595,
14105,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
382,
286,
5295,
198,
286,
90238,
286,
551,
2347,
19258,
8644,
4077,
310,
578,
2728,
1595,
16568,
18764,
63,
374,
6052,
11838,
555,
459,
4441,
369,
198,
310,
364,
17101,
992,
21052,
518,
422,
433,
3287,
956,
2736,
617,
430,
1401,
382,
14711,
6075,
512,
755,
721,
2071,
54575,
992,
21052,
1214,
11,
5942,
18764,
11,
3115,
4804,
997,
286,
3270,
286,
350,
4108,
311,
9993,
264,
47855,
2410,
311,
279,
5942,
382,
286,
25884,
422,
47855,
2410,
374,
3984,
1555,
1595,
16568,
18764,
13188,
286,
6062,
16696,
311,
471,
279,
10973,
7340,
315,
1595,
15487,
4804,
29687,
61411,
198,
286,
459,
1493,
422,
433,
4250,
9993,
264,
47855,
2410,
382,
286,
13831,
198,
286,
31423,
286,
3115,
4804,
551,
551,
2347,
19258,
496,
63,
477,
551,
79,
56533,
19258,
79,
56533,
38228,
27,
20473,
54822,
310,
3580,
5852,
1595,
15487,
4804,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
627,
286,
5942,
18764,
551,
551,
2347,
19258,
8644,
4077,
310,
3580,
5852,
1595,
14105,
63,
304,
538,
7419,
369,
810,
198,
310,
2038,
382,
286,
5295,
198,
286,
90238,
286,
551,
2347,
19258,
8644,
4077,
310,
578,
2728,
1595,
16568,
18764,
63,
374,
6052,
11838,
555,
459,
4441,
369,
198,
310,
364,
17101,
992,
21052,
518,
422,
433,
3287,
956,
2736,
617,
430,
1401,
382,
286,
3270,
286,
422,
5942,
18764,
673,
493,
17101,
992,
21052,
518,
2290,
8,
374,
2290,
512,
310,
1456,
512,
394,
5942,
18764,
681,
17101,
992,
21052,
663,
284,
1973,
31623,
62218,
4804,
1192,
310,
3734,
512,
394,
4933,
15764,
446,
13191,
539,
9993,
264,
47855,
2410,
311,
279,
6360,
792,
330,
16568,
13,
5321,
3493,
3060,
264,
47855,
6360,
792,
330,
13477,
477,
459,
4642,
2410,
892,
4101,
13352,
286,
471,
5942,
18764,
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
] |
biocommons/bioutils | src/bioutils/digests.py | seq_sha512 | def seq_sha512(seq, normalize=True):
"""returns unicode sequence sha512 hexdigest for sequence `seq`.
>>> seq_sha512('')
'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
>>> seq_sha512('ACGT')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt', normalize=False)
'785c1ac071dd89b69904372cf645b7826df587534d25c41edb2862e54fb2940d697218f2883d2bf1a11cdaee658c7f7ab945a1cfd08eb26cbce57ee88790250a'
"""
seq = normalize_sequence(seq) if normalize else seq
bseq = seq.encode("ascii")
return hashlib.sha512(bseq).hexdigest() | python | def seq_sha512(seq, normalize=True):
"""returns unicode sequence sha512 hexdigest for sequence `seq`.
>>> seq_sha512('')
'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
>>> seq_sha512('ACGT')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt', normalize=False)
'785c1ac071dd89b69904372cf645b7826df587534d25c41edb2862e54fb2940d697218f2883d2bf1a11cdaee658c7f7ab945a1cfd08eb26cbce57ee88790250a'
"""
seq = normalize_sequence(seq) if normalize else seq
bseq = seq.encode("ascii")
return hashlib.sha512(bseq).hexdigest() | [
"def",
"seq_sha512",
"(",
"seq",
",",
"normalize",
"=",
"True",
")",
":",
"seq",
"=",
"normalize_sequence",
"(",
"seq",
")",
"if",
"normalize",
"else",
"seq",
"bseq",
"=",
"seq",
".",
"encode",
"(",
"\"ascii\"",
")",
"return",
"hashlib",
".",
"sha512",
"(",
"bseq",
")",
".",
"hexdigest",
"(",
")"
] | returns unicode sequence sha512 hexdigest for sequence `seq`.
>>> seq_sha512('')
'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
>>> seq_sha512('ACGT')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt', normalize=False)
'785c1ac071dd89b69904372cf645b7826df587534d25c41edb2862e54fb2940d697218f2883d2bf1a11cdaee658c7f7ab945a1cfd08eb26cbce57ee88790250a' | [
"returns",
"unicode",
"sequence",
"sha512",
"hexdigest",
"for",
"sequence",
"seq",
"."
] | train | https://github.com/biocommons/bioutils/blob/88bcbdfa707268fed1110800e91b6d4f8e9475a0/src/bioutils/digests.py#L104-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:
returns unicode sequence sha512 hexdigest for sequence `seq`.
>>> seq_sha512('')
'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
>>> seq_sha512('ACGT')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt', normalize=False)
'785c1ac071dd89b69904372cf645b7826df587534d25c41edb2862e54fb2940d697218f2883d2bf1a11cdaee658c7f7ab945a1cfd08eb26cbce57ee88790250a'
### Response:
def seq_sha512(seq, normalize=True):
"""returns unicode sequence sha512 hexdigest for sequence `seq`.
>>> seq_sha512('')
'cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e'
>>> seq_sha512('ACGT')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt')
'68a178f7c740c5c240aa67ba41843b119d3bf9f8b0f0ac36cf701d26672964efbd536d197f51ce634fc70634d1eefe575bec34c83247abc52010f6e2bbdb8253'
>>> seq_sha512('acgt', normalize=False)
'785c1ac071dd89b69904372cf645b7826df587534d25c41edb2862e54fb2940d697218f2883d2bf1a11cdaee658c7f7ab945a1cfd08eb26cbce57ee88790250a'
"""
seq = normalize_sequence(seq) if normalize else seq
bseq = seq.encode("ascii")
return hashlib.sha512(bseq).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,
4310,
27169,
8668,
16249,
8358,
12651,
37439,
369,
8668,
1595,
13565,
63438,
262,
12382,
13278,
49936,
8358,
38465,
262,
364,
9991,
6069,
68,
8878,
22,
68,
830,
65,
23,
65,
3013,
10559,
15935,
15,
67,
2287,
67,
4728,
22,
67,
17416,
68,
16408,
15,
65,
22005,
20,
7783,
6069,
69,
19,
64,
22536,
67,
1927,
346,
24,
346,
2618,
67,
15,
67,
1032,
66,
20,
67,
5313,
69,
17,
65,
15,
544,
25009,
23,
67,
17897,
22,
96934,
17,
69,
5495,
65,
25717,
9117,
21358,
1114,
64,
5932,
64,
22600,
13817,
2642,
26437,
3315,
18,
68,
3961,
262,
12382,
13278,
49936,
8358,
493,
1741,
26460,
1329,
262,
364,
2614,
64,
11256,
69,
22,
66,
21112,
66,
20,
66,
8273,
5418,
3080,
4749,
19770,
3391,
65,
9079,
67,
18,
13536,
24,
69,
23,
65,
15,
69,
15,
582,
1927,
9991,
19597,
67,
15999,
22194,
1227,
830,
9117,
21600,
67,
4468,
69,
3971,
346,
24307,
8480,
22457,
1958,
67,
16,
68,
46053,
21228,
17106,
1958,
66,
23879,
2618,
13997,
15830,
605,
69,
21,
68,
17,
6194,
2042,
22091,
18,
3961,
262,
12382,
13278,
49936,
8358,
493,
582,
5289,
1329,
262,
364,
2614,
64,
11256,
69,
22,
66,
21112,
66,
20,
66,
8273,
5418,
3080,
4749,
19770,
3391,
65,
9079,
67,
18,
13536,
24,
69,
23,
65,
15,
69,
15,
582,
1927,
9991,
19597,
67,
15999,
22194,
1227,
830,
9117,
21600,
67,
4468,
69,
3971,
346,
24307,
8480,
22457,
1958,
67,
16,
68,
46053,
21228,
17106,
1958,
66,
23879,
2618,
13997,
15830,
605,
69,
21,
68,
17,
6194,
2042,
22091,
18,
3961,
262,
12382,
13278,
49936,
8358,
493,
582,
5289,
518,
22436,
5725,
340,
262,
364,
22539,
66,
16,
582,
24508,
634,
4578,
65,
23459,
17776,
5332,
9991,
22926,
65,
23833,
21,
3013,
22159,
22467,
67,
914,
66,
3174,
94827,
17361,
17,
68,
4370,
11032,
17168,
15,
67,
25388,
13302,
69,
15287,
18,
67,
17,
13536,
16,
64,
806,
66,
3315,
2176,
23654,
66,
22,
69,
22,
370,
24599,
64,
16,
66,
7047,
2318,
3141,
1627,
7369,
346,
3226,
2176,
26058,
21026,
1135,
64,
3961,
14711,
6075,
512,
755,
13278,
49936,
8358,
35920,
11,
22436,
3702,
997,
262,
4304,
4310,
27169,
8668,
16249,
8358,
12651,
37439,
369,
8668,
1595,
13565,
63438,
262,
12382,
13278,
49936,
8358,
38465,
262,
364,
9991,
6069,
68,
8878,
22,
68,
830,
65,
23,
65,
3013,
10559,
15935,
15,
67,
2287,
67,
4728,
22,
67,
17416,
68,
16408,
15,
65,
22005,
20,
7783,
6069,
69,
19,
64,
22536,
67,
1927,
346,
24,
346,
2618,
67,
15,
67,
1032,
66,
20,
67,
5313,
69,
17,
65,
15,
544,
25009,
23,
67,
17897,
22,
96934,
17,
69,
5495,
65,
25717,
9117,
21358,
1114,
64,
5932,
64,
22600,
13817,
2642,
26437,
3315,
18,
68,
3961,
262,
12382,
13278,
49936,
8358,
493,
1741,
26460,
1329,
262,
364,
2614,
64,
11256,
69,
22,
66,
21112,
66,
20
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
4310,
27169,
8668,
16249,
8358,
12651,
37439,
369,
8668,
1595,
13565,
63438,
262,
12382,
13278,
49936,
8358,
38465,
262,
364,
9991,
6069,
68,
8878,
22,
68,
830,
65,
23,
65,
3013,
10559,
15935,
15,
67,
2287,
67,
4728,
22,
67,
17416,
68,
16408,
15,
65,
22005,
20,
7783,
6069,
69,
19,
64,
22536,
67,
1927,
346,
24,
346,
2618,
67,
15,
67,
1032,
66,
20,
67,
5313,
69,
17,
65,
15,
544,
25009,
23,
67,
17897,
22,
96934,
17,
69,
5495,
65,
25717,
9117,
21358,
1114,
64,
5932,
64,
22600,
13817,
2642,
26437,
3315,
18,
68,
3961,
262,
12382,
13278,
49936,
8358,
493,
1741,
26460,
1329,
262,
364,
2614,
64,
11256,
69,
22,
66,
21112,
66,
20,
66,
8273,
5418,
3080,
4749,
19770,
3391,
65,
9079,
67,
18,
13536,
24,
69,
23,
65,
15,
69,
15,
582,
1927,
9991,
19597,
67,
15999,
22194,
1227,
830,
9117,
21600,
67,
4468,
69,
3971,
346,
24307,
8480,
22457,
1958,
67,
16,
68,
46053,
21228,
17106,
1958,
66,
23879,
2618,
13997,
15830,
605,
69,
21,
68,
17,
6194,
2042,
22091,
18,
3961,
262,
12382,
13278,
49936,
8358,
493,
582,
5289,
1329,
262,
364,
2614,
64,
11256,
69,
22,
66,
21112,
66,
20,
66,
8273,
5418,
3080,
4749,
19770,
3391,
65,
9079,
67,
18,
13536,
24,
69,
23,
65,
15,
69,
15,
582,
1927,
9991,
19597,
67,
15999,
22194,
1227,
830,
9117,
21600,
67,
4468,
69,
3971,
346,
24307,
8480,
22457,
1958,
67,
16,
68,
46053,
21228,
17106,
1958,
66,
23879,
2618,
13997,
15830,
605,
69,
21,
68,
17,
6194,
2042,
22091,
18,
3961,
262,
12382,
13278,
49936,
8358,
493,
582,
5289,
518,
22436,
5725,
340,
262,
364,
22539,
66,
16,
582,
24508,
634,
4578,
65,
23459,
17776,
5332,
9991,
22926,
65,
23833,
21,
3013,
22159,
22467,
67,
914,
66,
3174,
94827,
17361,
17,
68,
4370,
11032,
17168,
15,
67,
25388,
13302,
69,
15287,
18,
67,
17,
13536,
16,
64,
806,
66,
3315,
2176,
23654,
66,
22,
69,
22,
370,
24599,
64,
16,
66,
7047,
2318,
3141,
1627,
7369,
346,
3226,
2176,
26058,
21026,
1135,
64,
3961,
14711,
6075,
512,
755,
13278,
49936,
8358,
35920,
11,
22436,
3702,
997,
262,
4304,
4310,
27169,
8668,
16249,
8358,
12651,
37439,
369,
8668,
1595,
13565,
63438,
262,
12382,
13278,
49936,
8358,
38465,
262,
364,
9991,
6069,
68,
8878,
22,
68,
830,
65,
23,
65,
3013,
10559,
15935,
15,
67,
2287,
67,
4728,
22,
67,
17416,
68,
16408,
15,
65,
22005,
20,
7783,
6069,
69,
19,
64,
22536,
67,
1927,
346,
24,
346,
2618,
67,
15,
67,
1032,
66,
20,
67,
5313,
69,
17,
65,
15,
544,
25009,
23,
67,
17897,
22,
96934,
17,
69,
5495,
65,
25717,
9117,
21358,
1114,
64,
5932,
64,
22600,
13817,
2642,
26437,
3315,
18,
68,
3961,
262,
12382,
13278,
49936,
8358,
493,
1741,
26460,
1329,
262,
364,
2614,
64,
11256,
69,
22,
66,
21112,
66,
20
] |
wright-group/WrightTools | WrightTools/collection/_collection.py | Collection.flush | def flush(self):
"""Ensure contents are written to file."""
for name in self.item_names:
item = self[name]
item.flush()
self.file.flush() | python | def flush(self):
"""Ensure contents are written to file."""
for name in self.item_names:
item = self[name]
item.flush()
self.file.flush() | [
"def",
"flush",
"(",
"self",
")",
":",
"for",
"name",
"in",
"self",
".",
"item_names",
":",
"item",
"=",
"self",
"[",
"name",
"]",
"item",
".",
"flush",
"(",
")",
"self",
".",
"file",
".",
"flush",
"(",
")"
] | Ensure contents are written to file. | [
"Ensure",
"contents",
"are",
"written",
"to",
"file",
"."
] | train | https://github.com/wright-group/WrightTools/blob/80d3ddd5074d8d5c1bc03fd5a0e0f10d4b424aeb/WrightTools/collection/_collection.py#L158-L163 | <|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 contents are written to file.
### Response:
def flush(self):
"""Ensure contents are written to file."""
for name in self.item_names:
item = self[name]
item.flush()
self.file.flush()
<|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,
8970,
527,
5439,
311,
1052,
382,
14711,
6075,
512,
755,
18698,
1214,
997,
286,
4304,
65539,
8970,
527,
5439,
311,
1052,
14781,
286,
369,
836,
304,
659,
9161,
9366,
512,
310,
1537,
284,
659,
11174,
933,
310,
1537,
23907,
746,
286,
659,
9914,
23907,
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,
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,
65539,
8970,
527,
5439,
311,
1052,
382,
14711,
6075,
512,
755,
18698,
1214,
997,
286,
4304,
65539,
8970,
527,
5439,
311,
1052,
14781,
286,
369,
836,
304,
659,
9161,
9366,
512,
310,
1537,
284,
659,
11174,
933,
310,
1537,
23907,
746,
286,
659,
9914,
23907,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
yyuu/botornado | boto/dynamodb/layer1.py | Layer1.delete_item | def delete_item(self, table_name, key,
expected=None, return_values=None,
object_hook=None):
"""
Delete an item and all of it's attributes by primary key.
You can perform a conditional delete by specifying an
expected rule.
:type table_name: str
:param table_name: The name of the table containing the item.
:type key: dict
:param key: A Python version of the Key data structure
defined by DynamoDB.
:type expected: dict
:param expected: A Python version of the Expected
data structure defined by DynamoDB.
:type return_values: str
:param return_values: Controls the return of attribute
name-value pairs before then were changed. Possible
values are: None or 'ALL_OLD'. If 'ALL_OLD' is
specified and the item is overwritten, the content
of the old item is returned.
"""
data = {'TableName' : table_name,
'Key' : key}
if expected:
data['Expected'] = expected
if return_values:
data['ReturnValues'] = return_values
json_input = json.dumps(data)
return self.make_request('DeleteItem', json_input,
object_hook=object_hook) | python | def delete_item(self, table_name, key,
expected=None, return_values=None,
object_hook=None):
"""
Delete an item and all of it's attributes by primary key.
You can perform a conditional delete by specifying an
expected rule.
:type table_name: str
:param table_name: The name of the table containing the item.
:type key: dict
:param key: A Python version of the Key data structure
defined by DynamoDB.
:type expected: dict
:param expected: A Python version of the Expected
data structure defined by DynamoDB.
:type return_values: str
:param return_values: Controls the return of attribute
name-value pairs before then were changed. Possible
values are: None or 'ALL_OLD'. If 'ALL_OLD' is
specified and the item is overwritten, the content
of the old item is returned.
"""
data = {'TableName' : table_name,
'Key' : key}
if expected:
data['Expected'] = expected
if return_values:
data['ReturnValues'] = return_values
json_input = json.dumps(data)
return self.make_request('DeleteItem', json_input,
object_hook=object_hook) | [
"def",
"delete_item",
"(",
"self",
",",
"table_name",
",",
"key",
",",
"expected",
"=",
"None",
",",
"return_values",
"=",
"None",
",",
"object_hook",
"=",
"None",
")",
":",
"data",
"=",
"{",
"'TableName'",
":",
"table_name",
",",
"'Key'",
":",
"key",
"}",
"if",
"expected",
":",
"data",
"[",
"'Expected'",
"]",
"=",
"expected",
"if",
"return_values",
":",
"data",
"[",
"'ReturnValues'",
"]",
"=",
"return_values",
"json_input",
"=",
"json",
".",
"dumps",
"(",
"data",
")",
"return",
"self",
".",
"make_request",
"(",
"'DeleteItem'",
",",
"json_input",
",",
"object_hook",
"=",
"object_hook",
")"
] | Delete an item and all of it's attributes by primary key.
You can perform a conditional delete by specifying an
expected rule.
:type table_name: str
:param table_name: The name of the table containing the item.
:type key: dict
:param key: A Python version of the Key data structure
defined by DynamoDB.
:type expected: dict
:param expected: A Python version of the Expected
data structure defined by DynamoDB.
:type return_values: str
:param return_values: Controls the return of attribute
name-value pairs before then were changed. Possible
values are: None or 'ALL_OLD'. If 'ALL_OLD' is
specified and the item is overwritten, the content
of the old item is returned. | [
"Delete",
"an",
"item",
"and",
"all",
"of",
"it",
"s",
"attributes",
"by",
"primary",
"key",
".",
"You",
"can",
"perform",
"a",
"conditional",
"delete",
"by",
"specifying",
"an",
"expected",
"rule",
"."
] | train | https://github.com/yyuu/botornado/blob/fffb056f5ff2324d1d5c1304014cfb1d899f602e/boto/dynamodb/layer1.py#L378-L412 | <|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 an item and all of it's attributes by primary key.
You can perform a conditional delete by specifying an
expected rule.
:type table_name: str
:param table_name: The name of the table containing the item.
:type key: dict
:param key: A Python version of the Key data structure
defined by DynamoDB.
:type expected: dict
:param expected: A Python version of the Expected
data structure defined by DynamoDB.
:type return_values: str
:param return_values: Controls the return of attribute
name-value pairs before then were changed. Possible
values are: None or 'ALL_OLD'. If 'ALL_OLD' is
specified and the item is overwritten, the content
of the old item is returned.
### Response:
def delete_item(self, table_name, key,
expected=None, return_values=None,
object_hook=None):
"""
Delete an item and all of it's attributes by primary key.
You can perform a conditional delete by specifying an
expected rule.
:type table_name: str
:param table_name: The name of the table containing the item.
:type key: dict
:param key: A Python version of the Key data structure
defined by DynamoDB.
:type expected: dict
:param expected: A Python version of the Expected
data structure defined by DynamoDB.
:type return_values: str
:param return_values: Controls the return of attribute
name-value pairs before then were changed. Possible
values are: None or 'ALL_OLD'. If 'ALL_OLD' is
specified and the item is overwritten, the content
of the old item is returned.
"""
data = {'TableName' : table_name,
'Key' : key}
if expected:
data['Expected'] = expected
if return_values:
data['ReturnValues'] = return_values
json_input = json.dumps(data)
return self.make_request('DeleteItem', json_input,
object_hook=object_hook)
<|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,
459,
1537,
323,
682,
315,
433,
596,
8365,
555,
6156,
1401,
627,
286,
1472,
649,
2804,
264,
35787,
3783,
555,
38938,
459,
198,
286,
3685,
6037,
382,
286,
551,
1337,
2007,
1292,
25,
610,
198,
286,
551,
913,
2007,
1292,
25,
578,
836,
315,
279,
2007,
8649,
279,
1537,
382,
286,
551,
1337,
1401,
25,
6587,
198,
286,
551,
913,
1401,
25,
362,
13325,
2373,
315,
279,
5422,
828,
6070,
198,
310,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
3685,
25,
6587,
198,
286,
551,
913,
3685,
25,
362,
13325,
2373,
315,
279,
32121,
198,
310,
828,
6070,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
471,
9324,
25,
610,
198,
286,
551,
913,
471,
9324,
25,
33170,
279,
471,
315,
7180,
198,
310,
836,
19625,
13840,
1603,
1243,
1051,
5614,
13,
220,
37207,
198,
310,
2819,
527,
25,
2290,
477,
364,
4006,
83969,
4527,
1442,
364,
4006,
83969,
6,
374,
198,
310,
5300,
323,
279,
1537,
374,
60273,
11,
279,
2262,
198,
310,
315,
279,
2362,
1537,
374,
6052,
382,
14711,
6075,
512,
755,
3783,
5752,
1214,
11,
2007,
1292,
11,
1401,
345,
504,
3685,
5980,
11,
471,
9324,
5980,
345,
504,
1665,
33105,
5980,
997,
286,
3270,
286,
10645,
459,
1537,
323,
682,
315,
433,
596,
8365,
555,
6156,
1401,
627,
286,
1472,
649,
2804,
264,
35787,
3783,
555,
38938,
459,
198,
286,
3685,
6037,
382,
286,
551,
1337,
2007,
1292,
25,
610,
198,
286,
551,
913,
2007,
1292,
25,
578,
836,
315,
279,
2007,
8649,
279,
1537,
382,
286,
551,
1337,
1401,
25,
6587,
198,
286,
551,
913,
1401,
25,
362,
13325,
2373,
315,
279,
5422,
828,
6070,
198,
310,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
3685,
25,
6587,
198,
286,
551,
913,
3685,
25,
362,
13325,
2373,
315,
279,
32121,
198,
310,
828,
6070,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
471,
9324,
25,
610,
198,
286,
551,
913,
471,
9324,
25,
33170,
279,
471,
315,
7180,
198,
310,
836,
19625,
13840,
1603,
1243,
1051,
5614,
13,
220,
37207,
198,
310,
2819,
527,
25,
2290,
477,
364,
4006,
83969,
4527,
1442,
364,
4006,
83969,
6,
374,
198,
310,
5300,
323,
279,
1537,
374,
60273,
11,
279,
2262,
198,
310,
315,
279,
2362,
1537,
374,
6052,
627,
286,
3270,
286,
828,
284,
5473,
34327,
6,
551,
2007,
1292,
345,
394,
364,
1622,
6,
551,
1401,
534,
286,
422,
3685,
512,
310,
828,
681,
19430,
663,
284,
3685,
198,
286,
422,
471,
9324,
512,
310,
828,
681,
5715,
6359,
663,
284,
471,
9324,
198,
286,
3024,
6022,
284,
3024,
22252,
2657,
340,
286,
471,
659,
10325,
8052,
493,
6571,
1256,
518,
3024,
6022,
345,
792,
1665,
33105,
28,
1735,
33105,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
459,
1537,
323,
682,
315,
433,
596,
8365,
555,
6156,
1401,
627,
286,
1472,
649,
2804,
264,
35787,
3783,
555,
38938,
459,
198,
286,
3685,
6037,
382,
286,
551,
1337,
2007,
1292,
25,
610,
198,
286,
551,
913,
2007,
1292,
25,
578,
836,
315,
279,
2007,
8649,
279,
1537,
382,
286,
551,
1337,
1401,
25,
6587,
198,
286,
551,
913,
1401,
25,
362,
13325,
2373,
315,
279,
5422,
828,
6070,
198,
310,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
3685,
25,
6587,
198,
286,
551,
913,
3685,
25,
362,
13325,
2373,
315,
279,
32121,
198,
310,
828,
6070,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
471,
9324,
25,
610,
198,
286,
551,
913,
471,
9324,
25,
33170,
279,
471,
315,
7180,
198,
310,
836,
19625,
13840,
1603,
1243,
1051,
5614,
13,
220,
37207,
198,
310,
2819,
527,
25,
2290,
477,
364,
4006,
83969,
4527,
1442,
364,
4006,
83969,
6,
374,
198,
310,
5300,
323,
279,
1537,
374,
60273,
11,
279,
2262,
198,
310,
315,
279,
2362,
1537,
374,
6052,
382,
14711,
6075,
512,
755,
3783,
5752,
1214,
11,
2007,
1292,
11,
1401,
345,
504,
3685,
5980,
11,
471,
9324,
5980,
345,
504,
1665,
33105,
5980,
997,
286,
3270,
286,
10645,
459,
1537,
323,
682,
315,
433,
596,
8365,
555,
6156,
1401,
627,
286,
1472,
649,
2804,
264,
35787,
3783,
555,
38938,
459,
198,
286,
3685,
6037,
382,
286,
551,
1337,
2007,
1292,
25,
610,
198,
286,
551,
913,
2007,
1292,
25,
578,
836,
315,
279,
2007,
8649,
279,
1537,
382,
286,
551,
1337,
1401,
25,
6587,
198,
286,
551,
913,
1401,
25,
362,
13325,
2373,
315,
279,
5422,
828,
6070,
198,
310,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
3685,
25,
6587,
198,
286,
551,
913,
3685,
25,
362,
13325,
2373,
315,
279,
32121,
198,
310,
828,
6070,
4613,
555,
72913,
3590,
382,
286,
551,
1337,
471,
9324,
25,
610,
198,
286,
551,
913,
471,
9324,
25,
33170,
279,
471,
315,
7180,
198,
310,
836,
19625,
13840,
1603,
1243,
1051,
5614,
13,
220,
37207,
198,
310,
2819,
527,
25,
2290,
477,
364,
4006,
83969,
4527,
1442,
364,
4006,
83969,
6,
374,
198,
310,
5300,
323,
279,
1537,
374,
60273,
11,
279,
2262,
198,
310,
315,
279,
2362,
1537,
374,
6052,
627,
286,
3270,
286,
828,
284,
5473,
34327,
6,
551,
2007,
1292,
345,
394,
364,
1622,
6,
551,
1401,
534,
286,
422,
3685,
512,
310,
828,
681,
19430,
663,
284,
3685,
198,
286,
422,
471,
9324,
512,
310,
828,
681,
5715,
6359,
663,
284,
471,
9324,
198,
286,
3024,
6022,
284,
3024,
22252,
2657,
340,
286,
471,
659,
10325,
8052,
493,
6571,
1256,
518,
3024,
6022,
345,
792,
1665,
33105,
28,
1735,
33105,
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
] |
ThreatConnect-Inc/tcex | tcex/tcex_ti/tcex_ti.py | TcExTi.email | def email(self, name, to, from_addr, subject, body, header, owner=None, **kwargs):
"""
Create the Email TI object.
Args:
owner:
to:
from_addr:
name:
subject:
header:
body:
**kwargs:
Return:
"""
return Email(self.tcex, name, to, from_addr, subject, body, header, owner=owner, **kwargs) | python | def email(self, name, to, from_addr, subject, body, header, owner=None, **kwargs):
"""
Create the Email TI object.
Args:
owner:
to:
from_addr:
name:
subject:
header:
body:
**kwargs:
Return:
"""
return Email(self.tcex, name, to, from_addr, subject, body, header, owner=owner, **kwargs) | [
"def",
"email",
"(",
"self",
",",
"name",
",",
"to",
",",
"from_addr",
",",
"subject",
",",
"body",
",",
"header",
",",
"owner",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"Email",
"(",
"self",
".",
"tcex",
",",
"name",
",",
"to",
",",
"from_addr",
",",
"subject",
",",
"body",
",",
"header",
",",
"owner",
"=",
"owner",
",",
"*",
"*",
"kwargs",
")"
] | Create the Email TI object.
Args:
owner:
to:
from_addr:
name:
subject:
header:
body:
**kwargs:
Return: | [
"Create",
"the",
"Email",
"TI",
"object",
"."
] | train | https://github.com/ThreatConnect-Inc/tcex/blob/dd4d7a1ef723af1561687120191886b9a2fd4b47/tcex/tcex_ti/tcex_ti.py#L295-L312 | <|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:
Create the Email TI object.
Args:
owner:
to:
from_addr:
name:
subject:
header:
body:
**kwargs:
Return:
### Response:
def email(self, name, to, from_addr, subject, body, header, owner=None, **kwargs):
"""
Create the Email TI object.
Args:
owner:
to:
from_addr:
name:
subject:
header:
body:
**kwargs:
Return:
"""
return Email(self.tcex, name, to, from_addr, subject, body, header, owner=owner, **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,
4110,
279,
8463,
39237,
1665,
382,
286,
18161,
512,
310,
6506,
512,
310,
311,
512,
310,
505,
7539,
512,
310,
836,
512,
310,
3917,
512,
310,
4342,
512,
310,
2547,
512,
310,
3146,
9872,
1473,
286,
3494,
1473,
14711,
6075,
512,
755,
2613,
1214,
11,
836,
11,
311,
11,
505,
7539,
11,
3917,
11,
2547,
11,
4342,
11,
6506,
5980,
11,
3146,
9872,
997,
286,
3270,
286,
4324,
279,
8463,
39237,
1665,
382,
286,
18161,
512,
310,
6506,
512,
310,
311,
512,
310,
505,
7539,
512,
310,
836,
512,
310,
3917,
512,
310,
4342,
512,
310,
2547,
512,
310,
3146,
9872,
1473,
286,
3494,
1473,
286,
3270,
286,
471,
8463,
1214,
79690,
327,
11,
836,
11,
311,
11,
505,
7539,
11,
3917,
11,
2547,
11,
4342,
11,
6506,
28,
8281,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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,
4110,
279,
8463,
39237,
1665,
382,
286,
18161,
512,
310,
6506,
512,
310,
311,
512,
310,
505,
7539,
512,
310,
836,
512,
310,
3917,
512,
310,
4342,
512,
310,
2547,
512,
310,
3146,
9872,
1473,
286,
3494,
1473,
14711,
6075,
512,
755,
2613,
1214,
11,
836,
11,
311,
11,
505,
7539,
11,
3917,
11,
2547,
11,
4342,
11,
6506,
5980,
11,
3146,
9872,
997,
286,
3270,
286,
4324,
279,
8463,
39237,
1665,
382,
286,
18161,
512,
310,
6506,
512,
310,
311,
512,
310,
505,
7539,
512,
310,
836,
512,
310,
3917,
512,
310,
4342,
512,
310,
2547,
512,
310,
3146,
9872,
1473,
286,
3494,
1473,
286,
3270,
286,
471,
8463,
1214,
79690,
327,
11,
836,
11,
311,
11,
505,
7539,
11,
3917,
11,
2547,
11,
4342,
11,
6506,
28,
8281,
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
] |
oasiswork/zimsoap | zimsoap/client.py | ZimbraMailClient.delete_filter_rule | def delete_filter_rule(self, _filter, way='in'):
""" delete a filter rule
:param: _filter a zobjects.FilterRule or the filter name
:param: way string discribing if filter is for 'in' or 'out' messages
:returns: a list of zobjects.FilterRule
"""
updated_rules = []
rules = self.get_filter_rules(way=way)
if isinstance(_filter, zobjects.FilterRule):
_filter = _filter.name
if rules:
for rule in rules:
if not rule.name == _filter:
updated_rules.append(rule)
if rules != updated_rules:
content = {
'filterRules': {
'filterRule': [f._full_data for f in updated_rules]
}
}
if way == 'in':
self.request('ModifyFilterRules', content)
elif way == 'out':
self.request('ModifyOutgoingFilterRules', content)
return updated_rules | python | def delete_filter_rule(self, _filter, way='in'):
""" delete a filter rule
:param: _filter a zobjects.FilterRule or the filter name
:param: way string discribing if filter is for 'in' or 'out' messages
:returns: a list of zobjects.FilterRule
"""
updated_rules = []
rules = self.get_filter_rules(way=way)
if isinstance(_filter, zobjects.FilterRule):
_filter = _filter.name
if rules:
for rule in rules:
if not rule.name == _filter:
updated_rules.append(rule)
if rules != updated_rules:
content = {
'filterRules': {
'filterRule': [f._full_data for f in updated_rules]
}
}
if way == 'in':
self.request('ModifyFilterRules', content)
elif way == 'out':
self.request('ModifyOutgoingFilterRules', content)
return updated_rules | [
"def",
"delete_filter_rule",
"(",
"self",
",",
"_filter",
",",
"way",
"=",
"'in'",
")",
":",
"updated_rules",
"=",
"[",
"]",
"rules",
"=",
"self",
".",
"get_filter_rules",
"(",
"way",
"=",
"way",
")",
"if",
"isinstance",
"(",
"_filter",
",",
"zobjects",
".",
"FilterRule",
")",
":",
"_filter",
"=",
"_filter",
".",
"name",
"if",
"rules",
":",
"for",
"rule",
"in",
"rules",
":",
"if",
"not",
"rule",
".",
"name",
"==",
"_filter",
":",
"updated_rules",
".",
"append",
"(",
"rule",
")",
"if",
"rules",
"!=",
"updated_rules",
":",
"content",
"=",
"{",
"'filterRules'",
":",
"{",
"'filterRule'",
":",
"[",
"f",
".",
"_full_data",
"for",
"f",
"in",
"updated_rules",
"]",
"}",
"}",
"if",
"way",
"==",
"'in'",
":",
"self",
".",
"request",
"(",
"'ModifyFilterRules'",
",",
"content",
")",
"elif",
"way",
"==",
"'out'",
":",
"self",
".",
"request",
"(",
"'ModifyOutgoingFilterRules'",
",",
"content",
")",
"return",
"updated_rules"
] | delete a filter rule
:param: _filter a zobjects.FilterRule or the filter name
:param: way string discribing if filter is for 'in' or 'out' messages
:returns: a list of zobjects.FilterRule | [
"delete",
"a",
"filter",
"rule"
] | train | https://github.com/oasiswork/zimsoap/blob/d1ea2eb4d50f263c9a16e5549af03f1eff3e295e/zimsoap/client.py#L2042-L2071 | <|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 filter rule
:param: _filter a zobjects.FilterRule or the filter name
:param: way string discribing if filter is for 'in' or 'out' messages
:returns: a list of zobjects.FilterRule
### Response:
def delete_filter_rule(self, _filter, way='in'):
""" delete a filter rule
:param: _filter a zobjects.FilterRule or the filter name
:param: way string discribing if filter is for 'in' or 'out' messages
:returns: a list of zobjects.FilterRule
"""
updated_rules = []
rules = self.get_filter_rules(way=way)
if isinstance(_filter, zobjects.FilterRule):
_filter = _filter.name
if rules:
for rule in rules:
if not rule.name == _filter:
updated_rules.append(rule)
if rules != updated_rules:
content = {
'filterRules': {
'filterRule': [f._full_data for f in updated_rules]
}
}
if way == 'in':
self.request('ModifyFilterRules', content)
elif way == 'out':
self.request('ModifyOutgoingFilterRules', content)
return updated_rules
<|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,
4644,
264,
4141,
6037,
271,
286,
551,
913,
25,
721,
5428,
264,
1167,
19761,
32796,
11590,
477,
279,
4141,
836,
198,
286,
551,
913,
25,
1648,
925,
834,
44631,
422,
4141,
374,
369,
364,
258,
6,
477,
364,
412,
6,
6743,
198,
286,
551,
4310,
25,
264,
1160,
315,
1167,
19761,
32796,
11590,
271,
14711,
6075,
512,
755,
3783,
8901,
21808,
1214,
11,
721,
5428,
11,
1648,
1151,
258,
11290,
286,
4304,
3783,
264,
4141,
6037,
271,
286,
551,
913,
25,
721,
5428,
264,
1167,
19761,
32796,
11590,
477,
279,
4141,
836,
198,
286,
551,
913,
25,
1648,
925,
834,
44631,
422,
4141,
374,
369,
364,
258,
6,
477,
364,
412,
6,
6743,
198,
286,
551,
4310,
25,
264,
1160,
315,
1167,
19761,
32796,
11590,
198,
286,
3270,
286,
6177,
22122,
284,
4260,
286,
5718,
284,
659,
673,
8901,
22122,
7,
3195,
28,
3195,
696,
286,
422,
11656,
2551,
5428,
11,
1167,
19761,
32796,
11590,
997,
310,
721,
5428,
284,
721,
5428,
2710,
271,
286,
422,
5718,
512,
310,
369,
6037,
304,
5718,
512,
394,
422,
539,
6037,
2710,
624,
721,
5428,
512,
504,
6177,
22122,
2102,
36044,
696,
286,
422,
5718,
976,
6177,
22122,
512,
310,
2262,
284,
341,
394,
364,
5428,
27099,
1232,
341,
504,
364,
5428,
11590,
1232,
510,
69,
1462,
9054,
1807,
369,
282,
304,
6177,
22122,
933,
394,
457,
310,
457,
310,
422,
1648,
624,
364,
258,
3730,
394,
659,
8387,
493,
45527,
5750,
27099,
518,
2262,
340,
310,
4508,
1648,
624,
364,
412,
3730,
394,
659,
8387,
493,
45527,
2729,
9738,
5750,
27099,
518,
2262,
696,
286,
471,
6177,
22122,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4644,
264,
4141,
6037,
271,
286,
551,
913,
25,
721,
5428,
264,
1167,
19761,
32796,
11590,
477,
279,
4141,
836,
198,
286,
551,
913,
25,
1648,
925,
834,
44631,
422,
4141,
374,
369,
364,
258,
6,
477,
364,
412,
6,
6743,
198,
286,
551,
4310,
25,
264,
1160,
315,
1167,
19761,
32796,
11590,
271,
14711,
6075,
512,
755,
3783,
8901,
21808,
1214,
11,
721,
5428,
11,
1648,
1151,
258,
11290,
286,
4304,
3783,
264,
4141,
6037,
271,
286,
551,
913,
25,
721,
5428,
264,
1167,
19761,
32796,
11590,
477,
279,
4141,
836,
198,
286,
551,
913,
25,
1648,
925,
834,
44631,
422,
4141,
374,
369,
364,
258,
6,
477,
364,
412,
6,
6743,
198,
286,
551,
4310,
25,
264,
1160,
315,
1167,
19761,
32796,
11590,
198,
286,
3270,
286,
6177,
22122,
284,
4260,
286,
5718,
284,
659,
673,
8901,
22122,
7,
3195,
28,
3195,
696,
286,
422,
11656,
2551,
5428,
11,
1167,
19761,
32796,
11590,
997,
310,
721,
5428,
284,
721,
5428,
2710,
271,
286,
422,
5718,
512,
310,
369,
6037,
304,
5718,
512,
394,
422,
539,
6037,
2710,
624,
721,
5428,
512,
504,
6177,
22122,
2102,
36044,
696,
286,
422,
5718,
976,
6177,
22122,
512,
310,
2262,
284,
341,
394,
364,
5428,
27099,
1232,
341,
504,
364,
5428,
11590,
1232,
510,
69,
1462,
9054,
1807,
369,
282,
304,
6177,
22122,
933,
394,
457,
310,
457,
310,
422,
1648,
624,
364,
258,
3730,
394,
659,
8387,
493,
45527,
5750,
27099,
518,
2262,
340,
310,
4508,
1648,
624,
364,
412,
3730,
394,
659,
8387,
493,
45527,
2729,
9738,
5750,
27099,
518,
2262,
696,
286,
471,
6177,
22122,
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
] |
liampauling/betfair | betfairlightweight/utils.py | check_status_code | def check_status_code(response, codes=None):
"""
Checks response.status_code is in codes.
:param requests.request response: Requests response
:param list codes: List of accepted codes or callable
:raises: StatusCodeError if code invalid
"""
codes = codes or [200]
if response.status_code not in codes:
raise StatusCodeError(response.status_code) | python | def check_status_code(response, codes=None):
"""
Checks response.status_code is in codes.
:param requests.request response: Requests response
:param list codes: List of accepted codes or callable
:raises: StatusCodeError if code invalid
"""
codes = codes or [200]
if response.status_code not in codes:
raise StatusCodeError(response.status_code) | [
"def",
"check_status_code",
"(",
"response",
",",
"codes",
"=",
"None",
")",
":",
"codes",
"=",
"codes",
"or",
"[",
"200",
"]",
"if",
"response",
".",
"status_code",
"not",
"in",
"codes",
":",
"raise",
"StatusCodeError",
"(",
"response",
".",
"status_code",
")"
] | Checks response.status_code is in codes.
:param requests.request response: Requests response
:param list codes: List of accepted codes or callable
:raises: StatusCodeError if code invalid | [
"Checks",
"response",
".",
"status_code",
"is",
"in",
"codes",
"."
] | train | https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/utils.py#L7-L17 | <|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:
Checks response.status_code is in codes.
:param requests.request response: Requests response
:param list codes: List of accepted codes or callable
:raises: StatusCodeError if code invalid
### Response:
def check_status_code(response, codes=None):
"""
Checks response.status_code is in codes.
:param requests.request response: Requests response
:param list codes: List of accepted codes or callable
:raises: StatusCodeError if code invalid
"""
codes = codes or [200]
if response.status_code not in codes:
raise StatusCodeError(response.status_code)
<|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,
50920,
2077,
4397,
4229,
374,
304,
14236,
382,
262,
551,
913,
7540,
8387,
2077,
25,
51982,
2077,
198,
262,
551,
913,
1160,
14236,
25,
1796,
315,
11928,
14236,
477,
42022,
198,
262,
551,
33371,
25,
54503,
1480,
422,
2082,
8482,
271,
14711,
6075,
512,
755,
1817,
4878,
4229,
5802,
11,
14236,
5980,
997,
262,
3270,
262,
25884,
2077,
4397,
4229,
374,
304,
14236,
382,
262,
551,
913,
7540,
8387,
2077,
25,
51982,
2077,
198,
262,
551,
913,
1160,
14236,
25,
1796,
315,
11928,
14236,
477,
42022,
198,
262,
551,
33371,
25,
54503,
1480,
422,
2082,
8482,
198,
262,
3270,
262,
14236,
284,
14236,
477,
510,
1049,
933,
262,
422,
2077,
4397,
4229,
539,
304,
14236,
512,
286,
4933,
54503,
1480,
5802,
4397,
4229,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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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,
50920,
2077,
4397,
4229,
374,
304,
14236,
382,
262,
551,
913,
7540,
8387,
2077,
25,
51982,
2077,
198,
262,
551,
913,
1160,
14236,
25,
1796,
315,
11928,
14236,
477,
42022,
198,
262,
551,
33371,
25,
54503,
1480,
422,
2082,
8482,
271,
14711,
6075,
512,
755,
1817,
4878,
4229,
5802,
11,
14236,
5980,
997,
262,
3270,
262,
25884,
2077,
4397,
4229,
374,
304,
14236,
382,
262,
551,
913,
7540,
8387,
2077,
25,
51982,
2077,
198,
262,
551,
913,
1160,
14236,
25,
1796,
315,
11928,
14236,
477,
42022,
198,
262,
551,
33371,
25,
54503,
1480,
422,
2082,
8482,
198,
262,
3270,
262,
14236,
284,
14236,
477,
510,
1049,
933,
262,
422,
2077,
4397,
4229,
539,
304,
14236,
512,
286,
4933,
54503,
1480,
5802,
4397,
4229,
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
] |
log2timeline/plaso | plaso/output/timesketch_out.py | TimesketchOutputModule.SetTimelineOwner | def SetTimelineOwner(self, username):
"""Sets the username of the user that should own the timeline.
Args:
username (str): username.
"""
self._timeline_owner = username
logger.info('Owner of the timeline: {0!s}'.format(self._timeline_owner)) | python | def SetTimelineOwner(self, username):
"""Sets the username of the user that should own the timeline.
Args:
username (str): username.
"""
self._timeline_owner = username
logger.info('Owner of the timeline: {0!s}'.format(self._timeline_owner)) | [
"def",
"SetTimelineOwner",
"(",
"self",
",",
"username",
")",
":",
"self",
".",
"_timeline_owner",
"=",
"username",
"logger",
".",
"info",
"(",
"'Owner of the timeline: {0!s}'",
".",
"format",
"(",
"self",
".",
"_timeline_owner",
")",
")"
] | Sets the username of the user that should own the timeline.
Args:
username (str): username. | [
"Sets",
"the",
"username",
"of",
"the",
"user",
"that",
"should",
"own",
"the",
"timeline",
"."
] | train | https://github.com/log2timeline/plaso/blob/9c564698d2da3ffbe23607a3c54c0582ea18a6cc/plaso/output/timesketch_out.py#L77-L84 | <|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:
Sets the username of the user that should own the timeline.
Args:
username (str): username.
### Response:
def SetTimelineOwner(self, username):
"""Sets the username of the user that should own the timeline.
Args:
username (str): username.
"""
self._timeline_owner = username
logger.info('Owner of the timeline: {0!s}'.format(self._timeline_owner))
<|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,
31275,
279,
6059,
315,
279,
1217,
430,
1288,
1866,
279,
25845,
382,
262,
18161,
512,
415,
6059,
320,
496,
1680,
6059,
382,
14711,
6075,
512,
755,
2638,
60741,
14120,
1214,
11,
6059,
997,
262,
4304,
31275,
279,
6059,
315,
279,
1217,
430,
1288,
1866,
279,
25845,
382,
262,
18161,
512,
415,
6059,
320,
496,
1680,
6059,
627,
262,
3270,
262,
659,
1462,
50060,
30127,
284,
6059,
198,
262,
6050,
5506,
493,
14120,
315,
279,
25845,
25,
314,
15,
0,
82,
24398,
2293,
1214,
1462,
50060,
30127,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
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,
31275,
279,
6059,
315,
279,
1217,
430,
1288,
1866,
279,
25845,
382,
262,
18161,
512,
415,
6059,
320,
496,
1680,
6059,
382,
14711,
6075,
512,
755,
2638,
60741,
14120,
1214,
11,
6059,
997,
262,
4304,
31275,
279,
6059,
315,
279,
1217,
430,
1288,
1866,
279,
25845,
382,
262,
18161,
512,
415,
6059,
320,
496,
1680,
6059,
627,
262,
3270,
262,
659,
1462,
50060,
30127,
284,
6059,
198,
262,
6050,
5506,
493,
14120,
315,
279,
25845,
25,
314,
15,
0,
82,
24398,
2293,
1214,
1462,
50060,
30127,
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
] |
specialunderwear/django-easymode | easymode/utils/xmlutils.py | is_valid | def is_valid(xml_string):
"""validates a unicode string containing xml"""
xml_file = StringIO.StringIO(xml_string.encode('utf-8'))
parser = XmlScanner()
parser.setContentHandler(ContentHandler())
try:
parser.parse(xml_file)
except SAXParseException:
return False
return True | python | def is_valid(xml_string):
"""validates a unicode string containing xml"""
xml_file = StringIO.StringIO(xml_string.encode('utf-8'))
parser = XmlScanner()
parser.setContentHandler(ContentHandler())
try:
parser.parse(xml_file)
except SAXParseException:
return False
return True | [
"def",
"is_valid",
"(",
"xml_string",
")",
":",
"xml_file",
"=",
"StringIO",
".",
"StringIO",
"(",
"xml_string",
".",
"encode",
"(",
"'utf-8'",
")",
")",
"parser",
"=",
"XmlScanner",
"(",
")",
"parser",
".",
"setContentHandler",
"(",
"ContentHandler",
"(",
")",
")",
"try",
":",
"parser",
".",
"parse",
"(",
"xml_file",
")",
"except",
"SAXParseException",
":",
"return",
"False",
"return",
"True"
] | validates a unicode string containing xml | [
"validates",
"a",
"unicode",
"string",
"containing",
"xml"
] | train | https://github.com/specialunderwear/django-easymode/blob/92f674b91fb8c54d6e379e2664e2000872d9c95e/easymode/utils/xmlutils.py#L32-L43 | <|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:
validates a unicode string containing xml
### Response:
def is_valid(xml_string):
"""validates a unicode string containing xml"""
xml_file = StringIO.StringIO(xml_string.encode('utf-8'))
parser = XmlScanner()
parser.setContentHandler(ContentHandler())
try:
parser.parse(xml_file)
except SAXParseException:
return False
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,
1930,
988,
264,
27169,
925,
8649,
8562,
271,
14711,
6075,
512,
755,
374,
8501,
31032,
3991,
997,
262,
4304,
1930,
988,
264,
27169,
925,
8649,
8562,
7275,
262,
8562,
2517,
284,
68035,
6567,
3895,
31032,
3991,
17762,
493,
4867,
12,
23,
7132,
1084,
262,
6871,
284,
19752,
32102,
746,
262,
6871,
46293,
3126,
80452,
3126,
2455,
262,
1456,
512,
286,
6871,
4736,
31032,
2517,
340,
262,
3734,
75326,
60362,
512,
286,
471,
3641,
7361,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,
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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
] | [
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,
1930,
988,
264,
27169,
925,
8649,
8562,
271,
14711,
6075,
512,
755,
374,
8501,
31032,
3991,
997,
262,
4304,
1930,
988,
264,
27169,
925,
8649,
8562,
7275,
262,
8562,
2517,
284,
68035,
6567,
3895,
31032,
3991,
17762,
493,
4867,
12,
23,
7132,
1084,
262,
6871,
284,
19752,
32102,
746,
262,
6871,
46293,
3126,
80452,
3126,
2455,
262,
1456,
512,
286,
6871,
4736,
31032,
2517,
340,
262,
3734,
75326,
60362,
512,
286,
471,
3641,
7361,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
WebarchivCZ/WA-KAT | src/wa_kat/connectors/aleph.py | Author.search_by_name | def search_by_name(cls, name):
"""
Look for author in NK Aleph authority base by `name`.
Args:
name (str): Author's name.
Yields:
obj: :class:`Author` instances.
"""
records = aleph.downloadRecords(
aleph.searchInAleph("aut", name, False, "wau")
)
for record in records:
marc = MARCXMLRecord(record)
author = cls.parse_author(marc)
if author:
yield author | python | def search_by_name(cls, name):
"""
Look for author in NK Aleph authority base by `name`.
Args:
name (str): Author's name.
Yields:
obj: :class:`Author` instances.
"""
records = aleph.downloadRecords(
aleph.searchInAleph("aut", name, False, "wau")
)
for record in records:
marc = MARCXMLRecord(record)
author = cls.parse_author(marc)
if author:
yield author | [
"def",
"search_by_name",
"(",
"cls",
",",
"name",
")",
":",
"records",
"=",
"aleph",
".",
"downloadRecords",
"(",
"aleph",
".",
"searchInAleph",
"(",
"\"aut\"",
",",
"name",
",",
"False",
",",
"\"wau\"",
")",
")",
"for",
"record",
"in",
"records",
":",
"marc",
"=",
"MARCXMLRecord",
"(",
"record",
")",
"author",
"=",
"cls",
".",
"parse_author",
"(",
"marc",
")",
"if",
"author",
":",
"yield",
"author"
] | Look for author in NK Aleph authority base by `name`.
Args:
name (str): Author's name.
Yields:
obj: :class:`Author` instances. | [
"Look",
"for",
"author",
"in",
"NK",
"Aleph",
"authority",
"base",
"by",
"name",
"."
] | train | https://github.com/WebarchivCZ/WA-KAT/blob/16d064a3a775dc1d2713debda7847ded52dd2a06/src/wa_kat/connectors/aleph.py#L240-L260 | <|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:
Look for author in NK Aleph authority base by `name`.
Args:
name (str): Author's name.
Yields:
obj: :class:`Author` instances.
### Response:
def search_by_name(cls, name):
"""
Look for author in NK Aleph authority base by `name`.
Args:
name (str): Author's name.
Yields:
obj: :class:`Author` instances.
"""
records = aleph.downloadRecords(
aleph.searchInAleph("aut", name, False, "wau")
)
for record in records:
marc = MARCXMLRecord(record)
author = cls.parse_author(marc)
if author:
yield author
<|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,
10596,
369,
3229,
304,
71163,
19623,
764,
11447,
2385,
555,
1595,
609,
63438,
286,
18161,
512,
310,
836,
320,
496,
1680,
7030,
596,
836,
382,
286,
816,
7052,
512,
310,
2909,
25,
551,
1058,
19258,
7279,
63,
13422,
382,
14711,
6075,
512,
755,
2778,
3795,
1292,
21024,
11,
836,
997,
286,
3270,
286,
9372,
369,
3229,
304,
71163,
19623,
764,
11447,
2385,
555,
1595,
609,
63438,
286,
18161,
512,
310,
836,
320,
496,
1680,
7030,
596,
836,
382,
286,
816,
7052,
512,
310,
2909,
25,
551,
1058,
19258,
7279,
63,
13422,
627,
286,
3270,
286,
7576,
284,
22180,
764,
36481,
26962,
1021,
310,
22180,
764,
9472,
644,
84583,
764,
446,
2784,
498,
836,
11,
3641,
11,
330,
86,
2933,
1158,
286,
5235,
286,
369,
3335,
304,
7576,
512,
310,
60898,
284,
38599,
34,
10833,
6607,
24728,
696,
310,
3229,
284,
13082,
4736,
23790,
1278,
8362,
696,
310,
422,
3229,
512,
394,
7692,
3229,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
10596,
369,
3229,
304,
71163,
19623,
764,
11447,
2385,
555,
1595,
609,
63438,
286,
18161,
512,
310,
836,
320,
496,
1680,
7030,
596,
836,
382,
286,
816,
7052,
512,
310,
2909,
25,
551,
1058,
19258,
7279,
63,
13422,
382,
14711,
6075,
512,
755,
2778,
3795,
1292,
21024,
11,
836,
997,
286,
3270,
286,
9372,
369,
3229,
304,
71163,
19623,
764,
11447,
2385,
555,
1595,
609,
63438,
286,
18161,
512,
310,
836,
320,
496,
1680,
7030,
596,
836,
382,
286,
816,
7052,
512,
310,
2909,
25,
551,
1058,
19258,
7279,
63,
13422,
627,
286,
3270,
286,
7576,
284,
22180,
764,
36481,
26962,
1021,
310,
22180,
764,
9472,
644,
84583,
764,
446,
2784,
498,
836,
11,
3641,
11,
330,
86,
2933,
1158,
286,
5235,
286,
369,
3335,
304,
7576,
512,
310,
60898,
284,
38599,
34,
10833,
6607,
24728,
696,
310,
3229,
284,
13082,
4736,
23790,
1278,
8362,
696,
310,
422,
3229,
512,
394,
7692,
3229,
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
] |
Opentrons/opentrons | api/src/opentrons/hardware_control/__init__.py | API.home_plunger | async def home_plunger(self, mount: top_types.Mount):
"""
Home the plunger motor for a mount, and then return it to the 'bottom'
position.
:param mount: the mount associated with the target plunger
:type mount: :py:class:`.top_types.Mount`
"""
instr = self._attached_instruments[mount]
if instr:
await self.home([Axis.of_plunger(mount)])
await self._move_plunger(mount,
instr.config.bottom) | python | async def home_plunger(self, mount: top_types.Mount):
"""
Home the plunger motor for a mount, and then return it to the 'bottom'
position.
:param mount: the mount associated with the target plunger
:type mount: :py:class:`.top_types.Mount`
"""
instr = self._attached_instruments[mount]
if instr:
await self.home([Axis.of_plunger(mount)])
await self._move_plunger(mount,
instr.config.bottom) | [
"async",
"def",
"home_plunger",
"(",
"self",
",",
"mount",
":",
"top_types",
".",
"Mount",
")",
":",
"instr",
"=",
"self",
".",
"_attached_instruments",
"[",
"mount",
"]",
"if",
"instr",
":",
"await",
"self",
".",
"home",
"(",
"[",
"Axis",
".",
"of_plunger",
"(",
"mount",
")",
"]",
")",
"await",
"self",
".",
"_move_plunger",
"(",
"mount",
",",
"instr",
".",
"config",
".",
"bottom",
")"
] | Home the plunger motor for a mount, and then return it to the 'bottom'
position.
:param mount: the mount associated with the target plunger
:type mount: :py:class:`.top_types.Mount` | [
"Home",
"the",
"plunger",
"motor",
"for",
"a",
"mount",
"and",
"then",
"return",
"it",
"to",
"the",
"bottom",
"position",
"."
] | train | https://github.com/Opentrons/opentrons/blob/a7c15cc2636ecb64ab56c7edc1d8a57163aaeadf/api/src/opentrons/hardware_control/__init__.py#L383-L395 | <|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:
Home the plunger motor for a mount, and then return it to the 'bottom'
position.
:param mount: the mount associated with the target plunger
:type mount: :py:class:`.top_types.Mount`
### Response:
async def home_plunger(self, mount: top_types.Mount):
"""
Home the plunger motor for a mount, and then return it to the 'bottom'
position.
:param mount: the mount associated with the target plunger
:type mount: :py:class:`.top_types.Mount`
"""
instr = self._attached_instruments[mount]
if instr:
await self.home([Axis.of_plunger(mount)])
await self._move_plunger(mount,
instr.config.bottom)
<|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,
7778,
279,
628,
72722,
9048,
369,
264,
6606,
11,
323,
1243,
471,
433,
311,
279,
364,
15205,
1270,
286,
2361,
382,
286,
551,
913,
6606,
25,
279,
6606,
5938,
449,
279,
2218,
628,
72722,
198,
286,
551,
1337,
6606,
25,
551,
3368,
93064,
19258,
13,
3565,
9962,
1345,
632,
19884,
14711,
6075,
512,
7847,
711,
2162,
6451,
72722,
1214,
11,
6606,
25,
1948,
9962,
1345,
632,
997,
286,
3270,
286,
5492,
279,
628,
72722,
9048,
369,
264,
6606,
11,
323,
1243,
471,
433,
311,
279,
364,
15205,
1270,
286,
2361,
382,
286,
551,
913,
6606,
25,
279,
6606,
5938,
449,
279,
2218,
628,
72722,
198,
286,
551,
1337,
6606,
25,
551,
3368,
93064,
19258,
13,
3565,
9962,
1345,
632,
4077,
286,
3270,
286,
9680,
284,
659,
1462,
68597,
1265,
38818,
12335,
632,
933,
286,
422,
9680,
512,
310,
2597,
659,
23399,
2625,
8306,
10440,
6451,
72722,
1278,
632,
28243,
310,
2597,
659,
1462,
3479,
6451,
72722,
1278,
632,
345,
10812,
9680,
5539,
17993,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
7778,
279,
628,
72722,
9048,
369,
264,
6606,
11,
323,
1243,
471,
433,
311,
279,
364,
15205,
1270,
286,
2361,
382,
286,
551,
913,
6606,
25,
279,
6606,
5938,
449,
279,
2218,
628,
72722,
198,
286,
551,
1337,
6606,
25,
551,
3368,
93064,
19258,
13,
3565,
9962,
1345,
632,
19884,
14711,
6075,
512,
7847,
711,
2162,
6451,
72722,
1214,
11,
6606,
25,
1948,
9962,
1345,
632,
997,
286,
3270,
286,
5492,
279,
628,
72722,
9048,
369,
264,
6606,
11,
323,
1243,
471,
433,
311,
279,
364,
15205,
1270,
286,
2361,
382,
286,
551,
913,
6606,
25,
279,
6606,
5938,
449,
279,
2218,
628,
72722,
198,
286,
551,
1337,
6606,
25,
551,
3368,
93064,
19258,
13,
3565,
9962,
1345,
632,
4077,
286,
3270,
286,
9680,
284,
659,
1462,
68597,
1265,
38818,
12335,
632,
933,
286,
422,
9680,
512,
310,
2597,
659,
23399,
2625,
8306,
10440,
6451,
72722,
1278,
632,
28243,
310,
2597,
659,
1462,
3479,
6451,
72722,
1278,
632,
345,
10812,
9680,
5539,
17993,
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
] |
tamasgal/km3pipe | km3pipe/utils/streamds.py | convert_runsummary_to_json | def convert_runsummary_to_json(
df, comment='Uploaded via km3pipe.StreamDS', prefix='TEST_'
):
"""Convert a Pandas DataFrame with runsummary to JSON for DB upload"""
data_field = []
comment += ", by {}".format(getpass.getuser())
for det_id, det_data in df.groupby('det_id'):
runs_field = []
data_field.append({"DetectorId": det_id, "Runs": runs_field})
for run, run_data in det_data.groupby('run'):
parameters_field = []
runs_field.append({
"Run": int(run),
"Parameters": parameters_field
})
parameter_dict = {}
for row in run_data.itertuples():
for parameter_name in run_data.columns:
if parameter_name in REQUIRED_COLUMNS:
continue
if parameter_name not in parameter_dict:
entry = {'Name': prefix + parameter_name, 'Data': []}
parameter_dict[parameter_name] = entry
data_value = getattr(row, parameter_name)
try:
data_value = float(data_value)
except ValueError as e:
log.critical("Data values has to be floats!")
raise ValueError(e)
value = {'S': str(getattr(row, 'source')), 'D': data_value}
parameter_dict[parameter_name]['Data'].append(value)
for parameter_data in parameter_dict.values():
parameters_field.append(parameter_data)
data_to_upload = {"Comment": comment, "Data": data_field}
file_data_to_upload = json.dumps(data_to_upload)
return file_data_to_upload | python | def convert_runsummary_to_json(
df, comment='Uploaded via km3pipe.StreamDS', prefix='TEST_'
):
"""Convert a Pandas DataFrame with runsummary to JSON for DB upload"""
data_field = []
comment += ", by {}".format(getpass.getuser())
for det_id, det_data in df.groupby('det_id'):
runs_field = []
data_field.append({"DetectorId": det_id, "Runs": runs_field})
for run, run_data in det_data.groupby('run'):
parameters_field = []
runs_field.append({
"Run": int(run),
"Parameters": parameters_field
})
parameter_dict = {}
for row in run_data.itertuples():
for parameter_name in run_data.columns:
if parameter_name in REQUIRED_COLUMNS:
continue
if parameter_name not in parameter_dict:
entry = {'Name': prefix + parameter_name, 'Data': []}
parameter_dict[parameter_name] = entry
data_value = getattr(row, parameter_name)
try:
data_value = float(data_value)
except ValueError as e:
log.critical("Data values has to be floats!")
raise ValueError(e)
value = {'S': str(getattr(row, 'source')), 'D': data_value}
parameter_dict[parameter_name]['Data'].append(value)
for parameter_data in parameter_dict.values():
parameters_field.append(parameter_data)
data_to_upload = {"Comment": comment, "Data": data_field}
file_data_to_upload = json.dumps(data_to_upload)
return file_data_to_upload | [
"def",
"convert_runsummary_to_json",
"(",
"df",
",",
"comment",
"=",
"'Uploaded via km3pipe.StreamDS'",
",",
"prefix",
"=",
"'TEST_'",
")",
":",
"data_field",
"=",
"[",
"]",
"comment",
"+=",
"\", by {}\"",
".",
"format",
"(",
"getpass",
".",
"getuser",
"(",
")",
")",
"for",
"det_id",
",",
"det_data",
"in",
"df",
".",
"groupby",
"(",
"'det_id'",
")",
":",
"runs_field",
"=",
"[",
"]",
"data_field",
".",
"append",
"(",
"{",
"\"DetectorId\"",
":",
"det_id",
",",
"\"Runs\"",
":",
"runs_field",
"}",
")",
"for",
"run",
",",
"run_data",
"in",
"det_data",
".",
"groupby",
"(",
"'run'",
")",
":",
"parameters_field",
"=",
"[",
"]",
"runs_field",
".",
"append",
"(",
"{",
"\"Run\"",
":",
"int",
"(",
"run",
")",
",",
"\"Parameters\"",
":",
"parameters_field",
"}",
")",
"parameter_dict",
"=",
"{",
"}",
"for",
"row",
"in",
"run_data",
".",
"itertuples",
"(",
")",
":",
"for",
"parameter_name",
"in",
"run_data",
".",
"columns",
":",
"if",
"parameter_name",
"in",
"REQUIRED_COLUMNS",
":",
"continue",
"if",
"parameter_name",
"not",
"in",
"parameter_dict",
":",
"entry",
"=",
"{",
"'Name'",
":",
"prefix",
"+",
"parameter_name",
",",
"'Data'",
":",
"[",
"]",
"}",
"parameter_dict",
"[",
"parameter_name",
"]",
"=",
"entry",
"data_value",
"=",
"getattr",
"(",
"row",
",",
"parameter_name",
")",
"try",
":",
"data_value",
"=",
"float",
"(",
"data_value",
")",
"except",
"ValueError",
"as",
"e",
":",
"log",
".",
"critical",
"(",
"\"Data values has to be floats!\"",
")",
"raise",
"ValueError",
"(",
"e",
")",
"value",
"=",
"{",
"'S'",
":",
"str",
"(",
"getattr",
"(",
"row",
",",
"'source'",
")",
")",
",",
"'D'",
":",
"data_value",
"}",
"parameter_dict",
"[",
"parameter_name",
"]",
"[",
"'Data'",
"]",
".",
"append",
"(",
"value",
")",
"for",
"parameter_data",
"in",
"parameter_dict",
".",
"values",
"(",
")",
":",
"parameters_field",
".",
"append",
"(",
"parameter_data",
")",
"data_to_upload",
"=",
"{",
"\"Comment\"",
":",
"comment",
",",
"\"Data\"",
":",
"data_field",
"}",
"file_data_to_upload",
"=",
"json",
".",
"dumps",
"(",
"data_to_upload",
")",
"return",
"file_data_to_upload"
] | Convert a Pandas DataFrame with runsummary to JSON for DB upload | [
"Convert",
"a",
"Pandas",
"DataFrame",
"with",
"runsummary",
"to",
"JSON",
"for",
"DB",
"upload"
] | train | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/streamds.py#L165-L203 | <|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 a Pandas DataFrame with runsummary to JSON for DB upload
### Response:
def convert_runsummary_to_json(
df, comment='Uploaded via km3pipe.StreamDS', prefix='TEST_'
):
"""Convert a Pandas DataFrame with runsummary to JSON for DB upload"""
data_field = []
comment += ", by {}".format(getpass.getuser())
for det_id, det_data in df.groupby('det_id'):
runs_field = []
data_field.append({"DetectorId": det_id, "Runs": runs_field})
for run, run_data in det_data.groupby('run'):
parameters_field = []
runs_field.append({
"Run": int(run),
"Parameters": parameters_field
})
parameter_dict = {}
for row in run_data.itertuples():
for parameter_name in run_data.columns:
if parameter_name in REQUIRED_COLUMNS:
continue
if parameter_name not in parameter_dict:
entry = {'Name': prefix + parameter_name, 'Data': []}
parameter_dict[parameter_name] = entry
data_value = getattr(row, parameter_name)
try:
data_value = float(data_value)
except ValueError as e:
log.critical("Data values has to be floats!")
raise ValueError(e)
value = {'S': str(getattr(row, 'source')), 'D': data_value}
parameter_dict[parameter_name]['Data'].append(value)
for parameter_data in parameter_dict.values():
parameters_field.append(parameter_data)
data_to_upload = {"Comment": comment, "Data": data_field}
file_data_to_upload = json.dumps(data_to_upload)
return file_data_to_upload
<|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,
264,
34606,
300,
46886,
449,
1629,
1743,
311,
4823,
369,
6078,
8298,
271,
14711,
6075,
512,
755,
5625,
14334,
1743,
2401,
9643,
1021,
286,
6907,
11,
4068,
1151,
63161,
4669,
13437,
18,
14086,
34408,
6061,
518,
9436,
1151,
10238,
62,
1270,
997,
262,
4304,
12281,
264,
34606,
300,
46886,
449,
1629,
1743,
311,
4823,
369,
6078,
8298,
7275,
262,
828,
5121,
284,
4260,
262,
4068,
1447,
3755,
555,
21532,
2293,
5550,
6519,
673,
882,
2455,
262,
369,
3474,
851,
11,
3474,
1807,
304,
6907,
54782,
493,
19842,
851,
11290,
286,
8640,
5121,
284,
4260,
286,
828,
5121,
2102,
17289,
32706,
769,
794,
3474,
851,
11,
330,
75020,
794,
8640,
5121,
9000,
286,
369,
1629,
11,
1629,
1807,
304,
3474,
1807,
54782,
493,
6236,
11290,
310,
5137,
5121,
284,
4260,
310,
8640,
5121,
2102,
2313,
394,
330,
6869,
794,
528,
39872,
1350,
394,
330,
9905,
794,
5137,
5121,
198,
310,
9763,
310,
5852,
5356,
284,
5731,
310,
369,
2872,
304,
1629,
1807,
15965,
531,
29423,
4019,
394,
369,
5852,
1292,
304,
1629,
1807,
21838,
512,
504,
422,
5852,
1292,
304,
67677,
73003,
512,
667,
3136,
271,
504,
422,
5852,
1292,
539,
304,
5852,
5356,
512,
667,
4441,
284,
5473,
678,
1232,
9436,
489,
5852,
1292,
11,
364,
1061,
1232,
3132,
534,
667,
5852,
5356,
58,
16577,
1292,
60,
284,
4441,
198,
504,
828,
3220,
284,
31097,
7991,
11,
5852,
1292,
340,
504,
1456,
512,
667,
828,
3220,
284,
2273,
2657,
3220,
340,
504,
3734,
15764,
439,
384,
512,
667,
1515,
522,
14849,
446,
1061,
2819,
706,
311,
387,
49002,
23849,
667,
4933,
15764,
2069,
340,
504,
907,
284,
5473,
50,
1232,
610,
5550,
3064,
7991,
11,
364,
2484,
47359,
364,
35,
1232,
828,
3220,
534,
504,
5852,
5356,
58,
16577,
1292,
5465,
1061,
7352,
5200,
3764,
340,
310,
369,
5852,
1807,
304,
5852,
5356,
10883,
4019,
394,
5137,
5121,
2102,
42794,
1807,
340,
262,
828,
2401,
22433,
284,
5324,
10906,
794,
4068,
11,
330,
1061,
794,
828,
5121,
534,
262,
1052,
1807,
2401,
22433,
284,
3024,
22252,
2657,
2401,
22433,
340,
262,
471,
1052,
1807,
2401,
22433,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
264,
34606,
300,
46886,
449,
1629,
1743,
311,
4823,
369,
6078,
8298,
271,
14711,
6075,
512,
755,
5625,
14334,
1743,
2401,
9643,
1021,
286,
6907,
11,
4068,
1151,
63161,
4669,
13437,
18,
14086,
34408,
6061,
518,
9436,
1151,
10238,
62,
1270,
997,
262,
4304,
12281,
264,
34606,
300,
46886,
449,
1629,
1743,
311,
4823,
369,
6078,
8298,
7275,
262,
828,
5121,
284,
4260,
262,
4068,
1447,
3755,
555,
21532,
2293,
5550,
6519,
673,
882,
2455,
262,
369,
3474,
851,
11,
3474,
1807,
304,
6907,
54782,
493,
19842,
851,
11290,
286,
8640,
5121,
284,
4260,
286,
828,
5121,
2102,
17289,
32706,
769,
794,
3474,
851,
11,
330,
75020,
794,
8640,
5121,
9000,
286,
369,
1629,
11,
1629,
1807,
304,
3474,
1807,
54782,
493,
6236,
11290,
310,
5137,
5121,
284,
4260,
310,
8640,
5121,
2102,
2313,
394,
330,
6869,
794,
528,
39872,
1350,
394,
330,
9905,
794,
5137,
5121,
198,
310,
9763,
310,
5852,
5356,
284,
5731,
310,
369,
2872,
304,
1629,
1807,
15965,
531,
29423,
4019,
394,
369,
5852,
1292,
304,
1629,
1807,
21838,
512,
504,
422,
5852,
1292,
304,
67677,
73003,
512,
667,
3136,
271,
504,
422,
5852,
1292,
539,
304,
5852,
5356,
512,
667,
4441,
284,
5473,
678,
1232,
9436,
489,
5852,
1292,
11,
364,
1061,
1232,
3132,
534,
667,
5852,
5356,
58,
16577,
1292,
60,
284,
4441,
198,
504,
828,
3220,
284,
31097,
7991,
11,
5852,
1292,
340,
504,
1456,
512,
667,
828,
3220,
284,
2273,
2657,
3220,
340,
504,
3734,
15764,
439,
384,
512,
667,
1515,
522,
14849,
446,
1061,
2819,
706,
311,
387,
49002,
23849,
667,
4933,
15764,
2069,
340,
504,
907,
284,
5473,
50,
1232,
610,
5550,
3064,
7991,
11,
364,
2484,
47359,
364,
35,
1232,
828,
3220,
534,
504,
5852,
5356,
58,
16577,
1292,
5465,
1061,
7352,
5200,
3764,
340,
310,
369,
5852,
1807,
304,
5852,
5356,
10883,
4019,
394,
5137,
5121,
2102,
42794,
1807,
340,
262,
828,
2401,
22433,
284,
5324,
10906,
794,
4068,
11,
330,
1061,
794,
828,
5121,
534,
262,
1052,
1807,
2401,
22433,
284,
3024,
22252,
2657,
2401,
22433,
340,
262,
471,
1052,
1807,
2401,
22433,
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
] |
cloud-custodian/cloud-custodian | tools/c7n_logexporter/c7n_logexporter/exporter.py | export | def export(group, bucket, prefix, start, end, role, poll_period=120,
session=None, name="", region=None):
"""export a given log group to s3"""
start = start and isinstance(start, six.string_types) and parse(start) or start
end = (end and isinstance(start, six.string_types) and
parse(end) or end or datetime.now())
start = start.replace(tzinfo=tzlocal()).astimezone(tzutc())
end = end.replace(tzinfo=tzlocal()).astimezone(tzutc())
if session is None:
session = get_session(role, region)
client = session.client('logs')
paginator = client.get_paginator('describe_log_groups')
for p in paginator.paginate():
found = False
for _group in p['logGroups']:
if _group['logGroupName'] == group:
group = _group
found = True
break
if found:
break
if not found:
raise ValueError("Log group %s not found." % group)
if prefix:
prefix = "%s/%s" % (prefix.rstrip('/'), group['logGroupName'].strip('/'))
else:
prefix = group['logGroupName']
named_group = "%s:%s" % (name, group['logGroupName'])
log.info(
"Log exporting group:%s start:%s end:%s bucket:%s prefix:%s size:%s",
named_group,
start.strftime('%Y/%m/%d'),
end.strftime('%Y/%m/%d'),
bucket,
prefix,
group['storedBytes'])
t = time.time()
days = [(
start + timedelta(i)).replace(minute=0, hour=0, second=0, microsecond=0)
for i in range((end - start).days)]
day_count = len(days)
s3 = boto3.Session().client('s3')
days = filter_extant_exports(s3, bucket, prefix, days, start, end)
log.info("Group:%s filtering s3 extant keys from %d to %d start:%s end:%s",
named_group, day_count, len(days),
days[0] if days else '', days[-1] if days else '')
t = time.time()
retry = get_retry(('SlowDown',))
for idx, d in enumerate(days):
date = d.replace(minute=0, microsecond=0, hour=0)
export_prefix = "%s%s" % (prefix, date.strftime("/%Y/%m/%d"))
params = {
'taskName': "%s-%s" % ("c7n-log-exporter",
date.strftime("%Y-%m-%d")),
'logGroupName': group['logGroupName'],
'fromTime': int(time.mktime(
date.replace(
minute=0, microsecond=0, hour=0).timetuple()) * 1000),
'to': int(time.mktime(
date.replace(
minute=59, hour=23, microsecond=0).timetuple()) * 1000),
'destination': bucket,
'destinationPrefix': export_prefix
}
# if stream_prefix:
# params['logStreamPrefix'] = stream_prefix
try:
s3.head_object(Bucket=bucket, Key=prefix)
except ClientError as e:
if e.response['Error']['Code'] != '404': # Not Found
raise
s3.put_object(
Bucket=bucket,
Key=prefix,
Body=json.dumps({}),
ACL="bucket-owner-full-control",
ServerSideEncryption="AES256")
t = time.time()
counter = 0
while True:
counter += 1
try:
result = client.create_export_task(**params)
except ClientError as e:
if e.response['Error']['Code'] == 'LimitExceededException':
time.sleep(poll_period)
# log every 30m of export waiting
if counter % 6 == 0:
log.debug(
"group:%s day:%s waiting for %0.2f minutes",
named_group, d.strftime('%Y-%m-%d'),
(counter * poll_period) / 60.0)
continue
raise
retry(
s3.put_object_tagging,
Bucket=bucket, Key=prefix,
Tagging={
'TagSet': [{
'Key': 'LastExport',
'Value': d.isoformat()}]})
break
log.info(
"Log export time:%0.2f group:%s day:%s bucket:%s prefix:%s task:%s",
time.time() - t,
named_group,
d.strftime("%Y-%m-%d"),
bucket,
params['destinationPrefix'],
result['taskId'])
log.info(
("Exported log group:%s time:%0.2f days:%d start:%s"
" end:%s bucket:%s prefix:%s"),
named_group,
time.time() - t,
len(days),
start.strftime('%Y/%m/%d'),
end.strftime('%Y/%m/%d'),
bucket,
prefix) | python | def export(group, bucket, prefix, start, end, role, poll_period=120,
session=None, name="", region=None):
"""export a given log group to s3"""
start = start and isinstance(start, six.string_types) and parse(start) or start
end = (end and isinstance(start, six.string_types) and
parse(end) or end or datetime.now())
start = start.replace(tzinfo=tzlocal()).astimezone(tzutc())
end = end.replace(tzinfo=tzlocal()).astimezone(tzutc())
if session is None:
session = get_session(role, region)
client = session.client('logs')
paginator = client.get_paginator('describe_log_groups')
for p in paginator.paginate():
found = False
for _group in p['logGroups']:
if _group['logGroupName'] == group:
group = _group
found = True
break
if found:
break
if not found:
raise ValueError("Log group %s not found." % group)
if prefix:
prefix = "%s/%s" % (prefix.rstrip('/'), group['logGroupName'].strip('/'))
else:
prefix = group['logGroupName']
named_group = "%s:%s" % (name, group['logGroupName'])
log.info(
"Log exporting group:%s start:%s end:%s bucket:%s prefix:%s size:%s",
named_group,
start.strftime('%Y/%m/%d'),
end.strftime('%Y/%m/%d'),
bucket,
prefix,
group['storedBytes'])
t = time.time()
days = [(
start + timedelta(i)).replace(minute=0, hour=0, second=0, microsecond=0)
for i in range((end - start).days)]
day_count = len(days)
s3 = boto3.Session().client('s3')
days = filter_extant_exports(s3, bucket, prefix, days, start, end)
log.info("Group:%s filtering s3 extant keys from %d to %d start:%s end:%s",
named_group, day_count, len(days),
days[0] if days else '', days[-1] if days else '')
t = time.time()
retry = get_retry(('SlowDown',))
for idx, d in enumerate(days):
date = d.replace(minute=0, microsecond=0, hour=0)
export_prefix = "%s%s" % (prefix, date.strftime("/%Y/%m/%d"))
params = {
'taskName': "%s-%s" % ("c7n-log-exporter",
date.strftime("%Y-%m-%d")),
'logGroupName': group['logGroupName'],
'fromTime': int(time.mktime(
date.replace(
minute=0, microsecond=0, hour=0).timetuple()) * 1000),
'to': int(time.mktime(
date.replace(
minute=59, hour=23, microsecond=0).timetuple()) * 1000),
'destination': bucket,
'destinationPrefix': export_prefix
}
# if stream_prefix:
# params['logStreamPrefix'] = stream_prefix
try:
s3.head_object(Bucket=bucket, Key=prefix)
except ClientError as e:
if e.response['Error']['Code'] != '404': # Not Found
raise
s3.put_object(
Bucket=bucket,
Key=prefix,
Body=json.dumps({}),
ACL="bucket-owner-full-control",
ServerSideEncryption="AES256")
t = time.time()
counter = 0
while True:
counter += 1
try:
result = client.create_export_task(**params)
except ClientError as e:
if e.response['Error']['Code'] == 'LimitExceededException':
time.sleep(poll_period)
# log every 30m of export waiting
if counter % 6 == 0:
log.debug(
"group:%s day:%s waiting for %0.2f minutes",
named_group, d.strftime('%Y-%m-%d'),
(counter * poll_period) / 60.0)
continue
raise
retry(
s3.put_object_tagging,
Bucket=bucket, Key=prefix,
Tagging={
'TagSet': [{
'Key': 'LastExport',
'Value': d.isoformat()}]})
break
log.info(
"Log export time:%0.2f group:%s day:%s bucket:%s prefix:%s task:%s",
time.time() - t,
named_group,
d.strftime("%Y-%m-%d"),
bucket,
params['destinationPrefix'],
result['taskId'])
log.info(
("Exported log group:%s time:%0.2f days:%d start:%s"
" end:%s bucket:%s prefix:%s"),
named_group,
time.time() - t,
len(days),
start.strftime('%Y/%m/%d'),
end.strftime('%Y/%m/%d'),
bucket,
prefix) | [
"def",
"export",
"(",
"group",
",",
"bucket",
",",
"prefix",
",",
"start",
",",
"end",
",",
"role",
",",
"poll_period",
"=",
"120",
",",
"session",
"=",
"None",
",",
"name",
"=",
"\"\"",
",",
"region",
"=",
"None",
")",
":",
"start",
"=",
"start",
"and",
"isinstance",
"(",
"start",
",",
"six",
".",
"string_types",
")",
"and",
"parse",
"(",
"start",
")",
"or",
"start",
"end",
"=",
"(",
"end",
"and",
"isinstance",
"(",
"start",
",",
"six",
".",
"string_types",
")",
"and",
"parse",
"(",
"end",
")",
"or",
"end",
"or",
"datetime",
".",
"now",
"(",
")",
")",
"start",
"=",
"start",
".",
"replace",
"(",
"tzinfo",
"=",
"tzlocal",
"(",
")",
")",
".",
"astimezone",
"(",
"tzutc",
"(",
")",
")",
"end",
"=",
"end",
".",
"replace",
"(",
"tzinfo",
"=",
"tzlocal",
"(",
")",
")",
".",
"astimezone",
"(",
"tzutc",
"(",
")",
")",
"if",
"session",
"is",
"None",
":",
"session",
"=",
"get_session",
"(",
"role",
",",
"region",
")",
"client",
"=",
"session",
".",
"client",
"(",
"'logs'",
")",
"paginator",
"=",
"client",
".",
"get_paginator",
"(",
"'describe_log_groups'",
")",
"for",
"p",
"in",
"paginator",
".",
"paginate",
"(",
")",
":",
"found",
"=",
"False",
"for",
"_group",
"in",
"p",
"[",
"'logGroups'",
"]",
":",
"if",
"_group",
"[",
"'logGroupName'",
"]",
"==",
"group",
":",
"group",
"=",
"_group",
"found",
"=",
"True",
"break",
"if",
"found",
":",
"break",
"if",
"not",
"found",
":",
"raise",
"ValueError",
"(",
"\"Log group %s not found.\"",
"%",
"group",
")",
"if",
"prefix",
":",
"prefix",
"=",
"\"%s/%s\"",
"%",
"(",
"prefix",
".",
"rstrip",
"(",
"'/'",
")",
",",
"group",
"[",
"'logGroupName'",
"]",
".",
"strip",
"(",
"'/'",
")",
")",
"else",
":",
"prefix",
"=",
"group",
"[",
"'logGroupName'",
"]",
"named_group",
"=",
"\"%s:%s\"",
"%",
"(",
"name",
",",
"group",
"[",
"'logGroupName'",
"]",
")",
"log",
".",
"info",
"(",
"\"Log exporting group:%s start:%s end:%s bucket:%s prefix:%s size:%s\"",
",",
"named_group",
",",
"start",
".",
"strftime",
"(",
"'%Y/%m/%d'",
")",
",",
"end",
".",
"strftime",
"(",
"'%Y/%m/%d'",
")",
",",
"bucket",
",",
"prefix",
",",
"group",
"[",
"'storedBytes'",
"]",
")",
"t",
"=",
"time",
".",
"time",
"(",
")",
"days",
"=",
"[",
"(",
"start",
"+",
"timedelta",
"(",
"i",
")",
")",
".",
"replace",
"(",
"minute",
"=",
"0",
",",
"hour",
"=",
"0",
",",
"second",
"=",
"0",
",",
"microsecond",
"=",
"0",
")",
"for",
"i",
"in",
"range",
"(",
"(",
"end",
"-",
"start",
")",
".",
"days",
")",
"]",
"day_count",
"=",
"len",
"(",
"days",
")",
"s3",
"=",
"boto3",
".",
"Session",
"(",
")",
".",
"client",
"(",
"'s3'",
")",
"days",
"=",
"filter_extant_exports",
"(",
"s3",
",",
"bucket",
",",
"prefix",
",",
"days",
",",
"start",
",",
"end",
")",
"log",
".",
"info",
"(",
"\"Group:%s filtering s3 extant keys from %d to %d start:%s end:%s\"",
",",
"named_group",
",",
"day_count",
",",
"len",
"(",
"days",
")",
",",
"days",
"[",
"0",
"]",
"if",
"days",
"else",
"''",
",",
"days",
"[",
"-",
"1",
"]",
"if",
"days",
"else",
"''",
")",
"t",
"=",
"time",
".",
"time",
"(",
")",
"retry",
"=",
"get_retry",
"(",
"(",
"'SlowDown'",
",",
")",
")",
"for",
"idx",
",",
"d",
"in",
"enumerate",
"(",
"days",
")",
":",
"date",
"=",
"d",
".",
"replace",
"(",
"minute",
"=",
"0",
",",
"microsecond",
"=",
"0",
",",
"hour",
"=",
"0",
")",
"export_prefix",
"=",
"\"%s%s\"",
"%",
"(",
"prefix",
",",
"date",
".",
"strftime",
"(",
"\"/%Y/%m/%d\"",
")",
")",
"params",
"=",
"{",
"'taskName'",
":",
"\"%s-%s\"",
"%",
"(",
"\"c7n-log-exporter\"",
",",
"date",
".",
"strftime",
"(",
"\"%Y-%m-%d\"",
")",
")",
",",
"'logGroupName'",
":",
"group",
"[",
"'logGroupName'",
"]",
",",
"'fromTime'",
":",
"int",
"(",
"time",
".",
"mktime",
"(",
"date",
".",
"replace",
"(",
"minute",
"=",
"0",
",",
"microsecond",
"=",
"0",
",",
"hour",
"=",
"0",
")",
".",
"timetuple",
"(",
")",
")",
"*",
"1000",
")",
",",
"'to'",
":",
"int",
"(",
"time",
".",
"mktime",
"(",
"date",
".",
"replace",
"(",
"minute",
"=",
"59",
",",
"hour",
"=",
"23",
",",
"microsecond",
"=",
"0",
")",
".",
"timetuple",
"(",
")",
")",
"*",
"1000",
")",
",",
"'destination'",
":",
"bucket",
",",
"'destinationPrefix'",
":",
"export_prefix",
"}",
"# if stream_prefix:",
"# params['logStreamPrefix'] = stream_prefix",
"try",
":",
"s3",
".",
"head_object",
"(",
"Bucket",
"=",
"bucket",
",",
"Key",
"=",
"prefix",
")",
"except",
"ClientError",
"as",
"e",
":",
"if",
"e",
".",
"response",
"[",
"'Error'",
"]",
"[",
"'Code'",
"]",
"!=",
"'404'",
":",
"# Not Found",
"raise",
"s3",
".",
"put_object",
"(",
"Bucket",
"=",
"bucket",
",",
"Key",
"=",
"prefix",
",",
"Body",
"=",
"json",
".",
"dumps",
"(",
"{",
"}",
")",
",",
"ACL",
"=",
"\"bucket-owner-full-control\"",
",",
"ServerSideEncryption",
"=",
"\"AES256\"",
")",
"t",
"=",
"time",
".",
"time",
"(",
")",
"counter",
"=",
"0",
"while",
"True",
":",
"counter",
"+=",
"1",
"try",
":",
"result",
"=",
"client",
".",
"create_export_task",
"(",
"*",
"*",
"params",
")",
"except",
"ClientError",
"as",
"e",
":",
"if",
"e",
".",
"response",
"[",
"'Error'",
"]",
"[",
"'Code'",
"]",
"==",
"'LimitExceededException'",
":",
"time",
".",
"sleep",
"(",
"poll_period",
")",
"# log every 30m of export waiting",
"if",
"counter",
"%",
"6",
"==",
"0",
":",
"log",
".",
"debug",
"(",
"\"group:%s day:%s waiting for %0.2f minutes\"",
",",
"named_group",
",",
"d",
".",
"strftime",
"(",
"'%Y-%m-%d'",
")",
",",
"(",
"counter",
"*",
"poll_period",
")",
"/",
"60.0",
")",
"continue",
"raise",
"retry",
"(",
"s3",
".",
"put_object_tagging",
",",
"Bucket",
"=",
"bucket",
",",
"Key",
"=",
"prefix",
",",
"Tagging",
"=",
"{",
"'TagSet'",
":",
"[",
"{",
"'Key'",
":",
"'LastExport'",
",",
"'Value'",
":",
"d",
".",
"isoformat",
"(",
")",
"}",
"]",
"}",
")",
"break",
"log",
".",
"info",
"(",
"\"Log export time:%0.2f group:%s day:%s bucket:%s prefix:%s task:%s\"",
",",
"time",
".",
"time",
"(",
")",
"-",
"t",
",",
"named_group",
",",
"d",
".",
"strftime",
"(",
"\"%Y-%m-%d\"",
")",
",",
"bucket",
",",
"params",
"[",
"'destinationPrefix'",
"]",
",",
"result",
"[",
"'taskId'",
"]",
")",
"log",
".",
"info",
"(",
"(",
"\"Exported log group:%s time:%0.2f days:%d start:%s\"",
"\" end:%s bucket:%s prefix:%s\"",
")",
",",
"named_group",
",",
"time",
".",
"time",
"(",
")",
"-",
"t",
",",
"len",
"(",
"days",
")",
",",
"start",
".",
"strftime",
"(",
"'%Y/%m/%d'",
")",
",",
"end",
".",
"strftime",
"(",
"'%Y/%m/%d'",
")",
",",
"bucket",
",",
"prefix",
")"
] | export a given log group to s3 | [
"export",
"a",
"given",
"log",
"group",
"to",
"s3"
] | train | https://github.com/cloud-custodian/cloud-custodian/blob/52ef732eb3d7bc939d1579faf519314814695c08/tools/c7n_logexporter/c7n_logexporter/exporter.py#L777-L910 | <|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:
export a given log group to s3
### Response:
def export(group, bucket, prefix, start, end, role, poll_period=120,
session=None, name="", region=None):
"""export a given log group to s3"""
start = start and isinstance(start, six.string_types) and parse(start) or start
end = (end and isinstance(start, six.string_types) and
parse(end) or end or datetime.now())
start = start.replace(tzinfo=tzlocal()).astimezone(tzutc())
end = end.replace(tzinfo=tzlocal()).astimezone(tzutc())
if session is None:
session = get_session(role, region)
client = session.client('logs')
paginator = client.get_paginator('describe_log_groups')
for p in paginator.paginate():
found = False
for _group in p['logGroups']:
if _group['logGroupName'] == group:
group = _group
found = True
break
if found:
break
if not found:
raise ValueError("Log group %s not found." % group)
if prefix:
prefix = "%s/%s" % (prefix.rstrip('/'), group['logGroupName'].strip('/'))
else:
prefix = group['logGroupName']
named_group = "%s:%s" % (name, group['logGroupName'])
log.info(
"Log exporting group:%s start:%s end:%s bucket:%s prefix:%s size:%s",
named_group,
start.strftime('%Y/%m/%d'),
end.strftime('%Y/%m/%d'),
bucket,
prefix,
group['storedBytes'])
t = time.time()
days = [(
start + timedelta(i)).replace(minute=0, hour=0, second=0, microsecond=0)
for i in range((end - start).days)]
day_count = len(days)
s3 = boto3.Session().client('s3')
days = filter_extant_exports(s3, bucket, prefix, days, start, end)
log.info("Group:%s filtering s3 extant keys from %d to %d start:%s end:%s",
named_group, day_count, len(days),
days[0] if days else '', days[-1] if days else '')
t = time.time()
retry = get_retry(('SlowDown',))
for idx, d in enumerate(days):
date = d.replace(minute=0, microsecond=0, hour=0)
export_prefix = "%s%s" % (prefix, date.strftime("/%Y/%m/%d"))
params = {
'taskName': "%s-%s" % ("c7n-log-exporter",
date.strftime("%Y-%m-%d")),
'logGroupName': group['logGroupName'],
'fromTime': int(time.mktime(
date.replace(
minute=0, microsecond=0, hour=0).timetuple()) * 1000),
'to': int(time.mktime(
date.replace(
minute=59, hour=23, microsecond=0).timetuple()) * 1000),
'destination': bucket,
'destinationPrefix': export_prefix
}
# if stream_prefix:
# params['logStreamPrefix'] = stream_prefix
try:
s3.head_object(Bucket=bucket, Key=prefix)
except ClientError as e:
if e.response['Error']['Code'] != '404': # Not Found
raise
s3.put_object(
Bucket=bucket,
Key=prefix,
Body=json.dumps({}),
ACL="bucket-owner-full-control",
ServerSideEncryption="AES256")
t = time.time()
counter = 0
while True:
counter += 1
try:
result = client.create_export_task(**params)
except ClientError as e:
if e.response['Error']['Code'] == 'LimitExceededException':
time.sleep(poll_period)
# log every 30m of export waiting
if counter % 6 == 0:
log.debug(
"group:%s day:%s waiting for %0.2f minutes",
named_group, d.strftime('%Y-%m-%d'),
(counter * poll_period) / 60.0)
continue
raise
retry(
s3.put_object_tagging,
Bucket=bucket, Key=prefix,
Tagging={
'TagSet': [{
'Key': 'LastExport',
'Value': d.isoformat()}]})
break
log.info(
"Log export time:%0.2f group:%s day:%s bucket:%s prefix:%s task:%s",
time.time() - t,
named_group,
d.strftime("%Y-%m-%d"),
bucket,
params['destinationPrefix'],
result['taskId'])
log.info(
("Exported log group:%s time:%0.2f days:%d start:%s"
" end:%s bucket:%s prefix:%s"),
named_group,
time.time() - t,
len(days),
start.strftime('%Y/%m/%d'),
end.strftime('%Y/%m/%d'),
bucket,
prefix)
<|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,
1562,
264,
2728,
1515,
1912,
311,
274,
18,
271,
14711,
6075,
512,
755,
7637,
18158,
11,
15994,
11,
9436,
11,
1212,
11,
842,
11,
3560,
11,
7230,
21485,
28,
4364,
345,
1881,
3882,
5980,
11,
836,
46563,
5654,
5980,
997,
262,
4304,
1562,
264,
2728,
1515,
1912,
311,
274,
18,
7275,
262,
1212,
284,
1212,
323,
11656,
10865,
11,
4848,
4909,
9962,
8,
323,
4820,
10865,
8,
477,
1212,
198,
262,
842,
284,
320,
408,
323,
11656,
10865,
11,
4848,
4909,
9962,
8,
323,
198,
1881,
4820,
15426,
8,
477,
842,
477,
9050,
10930,
2455,
262,
1212,
284,
1212,
7125,
1175,
89,
2801,
24957,
89,
2497,
6139,
561,
547,
8855,
1175,
89,
29455,
2455,
262,
842,
284,
842,
7125,
1175,
89,
2801,
24957,
89,
2497,
6139,
561,
547,
8855,
1175,
89,
29455,
12647,
262,
422,
3882,
374,
2290,
512,
286,
3882,
284,
636,
12596,
36998,
11,
5654,
696,
262,
3016,
284,
3882,
6718,
493,
22856,
4713,
262,
70495,
284,
3016,
673,
623,
34228,
493,
12612,
5337,
21833,
1329,
262,
369,
281,
304,
70495,
73705,
3357,
4019,
286,
1766,
284,
3641,
198,
286,
369,
721,
4166,
304,
281,
681,
848,
22962,
18888,
310,
422,
721,
4166,
681,
848,
51669,
663,
624,
1912,
512,
394,
1912,
284,
721,
4166,
198,
394,
1766,
284,
3082,
198,
394,
1464,
198,
286,
422,
1766,
512,
310,
1464,
271,
262,
422,
539,
1766,
512,
286,
4933,
15764,
446,
2250,
1912,
1034,
82,
539,
1766,
1210,
1034,
1912,
696,
262,
422,
9436,
512,
286,
9436,
284,
6090,
82,
12915,
82,
1,
1034,
320,
12113,
60663,
3478,
4670,
1912,
681,
848,
51669,
7352,
13406,
3478,
7132,
262,
775,
512,
286,
9436,
284,
1912,
681,
848,
51669,
16049,
262,
7086,
6422,
284,
6090,
82,
7685,
82,
1,
1034,
320,
609,
11,
1912,
681,
848,
51669,
7519,
262,
1515,
5506,
1021,
286,
330,
2250,
61321,
1912,
7685,
82,
1212,
7685,
82,
842,
7685,
82,
15994,
7685,
82,
9436,
7685,
82,
1404,
7685,
82,
761,
286,
7086,
6422,
345,
286,
1212,
31314,
16428,
56,
12915,
76,
12915,
67,
3379,
286,
842,
31314,
16428,
56,
12915,
76,
12915,
67,
3379,
286,
15994,
345,
286,
9436,
345,
286,
1912,
681,
72349,
7223,
24287,
262,
259,
284,
892,
6512,
746,
262,
2919,
284,
510,
1021,
286,
1212,
489,
43355,
1998,
4682,
8319,
14478,
1088,
28,
15,
11,
6596,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
369,
602,
304,
2134,
1209,
408,
482,
1212,
570,
14097,
5680,
262,
1938,
3259,
284,
2479,
43695,
340,
262,
274,
18,
284,
61879,
18,
21331,
1020,
3045,
493,
82,
18,
1329,
262,
2919,
284,
4141,
10129,
519,
46409,
1161,
18,
11,
15994,
11,
9436,
11,
2919,
11,
1212,
11,
842,
696,
262,
1515,
5506,
446,
2878,
7685,
82,
30770,
274,
18,
1327,
519,
7039,
505,
1034,
67,
311,
1034,
67,
1212,
7685,
82,
842,
7685,
82
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
1562,
264,
2728,
1515,
1912,
311,
274,
18,
271,
14711,
6075,
512,
755,
7637,
18158,
11,
15994,
11,
9436,
11,
1212,
11,
842,
11,
3560,
11,
7230,
21485,
28,
4364,
345,
1881,
3882,
5980,
11,
836,
46563,
5654,
5980,
997,
262,
4304,
1562,
264,
2728,
1515,
1912,
311,
274,
18,
7275,
262,
1212,
284,
1212,
323,
11656,
10865,
11,
4848,
4909,
9962,
8,
323,
4820,
10865,
8,
477,
1212,
198,
262,
842,
284,
320,
408,
323,
11656,
10865,
11,
4848,
4909,
9962,
8,
323,
198,
1881,
4820,
15426,
8,
477,
842,
477,
9050,
10930,
2455,
262,
1212,
284,
1212,
7125,
1175,
89,
2801,
24957,
89,
2497,
6139,
561,
547,
8855,
1175,
89,
29455,
2455,
262,
842,
284,
842,
7125,
1175,
89,
2801,
24957,
89,
2497,
6139,
561,
547,
8855,
1175,
89,
29455,
12647,
262,
422,
3882,
374,
2290,
512,
286,
3882,
284,
636,
12596,
36998,
11,
5654,
696,
262,
3016,
284,
3882,
6718,
493,
22856,
4713,
262,
70495,
284,
3016,
673,
623,
34228,
493,
12612,
5337,
21833,
1329,
262,
369,
281,
304,
70495,
73705,
3357,
4019,
286,
1766,
284,
3641,
198,
286,
369,
721,
4166,
304,
281,
681,
848,
22962,
18888,
310,
422,
721,
4166,
681,
848,
51669,
663,
624,
1912,
512,
394,
1912,
284,
721,
4166,
198,
394,
1766,
284,
3082,
198,
394,
1464,
198,
286,
422,
1766,
512,
310,
1464,
271,
262,
422,
539,
1766,
512,
286,
4933,
15764,
446,
2250,
1912,
1034,
82,
539,
1766,
1210,
1034,
1912,
696,
262,
422,
9436,
512,
286,
9436,
284,
6090,
82,
12915,
82,
1,
1034,
320,
12113,
60663,
3478,
4670,
1912,
681,
848,
51669,
7352,
13406,
3478,
7132,
262,
775,
512,
286,
9436,
284,
1912,
681,
848,
51669,
16049,
262,
7086,
6422,
284,
6090,
82,
7685,
82,
1,
1034,
320,
609,
11,
1912,
681,
848,
51669,
7519,
262,
1515,
5506,
1021,
286,
330,
2250,
61321,
1912,
7685,
82,
1212,
7685,
82,
842,
7685,
82,
15994,
7685,
82,
9436,
7685,
82,
1404,
7685,
82,
761,
286,
7086,
6422,
345,
286,
1212,
31314,
16428,
56,
12915,
76,
12915,
67,
3379,
286,
842,
31314,
16428,
56,
12915,
76,
12915,
67,
3379,
286,
15994,
345,
286,
9436,
345,
286,
1912,
681,
72349,
7223,
24287,
262,
259,
284,
892,
6512,
746,
262,
2919,
284,
510,
1021,
286,
1212,
489,
43355,
1998,
4682,
8319,
14478,
1088,
28,
15,
11,
6596,
28,
15,
11,
2132,
28,
15,
11,
8162,
5686,
28,
15,
340,
286,
369,
602,
304,
2134,
1209,
408,
482,
1212,
570,
14097,
5680,
262,
1938,
3259,
284,
2479,
43695,
340,
262,
274,
18,
284,
61879,
18,
21331,
1020,
3045,
493,
82,
18,
1329,
262,
2919,
284,
4141,
10129,
519,
46409,
1161,
18,
11,
15994,
11,
9436,
11,
2919,
11,
1212,
11,
842,
696,
262,
1515,
5506,
446,
2878,
7685,
82,
30770,
274,
18,
1327,
519,
7039,
505,
1034,
67,
311,
1034,
67,
1212,
7685,
82,
842,
7685,
82
] |
pantsbuild/pants | src/python/pants/task/task.py | TaskBase._should_cache_target_dir | def _should_cache_target_dir(self, vt):
"""Return true if the given vt should be written to a cache (if configured)."""
return (
self.cache_target_dirs and
vt.cacheable and
(not vt.is_incremental or self.cache_incremental) and
self.artifact_cache_writes_enabled()
) | python | def _should_cache_target_dir(self, vt):
"""Return true if the given vt should be written to a cache (if configured)."""
return (
self.cache_target_dirs and
vt.cacheable and
(not vt.is_incremental or self.cache_incremental) and
self.artifact_cache_writes_enabled()
) | [
"def",
"_should_cache_target_dir",
"(",
"self",
",",
"vt",
")",
":",
"return",
"(",
"self",
".",
"cache_target_dirs",
"and",
"vt",
".",
"cacheable",
"and",
"(",
"not",
"vt",
".",
"is_incremental",
"or",
"self",
".",
"cache_incremental",
")",
"and",
"self",
".",
"artifact_cache_writes_enabled",
"(",
")",
")"
] | Return true if the given vt should be written to a cache (if configured). | [
"Return",
"true",
"if",
"the",
"given",
"vt",
"should",
"be",
"written",
"to",
"a",
"cache",
"(",
"if",
"configured",
")",
"."
] | train | https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/task/task.py#L548-L555 | <|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 true if the given vt should be written to a cache (if configured).
### Response:
def _should_cache_target_dir(self, vt):
"""Return true if the given vt should be written to a cache (if configured)."""
return (
self.cache_target_dirs and
vt.cacheable and
(not vt.is_incremental or self.cache_incremental) and
self.artifact_cache_writes_enabled()
)
<|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,
837,
422,
279,
2728,
40205,
1288,
387,
5439,
311,
264,
6636,
320,
333,
20336,
3677,
14711,
6075,
512,
755,
721,
5562,
11790,
11370,
4432,
1214,
11,
40205,
997,
262,
4304,
5715,
837,
422,
279,
2728,
40205,
1288,
387,
5439,
311,
264,
6636,
320,
333,
20336,
570,
7275,
262,
471,
2456,
415,
659,
20688,
11370,
45969,
323,
198,
415,
40205,
20688,
481,
323,
198,
415,
320,
1962,
40205,
2124,
52582,
278,
477,
659,
20688,
52582,
278,
8,
323,
198,
415,
659,
47986,
21417,
11790,
1704,
24143,
18721,
746,
262,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,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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
] | [
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,
837,
422,
279,
2728,
40205,
1288,
387,
5439,
311,
264,
6636,
320,
333,
20336,
3677,
14711,
6075,
512,
755,
721,
5562,
11790,
11370,
4432,
1214,
11,
40205,
997,
262,
4304,
5715,
837,
422,
279,
2728,
40205,
1288,
387,
5439,
311,
264,
6636,
320,
333,
20336,
570,
7275,
262,
471,
2456,
415,
659,
20688,
11370,
45969,
323,
198,
415,
40205,
20688,
481,
323,
198,
415,
320,
1962,
40205,
2124,
52582,
278,
477,
659,
20688,
52582,
278,
8,
323,
198,
415,
659,
47986,
21417,
11790,
1704,
24143,
18721,
746,
262,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
LogicalDash/LiSE | LiSE/LiSE/character.py | AbstractCharacter.cull_portals | def cull_portals(self, stat, threshold=0.5, comparator=ge):
"""Delete portals whose stat >= ``threshold`` (default 0.5).
Optional argument ``comparator`` will replace >= as the test
for whether to cull. You can use the name of a stored function.
"""
comparator = self._lookup_comparator(comparator)
dead = []
for u in self.portal:
for v in self.portal[u]:
if stat in self.portal[u][v] and comparator(
self.portal[u][v][stat], threshold
):
dead.append((u, v))
self.remove_edges_from(dead)
return self | python | def cull_portals(self, stat, threshold=0.5, comparator=ge):
"""Delete portals whose stat >= ``threshold`` (default 0.5).
Optional argument ``comparator`` will replace >= as the test
for whether to cull. You can use the name of a stored function.
"""
comparator = self._lookup_comparator(comparator)
dead = []
for u in self.portal:
for v in self.portal[u]:
if stat in self.portal[u][v] and comparator(
self.portal[u][v][stat], threshold
):
dead.append((u, v))
self.remove_edges_from(dead)
return self | [
"def",
"cull_portals",
"(",
"self",
",",
"stat",
",",
"threshold",
"=",
"0.5",
",",
"comparator",
"=",
"ge",
")",
":",
"comparator",
"=",
"self",
".",
"_lookup_comparator",
"(",
"comparator",
")",
"dead",
"=",
"[",
"]",
"for",
"u",
"in",
"self",
".",
"portal",
":",
"for",
"v",
"in",
"self",
".",
"portal",
"[",
"u",
"]",
":",
"if",
"stat",
"in",
"self",
".",
"portal",
"[",
"u",
"]",
"[",
"v",
"]",
"and",
"comparator",
"(",
"self",
".",
"portal",
"[",
"u",
"]",
"[",
"v",
"]",
"[",
"stat",
"]",
",",
"threshold",
")",
":",
"dead",
".",
"append",
"(",
"(",
"u",
",",
"v",
")",
")",
"self",
".",
"remove_edges_from",
"(",
"dead",
")",
"return",
"self"
] | Delete portals whose stat >= ``threshold`` (default 0.5).
Optional argument ``comparator`` will replace >= as the test
for whether to cull. You can use the name of a stored function. | [
"Delete",
"portals",
"whose",
"stat",
">",
"=",
"threshold",
"(",
"default",
"0",
".",
"5",
")",
"."
] | train | https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/character.py#L692-L708 | <|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 portals whose stat >= ``threshold`` (default 0.5).
Optional argument ``comparator`` will replace >= as the test
for whether to cull. You can use the name of a stored function.
### Response:
def cull_portals(self, stat, threshold=0.5, comparator=ge):
"""Delete portals whose stat >= ``threshold`` (default 0.5).
Optional argument ``comparator`` will replace >= as the test
for whether to cull. You can use the name of a stored function.
"""
comparator = self._lookup_comparator(comparator)
dead = []
for u in self.portal:
for v in self.portal[u]:
if stat in self.portal[u][v] and comparator(
self.portal[u][v][stat], threshold
):
dead.append((u, v))
self.remove_edges_from(dead)
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,
6571,
76563,
6832,
2863,
2669,
10103,
30002,
14196,
320,
2309,
220,
15,
13,
20,
3677,
286,
12536,
5811,
10103,
884,
12636,
14196,
690,
8454,
2669,
439,
279,
1296,
198,
286,
369,
3508,
311,
272,
620,
13,
1472,
649,
1005,
279,
836,
315,
264,
9967,
734,
382,
14711,
6075,
512,
755,
272,
620,
8889,
1147,
1214,
11,
2863,
11,
12447,
28,
15,
13,
20,
11,
53140,
28,
713,
997,
286,
4304,
6571,
76563,
6832,
2863,
2669,
10103,
30002,
14196,
320,
2309,
220,
15,
13,
20,
3677,
286,
12536,
5811,
10103,
884,
12636,
14196,
690,
8454,
2669,
439,
279,
1296,
198,
286,
369,
3508,
311,
272,
620,
13,
1472,
649,
1005,
279,
836,
315,
264,
9967,
734,
382,
286,
3270,
286,
53140,
284,
659,
1462,
21696,
3038,
12636,
14426,
12636,
340,
286,
5710,
284,
4260,
286,
369,
577,
304,
659,
35863,
512,
310,
369,
348,
304,
659,
35863,
22042,
10556,
394,
422,
2863,
304,
659,
35863,
22042,
1483,
85,
60,
323,
53140,
1021,
667,
659,
35863,
22042,
1483,
85,
1483,
10079,
1145,
12447,
198,
394,
21711,
504,
5710,
2102,
1209,
84,
11,
348,
1192,
286,
659,
4955,
29126,
5791,
84307,
340,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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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669,
10103,
30002,
14196,
320,
2309,
220,
15,
13,
20,
3677,
286,
12536,
5811,
10103,
884,
12636,
14196,
690,
8454,
2669,
439,
279,
1296,
198,
286,
369,
3508,
311,
272,
620,
13,
1472,
649,
1005,
279,
836,
315,
264,
9967,
734,
382,
14711,
6075,
512,
755,
272,
620,
8889,
1147,
1214,
11,
2863,
11,
12447,
28,
15,
13,
20,
11,
53140,
28,
713,
997,
286,
4304,
6571,
76563,
6832,
2863,
2669,
10103,
30002,
14196,
320,
2309,
220,
15,
13,
20,
3677,
286,
12536,
5811,
10103,
884,
12636,
14196,
690,
8454,
2669,
439,
279,
1296,
198,
286,
369,
3508,
311,
272,
620,
13,
1472,
649,
1005,
279,
836,
315,
264,
9967,
734,
382,
286,
3270,
286,
53140,
284,
659,
1462,
21696,
3038,
12636,
14426,
12636,
340,
286,
5710,
284,
4260,
286,
369,
577,
304,
659,
35863,
512,
310,
369,
348,
304,
659,
35863,
22042,
10556,
394,
422,
2863,
304,
659,
35863,
22042,
1483,
85,
60,
323,
53140,
1021,
667,
659,
35863,
22042,
1483,
85,
1483,
10079,
1145,
12447,
198,
394,
21711,
504,
5710,
2102,
1209,
84,
11,
348,
1192,
286,
659,
4955,
29126,
5791,
84307,
340,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
nuagenetworks/bambou | bambou/utils/nuremote_attribute.py | NURemoteAttribute.get_min_value | def get_min_value(self):
""" Get the minimum value """
value = self.get_default_value()
if self.attribute_type is str:
min_value = value[:self.min_length - 1]
elif self.attribute_type is int:
min_value = self.min_length - 1
else:
raise TypeError('Attribute %s can not have a minimum value' % self.local_name)
return min_value | python | def get_min_value(self):
""" Get the minimum value """
value = self.get_default_value()
if self.attribute_type is str:
min_value = value[:self.min_length - 1]
elif self.attribute_type is int:
min_value = self.min_length - 1
else:
raise TypeError('Attribute %s can not have a minimum value' % self.local_name)
return min_value | [
"def",
"get_min_value",
"(",
"self",
")",
":",
"value",
"=",
"self",
".",
"get_default_value",
"(",
")",
"if",
"self",
".",
"attribute_type",
"is",
"str",
":",
"min_value",
"=",
"value",
"[",
":",
"self",
".",
"min_length",
"-",
"1",
"]",
"elif",
"self",
".",
"attribute_type",
"is",
"int",
":",
"min_value",
"=",
"self",
".",
"min_length",
"-",
"1",
"else",
":",
"raise",
"TypeError",
"(",
"'Attribute %s can not have a minimum value'",
"%",
"self",
".",
"local_name",
")",
"return",
"min_value"
] | Get the minimum value | [
"Get",
"the",
"minimum",
"value"
] | train | https://github.com/nuagenetworks/bambou/blob/d334fea23e384d3df8e552fe1849ad707941c666/bambou/utils/nuremote_attribute.py#L143-L157 | <|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 minimum value
### Response:
def get_min_value(self):
""" Get the minimum value """
value = self.get_default_value()
if self.attribute_type is str:
min_value = value[:self.min_length - 1]
elif self.attribute_type is int:
min_value = self.min_length - 1
else:
raise TypeError('Attribute %s can not have a minimum value' % self.local_name)
return min_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,
1991,
279,
8187,
907,
271,
14711,
6075,
512,
755,
636,
7408,
3220,
1214,
997,
286,
4304,
2175,
279,
8187,
907,
12713,
286,
907,
284,
659,
673,
10198,
3220,
2892,
286,
422,
659,
39910,
1857,
374,
610,
512,
310,
1332,
3220,
284,
907,
3530,
726,
4456,
5228,
482,
220,
16,
2595,
286,
4508,
659,
39910,
1857,
374,
528,
512,
310,
1332,
3220,
284,
659,
4456,
5228,
482,
220,
16,
271,
286,
775,
512,
310,
4933,
26082,
493,
3994,
1034,
82,
649,
539,
617,
264,
8187,
907,
6,
1034,
659,
11279,
1292,
696,
286,
471,
1332,
3220,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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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,
1991,
279,
8187,
907,
271,
14711,
6075,
512,
755,
636,
7408,
3220,
1214,
997,
286,
4304,
2175,
279,
8187,
907,
12713,
286,
907,
284,
659,
673,
10198,
3220,
2892,
286,
422,
659,
39910,
1857,
374,
610,
512,
310,
1332,
3220,
284,
907,
3530,
726,
4456,
5228,
482,
220,
16,
2595,
286,
4508,
659,
39910,
1857,
374,
528,
512,
310,
1332,
3220,
284,
659,
4456,
5228,
482,
220,
16,
271,
286,
775,
512,
310,
4933,
26082,
493,
3994,
1034,
82,
649,
539,
617,
264,
8187,
907,
6,
1034,
659,
11279,
1292,
696,
286,
471,
1332,
3220,
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
] |
RedHatInsights/insights-core | insights/core/__init__.py | LogFileOutput.parse_content | def parse_content(self, content):
"""
Use all the defined scanners to search the log file, setting the
properties defined in the scanner.
"""
self.lines = content
for scanner in self.scanners:
scanner(self) | python | def parse_content(self, content):
"""
Use all the defined scanners to search the log file, setting the
properties defined in the scanner.
"""
self.lines = content
for scanner in self.scanners:
scanner(self) | [
"def",
"parse_content",
"(",
"self",
",",
"content",
")",
":",
"self",
".",
"lines",
"=",
"content",
"for",
"scanner",
"in",
"self",
".",
"scanners",
":",
"scanner",
"(",
"self",
")"
] | Use all the defined scanners to search the log file, setting the
properties defined in the scanner. | [
"Use",
"all",
"the",
"defined",
"scanners",
"to",
"search",
"the",
"log",
"file",
"setting",
"the",
"properties",
"defined",
"in",
"the",
"scanner",
"."
] | train | https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/__init__.py#L902-L909 | <|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 all the defined scanners to search the log file, setting the
properties defined in the scanner.
### Response:
def parse_content(self, content):
"""
Use all the defined scanners to search the log file, setting the
properties defined in the scanner.
"""
self.lines = content
for scanner in self.scanners:
scanner(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,
10464,
682,
279,
4613,
95146,
311,
2778,
279,
1515,
1052,
11,
6376,
279,
198,
286,
6012,
4613,
304,
279,
21438,
382,
14711,
6075,
512,
755,
4820,
7647,
1214,
11,
2262,
997,
286,
3270,
286,
5560,
682,
279,
4613,
95146,
311,
2778,
279,
1515,
1052,
11,
6376,
279,
198,
286,
6012,
4613,
304,
279,
21438,
627,
286,
3270,
286,
659,
45161,
284,
2262,
198,
286,
369,
21438,
304,
659,
7840,
24960,
512,
310,
21438,
1214,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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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,
10464,
682,
279,
4613,
95146,
311,
2778,
279,
1515,
1052,
11,
6376,
279,
198,
286,
6012,
4613,
304,
279,
21438,
382,
14711,
6075,
512,
755,
4820,
7647,
1214,
11,
2262,
997,
286,
3270,
286,
5560,
682,
279,
4613,
95146,
311,
2778,
279,
1515,
1052,
11,
6376,
279,
198,
286,
6012,
4613,
304,
279,
21438,
627,
286,
3270,
286,
659,
45161,
284,
2262,
198,
286,
369,
21438,
304,
659,
7840,
24960,
512,
310,
21438,
1214,
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
] |
pytroll/trollimage | trollimage/colorspaces.py | rgb2xyz | def rgb2xyz(r__, g__, b__):
"""RGB to XYZ
"""
r2_ = r__ / 255.0
g2_ = g__ / 255.0
b2_ = b__ / 255.0
def f__(arr):
"""Forward
"""
return np.where(arr > 0.04045,
((arr + 0.055) / 1.055) ** 2.4,
arr / 12.92)
r2_ = f__(r2_) * 100
g2_ = f__(g2_) * 100
b2_ = f__(b2_) * 100
x__ = r2_ * 0.4124 + g2_ * 0.3576 + b2_ * 0.1805
y__ = r2_ * 0.2126 + g2_ * 0.7152 + b2_ * 0.0722
z__ = r2_ * 0.0193 + g2_ * 0.1192 + b2_ * 0.9505
return x__, y__, z__ | python | def rgb2xyz(r__, g__, b__):
"""RGB to XYZ
"""
r2_ = r__ / 255.0
g2_ = g__ / 255.0
b2_ = b__ / 255.0
def f__(arr):
"""Forward
"""
return np.where(arr > 0.04045,
((arr + 0.055) / 1.055) ** 2.4,
arr / 12.92)
r2_ = f__(r2_) * 100
g2_ = f__(g2_) * 100
b2_ = f__(b2_) * 100
x__ = r2_ * 0.4124 + g2_ * 0.3576 + b2_ * 0.1805
y__ = r2_ * 0.2126 + g2_ * 0.7152 + b2_ * 0.0722
z__ = r2_ * 0.0193 + g2_ * 0.1192 + b2_ * 0.9505
return x__, y__, z__ | [
"def",
"rgb2xyz",
"(",
"r__",
",",
"g__",
",",
"b__",
")",
":",
"r2_",
"=",
"r__",
"/",
"255.0",
"g2_",
"=",
"g__",
"/",
"255.0",
"b2_",
"=",
"b__",
"/",
"255.0",
"def",
"f__",
"(",
"arr",
")",
":",
"\"\"\"Forward\n \"\"\"",
"return",
"np",
".",
"where",
"(",
"arr",
">",
"0.04045",
",",
"(",
"(",
"arr",
"+",
"0.055",
")",
"/",
"1.055",
")",
"**",
"2.4",
",",
"arr",
"/",
"12.92",
")",
"r2_",
"=",
"f__",
"(",
"r2_",
")",
"*",
"100",
"g2_",
"=",
"f__",
"(",
"g2_",
")",
"*",
"100",
"b2_",
"=",
"f__",
"(",
"b2_",
")",
"*",
"100",
"x__",
"=",
"r2_",
"*",
"0.4124",
"+",
"g2_",
"*",
"0.3576",
"+",
"b2_",
"*",
"0.1805",
"y__",
"=",
"r2_",
"*",
"0.2126",
"+",
"g2_",
"*",
"0.7152",
"+",
"b2_",
"*",
"0.0722",
"z__",
"=",
"r2_",
"*",
"0.0193",
"+",
"g2_",
"*",
"0.1192",
"+",
"b2_",
"*",
"0.9505",
"return",
"x__",
",",
"y__",
",",
"z__"
] | RGB to XYZ | [
"RGB",
"to",
"XYZ"
] | train | https://github.com/pytroll/trollimage/blob/d35a7665ad475ff230e457085523e21f2cd3f454/trollimage/colorspaces.py#L87-L111 | <|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:
RGB to XYZ
### Response:
def rgb2xyz(r__, g__, b__):
"""RGB to XYZ
"""
r2_ = r__ / 255.0
g2_ = g__ / 255.0
b2_ = b__ / 255.0
def f__(arr):
"""Forward
"""
return np.where(arr > 0.04045,
((arr + 0.055) / 1.055) ** 2.4,
arr / 12.92)
r2_ = f__(r2_) * 100
g2_ = f__(g2_) * 100
b2_ = f__(b2_) * 100
x__ = r2_ * 0.4124 + g2_ * 0.3576 + b2_ * 0.1805
y__ = r2_ * 0.2126 + g2_ * 0.7152 + b2_ * 0.0722
z__ = r2_ * 0.0193 + g2_ * 0.1192 + b2_ * 0.9505
return x__, y__, z__
<|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,
18683,
311,
72189,
271,
14711,
6075,
512,
755,
18477,
17,
29954,
2666,
10662,
342,
10662,
293,
565,
997,
262,
4304,
18683,
311,
72189,
198,
262,
12713,
262,
436,
17,
62,
284,
436,
565,
611,
220,
3192,
13,
15,
198,
262,
342,
17,
62,
284,
342,
565,
611,
220,
3192,
13,
15,
198,
262,
293,
17,
62,
284,
293,
565,
611,
220,
3192,
13,
15,
271,
262,
711,
282,
3889,
1138,
997,
286,
4304,
27014,
198,
286,
3270,
286,
471,
2660,
18486,
11179,
871,
220,
15,
13,
12505,
1774,
345,
667,
1819,
1138,
489,
220,
15,
13,
22913,
8,
611,
220,
16,
13,
22913,
8,
3146,
220,
17,
13,
19,
345,
667,
2961,
611,
220,
717,
13,
6083,
3707,
262,
436,
17,
62,
284,
282,
3889,
81,
17,
16726,
353,
220,
1041,
198,
262,
342,
17,
62,
284,
282,
3889,
70,
17,
16726,
353,
220,
1041,
198,
262,
293,
17,
62,
284,
282,
3889,
65,
17,
16726,
353,
220,
1041,
271,
262,
865,
565,
284,
436,
17,
62,
353,
220,
15,
13,
17574,
19,
489,
342,
17,
62,
353,
220,
15,
13,
18520,
21,
489,
293,
17,
62,
353,
220,
15,
13,
5245,
20,
198,
262,
379,
565,
284,
436,
17,
62,
353,
220,
15,
13,
11227,
21,
489,
342,
17,
62,
353,
220,
15,
13,
22744,
17,
489,
293,
17,
62,
353,
220,
15,
13,
23439,
17,
198,
262,
1167,
565,
284,
436,
17,
62,
353,
220,
15,
13,
18089,
18,
489,
342,
17,
62,
353,
220,
15,
13,
9079,
17,
489,
293,
17,
62,
353,
220,
15,
13,
15862,
20,
271,
262,
471,
865,
10662,
379,
10662,
1167,
12423,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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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,
18683,
311,
72189,
271,
14711,
6075,
512,
755,
18477,
17,
29954,
2666,
10662,
342,
10662,
293,
565,
997,
262,
4304,
18683,
311,
72189,
198,
262,
12713,
262,
436,
17,
62,
284,
436,
565,
611,
220,
3192,
13,
15,
198,
262,
342,
17,
62,
284,
342,
565,
611,
220,
3192,
13,
15,
198,
262,
293,
17,
62,
284,
293,
565,
611,
220,
3192,
13,
15,
271,
262,
711,
282,
3889,
1138,
997,
286,
4304,
27014,
198,
286,
3270,
286,
471,
2660,
18486,
11179,
871,
220,
15,
13,
12505,
1774,
345,
667,
1819,
1138,
489,
220,
15,
13,
22913,
8,
611,
220,
16,
13,
22913,
8,
3146,
220,
17,
13,
19,
345,
667,
2961,
611,
220,
717,
13,
6083,
3707,
262,
436,
17,
62,
284,
282,
3889,
81,
17,
16726,
353,
220,
1041,
198,
262,
342,
17,
62,
284,
282,
3889,
70,
17,
16726,
353,
220,
1041,
198,
262,
293,
17,
62,
284,
282,
3889,
65,
17,
16726,
353,
220,
1041,
271,
262,
865,
565,
284,
436,
17,
62,
353,
220,
15,
13,
17574,
19,
489,
342,
17,
62,
353,
220,
15,
13,
18520,
21,
489,
293,
17,
62,
353,
220,
15,
13,
5245,
20,
198,
262,
379,
565,
284,
436,
17,
62,
353,
220,
15,
13,
11227,
21,
489,
342,
17,
62,
353,
220,
15,
13,
22744,
17,
489,
293,
17,
62,
353,
220,
15,
13,
23439,
17,
198,
262,
1167,
565,
284,
436,
17,
62,
353,
220,
15,
13,
18089,
18,
489,
342,
17,
62,
353,
220,
15,
13,
9079,
17,
489,
293,
17,
62,
353,
220,
15,
13,
15862,
20,
271,
262,
471,
865,
10662,
379,
10662,
1167,
12423,
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
] |
hardbyte/python-can | can/interfaces/ics_neovi/neovi_bus.py | NeoViBus.get_serial_number | def get_serial_number(device):
"""Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str
"""
a0000 = 604661760
if device.SerialNumber >= a0000:
return ics.base36enc(device.SerialNumber)
return str(device.SerialNumber) | python | def get_serial_number(device):
"""Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str
"""
a0000 = 604661760
if device.SerialNumber >= a0000:
return ics.base36enc(device.SerialNumber)
return str(device.SerialNumber) | [
"def",
"get_serial_number",
"(",
"device",
")",
":",
"a0000",
"=",
"604661760",
"if",
"device",
".",
"SerialNumber",
">=",
"a0000",
":",
"return",
"ics",
".",
"base36enc",
"(",
"device",
".",
"SerialNumber",
")",
"return",
"str",
"(",
"device",
".",
"SerialNumber",
")"
] | Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str | [
"Decode",
"(",
"if",
"needed",
")",
"and",
"return",
"the",
"ICS",
"device",
"serial",
"string"
] | train | https://github.com/hardbyte/python-can/blob/cdc5254d96072df7739263623f3e920628a7d214/can/interfaces/ics_neovi/neovi_bus.py#L164-L174 | <|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:
Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str
### Response:
def get_serial_number(device):
"""Decode (if needed) and return the ICS device serial string
:param device: ics device
:return: ics device serial string
:rtype: str
"""
a0000 = 604661760
if device.SerialNumber >= a0000:
return ics.base36enc(device.SerialNumber)
return str(device.SerialNumber)
<|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,
33664,
320,
333,
4460,
8,
323,
471,
279,
358,
6546,
3756,
6275,
925,
271,
286,
551,
913,
3756,
25,
220,
1233,
3756,
198,
286,
551,
693,
25,
220,
1233,
3756,
6275,
925,
198,
286,
551,
33613,
25,
610,
271,
14711,
6075,
512,
755,
636,
26684,
5617,
18329,
997,
286,
4304,
33664,
320,
333,
4460,
8,
323,
471,
279,
358,
6546,
3756,
6275,
925,
271,
286,
551,
913,
3756,
25,
220,
1233,
3756,
198,
286,
551,
693,
25,
220,
1233,
3756,
6275,
925,
198,
286,
551,
33613,
25,
610,
198,
286,
3270,
286,
264,
931,
15,
284,
220,
20354,
24132,
19104,
198,
286,
422,
3756,
13717,
2903,
2669,
264,
931,
15,
512,
310,
471,
220,
1233,
9105,
1927,
967,
18329,
13717,
2903,
340,
286,
471,
610,
18329,
13717,
2903,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
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,
33664,
320,
333,
4460,
8,
323,
471,
279,
358,
6546,
3756,
6275,
925,
271,
286,
551,
913,
3756,
25,
220,
1233,
3756,
198,
286,
551,
693,
25,
220,
1233,
3756,
6275,
925,
198,
286,
551,
33613,
25,
610,
271,
14711,
6075,
512,
755,
636,
26684,
5617,
18329,
997,
286,
4304,
33664,
320,
333,
4460,
8,
323,
471,
279,
358,
6546,
3756,
6275,
925,
271,
286,
551,
913,
3756,
25,
220,
1233,
3756,
198,
286,
551,
693,
25,
220,
1233,
3756,
6275,
925,
198,
286,
551,
33613,
25,
610,
198,
286,
3270,
286,
264,
931,
15,
284,
220,
20354,
24132,
19104,
198,
286,
422,
3756,
13717,
2903,
2669,
264,
931,
15,
512,
310,
471,
220,
1233,
9105,
1927,
967,
18329,
13717,
2903,
340,
286,
471,
610,
18329,
13717,
2903,
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
] |
delph-in/pydelphin | delphin/mrs/xmrs.py | Xmrs.nodeid | def nodeid(self, iv, quantifier=False):
"""
Return the nodeid of the predication selected by *iv*.
Args:
iv: the intrinsic variable of the predication to select
quantifier: if `True`, treat *iv* as a bound variable and
find its quantifier; otherwise the non-quantifier will
be returned
"""
return next(iter(self.nodeids(ivs=[iv], quantifier=quantifier)), None) | python | def nodeid(self, iv, quantifier=False):
"""
Return the nodeid of the predication selected by *iv*.
Args:
iv: the intrinsic variable of the predication to select
quantifier: if `True`, treat *iv* as a bound variable and
find its quantifier; otherwise the non-quantifier will
be returned
"""
return next(iter(self.nodeids(ivs=[iv], quantifier=quantifier)), None) | [
"def",
"nodeid",
"(",
"self",
",",
"iv",
",",
"quantifier",
"=",
"False",
")",
":",
"return",
"next",
"(",
"iter",
"(",
"self",
".",
"nodeids",
"(",
"ivs",
"=",
"[",
"iv",
"]",
",",
"quantifier",
"=",
"quantifier",
")",
")",
",",
"None",
")"
] | Return the nodeid of the predication selected by *iv*.
Args:
iv: the intrinsic variable of the predication to select
quantifier: if `True`, treat *iv* as a bound variable and
find its quantifier; otherwise the non-quantifier will
be returned | [
"Return",
"the",
"nodeid",
"of",
"the",
"predication",
"selected",
"by",
"*",
"iv",
"*",
"."
] | train | https://github.com/delph-in/pydelphin/blob/7bd2cd63ab7cf74803e1d6547b9ebc014b382abd/delphin/mrs/xmrs.py#L255-L265 | <|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 nodeid of the predication selected by *iv*.
Args:
iv: the intrinsic variable of the predication to select
quantifier: if `True`, treat *iv* as a bound variable and
find its quantifier; otherwise the non-quantifier will
be returned
### Response:
def nodeid(self, iv, quantifier=False):
"""
Return the nodeid of the predication selected by *iv*.
Args:
iv: the intrinsic variable of the predication to select
quantifier: if `True`, treat *iv* as a bound variable and
find its quantifier; otherwise the non-quantifier will
be returned
"""
return next(iter(self.nodeids(ivs=[iv], quantifier=quantifier)), 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,
2494,
307,
315,
279,
4255,
20901,
4183,
555,
353,
344,
9,
382,
286,
18161,
512,
310,
17967,
25,
279,
47701,
3977,
315,
279,
4255,
20901,
311,
3373,
198,
310,
10484,
3125,
25,
422,
1595,
2575,
7964,
4322,
353,
344,
9,
439,
264,
6965,
3977,
323,
198,
394,
1505,
1202,
10484,
3125,
26,
6062,
279,
2536,
12,
31548,
3125,
690,
198,
394,
387,
6052,
271,
14711,
6075,
512,
755,
2494,
307,
1214,
11,
17967,
11,
10484,
3125,
5725,
997,
286,
3270,
286,
3494,
279,
2494,
307,
315,
279,
4255,
20901,
4183,
555,
353,
344,
9,
382,
286,
18161,
512,
310,
17967,
25,
279,
47701,
3977,
315,
279,
4255,
20901,
311,
3373,
198,
310,
10484,
3125,
25,
422,
1595,
2575,
7964,
4322,
353,
344,
9,
439,
264,
6965,
3977,
323,
198,
394,
1505,
1202,
10484,
3125,
26,
6062,
279,
2536,
12,
31548,
3125,
690,
198,
394,
387,
6052,
198,
286,
3270,
286,
471,
1828,
28169,
1214,
12368,
3447,
72814,
82,
5941,
344,
1145,
10484,
3125,
28,
31548,
3125,
5850,
2290,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
2494,
307,
315,
279,
4255,
20901,
4183,
555,
353,
344,
9,
382,
286,
18161,
512,
310,
17967,
25,
279,
47701,
3977,
315,
279,
4255,
20901,
311,
3373,
198,
310,
10484,
3125,
25,
422,
1595,
2575,
7964,
4322,
353,
344,
9,
439,
264,
6965,
3977,
323,
198,
394,
1505,
1202,
10484,
3125,
26,
6062,
279,
2536,
12,
31548,
3125,
690,
198,
394,
387,
6052,
271,
14711,
6075,
512,
755,
2494,
307,
1214,
11,
17967,
11,
10484,
3125,
5725,
997,
286,
3270,
286,
3494,
279,
2494,
307,
315,
279,
4255,
20901,
4183,
555,
353,
344,
9,
382,
286,
18161,
512,
310,
17967,
25,
279,
47701,
3977,
315,
279,
4255,
20901,
311,
3373,
198,
310,
10484,
3125,
25,
422,
1595,
2575,
7964,
4322,
353,
344,
9,
439,
264,
6965,
3977,
323,
198,
394,
1505,
1202,
10484,
3125,
26,
6062,
279,
2536,
12,
31548,
3125,
690,
198,
394,
387,
6052,
198,
286,
3270,
286,
471,
1828,
28169,
1214,
12368,
3447,
72814,
82,
5941,
344,
1145,
10484,
3125,
28,
31548,
3125,
5850,
2290,
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
] |
artefactual-labs/mets-reader-writer | metsrw/metadata.py | MDWrap.parse | def parse(cls, root):
"""
Create a new MDWrap by parsing root.
:param root: Element or ElementTree to be parsed into a MDWrap.
:raises exceptions.ParseError: If mdWrap does not contain MDTYPE
:raises exceptions.ParseError: If xmlData contains no children
"""
if root.tag != utils.lxmlns("mets") + "mdWrap":
raise exceptions.ParseError(
"MDWrap can only parse mdWrap elements with METS namespace."
)
mdtype = root.get("MDTYPE")
if not mdtype:
raise exceptions.ParseError("mdWrap must have a MDTYPE")
othermdtype = root.get("OTHERMDTYPE")
document = root.xpath("mets:xmlData/*", namespaces=utils.NAMESPACES)
if len(document) == 0:
raise exceptions.ParseError(
"All mdWrap/xmlData elements must have at least one child; this"
" one has none"
)
elif len(document) == 1:
document = document[0]
# Create a copy, so that the element is not moved by duplicate references.
document = copy.deepcopy(document)
return cls(document, mdtype, othermdtype) | python | def parse(cls, root):
"""
Create a new MDWrap by parsing root.
:param root: Element or ElementTree to be parsed into a MDWrap.
:raises exceptions.ParseError: If mdWrap does not contain MDTYPE
:raises exceptions.ParseError: If xmlData contains no children
"""
if root.tag != utils.lxmlns("mets") + "mdWrap":
raise exceptions.ParseError(
"MDWrap can only parse mdWrap elements with METS namespace."
)
mdtype = root.get("MDTYPE")
if not mdtype:
raise exceptions.ParseError("mdWrap must have a MDTYPE")
othermdtype = root.get("OTHERMDTYPE")
document = root.xpath("mets:xmlData/*", namespaces=utils.NAMESPACES)
if len(document) == 0:
raise exceptions.ParseError(
"All mdWrap/xmlData elements must have at least one child; this"
" one has none"
)
elif len(document) == 1:
document = document[0]
# Create a copy, so that the element is not moved by duplicate references.
document = copy.deepcopy(document)
return cls(document, mdtype, othermdtype) | [
"def",
"parse",
"(",
"cls",
",",
"root",
")",
":",
"if",
"root",
".",
"tag",
"!=",
"utils",
".",
"lxmlns",
"(",
"\"mets\"",
")",
"+",
"\"mdWrap\"",
":",
"raise",
"exceptions",
".",
"ParseError",
"(",
"\"MDWrap can only parse mdWrap elements with METS namespace.\"",
")",
"mdtype",
"=",
"root",
".",
"get",
"(",
"\"MDTYPE\"",
")",
"if",
"not",
"mdtype",
":",
"raise",
"exceptions",
".",
"ParseError",
"(",
"\"mdWrap must have a MDTYPE\"",
")",
"othermdtype",
"=",
"root",
".",
"get",
"(",
"\"OTHERMDTYPE\"",
")",
"document",
"=",
"root",
".",
"xpath",
"(",
"\"mets:xmlData/*\"",
",",
"namespaces",
"=",
"utils",
".",
"NAMESPACES",
")",
"if",
"len",
"(",
"document",
")",
"==",
"0",
":",
"raise",
"exceptions",
".",
"ParseError",
"(",
"\"All mdWrap/xmlData elements must have at least one child; this\"",
"\" one has none\"",
")",
"elif",
"len",
"(",
"document",
")",
"==",
"1",
":",
"document",
"=",
"document",
"[",
"0",
"]",
"# Create a copy, so that the element is not moved by duplicate references.",
"document",
"=",
"copy",
".",
"deepcopy",
"(",
"document",
")",
"return",
"cls",
"(",
"document",
",",
"mdtype",
",",
"othermdtype",
")"
] | Create a new MDWrap by parsing root.
:param root: Element or ElementTree to be parsed into a MDWrap.
:raises exceptions.ParseError: If mdWrap does not contain MDTYPE
:raises exceptions.ParseError: If xmlData contains no children | [
"Create",
"a",
"new",
"MDWrap",
"by",
"parsing",
"root",
"."
] | train | https://github.com/artefactual-labs/mets-reader-writer/blob/d95939cabdfdc25cb1bf67df0c84bd0d6e6a73ff/metsrw/metadata.py#L540-L568 | <|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:
Create a new MDWrap by parsing root.
:param root: Element or ElementTree to be parsed into a MDWrap.
:raises exceptions.ParseError: If mdWrap does not contain MDTYPE
:raises exceptions.ParseError: If xmlData contains no children
### Response:
def parse(cls, root):
"""
Create a new MDWrap by parsing root.
:param root: Element or ElementTree to be parsed into a MDWrap.
:raises exceptions.ParseError: If mdWrap does not contain MDTYPE
:raises exceptions.ParseError: If xmlData contains no children
"""
if root.tag != utils.lxmlns("mets") + "mdWrap":
raise exceptions.ParseError(
"MDWrap can only parse mdWrap elements with METS namespace."
)
mdtype = root.get("MDTYPE")
if not mdtype:
raise exceptions.ParseError("mdWrap must have a MDTYPE")
othermdtype = root.get("OTHERMDTYPE")
document = root.xpath("mets:xmlData/*", namespaces=utils.NAMESPACES)
if len(document) == 0:
raise exceptions.ParseError(
"All mdWrap/xmlData elements must have at least one child; this"
" one has none"
)
elif len(document) == 1:
document = document[0]
# Create a copy, so that the element is not moved by duplicate references.
document = copy.deepcopy(document)
return cls(document, mdtype, othermdtype)
<|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,
4110,
264,
502,
14306,
27885,
555,
23115,
3789,
382,
286,
551,
913,
3789,
25,
8711,
477,
8711,
6670,
311,
387,
16051,
1139,
264,
14306,
27885,
627,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
10918,
27885,
1587,
539,
6782,
14306,
9692,
198,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
8562,
1061,
5727,
912,
2911,
271,
14711,
6075,
512,
755,
4820,
21024,
11,
3789,
997,
286,
3270,
286,
4324,
264,
502,
14306,
27885,
555,
23115,
3789,
382,
286,
551,
913,
3789,
25,
8711,
477,
8711,
6670,
311,
387,
16051,
1139,
264,
14306,
27885,
627,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
10918,
27885,
1587,
539,
6782,
14306,
9692,
198,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
8562,
1061,
5727,
912,
2911,
198,
286,
3270,
286,
422,
3789,
12681,
976,
12721,
929,
75255,
446,
76,
1441,
909,
489,
330,
2329,
27885,
4764,
310,
4933,
20157,
9114,
1480,
1021,
394,
330,
6204,
27885,
649,
1193,
4820,
10918,
27885,
5540,
449,
37922,
50,
4573,
10246,
310,
1763,
286,
10918,
1337,
284,
3789,
673,
446,
6204,
9692,
1158,
286,
422,
539,
10918,
1337,
512,
310,
4933,
20157,
9114,
1480,
446,
2329,
27885,
2011,
617,
264,
14306,
9692,
1158,
286,
1023,
2329,
1337,
284,
3789,
673,
446,
31367,
6204,
9692,
1158,
286,
2246,
284,
3789,
23472,
446,
76,
1441,
25,
6591,
1061,
1075,
498,
59191,
28,
6159,
2112,
15981,
47,
53181,
340,
286,
422,
2479,
15649,
8,
624,
220,
15,
512,
310,
4933,
20157,
9114,
1480,
1021,
394,
330,
2460,
10918,
27885,
37624,
1061,
5540,
2011,
617,
520,
3325,
832,
1716,
26,
420,
702,
394,
330,
832,
706,
7000,
702,
310,
1763,
286,
4508,
2479,
15649,
8,
624,
220,
16,
512,
310,
2246,
284,
2246,
58,
15,
2595,
286,
674,
4324,
264,
3048,
11,
779,
430,
279,
2449,
374,
539,
7882,
555,
23329,
15407,
627,
286,
2246,
284,
3048,
52748,
15649,
696,
286,
471,
13082,
15649,
11,
10918,
1337,
11,
1023,
2329,
1337,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
4110,
264,
502,
14306,
27885,
555,
23115,
3789,
382,
286,
551,
913,
3789,
25,
8711,
477,
8711,
6670,
311,
387,
16051,
1139,
264,
14306,
27885,
627,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
10918,
27885,
1587,
539,
6782,
14306,
9692,
198,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
8562,
1061,
5727,
912,
2911,
271,
14711,
6075,
512,
755,
4820,
21024,
11,
3789,
997,
286,
3270,
286,
4324,
264,
502,
14306,
27885,
555,
23115,
3789,
382,
286,
551,
913,
3789,
25,
8711,
477,
8711,
6670,
311,
387,
16051,
1139,
264,
14306,
27885,
627,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
10918,
27885,
1587,
539,
6782,
14306,
9692,
198,
286,
551,
33371,
20157,
9114,
1480,
25,
1442,
8562,
1061,
5727,
912,
2911,
198,
286,
3270,
286,
422,
3789,
12681,
976,
12721,
929,
75255,
446,
76,
1441,
909,
489,
330,
2329,
27885,
4764,
310,
4933,
20157,
9114,
1480,
1021,
394,
330,
6204,
27885,
649,
1193,
4820,
10918,
27885,
5540,
449,
37922,
50,
4573,
10246,
310,
1763,
286,
10918,
1337,
284,
3789,
673,
446,
6204,
9692,
1158,
286,
422,
539,
10918,
1337,
512,
310,
4933,
20157,
9114,
1480,
446,
2329,
27885,
2011,
617,
264,
14306,
9692,
1158,
286,
1023,
2329,
1337,
284,
3789,
673,
446,
31367,
6204,
9692,
1158,
286,
2246,
284,
3789,
23472,
446,
76,
1441,
25,
6591,
1061,
1075,
498,
59191,
28,
6159,
2112,
15981,
47,
53181,
340,
286,
422,
2479,
15649,
8,
624,
220,
15,
512,
310,
4933,
20157,
9114,
1480,
1021,
394,
330,
2460,
10918,
27885,
37624,
1061,
5540,
2011,
617,
520,
3325,
832,
1716,
26,
420,
702,
394,
330,
832,
706,
7000,
702,
310,
1763,
286,
4508,
2479,
15649,
8,
624,
220,
16,
512,
310,
2246,
284,
2246,
58,
15,
2595,
286,
674,
4324,
264,
3048,
11,
779,
430,
279,
2449,
374,
539,
7882,
555,
23329,
15407,
627,
286,
2246,
284,
3048,
52748,
15649,
696,
286,
471,
13082,
15649,
11,
10918,
1337,
11,
1023,
2329,
1337,
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
] |
pyQode/pyqode.core | pyqode/core/panels/global_checker.py | GlobalCheckerPanel.get_marker_height | def get_marker_height(self):
"""
Gets the height of message marker.
"""
return self.editor.viewport().height() / TextHelper(
self.editor).line_count() | python | def get_marker_height(self):
"""
Gets the height of message marker.
"""
return self.editor.viewport().height() / TextHelper(
self.editor).line_count() | [
"def",
"get_marker_height",
"(",
"self",
")",
":",
"return",
"self",
".",
"editor",
".",
"viewport",
"(",
")",
".",
"height",
"(",
")",
"/",
"TextHelper",
"(",
"self",
".",
"editor",
")",
".",
"line_count",
"(",
")"
] | Gets the height of message marker. | [
"Gets",
"the",
"height",
"of",
"message",
"marker",
"."
] | train | https://github.com/pyQode/pyqode.core/blob/a99ec6cd22d519394f613309412f8329dc4e90cb/pyqode/core/panels/global_checker.py#L85-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:
Gets the height of message marker.
### Response:
def get_marker_height(self):
"""
Gets the height of message marker.
"""
return self.editor.viewport().height() / TextHelper(
self.editor).line_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,
50458,
279,
2673,
315,
1984,
11381,
382,
14711,
6075,
512,
755,
636,
27363,
9755,
1214,
997,
286,
3270,
286,
10523,
279,
2673,
315,
1984,
11381,
627,
286,
3270,
286,
471,
659,
35993,
78260,
1020,
2627,
368,
611,
2991,
5628,
1021,
310,
659,
35993,
570,
1074,
3259,
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,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
50458,
279,
2673,
315,
1984,
11381,
382,
14711,
6075,
512,
755,
636,
27363,
9755,
1214,
997,
286,
3270,
286,
10523,
279,
2673,
315,
1984,
11381,
627,
286,
3270,
286,
471,
659,
35993,
78260,
1020,
2627,
368,
611,
2991,
5628,
1021,
310,
659,
35993,
570,
1074,
3259,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
dbcli/athenacli | athenacli/completer.py | AthenaCompleter.populate_schema_objects | def populate_schema_objects(self, schema, obj_type):
"""Returns list of tables or functions for a (optional) schema"""
metadata = self.dbmetadata[obj_type]
schema = schema or self.dbname
try:
objects = metadata[schema].keys()
except KeyError:
# schema doesn't exist
objects = []
return objects | python | def populate_schema_objects(self, schema, obj_type):
"""Returns list of tables or functions for a (optional) schema"""
metadata = self.dbmetadata[obj_type]
schema = schema or self.dbname
try:
objects = metadata[schema].keys()
except KeyError:
# schema doesn't exist
objects = []
return objects | [
"def",
"populate_schema_objects",
"(",
"self",
",",
"schema",
",",
"obj_type",
")",
":",
"metadata",
"=",
"self",
".",
"dbmetadata",
"[",
"obj_type",
"]",
"schema",
"=",
"schema",
"or",
"self",
".",
"dbname",
"try",
":",
"objects",
"=",
"metadata",
"[",
"schema",
"]",
".",
"keys",
"(",
")",
"except",
"KeyError",
":",
"# schema doesn't exist",
"objects",
"=",
"[",
"]",
"return",
"objects"
] | Returns list of tables or functions for a (optional) schema | [
"Returns",
"list",
"of",
"tables",
"or",
"functions",
"for",
"a",
"(",
"optional",
")",
"schema"
] | train | https://github.com/dbcli/athenacli/blob/bcab59e4953145866430083e902ed4d042d4ebba/athenacli/completer.py#L388-L399 | <|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 list of tables or functions for a (optional) schema
### Response:
def populate_schema_objects(self, schema, obj_type):
"""Returns list of tables or functions for a (optional) schema"""
metadata = self.dbmetadata[obj_type]
schema = schema or self.dbname
try:
objects = metadata[schema].keys()
except KeyError:
# schema doesn't exist
objects = []
return objects
<|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,
1160,
315,
12920,
477,
5865,
369,
264,
320,
13099,
8,
11036,
271,
14711,
6075,
512,
755,
31546,
26443,
25915,
1214,
11,
11036,
11,
2909,
1857,
997,
286,
4304,
16851,
1160,
315,
12920,
477,
5865,
369,
264,
320,
13099,
8,
11036,
7275,
286,
11408,
284,
659,
7221,
18103,
71378,
1857,
933,
286,
11036,
284,
11036,
477,
659,
7221,
609,
271,
286,
1456,
512,
310,
6302,
284,
11408,
12144,
3499,
948,
10786,
746,
286,
3734,
39194,
512,
310,
674,
11036,
3250,
956,
3073,
198,
310,
6302,
284,
14941,
286,
471,
6302,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,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193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
16851,
1160,
315,
12920,
477,
5865,
369,
264,
320,
13099,
8,
11036,
271,
14711,
6075,
512,
755,
31546,
26443,
25915,
1214,
11,
11036,
11,
2909,
1857,
997,
286,
4304,
16851,
1160,
315,
12920,
477,
5865,
369,
264,
320,
13099,
8,
11036,
7275,
286,
11408,
284,
659,
7221,
18103,
71378,
1857,
933,
286,
11036,
284,
11036,
477,
659,
7221,
609,
271,
286,
1456,
512,
310,
6302,
284,
11408,
12144,
3499,
948,
10786,
746,
286,
3734,
39194,
512,
310,
674,
11036,
3250,
956,
3073,
198,
310,
6302,
284,
14941,
286,
471,
6302,
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
] |
autokey/autokey | lib/autokey/scripting.py | Window.activate | def activate(self, title, switchDesktop=False, matchClass=False):
"""
Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current desktop
and activated. Otherwise, switch to the window's current desktop and activate it there.
@param title: window title to match against (as case-insensitive substring match)
@param switchDesktop: whether or not to switch to the window's current desktop
@param matchClass: if True, match on the window class instead of the title
"""
if switchDesktop:
args = ["-a", title]
else:
args = ["-R", title]
if matchClass:
args += ["-x"]
self._run_wmctrl(args) | python | def activate(self, title, switchDesktop=False, matchClass=False):
"""
Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current desktop
and activated. Otherwise, switch to the window's current desktop and activate it there.
@param title: window title to match against (as case-insensitive substring match)
@param switchDesktop: whether or not to switch to the window's current desktop
@param matchClass: if True, match on the window class instead of the title
"""
if switchDesktop:
args = ["-a", title]
else:
args = ["-R", title]
if matchClass:
args += ["-x"]
self._run_wmctrl(args) | [
"def",
"activate",
"(",
"self",
",",
"title",
",",
"switchDesktop",
"=",
"False",
",",
"matchClass",
"=",
"False",
")",
":",
"if",
"switchDesktop",
":",
"args",
"=",
"[",
"\"-a\"",
",",
"title",
"]",
"else",
":",
"args",
"=",
"[",
"\"-R\"",
",",
"title",
"]",
"if",
"matchClass",
":",
"args",
"+=",
"[",
"\"-x\"",
"]",
"self",
".",
"_run_wmctrl",
"(",
"args",
")"
] | Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current desktop
and activated. Otherwise, switch to the window's current desktop and activate it there.
@param title: window title to match against (as case-insensitive substring match)
@param switchDesktop: whether or not to switch to the window's current desktop
@param matchClass: if True, match on the window class instead of the title | [
"Activate",
"the",
"specified",
"window",
"giving",
"it",
"input",
"focus"
] | train | https://github.com/autokey/autokey/blob/35decb72f286ce68cd2a1f09ace8891a520b58d1/lib/autokey/scripting.py#L963-L982 | <|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:
Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current desktop
and activated. Otherwise, switch to the window's current desktop and activate it there.
@param title: window title to match against (as case-insensitive substring match)
@param switchDesktop: whether or not to switch to the window's current desktop
@param matchClass: if True, match on the window class instead of the title
### Response:
def activate(self, title, switchDesktop=False, matchClass=False):
"""
Activate the specified window, giving it input focus
Usage: C{window.activate(title, switchDesktop=False, matchClass=False)}
If switchDesktop is False (default), the window will be moved to the current desktop
and activated. Otherwise, switch to the window's current desktop and activate it there.
@param title: window title to match against (as case-insensitive substring match)
@param switchDesktop: whether or not to switch to the window's current desktop
@param matchClass: if True, match on the window class instead of the title
"""
if switchDesktop:
args = ["-a", title]
else:
args = ["-R", title]
if matchClass:
args += ["-x"]
self._run_wmctrl(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,
32342,
279,
5300,
3321,
11,
7231,
433,
1988,
5357,
271,
286,
25585,
25,
356,
90,
5624,
56189,
12787,
11,
3480,
24514,
5725,
11,
2489,
1999,
5725,
10792,
1827,
286,
1442,
3480,
24514,
374,
3641,
320,
2309,
705,
279,
3321,
690,
387,
7882,
311,
279,
1510,
17963,
198,
286,
323,
22756,
13,
18715,
11,
3480,
311,
279,
3321,
596,
1510,
17963,
323,
20891,
433,
1070,
627,
1827,
286,
571,
913,
2316,
25,
3321,
2316,
311,
2489,
2403,
320,
300,
1162,
22610,
19245,
39549,
2489,
340,
286,
571,
913,
3480,
24514,
25,
3508,
477,
539,
311,
3480,
311,
279,
3321,
596,
1510,
17963,
198,
286,
571,
913,
2489,
1999,
25,
422,
3082,
11,
2489,
389,
279,
3321,
538,
4619,
315,
279,
2316,
271,
14711,
6075,
512,
755,
20891,
1214,
11,
2316,
11,
3480,
24514,
5725,
11,
2489,
1999,
5725,
997,
286,
3270,
286,
52814,
279,
5300,
3321,
11,
7231,
433,
1988,
5357,
271,
286,
25585,
25,
356,
90,
5624,
56189,
12787,
11,
3480,
24514,
5725,
11,
2489,
1999,
5725,
10792,
1827,
286,
1442,
3480,
24514,
374,
3641,
320,
2309,
705,
279,
3321,
690,
387,
7882,
311,
279,
1510,
17963,
198,
286,
323,
22756,
13,
18715,
11,
3480,
311,
279,
3321,
596,
1510,
17963,
323,
20891,
433,
1070,
627,
1827,
286,
571,
913,
2316,
25,
3321,
2316,
311,
2489,
2403,
320,
300,
1162,
22610,
19245,
39549,
2489,
340,
286,
571,
913,
3480,
24514,
25,
3508,
477,
539,
311,
3480,
311,
279,
3321,
596,
1510,
17963,
198,
286,
571,
913,
2489,
1999,
25,
422,
3082,
11,
2489,
389,
279,
3321,
538,
4619,
315,
279,
2316,
198,
286,
3270,
286,
422,
3480,
24514,
512,
310,
2897,
284,
4482,
12,
64,
498,
2316,
933,
286,
775,
512,
310,
2897,
284,
4482,
12,
49,
498,
2316,
933,
286,
422,
2489,
1999,
512,
310,
2897,
1447,
4482,
12,
87,
7171,
286,
659,
1462,
6236,
1704,
76,
12199,
7506,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
32342,
279,
5300,
3321,
11,
7231,
433,
1988,
5357,
271,
286,
25585,
25,
356,
90,
5624,
56189,
12787,
11,
3480,
24514,
5725,
11,
2489,
1999,
5725,
10792,
1827,
286,
1442,
3480,
24514,
374,
3641,
320,
2309,
705,
279,
3321,
690,
387,
7882,
311,
279,
1510,
17963,
198,
286,
323,
22756,
13,
18715,
11,
3480,
311,
279,
3321,
596,
1510,
17963,
323,
20891,
433,
1070,
627,
1827,
286,
571,
913,
2316,
25,
3321,
2316,
311,
2489,
2403,
320,
300,
1162,
22610,
19245,
39549,
2489,
340,
286,
571,
913,
3480,
24514,
25,
3508,
477,
539,
311,
3480,
311,
279,
3321,
596,
1510,
17963,
198,
286,
571,
913,
2489,
1999,
25,
422,
3082,
11,
2489,
389,
279,
3321,
538,
4619,
315,
279,
2316,
271,
14711,
6075,
512,
755,
20891,
1214,
11,
2316,
11,
3480,
24514,
5725,
11,
2489,
1999,
5725,
997,
286,
3270,
286,
52814,
279,
5300,
3321,
11,
7231,
433,
1988,
5357,
271,
286,
25585,
25,
356,
90,
5624,
56189,
12787,
11,
3480,
24514,
5725,
11,
2489,
1999,
5725,
10792,
1827,
286,
1442,
3480,
24514,
374,
3641,
320,
2309,
705,
279,
3321,
690,
387,
7882,
311,
279,
1510,
17963,
198,
286,
323,
22756,
13,
18715,
11,
3480,
311,
279,
3321,
596,
1510,
17963,
323,
20891,
433,
1070,
627,
1827,
286,
571,
913,
2316,
25,
3321,
2316,
311,
2489,
2403,
320,
300,
1162,
22610,
19245,
39549,
2489,
340,
286,
571,
913,
3480,
24514,
25,
3508,
477,
539,
311,
3480,
311,
279,
3321,
596,
1510,
17963,
198,
286,
571,
913,
2489,
1999,
25,
422,
3082,
11,
2489,
389,
279,
3321,
538,
4619,
315,
279,
2316,
198,
286,
3270,
286,
422,
3480,
24514,
512,
310,
2897,
284,
4482,
12,
64,
498,
2316,
933,
286,
775,
512,
310,
2897,
284,
4482,
12,
49,
498,
2316,
933,
286,
422,
2489,
1999,
512,
310,
2897,
1447,
4482,
12,
87,
7171,
286,
659,
1462,
6236,
1704,
76,
12199,
7506,
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
] |
CitrineInformatics/pif-dft | dfttopif/parsers/pwscf.py | PwscfParser._is_converged | def _is_converged(self):
'''Determine if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output'''
if self.is_relaxed():
# relaxation run case
return self._get_line(['End of', 'Geometry Optimization'], self.outputf, return_string=False)
else:
# static run case
return self._get_line('convergence has been achieved', self.outputf, return_string=False) | python | def _is_converged(self):
'''Determine if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output'''
if self.is_relaxed():
# relaxation run case
return self._get_line(['End of', 'Geometry Optimization'], self.outputf, return_string=False)
else:
# static run case
return self._get_line('convergence has been achieved', self.outputf, return_string=False) | [
"def",
"_is_converged",
"(",
"self",
")",
":",
"if",
"self",
".",
"is_relaxed",
"(",
")",
":",
"# relaxation run case",
"return",
"self",
".",
"_get_line",
"(",
"[",
"'End of'",
",",
"'Geometry Optimization'",
"]",
",",
"self",
".",
"outputf",
",",
"return_string",
"=",
"False",
")",
"else",
":",
"# static run case",
"return",
"self",
".",
"_get_line",
"(",
"'convergence has been achieved'",
",",
"self",
".",
"outputf",
",",
"return_string",
"=",
"False",
")"
] | Determine if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output | [
"Determine",
"if",
"calculation",
"converged",
";",
"for",
"a",
"relaxation",
"(",
"static",
")",
"run",
"we",
"look",
"for",
"ionic",
"(",
"electronic",
")",
"convergence",
"in",
"the",
"output"
] | train | https://github.com/CitrineInformatics/pif-dft/blob/d5411dc1f6c6e8d454b132977ca7ab3bb8131a80/dfttopif/parsers/pwscf.py#L114-L122 | <|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 if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output
### Response:
def _is_converged(self):
'''Determine if calculation converged; for a relaxation (static) run
we look for ionic (electronic) convergence in the output'''
if self.is_relaxed():
# relaxation run case
return self._get_line(['End of', 'Geometry Optimization'], self.outputf, return_string=False)
else:
# static run case
return self._get_line('convergence has been achieved', self.outputf, return_string=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,
35,
25296,
422,
22702,
97875,
26,
369,
264,
43685,
320,
2020,
8,
1629,
198,
286,
584,
1427,
369,
220,
21427,
320,
19493,
8535,
8,
56541,
304,
279,
2612,
271,
14711,
6075,
512,
755,
721,
285,
3464,
424,
3640,
1214,
997,
286,
11712,
35,
25296,
422,
22702,
97875,
26,
369,
264,
43685,
320,
2020,
8,
1629,
198,
286,
584,
1427,
369,
220,
21427,
320,
19493,
8535,
8,
56541,
304,
279,
2612,
15029,
286,
422,
659,
2124,
13869,
52551,
4019,
310,
674,
43685,
1629,
1162,
198,
310,
471,
659,
1462,
456,
6665,
6561,
3812,
315,
518,
364,
21450,
58839,
4181,
659,
13718,
69,
11,
471,
3991,
5725,
340,
286,
775,
512,
310,
674,
1118,
1629,
1162,
198,
310,
471,
659,
1462,
456,
6665,
493,
444,
81848,
706,
1027,
17427,
518,
659,
13718,
69,
11,
471,
3991,
5725,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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,
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,
422,
22702,
97875,
26,
369,
264,
43685,
320,
2020,
8,
1629,
198,
286,
584,
1427,
369,
220,
21427,
320,
19493,
8535,
8,
56541,
304,
279,
2612,
271,
14711,
6075,
512,
755,
721,
285,
3464,
424,
3640,
1214,
997,
286,
11712,
35,
25296,
422,
22702,
97875,
26,
369,
264,
43685,
320,
2020,
8,
1629,
198,
286,
584,
1427,
369,
220,
21427,
320,
19493,
8535,
8,
56541,
304,
279,
2612,
15029,
286,
422,
659,
2124,
13869,
52551,
4019,
310,
674,
43685,
1629,
1162,
198,
310,
471,
659,
1462,
456,
6665,
6561,
3812,
315,
518,
364,
21450,
58839,
4181,
659,
13718,
69,
11,
471,
3991,
5725,
340,
286,
775,
512,
310,
674,
1118,
1629,
1162,
198,
310,
471,
659,
1462,
456,
6665,
493,
444,
81848,
706,
1027,
17427,
518,
659,
13718,
69,
11,
471,
3991,
5725,
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
] |
miku/gluish | gluish/task.py | MockTask.run | def run(self):
""" Just copy the fixture, so we have some output. """
luigi.LocalTarget(path=self.fixture).copy(self.output().path) | python | def run(self):
""" Just copy the fixture, so we have some output. """
luigi.LocalTarget(path=self.fixture).copy(self.output().path) | [
"def",
"run",
"(",
"self",
")",
":",
"luigi",
".",
"LocalTarget",
"(",
"path",
"=",
"self",
".",
"fixture",
")",
".",
"copy",
"(",
"self",
".",
"output",
"(",
")",
".",
"path",
")"
] | Just copy the fixture, so we have some output. | [
"Just",
"copy",
"the",
"fixture",
"so",
"we",
"have",
"some",
"output",
"."
] | train | https://github.com/miku/gluish/blob/56d3ac4f41a944e31ecac0aa3b6d1dc2ce705e29/gluish/task.py#L149-L151 | <|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:
Just copy the fixture, so we have some output.
### Response:
def run(self):
""" Just copy the fixture, so we have some output. """
luigi.LocalTarget(path=self.fixture).copy(self.output().path)
<|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,
10156,
3048,
279,
12790,
11,
779,
584,
617,
1063,
2612,
382,
14711,
6075,
512,
755,
1629,
1214,
997,
286,
4304,
4702,
3048,
279,
12790,
11,
779,
584,
617,
1063,
2612,
13,
3270,
286,
25774,
30637,
21525,
6531,
5698,
7822,
51636,
570,
8728,
1214,
13718,
1020,
2398,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,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
3048,
279,
12790,
11,
779,
584,
617,
1063,
2612,
382,
14711,
6075,
512,
755,
1629,
1214,
997,
286,
4304,
4702,
3048,
279,
12790,
11,
779,
584,
617,
1063,
2612,
13,
3270,
286,
25774,
30637,
21525,
6531,
5698,
7822,
51636,
570,
8728,
1214,
13718,
1020,
2398,
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
] |
amperser/proselint | proselint/checks/misc/currency.py | check | def check(text):
"""Check the text."""
err = "misc.currency"
msg = u"Incorrect use of symbols in {}."
symbols = [
"\$[\d]* ?(?:dollars|usd|us dollars)"
]
return existence_check(text, symbols, err, msg) | python | def check(text):
"""Check the text."""
err = "misc.currency"
msg = u"Incorrect use of symbols in {}."
symbols = [
"\$[\d]* ?(?:dollars|usd|us dollars)"
]
return existence_check(text, symbols, err, msg) | [
"def",
"check",
"(",
"text",
")",
":",
"err",
"=",
"\"misc.currency\"",
"msg",
"=",
"u\"Incorrect use of symbols in {}.\"",
"symbols",
"=",
"[",
"\"\\$[\\d]* ?(?:dollars|usd|us dollars)\"",
"]",
"return",
"existence_check",
"(",
"text",
",",
"symbols",
",",
"err",
",",
"msg",
")"
] | Check the text. | [
"Check",
"the",
"text",
"."
] | train | https://github.com/amperser/proselint/blob/cb619ee4023cc7856f5fb96aec2a33a2c9f1a2e2/proselint/checks/misc/currency.py#L20-L29 | <|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 the text.
### Response:
def check(text):
"""Check the text."""
err = "misc.currency"
msg = u"Incorrect use of symbols in {}."
symbols = [
"\$[\d]* ?(?:dollars|usd|us dollars)"
]
return existence_check(text, symbols, err, 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,
4061,
279,
1495,
382,
14711,
6075,
512,
755,
1817,
7383,
997,
262,
4304,
4061,
279,
1495,
14781,
262,
1886,
284,
330,
48340,
46518,
702,
262,
3835,
284,
577,
33703,
20523,
1005,
315,
18210,
304,
4792,
2266,
262,
18210,
284,
2330,
286,
2990,
3,
27148,
67,
8632,
949,
68250,
78289,
1590,
91,
355,
67,
91,
355,
11441,
13251,
262,
10661,
262,
471,
14209,
7348,
7383,
11,
18210,
11,
1886,
11,
3835,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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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
264,
11190,
15592,
15840,
18328,
13,
20400,
1193,
13325,
2082,
2085,
41941,
13,
40633,
1193,
304,
6498,
382,
14711,
5546,
512,
4061,
279,
1495,
382,
14711,
6075,
512,
755,
1817,
7383,
997,
262,
4304,
4061,
279,
1495,
14781,
262,
1886,
284,
330,
48340,
46518,
702,
262,
3835,
284,
577,
33703,
20523,
1005,
315,
18210,
304,
4792,
2266,
262,
18210,
284,
2330,
286,
2990,
3,
27148,
67,
8632,
949,
68250,
78289,
1590,
91,
355,
67,
91,
355,
11441,
13251,
262,
10661,
262,
471,
14209,
7348,
7383,
11,
18210,
11,
1886,
11,
3835,
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
] |
clalancette/pycdlib | pycdlib/udf.py | UDFFileEntry.track_file_ident_desc | def track_file_ident_desc(self, file_ident):
# type: (UDFFileIdentifierDescriptor) -> None
'''
A method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
self.fi_descs.append(file_ident) | python | def track_file_ident_desc(self, file_ident):
# type: (UDFFileIdentifierDescriptor) -> None
'''
A method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
self.fi_descs.append(file_ident) | [
"def",
"track_file_ident_desc",
"(",
"self",
",",
"file_ident",
")",
":",
"# type: (UDFFileIdentifierDescriptor) -> None",
"if",
"not",
"self",
".",
"_initialized",
":",
"raise",
"pycdlibexception",
".",
"PyCdlibInternalError",
"(",
"'UDF File Entry not initialized'",
")",
"self",
".",
"fi_descs",
".",
"append",
"(",
"file_ident",
")"
] | A method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing. | [
"A",
"method",
"to",
"start",
"tracking",
"a",
"UDF",
"File",
"Identifier",
"descriptor",
"in",
"this",
"UDF",
"File",
"Entry",
".",
"Both",
"tracking",
"and",
"addition",
"add",
"the",
"identifier",
"to",
"the",
"list",
"of",
"file",
"identifiers",
"but",
"tracking",
"doees",
"not",
"expand",
"or",
"otherwise",
"modify",
"the",
"UDF",
"File",
"Entry",
"."
] | train | https://github.com/clalancette/pycdlib/blob/1e7b77a809e905d67dc71e12d70e850be26b6233/pycdlib/udf.py#L3184-L3200 | <|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 method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing.
### Response:
def track_file_ident_desc(self, file_ident):
# type: (UDFFileIdentifierDescriptor) -> None
'''
A method to start tracking a UDF File Identifier descriptor in this
UDF File Entry. Both 'tracking' and 'addition' add the identifier to
the list of file identifiers, but tracking doees not expand or
otherwise modify the UDF File Entry.
Parameters:
file_ident - The UDF File Identifier Descriptor to start tracking.
Returns:
Nothing.
'''
if not self._initialized:
raise pycdlibexception.PyCdlibInternalError('UDF File Entry not initialized')
self.fi_descs.append(file_ident)
<|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,
1749,
311,
1212,
15194,
264,
549,
5375,
2958,
35721,
16819,
304,
420,
198,
286,
549,
5375,
2958,
16165,
13,
220,
11995,
364,
45653,
6,
323,
364,
723,
684,
6,
923,
279,
13110,
311,
198,
286,
279,
1160,
315,
1052,
48316,
11,
719,
15194,
656,
5633,
539,
9407,
477,
198,
286,
6062,
5719,
279,
549,
5375,
2958,
16165,
382,
286,
13831,
512,
260,
1052,
39499,
482,
578,
549,
5375,
2958,
35721,
56792,
311,
1212,
15194,
627,
286,
5295,
512,
260,
12334,
382,
14711,
6075,
512,
755,
3839,
2517,
39499,
11229,
1214,
11,
1052,
39499,
997,
286,
674,
955,
25,
320,
4760,
37,
1738,
8887,
11971,
8,
1492,
2290,
198,
286,
11414,
286,
362,
1749,
311,
1212,
15194,
264,
549,
5375,
2958,
35721,
16819,
304,
420,
198,
286,
549,
5375,
2958,
16165,
13,
220,
11995,
364,
45653,
6,
323,
364,
723,
684,
6,
923,
279,
13110,
311,
198,
286,
279,
1160,
315,
1052,
48316,
11,
719,
15194,
656,
5633,
539,
9407,
477,
198,
286,
6062,
5719,
279,
549,
5375,
2958,
16165,
382,
286,
13831,
512,
260,
1052,
39499,
482,
578,
549,
5375,
2958,
35721,
56792,
311,
1212,
15194,
627,
286,
5295,
512,
260,
12334,
627,
286,
11414,
286,
422,
539,
659,
1462,
37261,
512,
310,
4933,
281,
3418,
67,
2808,
7959,
1087,
88,
91300,
2808,
11830,
1480,
493,
4760,
37,
2958,
16165,
539,
17719,
4713,
286,
659,
62886,
11229,
82,
2102,
4971,
39499,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
1749,
311,
1212,
15194,
264,
549,
5375,
2958,
35721,
16819,
304,
420,
198,
286,
549,
5375,
2958,
16165,
13,
220,
11995,
364,
45653,
6,
323,
364,
723,
684,
6,
923,
279,
13110,
311,
198,
286,
279,
1160,
315,
1052,
48316,
11,
719,
15194,
656,
5633,
539,
9407,
477,
198,
286,
6062,
5719,
279,
549,
5375,
2958,
16165,
382,
286,
13831,
512,
260,
1052,
39499,
482,
578,
549,
5375,
2958,
35721,
56792,
311,
1212,
15194,
627,
286,
5295,
512,
260,
12334,
382,
14711,
6075,
512,
755,
3839,
2517,
39499,
11229,
1214,
11,
1052,
39499,
997,
286,
674,
955,
25,
320,
4760,
37,
1738,
8887,
11971,
8,
1492,
2290,
198,
286,
11414,
286,
362,
1749,
311,
1212,
15194,
264,
549,
5375,
2958,
35721,
16819,
304,
420,
198,
286,
549,
5375,
2958,
16165,
13,
220,
11995,
364,
45653,
6,
323,
364,
723,
684,
6,
923,
279,
13110,
311,
198,
286,
279,
1160,
315,
1052,
48316,
11,
719,
15194,
656,
5633,
539,
9407,
477,
198,
286,
6062,
5719,
279,
549,
5375,
2958,
16165,
382,
286,
13831,
512,
260,
1052,
39499,
482,
578,
549,
5375,
2958,
35721,
56792,
311,
1212,
15194,
627,
286,
5295,
512,
260,
12334,
627,
286,
11414,
286,
422,
539,
659,
1462,
37261,
512,
310,
4933,
281,
3418,
67,
2808,
7959,
1087,
88,
91300,
2808,
11830,
1480,
493,
4760,
37,
2958,
16165,
539,
17719,
4713,
286,
659,
62886,
11229,
82,
2102,
4971,
39499,
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
] |
hmeine/qimage2ndarray | qimage2ndarray/__init__.py | gray2qimage | def gray2qimage(gray, normalize = False):
"""Convert the 2D numpy array `gray` into a 8-bit, indexed QImage_
with a gray colormap. The first dimension represents the vertical
image axis.
The parameter `normalize` can be used to normalize an image's
value range to 0..255:
`normalize` = (nmin, nmax):
scale & clip image values from nmin..nmax to 0..255
`normalize` = nmax:
lets nmin default to zero, i.e. scale & clip the range 0..nmax
to 0..255
`normalize` = True:
scale image values to 0..255 (same as passing (gray.min(),
gray.max()))
If the source array `gray` contains masked values, the result will
have only 255 shades of gray, and one color map entry will be used
to make the corresponding pixels transparent.
A full alpha channel cannot be supported with indexed images;
instead, use `array2qimage` to convert into a 32-bit QImage.
:param gray: image data which should be converted (copied) into a QImage_
:type gray: 2D or 3D numpy.ndarray_ or `numpy.ma.array <masked arrays>`_
:param normalize: normalization parameter (see above, default: no value changing)
:type normalize: bool, scalar, or pair
:rtype: QImage_ with RGB32 or ARGB32 format"""
if _np.ndim(gray) != 2:
raise ValueError("gray2QImage can only convert 2D arrays" +
" (try using array2qimage)" if _np.ndim(gray) == 3 else "")
h, w = gray.shape
result = _qt.QImage(w, h, _qt.QImage.Format_Indexed8)
if not _np.ma.is_masked(gray):
for i in range(256):
result.setColor(i, _qt.qRgb(i,i,i))
_qimageview(result)[:] = _normalize255(gray, normalize)
else:
# map gray value 1 to gray value 0, in order to make room for
# transparent colormap entry:
result.setColor(0, _qt.qRgb(0,0,0))
for i in range(2, 256):
result.setColor(i-1, _qt.qRgb(i,i,i))
_qimageview(result)[:] = _normalize255(gray, normalize, clip = (1, 255)) - 1
result.setColor(255, 0)
_qimageview(result)[gray.mask] = 255
return result | python | def gray2qimage(gray, normalize = False):
"""Convert the 2D numpy array `gray` into a 8-bit, indexed QImage_
with a gray colormap. The first dimension represents the vertical
image axis.
The parameter `normalize` can be used to normalize an image's
value range to 0..255:
`normalize` = (nmin, nmax):
scale & clip image values from nmin..nmax to 0..255
`normalize` = nmax:
lets nmin default to zero, i.e. scale & clip the range 0..nmax
to 0..255
`normalize` = True:
scale image values to 0..255 (same as passing (gray.min(),
gray.max()))
If the source array `gray` contains masked values, the result will
have only 255 shades of gray, and one color map entry will be used
to make the corresponding pixels transparent.
A full alpha channel cannot be supported with indexed images;
instead, use `array2qimage` to convert into a 32-bit QImage.
:param gray: image data which should be converted (copied) into a QImage_
:type gray: 2D or 3D numpy.ndarray_ or `numpy.ma.array <masked arrays>`_
:param normalize: normalization parameter (see above, default: no value changing)
:type normalize: bool, scalar, or pair
:rtype: QImage_ with RGB32 or ARGB32 format"""
if _np.ndim(gray) != 2:
raise ValueError("gray2QImage can only convert 2D arrays" +
" (try using array2qimage)" if _np.ndim(gray) == 3 else "")
h, w = gray.shape
result = _qt.QImage(w, h, _qt.QImage.Format_Indexed8)
if not _np.ma.is_masked(gray):
for i in range(256):
result.setColor(i, _qt.qRgb(i,i,i))
_qimageview(result)[:] = _normalize255(gray, normalize)
else:
# map gray value 1 to gray value 0, in order to make room for
# transparent colormap entry:
result.setColor(0, _qt.qRgb(0,0,0))
for i in range(2, 256):
result.setColor(i-1, _qt.qRgb(i,i,i))
_qimageview(result)[:] = _normalize255(gray, normalize, clip = (1, 255)) - 1
result.setColor(255, 0)
_qimageview(result)[gray.mask] = 255
return result | [
"def",
"gray2qimage",
"(",
"gray",
",",
"normalize",
"=",
"False",
")",
":",
"if",
"_np",
".",
"ndim",
"(",
"gray",
")",
"!=",
"2",
":",
"raise",
"ValueError",
"(",
"\"gray2QImage can only convert 2D arrays\"",
"+",
"\" (try using array2qimage)\"",
"if",
"_np",
".",
"ndim",
"(",
"gray",
")",
"==",
"3",
"else",
"\"\"",
")",
"h",
",",
"w",
"=",
"gray",
".",
"shape",
"result",
"=",
"_qt",
".",
"QImage",
"(",
"w",
",",
"h",
",",
"_qt",
".",
"QImage",
".",
"Format_Indexed8",
")",
"if",
"not",
"_np",
".",
"ma",
".",
"is_masked",
"(",
"gray",
")",
":",
"for",
"i",
"in",
"range",
"(",
"256",
")",
":",
"result",
".",
"setColor",
"(",
"i",
",",
"_qt",
".",
"qRgb",
"(",
"i",
",",
"i",
",",
"i",
")",
")",
"_qimageview",
"(",
"result",
")",
"[",
":",
"]",
"=",
"_normalize255",
"(",
"gray",
",",
"normalize",
")",
"else",
":",
"# map gray value 1 to gray value 0, in order to make room for",
"# transparent colormap entry:",
"result",
".",
"setColor",
"(",
"0",
",",
"_qt",
".",
"qRgb",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
"for",
"i",
"in",
"range",
"(",
"2",
",",
"256",
")",
":",
"result",
".",
"setColor",
"(",
"i",
"-",
"1",
",",
"_qt",
".",
"qRgb",
"(",
"i",
",",
"i",
",",
"i",
")",
")",
"_qimageview",
"(",
"result",
")",
"[",
":",
"]",
"=",
"_normalize255",
"(",
"gray",
",",
"normalize",
",",
"clip",
"=",
"(",
"1",
",",
"255",
")",
")",
"-",
"1",
"result",
".",
"setColor",
"(",
"255",
",",
"0",
")",
"_qimageview",
"(",
"result",
")",
"[",
"gray",
".",
"mask",
"]",
"=",
"255",
"return",
"result"
] | Convert the 2D numpy array `gray` into a 8-bit, indexed QImage_
with a gray colormap. The first dimension represents the vertical
image axis.
The parameter `normalize` can be used to normalize an image's
value range to 0..255:
`normalize` = (nmin, nmax):
scale & clip image values from nmin..nmax to 0..255
`normalize` = nmax:
lets nmin default to zero, i.e. scale & clip the range 0..nmax
to 0..255
`normalize` = True:
scale image values to 0..255 (same as passing (gray.min(),
gray.max()))
If the source array `gray` contains masked values, the result will
have only 255 shades of gray, and one color map entry will be used
to make the corresponding pixels transparent.
A full alpha channel cannot be supported with indexed images;
instead, use `array2qimage` to convert into a 32-bit QImage.
:param gray: image data which should be converted (copied) into a QImage_
:type gray: 2D or 3D numpy.ndarray_ or `numpy.ma.array <masked arrays>`_
:param normalize: normalization parameter (see above, default: no value changing)
:type normalize: bool, scalar, or pair
:rtype: QImage_ with RGB32 or ARGB32 format | [
"Convert",
"the",
"2D",
"numpy",
"array",
"gray",
"into",
"a",
"8",
"-",
"bit",
"indexed",
"QImage_",
"with",
"a",
"gray",
"colormap",
".",
"The",
"first",
"dimension",
"represents",
"the",
"vertical",
"image",
"axis",
"."
] | train | https://github.com/hmeine/qimage2ndarray/blob/023f3c67f90e646ce2fd80418fed85b9c7660bfc/qimage2ndarray/__init__.py#L203-L258 | <|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 the 2D numpy array `gray` into a 8-bit, indexed QImage_
with a gray colormap. The first dimension represents the vertical
image axis.
The parameter `normalize` can be used to normalize an image's
value range to 0..255:
`normalize` = (nmin, nmax):
scale & clip image values from nmin..nmax to 0..255
`normalize` = nmax:
lets nmin default to zero, i.e. scale & clip the range 0..nmax
to 0..255
`normalize` = True:
scale image values to 0..255 (same as passing (gray.min(),
gray.max()))
If the source array `gray` contains masked values, the result will
have only 255 shades of gray, and one color map entry will be used
to make the corresponding pixels transparent.
A full alpha channel cannot be supported with indexed images;
instead, use `array2qimage` to convert into a 32-bit QImage.
:param gray: image data which should be converted (copied) into a QImage_
:type gray: 2D or 3D numpy.ndarray_ or `numpy.ma.array <masked arrays>`_
:param normalize: normalization parameter (see above, default: no value changing)
:type normalize: bool, scalar, or pair
:rtype: QImage_ with RGB32 or ARGB32 format
### Response:
def gray2qimage(gray, normalize = False):
"""Convert the 2D numpy array `gray` into a 8-bit, indexed QImage_
with a gray colormap. The first dimension represents the vertical
image axis.
The parameter `normalize` can be used to normalize an image's
value range to 0..255:
`normalize` = (nmin, nmax):
scale & clip image values from nmin..nmax to 0..255
`normalize` = nmax:
lets nmin default to zero, i.e. scale & clip the range 0..nmax
to 0..255
`normalize` = True:
scale image values to 0..255 (same as passing (gray.min(),
gray.max()))
If the source array `gray` contains masked values, the result will
have only 255 shades of gray, and one color map entry will be used
to make the corresponding pixels transparent.
A full alpha channel cannot be supported with indexed images;
instead, use `array2qimage` to convert into a 32-bit QImage.
:param gray: image data which should be converted (copied) into a QImage_
:type gray: 2D or 3D numpy.ndarray_ or `numpy.ma.array <masked arrays>`_
:param normalize: normalization parameter (see above, default: no value changing)
:type normalize: bool, scalar, or pair
:rtype: QImage_ with RGB32 or ARGB32 format"""
if _np.ndim(gray) != 2:
raise ValueError("gray2QImage can only convert 2D arrays" +
" (try using array2qimage)" if _np.ndim(gray) == 3 else "")
h, w = gray.shape
result = _qt.QImage(w, h, _qt.QImage.Format_Indexed8)
if not _np.ma.is_masked(gray):
for i in range(256):
result.setColor(i, _qt.qRgb(i,i,i))
_qimageview(result)[:] = _normalize255(gray, normalize)
else:
# map gray value 1 to gray value 0, in order to make room for
# transparent colormap entry:
result.setColor(0, _qt.qRgb(0,0,0))
for i in range(2, 256):
result.setColor(i-1, _qt.qRgb(i,i,i))
_qimageview(result)[:] = _normalize255(gray, normalize, clip = (1, 255)) - 1
result.setColor(255, 0)
_qimageview(result)[gray.mask] = 255
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,
12281,
279,
220,
17,
35,
8760,
1358,
1595,
11912,
63,
1139,
264,
220,
23,
15615,
11,
31681,
78527,
13220,
262,
449,
264,
18004,
77110,
13,
220,
578,
1176,
13167,
11105,
279,
12414,
198,
262,
2217,
8183,
382,
262,
578,
5852,
1595,
31690,
63,
649,
387,
1511,
311,
22436,
459,
2217,
596,
198,
262,
907,
2134,
311,
220,
15,
497,
3192,
1473,
262,
1595,
31690,
63,
284,
320,
77,
1083,
11,
308,
2880,
997,
415,
5569,
612,
12607,
2217,
2819,
505,
308,
1083,
497,
77,
2880,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
308,
2880,
512,
415,
15714,
308,
1083,
1670,
311,
7315,
11,
602,
1770,
13,
5569,
612,
12607,
279,
2134,
220,
15,
497,
77,
2880,
198,
415,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
3082,
512,
415,
5569,
2217,
2819,
311,
220,
15,
497,
3192,
320,
25030,
439,
12579,
320,
11912,
4456,
3227,
415,
18004,
6817,
51062,
262,
1442,
279,
2592,
1358,
1595,
11912,
63,
5727,
43248,
2819,
11,
279,
1121,
690,
198,
262,
617,
1193,
220,
3192,
37199,
315,
18004,
11,
323,
832,
1933,
2472,
4441,
690,
387,
1511,
198,
262,
311,
1304,
279,
12435,
16128,
18300,
382,
262,
362,
2539,
8451,
5613,
4250,
387,
7396,
449,
31681,
5448,
280,
262,
4619,
11,
1005,
1595,
1686,
17,
80,
1843,
63,
311,
5625,
1139,
264,
220,
843,
15615,
78527,
382,
262,
551,
913,
18004,
25,
2217,
828,
902,
1288,
387,
16489,
320,
38828,
1142,
8,
1139,
264,
78527,
13220,
262,
551,
1337,
18004,
25,
220,
17,
35,
477,
220,
18,
35,
8760,
36649,
62,
477,
1595,
36183,
63902,
7382,
366,
82635,
18893,
44726,
13220,
262,
551,
913,
22436,
25,
49823,
5852,
320,
4151,
3485,
11,
1670,
25,
912,
907,
10223,
340,
262,
551,
1337,
22436,
25,
1845,
11,
17722,
11,
477,
6857,
198,
262,
551,
33613,
25,
78527,
62,
449,
21653,
843,
477,
6395,
5494,
843,
3645,
271,
14711,
6075,
512,
755,
18004,
17,
80,
1843,
75385,
11,
22436,
284,
3641,
997,
262,
4304,
12281,
279,
220,
17,
35,
8760,
1358,
1595,
11912,
63,
1139,
264,
220,
23,
15615,
11,
31681,
78527,
13220,
262,
449,
264,
18004,
77110,
13,
220,
578,
1176,
13167,
11105,
279,
12414,
198,
262,
2217,
8183,
382,
262,
578,
5852,
1595,
31690,
63,
649,
387,
1511,
311,
22436,
459,
2217,
596,
198,
262,
907,
2134,
311,
220,
15,
497,
3192,
1473,
262,
1595,
31690,
63,
284,
320,
77,
1083,
11,
308,
2880,
997,
415,
5569,
612,
12607,
2217,
2819,
505,
308,
1083,
497,
77,
2880,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
308,
2880,
512,
415,
15714,
308,
1083,
1670,
311,
7315,
11,
602,
1770,
13,
5569,
612,
12607,
279,
2134,
220,
15,
497,
77,
2880,
198,
415,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
3082,
512,
415,
5569,
2217,
2819,
311
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
279,
220,
17,
35,
8760,
1358,
1595,
11912,
63,
1139,
264,
220,
23,
15615,
11,
31681,
78527,
13220,
262,
449,
264,
18004,
77110,
13,
220,
578,
1176,
13167,
11105,
279,
12414,
198,
262,
2217,
8183,
382,
262,
578,
5852,
1595,
31690,
63,
649,
387,
1511,
311,
22436,
459,
2217,
596,
198,
262,
907,
2134,
311,
220,
15,
497,
3192,
1473,
262,
1595,
31690,
63,
284,
320,
77,
1083,
11,
308,
2880,
997,
415,
5569,
612,
12607,
2217,
2819,
505,
308,
1083,
497,
77,
2880,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
308,
2880,
512,
415,
15714,
308,
1083,
1670,
311,
7315,
11,
602,
1770,
13,
5569,
612,
12607,
279,
2134,
220,
15,
497,
77,
2880,
198,
415,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
3082,
512,
415,
5569,
2217,
2819,
311,
220,
15,
497,
3192,
320,
25030,
439,
12579,
320,
11912,
4456,
3227,
415,
18004,
6817,
51062,
262,
1442,
279,
2592,
1358,
1595,
11912,
63,
5727,
43248,
2819,
11,
279,
1121,
690,
198,
262,
617,
1193,
220,
3192,
37199,
315,
18004,
11,
323,
832,
1933,
2472,
4441,
690,
387,
1511,
198,
262,
311,
1304,
279,
12435,
16128,
18300,
382,
262,
362,
2539,
8451,
5613,
4250,
387,
7396,
449,
31681,
5448,
280,
262,
4619,
11,
1005,
1595,
1686,
17,
80,
1843,
63,
311,
5625,
1139,
264,
220,
843,
15615,
78527,
382,
262,
551,
913,
18004,
25,
2217,
828,
902,
1288,
387,
16489,
320,
38828,
1142,
8,
1139,
264,
78527,
13220,
262,
551,
1337,
18004,
25,
220,
17,
35,
477,
220,
18,
35,
8760,
36649,
62,
477,
1595,
36183,
63902,
7382,
366,
82635,
18893,
44726,
13220,
262,
551,
913,
22436,
25,
49823,
5852,
320,
4151,
3485,
11,
1670,
25,
912,
907,
10223,
340,
262,
551,
1337,
22436,
25,
1845,
11,
17722,
11,
477,
6857,
198,
262,
551,
33613,
25,
78527,
62,
449,
21653,
843,
477,
6395,
5494,
843,
3645,
271,
14711,
6075,
512,
755,
18004,
17,
80,
1843,
75385,
11,
22436,
284,
3641,
997,
262,
4304,
12281,
279,
220,
17,
35,
8760,
1358,
1595,
11912,
63,
1139,
264,
220,
23,
15615,
11,
31681,
78527,
13220,
262,
449,
264,
18004,
77110,
13,
220,
578,
1176,
13167,
11105,
279,
12414,
198,
262,
2217,
8183,
382,
262,
578,
5852,
1595,
31690,
63,
649,
387,
1511,
311,
22436,
459,
2217,
596,
198,
262,
907,
2134,
311,
220,
15,
497,
3192,
1473,
262,
1595,
31690,
63,
284,
320,
77,
1083,
11,
308,
2880,
997,
415,
5569,
612,
12607,
2217,
2819,
505,
308,
1083,
497,
77,
2880,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
308,
2880,
512,
415,
15714,
308,
1083,
1670,
311,
7315,
11,
602,
1770,
13,
5569,
612,
12607,
279,
2134,
220,
15,
497,
77,
2880,
198,
415,
311,
220,
15,
497,
3192,
271,
262,
1595,
31690,
63,
284,
3082,
512,
415,
5569,
2217,
2819,
311
] |
spulec/moto | moto/dynamodb/models.py | DynamoType.compare | def compare(self, range_comparison, range_objs):
"""
Compares this type against comparison filters
"""
range_values = [obj.value for obj in range_objs]
comparison_func = get_comparison_func(range_comparison)
return comparison_func(self.value, *range_values) | python | def compare(self, range_comparison, range_objs):
"""
Compares this type against comparison filters
"""
range_values = [obj.value for obj in range_objs]
comparison_func = get_comparison_func(range_comparison)
return comparison_func(self.value, *range_values) | [
"def",
"compare",
"(",
"self",
",",
"range_comparison",
",",
"range_objs",
")",
":",
"range_values",
"=",
"[",
"obj",
".",
"value",
"for",
"obj",
"in",
"range_objs",
"]",
"comparison_func",
"=",
"get_comparison_func",
"(",
"range_comparison",
")",
"return",
"comparison_func",
"(",
"self",
".",
"value",
",",
"*",
"range_values",
")"
] | Compares this type against comparison filters | [
"Compares",
"this",
"type",
"against",
"comparison",
"filters"
] | train | https://github.com/spulec/moto/blob/4a286c4bc288933bb023396e2784a6fdbb966bc9/moto/dynamodb/models.py#L47-L53 | <|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:
Compares this type against comparison filters
### Response:
def compare(self, range_comparison, range_objs):
"""
Compares this type against comparison filters
"""
range_values = [obj.value for obj in range_objs]
comparison_func = get_comparison_func(range_comparison)
return comparison_func(self.value, *range_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,
13864,
5518,
420,
955,
2403,
12593,
13711,
271,
14711,
6075,
512,
755,
9616,
1214,
11,
2134,
91897,
11,
2134,
63773,
997,
286,
3270,
286,
13620,
5518,
420,
955,
2403,
12593,
13711,
198,
286,
3270,
286,
2134,
9324,
284,
510,
2347,
2894,
369,
2909,
304,
2134,
63773,
933,
286,
12593,
9791,
284,
636,
91897,
9791,
23147,
91897,
340,
286,
471,
12593,
9791,
1214,
2894,
11,
353,
9866,
9324,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
13864,
5518,
420,
955,
2403,
12593,
13711,
271,
14711,
6075,
512,
755,
9616,
1214,
11,
2134,
91897,
11,
2134,
63773,
997,
286,
3270,
286,
13620,
5518,
420,
955,
2403,
12593,
13711,
198,
286,
3270,
286,
2134,
9324,
284,
510,
2347,
2894,
369,
2909,
304,
2134,
63773,
933,
286,
12593,
9791,
284,
636,
91897,
9791,
23147,
91897,
340,
286,
471,
12593,
9791,
1214,
2894,
11,
353,
9866,
9324,
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
] |
androguard/androguard | androguard/core/bytecodes/dvm.py | MapList.show | def show(self):
"""
Print with a pretty display the MapList object
"""
bytecode._Print("MAP_LIST SIZE", self.size)
for i in self.map_item:
if i.item != self:
# FIXME this does not work for CodeItems!
# as we do not have the method analysis here...
i.show() | python | def show(self):
"""
Print with a pretty display the MapList object
"""
bytecode._Print("MAP_LIST SIZE", self.size)
for i in self.map_item:
if i.item != self:
# FIXME this does not work for CodeItems!
# as we do not have the method analysis here...
i.show() | [
"def",
"show",
"(",
"self",
")",
":",
"bytecode",
".",
"_Print",
"(",
"\"MAP_LIST SIZE\"",
",",
"self",
".",
"size",
")",
"for",
"i",
"in",
"self",
".",
"map_item",
":",
"if",
"i",
".",
"item",
"!=",
"self",
":",
"# FIXME this does not work for CodeItems!",
"# as we do not have the method analysis here...",
"i",
".",
"show",
"(",
")"
] | Print with a pretty display the MapList object | [
"Print",
"with",
"a",
"pretty",
"display",
"the",
"MapList",
"object"
] | train | https://github.com/androguard/androguard/blob/984c0d981be2950cf0451e484f7b0d4d53bc4911/androguard/core/bytecodes/dvm.py#L7550-L7559 | <|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 with a pretty display the MapList object
### Response:
def show(self):
"""
Print with a pretty display the MapList object
"""
bytecode._Print("MAP_LIST SIZE", self.size)
for i in self.map_item:
if i.item != self:
# FIXME this does not work for CodeItems!
# as we do not have the method analysis here...
i.show()
<|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,
449,
264,
5128,
3113,
279,
5135,
861,
1665,
271,
14711,
6075,
512,
755,
1501,
1214,
997,
286,
3270,
286,
8377,
449,
264,
5128,
3113,
279,
5135,
861,
1665,
198,
286,
3270,
286,
76229,
1462,
9171,
446,
18082,
12163,
26410,
498,
659,
2546,
340,
286,
369,
602,
304,
659,
4875,
5752,
512,
310,
422,
602,
9161,
976,
659,
512,
394,
674,
28575,
420,
1587,
539,
990,
369,
6247,
4451,
4999,
394,
674,
439,
584,
656,
539,
617,
279,
1749,
6492,
1618,
9522,
394,
602,
5577,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
449,
264,
5128,
3113,
279,
5135,
861,
1665,
271,
14711,
6075,
512,
755,
1501,
1214,
997,
286,
3270,
286,
8377,
449,
264,
5128,
3113,
279,
5135,
861,
1665,
198,
286,
3270,
286,
76229,
1462,
9171,
446,
18082,
12163,
26410,
498,
659,
2546,
340,
286,
369,
602,
304,
659,
4875,
5752,
512,
310,
422,
602,
9161,
976,
659,
512,
394,
674,
28575,
420,
1587,
539,
990,
369,
6247,
4451,
4999,
394,
674,
439,
584,
656,
539,
617,
279,
1749,
6492,
1618,
9522,
394,
602,
5577,
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
] |
saltstack/salt | salt/states/schedule.py | disabled | def disabled(name, **kwargs):
'''
Ensure a job is disabled in the schedule
name
The unique name that is given to the scheduled job.
persist
Whether the job should persist between minion restarts, defaults to True.
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': []}
current_schedule = __salt__['schedule.list'](show_all=True, return_yaml=False)
if name in current_schedule:
if 'test' in __opts__ and __opts__['test']:
kwargs['test'] = True
result = __salt__['schedule.disable_job'](name, **kwargs)
ret['comment'].append(result['comment'])
else:
result = __salt__['schedule.disable_job'](name, **kwargs)
if not result['result']:
ret['result'] = result['result']
ret['comment'] = result['comment']
return ret
else:
ret['comment'].append('Disabled job {0} from schedule'.format(name))
else:
ret['comment'].append('Job {0} not present in schedule'.format(name))
ret['comment'] = '\n'.join(ret['comment'])
return ret | python | def disabled(name, **kwargs):
'''
Ensure a job is disabled in the schedule
name
The unique name that is given to the scheduled job.
persist
Whether the job should persist between minion restarts, defaults to True.
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': []}
current_schedule = __salt__['schedule.list'](show_all=True, return_yaml=False)
if name in current_schedule:
if 'test' in __opts__ and __opts__['test']:
kwargs['test'] = True
result = __salt__['schedule.disable_job'](name, **kwargs)
ret['comment'].append(result['comment'])
else:
result = __salt__['schedule.disable_job'](name, **kwargs)
if not result['result']:
ret['result'] = result['result']
ret['comment'] = result['comment']
return ret
else:
ret['comment'].append('Disabled job {0} from schedule'.format(name))
else:
ret['comment'].append('Job {0} not present in schedule'.format(name))
ret['comment'] = '\n'.join(ret['comment'])
return ret | [
"def",
"disabled",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
":",
"ret",
"=",
"{",
"'name'",
":",
"name",
",",
"'result'",
":",
"True",
",",
"'changes'",
":",
"{",
"}",
",",
"'comment'",
":",
"[",
"]",
"}",
"current_schedule",
"=",
"__salt__",
"[",
"'schedule.list'",
"]",
"(",
"show_all",
"=",
"True",
",",
"return_yaml",
"=",
"False",
")",
"if",
"name",
"in",
"current_schedule",
":",
"if",
"'test'",
"in",
"__opts__",
"and",
"__opts__",
"[",
"'test'",
"]",
":",
"kwargs",
"[",
"'test'",
"]",
"=",
"True",
"result",
"=",
"__salt__",
"[",
"'schedule.disable_job'",
"]",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"ret",
"[",
"'comment'",
"]",
".",
"append",
"(",
"result",
"[",
"'comment'",
"]",
")",
"else",
":",
"result",
"=",
"__salt__",
"[",
"'schedule.disable_job'",
"]",
"(",
"name",
",",
"*",
"*",
"kwargs",
")",
"if",
"not",
"result",
"[",
"'result'",
"]",
":",
"ret",
"[",
"'result'",
"]",
"=",
"result",
"[",
"'result'",
"]",
"ret",
"[",
"'comment'",
"]",
"=",
"result",
"[",
"'comment'",
"]",
"return",
"ret",
"else",
":",
"ret",
"[",
"'comment'",
"]",
".",
"append",
"(",
"'Disabled job {0} from schedule'",
".",
"format",
"(",
"name",
")",
")",
"else",
":",
"ret",
"[",
"'comment'",
"]",
".",
"append",
"(",
"'Job {0} not present in schedule'",
".",
"format",
"(",
"name",
")",
")",
"ret",
"[",
"'comment'",
"]",
"=",
"'\\n'",
".",
"join",
"(",
"ret",
"[",
"'comment'",
"]",
")",
"return",
"ret"
] | Ensure a job is disabled in the schedule
name
The unique name that is given to the scheduled job.
persist
Whether the job should persist between minion restarts, defaults to True. | [
"Ensure",
"a",
"job",
"is",
"disabled",
"in",
"the",
"schedule"
] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/schedule.py#L344-L379 | <|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 a job is disabled in the schedule
name
The unique name that is given to the scheduled job.
persist
Whether the job should persist between minion restarts, defaults to True.
### Response:
def disabled(name, **kwargs):
'''
Ensure a job is disabled in the schedule
name
The unique name that is given to the scheduled job.
persist
Whether the job should persist between minion restarts, defaults to True.
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': []}
current_schedule = __salt__['schedule.list'](show_all=True, return_yaml=False)
if name in current_schedule:
if 'test' in __opts__ and __opts__['test']:
kwargs['test'] = True
result = __salt__['schedule.disable_job'](name, **kwargs)
ret['comment'].append(result['comment'])
else:
result = __salt__['schedule.disable_job'](name, **kwargs)
if not result['result']:
ret['result'] = result['result']
ret['comment'] = result['comment']
return ret
else:
ret['comment'].append('Disabled job {0} from schedule'.format(name))
else:
ret['comment'].append('Job {0} not present in schedule'.format(name))
ret['comment'] = '\n'.join(ret['comment'])
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,
65539,
264,
2683,
374,
8552,
304,
279,
9899,
271,
262,
836,
198,
286,
578,
5016,
836,
430,
374,
2728,
311,
279,
13847,
2683,
382,
262,
23135,
198,
286,
13440,
279,
2683,
1288,
23135,
1990,
63635,
17460,
82,
11,
17088,
311,
3082,
382,
14711,
6075,
512,
755,
8552,
3232,
11,
3146,
9872,
997,
262,
11414,
262,
30379,
264,
2683,
374,
8552,
304,
279,
9899,
271,
262,
836,
198,
286,
578,
5016,
836,
430,
374,
2728,
311,
279,
13847,
2683,
382,
262,
23135,
198,
286,
13440,
279,
2683,
1288,
23135,
1990,
63635,
17460,
82,
11,
17088,
311,
3082,
382,
262,
45832,
262,
2160,
284,
5473,
609,
1232,
836,
345,
1881,
364,
1407,
1232,
3082,
345,
1881,
364,
19926,
1232,
14915,
1881,
364,
6313,
1232,
3132,
633,
262,
1510,
35630,
284,
1328,
43326,
565,
681,
29730,
6556,
85433,
3528,
5823,
3702,
11,
471,
65480,
5725,
340,
262,
422,
836,
304,
1510,
35630,
512,
286,
422,
364,
1985,
6,
304,
1328,
10740,
565,
323,
1328,
10740,
565,
681,
1985,
18888,
310,
16901,
681,
1985,
663,
284,
3082,
198,
310,
1121,
284,
1328,
43326,
565,
681,
29730,
43728,
20916,
85433,
609,
11,
3146,
9872,
340,
310,
2160,
681,
6313,
7352,
5200,
4556,
681,
6313,
7519,
286,
775,
512,
310,
1121,
284,
1328,
43326,
565,
681,
29730,
43728,
20916,
85433,
609,
11,
3146,
9872,
340,
310,
422,
539,
1121,
681,
1407,
18888,
394,
2160,
681,
1407,
663,
284,
1121,
681,
1407,
4532,
394,
2160,
681,
6313,
663,
284,
1121,
681,
6313,
4532,
394,
471,
2160,
198,
310,
775,
512,
394,
2160,
681,
6313,
7352,
5200,
493,
26996,
2683,
314,
15,
92,
505,
9899,
4527,
2293,
3232,
1192,
262,
775,
512,
286,
2160,
681,
6313,
7352,
5200,
493,
12524,
314,
15,
92,
539,
3118,
304,
9899,
4527,
2293,
3232,
4489,
262,
2160,
681,
6313,
663,
284,
5307,
77,
4527,
6115,
16442,
681,
6313,
7519,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,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
264,
2683,
374,
8552,
304,
279,
9899,
271,
262,
836,
198,
286,
578,
5016,
836,
430,
374,
2728,
311,
279,
13847,
2683,
382,
262,
23135,
198,
286,
13440,
279,
2683,
1288,
23135,
1990,
63635,
17460,
82,
11,
17088,
311,
3082,
382,
14711,
6075,
512,
755,
8552,
3232,
11,
3146,
9872,
997,
262,
11414,
262,
30379,
264,
2683,
374,
8552,
304,
279,
9899,
271,
262,
836,
198,
286,
578,
5016,
836,
430,
374,
2728,
311,
279,
13847,
2683,
382,
262,
23135,
198,
286,
13440,
279,
2683,
1288,
23135,
1990,
63635,
17460,
82,
11,
17088,
311,
3082,
382,
262,
45832,
262,
2160,
284,
5473,
609,
1232,
836,
345,
1881,
364,
1407,
1232,
3082,
345,
1881,
364,
19926,
1232,
14915,
1881,
364,
6313,
1232,
3132,
633,
262,
1510,
35630,
284,
1328,
43326,
565,
681,
29730,
6556,
85433,
3528,
5823,
3702,
11,
471,
65480,
5725,
340,
262,
422,
836,
304,
1510,
35630,
512,
286,
422,
364,
1985,
6,
304,
1328,
10740,
565,
323,
1328,
10740,
565,
681,
1985,
18888,
310,
16901,
681,
1985,
663,
284,
3082,
198,
310,
1121,
284,
1328,
43326,
565,
681,
29730,
43728,
20916,
85433,
609,
11,
3146,
9872,
340,
310,
2160,
681,
6313,
7352,
5200,
4556,
681,
6313,
7519,
286,
775,
512,
310,
1121,
284,
1328,
43326,
565,
681,
29730,
43728,
20916,
85433,
609,
11,
3146,
9872,
340,
310,
422,
539,
1121,
681,
1407,
18888,
394,
2160,
681,
1407,
663,
284,
1121,
681,
1407,
4532,
394,
2160,
681,
6313,
663,
284,
1121,
681,
6313,
4532,
394,
471,
2160,
198,
310,
775,
512,
394,
2160,
681,
6313,
7352,
5200,
493,
26996,
2683,
314,
15,
92,
505,
9899,
4527,
2293,
3232,
1192,
262,
775,
512,
286,
2160,
681,
6313,
7352,
5200,
493,
12524,
314,
15,
92,
539,
3118,
304,
9899,
4527,
2293,
3232,
4489,
262,
2160,
681,
6313,
663,
284,
5307,
77,
4527,
6115,
16442,
681,
6313,
7519,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
jameslyons/python_speech_features | python_speech_features/base.py | delta | def delta(feat, N):
"""Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns: A numpy array of size (NUMFRAMES by number of features) containing delta features. Each row holds 1 delta feature vector.
"""
if N < 1:
raise ValueError('N must be an integer >= 1')
NUMFRAMES = len(feat)
denominator = 2 * sum([i**2 for i in range(1, N+1)])
delta_feat = numpy.empty_like(feat)
padded = numpy.pad(feat, ((N, N), (0, 0)), mode='edge') # padded version of feat
for t in range(NUMFRAMES):
delta_feat[t] = numpy.dot(numpy.arange(-N, N+1), padded[t : t+2*N+1]) / denominator # [t : t+2*N+1] == [(N+t)-N : (N+t)+N+1]
return delta_feat | python | def delta(feat, N):
"""Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns: A numpy array of size (NUMFRAMES by number of features) containing delta features. Each row holds 1 delta feature vector.
"""
if N < 1:
raise ValueError('N must be an integer >= 1')
NUMFRAMES = len(feat)
denominator = 2 * sum([i**2 for i in range(1, N+1)])
delta_feat = numpy.empty_like(feat)
padded = numpy.pad(feat, ((N, N), (0, 0)), mode='edge') # padded version of feat
for t in range(NUMFRAMES):
delta_feat[t] = numpy.dot(numpy.arange(-N, N+1), padded[t : t+2*N+1]) / denominator # [t : t+2*N+1] == [(N+t)-N : (N+t)+N+1]
return delta_feat | [
"def",
"delta",
"(",
"feat",
",",
"N",
")",
":",
"if",
"N",
"<",
"1",
":",
"raise",
"ValueError",
"(",
"'N must be an integer >= 1'",
")",
"NUMFRAMES",
"=",
"len",
"(",
"feat",
")",
"denominator",
"=",
"2",
"*",
"sum",
"(",
"[",
"i",
"**",
"2",
"for",
"i",
"in",
"range",
"(",
"1",
",",
"N",
"+",
"1",
")",
"]",
")",
"delta_feat",
"=",
"numpy",
".",
"empty_like",
"(",
"feat",
")",
"padded",
"=",
"numpy",
".",
"pad",
"(",
"feat",
",",
"(",
"(",
"N",
",",
"N",
")",
",",
"(",
"0",
",",
"0",
")",
")",
",",
"mode",
"=",
"'edge'",
")",
"# padded version of feat",
"for",
"t",
"in",
"range",
"(",
"NUMFRAMES",
")",
":",
"delta_feat",
"[",
"t",
"]",
"=",
"numpy",
".",
"dot",
"(",
"numpy",
".",
"arange",
"(",
"-",
"N",
",",
"N",
"+",
"1",
")",
",",
"padded",
"[",
"t",
":",
"t",
"+",
"2",
"*",
"N",
"+",
"1",
"]",
")",
"/",
"denominator",
"# [t : t+2*N+1] == [(N+t)-N : (N+t)+N+1]",
"return",
"delta_feat"
] | Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns: A numpy array of size (NUMFRAMES by number of features) containing delta features. Each row holds 1 delta feature vector. | [
"Compute",
"delta",
"features",
"from",
"a",
"feature",
"vector",
"sequence",
"."
] | train | https://github.com/jameslyons/python_speech_features/blob/40c590269b57c64a8c1f1ddaaff2162008d1850c/python_speech_features/base.py#L195-L210 | <|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:
Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns: A numpy array of size (NUMFRAMES by number of features) containing delta features. Each row holds 1 delta feature vector.
### Response:
def delta(feat, N):
"""Compute delta features from a feature vector sequence.
:param feat: A numpy array of size (NUMFRAMES by number of features) containing features. Each row holds 1 feature vector.
:param N: For each frame, calculate delta features based on preceding and following N frames
:returns: A numpy array of size (NUMFRAMES by number of features) containing delta features. Each row holds 1 delta feature vector.
"""
if N < 1:
raise ValueError('N must be an integer >= 1')
NUMFRAMES = len(feat)
denominator = 2 * sum([i**2 for i in range(1, N+1)])
delta_feat = numpy.empty_like(feat)
padded = numpy.pad(feat, ((N, N), (0, 0)), mode='edge') # padded version of feat
for t in range(NUMFRAMES):
delta_feat[t] = numpy.dot(numpy.arange(-N, N+1), padded[t : t+2*N+1]) / denominator # [t : t+2*N+1] == [(N+t)-N : (N+t)+N+1]
return delta_feat
<|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,
47354,
9665,
4519,
505,
264,
4668,
4724,
8668,
382,
262,
551,
913,
12627,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
4519,
13,
9062,
2872,
10187,
220,
16,
4668,
4724,
627,
262,
551,
913,
452,
25,
1789,
1855,
4124,
11,
11294,
9665,
4519,
3196,
389,
38846,
323,
2768,
452,
14418,
198,
262,
551,
4310,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
9665,
4519,
13,
9062,
2872,
10187,
220,
16,
9665,
4668,
4724,
382,
14711,
6075,
512,
755,
9665,
968,
33166,
11,
452,
997,
262,
4304,
47354,
9665,
4519,
505,
264,
4668,
4724,
8668,
382,
262,
551,
913,
12627,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
4519,
13,
9062,
2872,
10187,
220,
16,
4668,
4724,
627,
262,
551,
913,
452,
25,
1789,
1855,
4124,
11,
11294,
9665,
4519,
3196,
389,
38846,
323,
2768,
452,
14418,
198,
262,
551,
4310,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
9665,
4519,
13,
9062,
2872,
10187,
220,
16,
9665,
4668,
4724,
627,
262,
3270,
262,
422,
452,
366,
220,
16,
512,
286,
4933,
15764,
493,
45,
2011,
387,
459,
7698,
2669,
220,
16,
1329,
262,
16322,
10725,
15981,
284,
2479,
968,
33166,
340,
262,
48012,
284,
220,
17,
353,
2694,
2625,
72,
334,
17,
369,
602,
304,
2134,
7,
16,
11,
452,
10,
16,
28243,
262,
9665,
47853,
284,
8760,
9357,
26616,
968,
33166,
340,
262,
44968,
284,
8760,
57366,
968,
33166,
11,
1819,
45,
11,
452,
705,
320,
15,
11,
220,
15,
5850,
3941,
1151,
7334,
873,
256,
674,
44968,
2373,
315,
12627,
198,
262,
369,
259,
304,
2134,
80028,
10725,
15981,
997,
286,
9665,
47853,
14527,
60,
284,
8760,
23633,
83948,
25306,
4172,
45,
11,
452,
10,
16,
705,
44968,
14527,
551,
259,
10,
17,
45729,
10,
16,
2526,
611,
48012,
256,
674,
510,
83,
551,
259,
10,
17,
45729,
10,
16,
60,
624,
18305,
45,
42801,
7435,
45,
551,
320,
45,
42801,
7405,
45,
10,
16,
933,
262,
471,
9665,
47853,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
47354,
9665,
4519,
505,
264,
4668,
4724,
8668,
382,
262,
551,
913,
12627,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
4519,
13,
9062,
2872,
10187,
220,
16,
4668,
4724,
627,
262,
551,
913,
452,
25,
1789,
1855,
4124,
11,
11294,
9665,
4519,
3196,
389,
38846,
323,
2768,
452,
14418,
198,
262,
551,
4310,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
9665,
4519,
13,
9062,
2872,
10187,
220,
16,
9665,
4668,
4724,
382,
14711,
6075,
512,
755,
9665,
968,
33166,
11,
452,
997,
262,
4304,
47354,
9665,
4519,
505,
264,
4668,
4724,
8668,
382,
262,
551,
913,
12627,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
4519,
13,
9062,
2872,
10187,
220,
16,
4668,
4724,
627,
262,
551,
913,
452,
25,
1789,
1855,
4124,
11,
11294,
9665,
4519,
3196,
389,
38846,
323,
2768,
452,
14418,
198,
262,
551,
4310,
25,
362,
8760,
1358,
315,
1404,
320,
17946,
10725,
15981,
555,
1396,
315,
4519,
8,
8649,
9665,
4519,
13,
9062,
2872,
10187,
220,
16,
9665,
4668,
4724,
627,
262,
3270,
262,
422,
452,
366,
220,
16,
512,
286,
4933,
15764,
493,
45,
2011,
387,
459,
7698,
2669,
220,
16,
1329,
262,
16322,
10725,
15981,
284,
2479,
968,
33166,
340,
262,
48012,
284,
220,
17,
353,
2694,
2625,
72,
334,
17,
369,
602,
304,
2134,
7,
16,
11,
452,
10,
16,
28243,
262,
9665,
47853,
284,
8760,
9357,
26616,
968,
33166,
340,
262,
44968,
284,
8760,
57366,
968,
33166,
11,
1819,
45,
11,
452,
705,
320,
15,
11,
220,
15,
5850,
3941,
1151,
7334,
873,
256,
674,
44968,
2373,
315,
12627,
198,
262,
369,
259,
304,
2134,
80028,
10725,
15981,
997,
286,
9665,
47853,
14527,
60,
284,
8760,
23633,
83948,
25306,
4172,
45,
11,
452,
10,
16,
705,
44968,
14527,
551,
259,
10,
17,
45729,
10,
16,
2526,
611,
48012,
256,
674,
510,
83,
551,
259,
10,
17,
45729,
10,
16,
60,
624,
18305,
45,
42801,
7435,
45,
551,
320,
45,
42801,
7405,
45,
10,
16,
933,
262,
471,
9665,
47853,
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
] |
marrow/cinje | cinje/util.py | stream | def stream(input, encoding=None, errors='strict'):
"""Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body.
"""
input = (i for i in input if i) # Omits `None` (empty wrappers) and empty chunks.
if encoding: # Automatically, and iteratively, encode the text if requested.
input = iterencode(input, encoding, errors=errors)
return input | python | def stream(input, encoding=None, errors='strict'):
"""Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body.
"""
input = (i for i in input if i) # Omits `None` (empty wrappers) and empty chunks.
if encoding: # Automatically, and iteratively, encode the text if requested.
input = iterencode(input, encoding, errors=errors)
return input | [
"def",
"stream",
"(",
"input",
",",
"encoding",
"=",
"None",
",",
"errors",
"=",
"'strict'",
")",
":",
"input",
"=",
"(",
"i",
"for",
"i",
"in",
"input",
"if",
"i",
")",
"# Omits `None` (empty wrappers) and empty chunks.",
"if",
"encoding",
":",
"# Automatically, and iteratively, encode the text if requested.",
"input",
"=",
"iterencode",
"(",
"input",
",",
"encoding",
",",
"errors",
"=",
"errors",
")",
"return",
"input"
] | Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body. | [
"Safely",
"iterate",
"a",
"template",
"generator",
"ignoring",
"None",
"values",
"and",
"optionally",
"stream",
"encoding",
".",
"Used",
"internally",
"by",
"cinje",
".",
"flatten",
"this",
"allows",
"for",
"easy",
"use",
"of",
"a",
"template",
"generator",
"as",
"a",
"WSGI",
"body",
"."
] | train | https://github.com/marrow/cinje/blob/413bdac7242020ce8379d272720c649a9196daa2/cinje/util.py#L71-L82 | <|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:
Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body.
### Response:
def stream(input, encoding=None, errors='strict'):
"""Safely iterate a template generator, ignoring ``None`` values and optionally stream encoding.
Used internally by ``cinje.flatten``, this allows for easy use of a template generator as a WSGI body.
"""
input = (i for i in input if i) # Omits `None` (empty wrappers) and empty chunks.
if encoding: # Automatically, and iteratively, encode the text if requested.
input = iterencode(input, encoding, errors=errors)
return input
<|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,
2642,
989,
30729,
264,
3896,
14143,
11,
32003,
10103,
4155,
14196,
2819,
323,
46624,
4365,
11418,
627,
1602,
197,
23580,
34167,
555,
10103,
18595,
3841,
49298,
91816,
420,
6276,
369,
4228,
1005,
315,
264,
3896,
14143,
439,
264,
468,
7939,
40,
2547,
382,
14711,
6075,
512,
755,
4365,
5498,
11,
11418,
5980,
11,
6103,
1151,
6765,
11290,
197,
12885,
50,
2642,
989,
30729,
264,
3896,
14143,
11,
32003,
10103,
4155,
14196,
2819,
323,
46624,
4365,
11418,
627,
1602,
197,
23580,
34167,
555,
10103,
18595,
3841,
49298,
91816,
420,
6276,
369,
4228,
1005,
315,
264,
3896,
14143,
439,
264,
468,
7939,
40,
2547,
627,
197,
7275,
1602,
23235,
284,
320,
72,
369,
602,
304,
1988,
422,
602,
8,
220,
674,
19116,
1220,
1595,
4155,
63,
320,
3274,
79194,
8,
323,
4384,
27855,
627,
1602,
748,
11418,
25,
220,
674,
71250,
11,
323,
5480,
8046,
11,
16559,
279,
1495,
422,
11472,
627,
197,
23235,
284,
5480,
6311,
5498,
11,
11418,
11,
6103,
28,
7805,
340,
1602,
862,
1988,
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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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
] | [
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,
2642,
989,
30729,
264,
3896,
14143,
11,
32003,
10103,
4155,
14196,
2819,
323,
46624,
4365,
11418,
627,
1602,
197,
23580,
34167,
555,
10103,
18595,
3841,
49298,
91816,
420,
6276,
369,
4228,
1005,
315,
264,
3896,
14143,
439,
264,
468,
7939,
40,
2547,
382,
14711,
6075,
512,
755,
4365,
5498,
11,
11418,
5980,
11,
6103,
1151,
6765,
11290,
197,
12885,
50,
2642,
989,
30729,
264,
3896,
14143,
11,
32003,
10103,
4155,
14196,
2819,
323,
46624,
4365,
11418,
627,
1602,
197,
23580,
34167,
555,
10103,
18595,
3841,
49298,
91816,
420,
6276,
369,
4228,
1005,
315,
264,
3896,
14143,
439,
264,
468,
7939,
40,
2547,
627,
197,
7275,
1602,
23235,
284,
320,
72,
369,
602,
304,
1988,
422,
602,
8,
220,
674,
19116,
1220,
1595,
4155,
63,
320,
3274,
79194,
8,
323,
4384,
27855,
627,
1602,
748,
11418,
25,
220,
674,
71250,
11,
323,
5480,
8046,
11,
16559,
279,
1495,
422,
11472,
627,
197,
23235,
284,
5480,
6311,
5498,
11,
11418,
11,
6103,
28,
7805,
340,
1602,
862,
1988,
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
] |
Erotemic/utool | utool/util_list.py | safe_listget | def safe_listget(list_, index, default='?'):
""" depricate """
if index >= len(list_):
return default
ret = list_[index]
if ret is None:
return default
return ret | python | def safe_listget(list_, index, default='?'):
""" depricate """
if index >= len(list_):
return default
ret = list_[index]
if ret is None:
return default
return ret | [
"def",
"safe_listget",
"(",
"list_",
",",
"index",
",",
"default",
"=",
"'?'",
")",
":",
"if",
"index",
">=",
"len",
"(",
"list_",
")",
":",
"return",
"default",
"ret",
"=",
"list_",
"[",
"index",
"]",
"if",
"ret",
"is",
"None",
":",
"return",
"default",
"return",
"ret"
] | depricate | [
"depricate"
] | train | https://github.com/Erotemic/utool/blob/3b27e1f4e6e6fb23cd8744af7b7195b57d99e03a/utool/util_list.py#L246-L253 | <|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:
depricate
### Response:
def safe_listget(list_, index, default='?'):
""" depricate """
if index >= len(list_):
return default
ret = list_[index]
if ret is None:
return default
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,
451,
652,
8630,
271,
14711,
6075,
512,
755,
6220,
2062,
456,
7455,
7022,
1963,
11,
1670,
1151,
30,
11290,
262,
4304,
36980,
8630,
3270,
262,
422,
1963,
2669,
2479,
7455,
62,
997,
286,
471,
1670,
198,
262,
2160,
284,
1160,
12147,
1275,
933,
262,
422,
2160,
374,
2290,
512,
286,
471,
1670,
198,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,
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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
] | [
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,
451,
652,
8630,
271,
14711,
6075,
512,
755,
6220,
2062,
456,
7455,
7022,
1963,
11,
1670,
1151,
30,
11290,
262,
4304,
36980,
8630,
3270,
262,
422,
1963,
2669,
2479,
7455,
62,
997,
286,
471,
1670,
198,
262,
2160,
284,
1160,
12147,
1275,
933,
262,
422,
2160,
374,
2290,
512,
286,
471,
1670,
198,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
acorg/dark-matter | dark/utils.py | countPrint | def countPrint(mesg, count, len1, len2=None):
"""
Format a message followed by an integer count and a percentage (or
two, if the sequence lengths are unequal).
@param mesg: a C{str} message.
@param count: a numeric value.
@param len1: the C{int} length of sequence 1.
@param len2: the C{int} length of sequence 2. If C{None}, will
default to C{len1}.
@return: A C{str} for printing.
"""
def percentage(a, b):
"""
What percent of a is b?
@param a: a numeric value.
@param b: a numeric value.
@return: the C{float} percentage.
"""
return 100.0 * a / b if b else 0.0
if count == 0:
return '%s: %d' % (mesg, count)
else:
len2 = len2 or len1
if len1 == len2:
return '%s: %d/%d (%.2f%%)' % (
mesg, count, len1, percentage(count, len1))
else:
return ('%s: %d/%d (%.2f%%) of sequence 1, '
'%d/%d (%.2f%%) of sequence 2' % (
mesg,
count, len1, percentage(count, len1),
count, len2, percentage(count, len2))) | python | def countPrint(mesg, count, len1, len2=None):
"""
Format a message followed by an integer count and a percentage (or
two, if the sequence lengths are unequal).
@param mesg: a C{str} message.
@param count: a numeric value.
@param len1: the C{int} length of sequence 1.
@param len2: the C{int} length of sequence 2. If C{None}, will
default to C{len1}.
@return: A C{str} for printing.
"""
def percentage(a, b):
"""
What percent of a is b?
@param a: a numeric value.
@param b: a numeric value.
@return: the C{float} percentage.
"""
return 100.0 * a / b if b else 0.0
if count == 0:
return '%s: %d' % (mesg, count)
else:
len2 = len2 or len1
if len1 == len2:
return '%s: %d/%d (%.2f%%)' % (
mesg, count, len1, percentage(count, len1))
else:
return ('%s: %d/%d (%.2f%%) of sequence 1, '
'%d/%d (%.2f%%) of sequence 2' % (
mesg,
count, len1, percentage(count, len1),
count, len2, percentage(count, len2))) | [
"def",
"countPrint",
"(",
"mesg",
",",
"count",
",",
"len1",
",",
"len2",
"=",
"None",
")",
":",
"def",
"percentage",
"(",
"a",
",",
"b",
")",
":",
"\"\"\"\n What percent of a is b?\n\n @param a: a numeric value.\n @param b: a numeric value.\n @return: the C{float} percentage.\n \"\"\"",
"return",
"100.0",
"*",
"a",
"/",
"b",
"if",
"b",
"else",
"0.0",
"if",
"count",
"==",
"0",
":",
"return",
"'%s: %d'",
"%",
"(",
"mesg",
",",
"count",
")",
"else",
":",
"len2",
"=",
"len2",
"or",
"len1",
"if",
"len1",
"==",
"len2",
":",
"return",
"'%s: %d/%d (%.2f%%)'",
"%",
"(",
"mesg",
",",
"count",
",",
"len1",
",",
"percentage",
"(",
"count",
",",
"len1",
")",
")",
"else",
":",
"return",
"(",
"'%s: %d/%d (%.2f%%) of sequence 1, '",
"'%d/%d (%.2f%%) of sequence 2'",
"%",
"(",
"mesg",
",",
"count",
",",
"len1",
",",
"percentage",
"(",
"count",
",",
"len1",
")",
",",
"count",
",",
"len2",
",",
"percentage",
"(",
"count",
",",
"len2",
")",
")",
")"
] | Format a message followed by an integer count and a percentage (or
two, if the sequence lengths are unequal).
@param mesg: a C{str} message.
@param count: a numeric value.
@param len1: the C{int} length of sequence 1.
@param len2: the C{int} length of sequence 2. If C{None}, will
default to C{len1}.
@return: A C{str} for printing. | [
"Format",
"a",
"message",
"followed",
"by",
"an",
"integer",
"count",
"and",
"a",
"percentage",
"(",
"or",
"two",
"if",
"the",
"sequence",
"lengths",
"are",
"unequal",
")",
"."
] | train | https://github.com/acorg/dark-matter/blob/c78a1bf262667fa5db3548fa7066c4ec14d0551d/dark/utils.py#L219-L253 | <|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 a message followed by an integer count and a percentage (or
two, if the sequence lengths are unequal).
@param mesg: a C{str} message.
@param count: a numeric value.
@param len1: the C{int} length of sequence 1.
@param len2: the C{int} length of sequence 2. If C{None}, will
default to C{len1}.
@return: A C{str} for printing.
### Response:
def countPrint(mesg, count, len1, len2=None):
"""
Format a message followed by an integer count and a percentage (or
two, if the sequence lengths are unequal).
@param mesg: a C{str} message.
@param count: a numeric value.
@param len1: the C{int} length of sequence 1.
@param len2: the C{int} length of sequence 2. If C{None}, will
default to C{len1}.
@return: A C{str} for printing.
"""
def percentage(a, b):
"""
What percent of a is b?
@param a: a numeric value.
@param b: a numeric value.
@return: the C{float} percentage.
"""
return 100.0 * a / b if b else 0.0
if count == 0:
return '%s: %d' % (mesg, count)
else:
len2 = len2 or len1
if len1 == len2:
return '%s: %d/%d (%.2f%%)' % (
mesg, count, len1, percentage(count, len1))
else:
return ('%s: %d/%d (%.2f%%) of sequence 1, '
'%d/%d (%.2f%%) of sequence 2' % (
mesg,
count, len1, percentage(count, len1),
count, len2, percentage(count, len2)))
<|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,
264,
1984,
8272,
555,
459,
7698,
1797,
323,
264,
11668,
320,
269,
198,
262,
1403,
11,
422,
279,
8668,
29416,
527,
78295,
3677,
262,
571,
913,
11083,
70,
25,
264,
356,
90,
496,
92,
1984,
627,
262,
571,
913,
1797,
25,
264,
25031,
907,
627,
262,
571,
913,
2479,
16,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
16,
627,
262,
571,
913,
2479,
17,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
17,
13,
1442,
356,
90,
4155,
2186,
690,
198,
286,
1670,
311,
356,
90,
2963,
16,
28374,
262,
571,
693,
25,
362,
356,
90,
496,
92,
369,
18991,
382,
14711,
6075,
512,
755,
1797,
9171,
1278,
288,
70,
11,
1797,
11,
2479,
16,
11,
2479,
17,
5980,
997,
262,
3270,
262,
15392,
264,
1984,
8272,
555,
459,
7698,
1797,
323,
264,
11668,
320,
269,
198,
262,
1403,
11,
422,
279,
8668,
29416,
527,
78295,
3677,
262,
571,
913,
11083,
70,
25,
264,
356,
90,
496,
92,
1984,
627,
262,
571,
913,
1797,
25,
264,
25031,
907,
627,
262,
571,
913,
2479,
16,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
16,
627,
262,
571,
913,
2479,
17,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
17,
13,
1442,
356,
90,
4155,
2186,
690,
198,
286,
1670,
311,
356,
90,
2963,
16,
28374,
262,
571,
693,
25,
362,
356,
90,
496,
92,
369,
18991,
627,
262,
3270,
262,
711,
11668,
2948,
11,
293,
997,
286,
3270,
286,
3639,
3346,
315,
264,
374,
293,
1980,
286,
571,
913,
264,
25,
264,
25031,
907,
627,
286,
571,
913,
293,
25,
264,
25031,
907,
627,
286,
571,
693,
25,
279,
356,
90,
3733,
92,
11668,
627,
286,
3270,
286,
471,
220,
1041,
13,
15,
353,
264,
611,
293,
422,
293,
775,
220,
15,
13,
15,
271,
262,
422,
1797,
624,
220,
15,
512,
286,
471,
7832,
82,
25,
1034,
67,
6,
1034,
320,
9004,
70,
11,
1797,
340,
262,
775,
512,
286,
2479,
17,
284,
2479,
17,
477,
2479,
16,
198,
286,
422,
2479,
16,
624,
2479,
17,
512,
310,
471,
7832,
82,
25,
1034,
67,
12915,
67,
13764,
13,
17,
69,
2838,
22367,
1034,
2456,
394,
11083,
70,
11,
1797,
11,
2479,
16,
11,
11668,
11773,
11,
2479,
16,
1192,
286,
775,
512,
310,
471,
4417,
4,
82,
25,
1034,
67,
12915,
67,
13764,
13,
17,
69,
2838,
8,
315,
8668,
220,
16,
11,
8044,
504,
7832,
67,
12915,
67,
13764,
13,
17,
69,
2838,
8,
315,
8668,
220,
17,
6,
1034,
2456,
667,
11083,
70,
345,
667,
1797,
11,
2479,
16,
11,
11668,
11773,
11,
2479,
16,
1350,
667,
1797,
11,
2479,
17,
11,
11668,
11773,
11,
2479,
17,
6054,
27,
91,
8862,
728,
428,
91,
29,
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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
459,
7698,
1797,
323,
264,
11668,
320,
269,
198,
262,
1403,
11,
422,
279,
8668,
29416,
527,
78295,
3677,
262,
571,
913,
11083,
70,
25,
264,
356,
90,
496,
92,
1984,
627,
262,
571,
913,
1797,
25,
264,
25031,
907,
627,
262,
571,
913,
2479,
16,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
16,
627,
262,
571,
913,
2479,
17,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
17,
13,
1442,
356,
90,
4155,
2186,
690,
198,
286,
1670,
311,
356,
90,
2963,
16,
28374,
262,
571,
693,
25,
362,
356,
90,
496,
92,
369,
18991,
382,
14711,
6075,
512,
755,
1797,
9171,
1278,
288,
70,
11,
1797,
11,
2479,
16,
11,
2479,
17,
5980,
997,
262,
3270,
262,
15392,
264,
1984,
8272,
555,
459,
7698,
1797,
323,
264,
11668,
320,
269,
198,
262,
1403,
11,
422,
279,
8668,
29416,
527,
78295,
3677,
262,
571,
913,
11083,
70,
25,
264,
356,
90,
496,
92,
1984,
627,
262,
571,
913,
1797,
25,
264,
25031,
907,
627,
262,
571,
913,
2479,
16,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
16,
627,
262,
571,
913,
2479,
17,
25,
279,
356,
90,
396,
92,
3160,
315,
8668,
220,
17,
13,
1442,
356,
90,
4155,
2186,
690,
198,
286,
1670,
311,
356,
90,
2963,
16,
28374,
262,
571,
693,
25,
362,
356,
90,
496,
92,
369,
18991,
627,
262,
3270,
262,
711,
11668,
2948,
11,
293,
997,
286,
3270,
286,
3639,
3346,
315,
264,
374,
293,
1980,
286,
571,
913,
264,
25,
264,
25031,
907,
627,
286,
571,
913,
293,
25,
264,
25031,
907,
627,
286,
571,
693,
25,
279,
356,
90,
3733,
92,
11668,
627,
286,
3270,
286,
471,
220,
1041,
13,
15,
353,
264,
611,
293,
422,
293,
775,
220,
15,
13,
15,
271,
262,
422,
1797,
624,
220,
15,
512,
286,
471,
7832,
82,
25,
1034,
67,
6,
1034,
320,
9004,
70,
11,
1797,
340,
262,
775,
512,
286,
2479,
17,
284,
2479,
17,
477,
2479,
16,
198,
286,
422,
2479,
16,
624,
2479,
17,
512,
310,
471,
7832,
82,
25,
1034,
67,
12915,
67,
13764,
13,
17,
69,
2838,
22367,
1034,
2456,
394,
11083,
70,
11,
1797,
11,
2479,
16,
11,
11668,
11773,
11,
2479,
16,
1192,
286,
775,
512,
310,
471,
4417,
4,
82,
25,
1034,
67,
12915,
67,
13764,
13,
17,
69,
2838,
8,
315,
8668,
220,
16,
11,
8044,
504,
7832,
67,
12915,
67,
13764,
13,
17,
69,
2838,
8,
315,
8668,
220,
17,
6,
1034,
2456,
667,
11083,
70,
345,
667,
1797,
11,
2479,
16,
11,
11668,
11773,
11,
2479,
16,
1350,
667,
1797,
11,
2479,
17,
11,
11668,
11773,
11,
2479,
17,
6054,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
olasitarska/django-gulp-rev | gulp_rev/__init__.py | static_rev | def static_rev(path):
"""
Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base.css?d9wdjs
On DEBUG=False will return: /static/css/base-d9wdjs.css
"""
static_path = StaticNode.handle_simple(path)
if is_debug():
return dev_url(static_path)
return production_url(path, static_path) | python | def static_rev(path):
"""
Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base.css?d9wdjs
On DEBUG=False will return: /static/css/base-d9wdjs.css
"""
static_path = StaticNode.handle_simple(path)
if is_debug():
return dev_url(static_path)
return production_url(path, static_path) | [
"def",
"static_rev",
"(",
"path",
")",
":",
"static_path",
"=",
"StaticNode",
".",
"handle_simple",
"(",
"path",
")",
"if",
"is_debug",
"(",
")",
":",
"return",
"dev_url",
"(",
"static_path",
")",
"return",
"production_url",
"(",
"path",
",",
"static_path",
")"
] | Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base.css?d9wdjs
On DEBUG=False will return: /static/css/base-d9wdjs.css | [
"Gets",
"a",
"joined",
"path",
"with",
"the",
"STATIC_URL",
"setting",
"and",
"applies",
"revisioning",
"depending",
"on",
"DEBUG",
"setting",
"."
] | train | https://github.com/olasitarska/django-gulp-rev/blob/cb6b725d23906ef4451e9d73b91d8e1888a0b954/gulp_rev/__init__.py#L58-L77 | <|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:
Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base.css?d9wdjs
On DEBUG=False will return: /static/css/base-d9wdjs.css
### Response:
def static_rev(path):
"""
Gets a joined path with the STATIC_URL setting, and applies revisioning
depending on DEBUG setting.
Usage::
{% load rev %}
{% static_rev "css/base.css" %}
Example::
{% static_rev "css/base.css" %}
On DEBUG=True will return: /static/css/base.css?d9wdjs
On DEBUG=False will return: /static/css/base-d9wdjs.css
"""
static_path = StaticNode.handle_simple(path)
if is_debug():
return dev_url(static_path)
return production_url(path, static_path)
<|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,
50458,
264,
11096,
1853,
449,
279,
64649,
8159,
6376,
11,
323,
17208,
24493,
287,
198,
262,
11911,
389,
12946,
6376,
382,
262,
25585,
50677,
286,
53361,
2865,
5891,
69014,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
1034,
633,
262,
13688,
50677,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
69014,
286,
1952,
12946,
3702,
690,
471,
25,
611,
2020,
6851,
27182,
4425,
30,
67,
24,
6511,
2580,
198,
286,
1952,
12946,
5725,
690,
471,
25,
611,
2020,
6851,
27182,
1773,
24,
6511,
2580,
4425,
271,
14711,
6075,
512,
755,
1118,
39182,
5698,
997,
262,
3270,
262,
10523,
264,
11096,
1853,
449,
279,
64649,
8159,
6376,
11,
323,
17208,
24493,
287,
198,
262,
11911,
389,
12946,
6376,
382,
262,
25585,
50677,
286,
53361,
2865,
5891,
69014,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
1034,
633,
262,
13688,
50677,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
69014,
286,
1952,
12946,
3702,
690,
471,
25,
611,
2020,
6851,
27182,
4425,
30,
67,
24,
6511,
2580,
198,
286,
1952,
12946,
5725,
690,
471,
25,
611,
2020,
6851,
27182,
1773,
24,
6511,
2580,
4425,
198,
262,
3270,
262,
1118,
2703,
284,
23977,
1997,
10341,
31115,
5698,
696,
262,
422,
374,
15810,
4019,
286,
471,
3567,
2975,
28710,
2703,
696,
262,
471,
5788,
2975,
5698,
11,
1118,
2703,
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
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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
] | [
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,
50458,
264,
11096,
1853,
449,
279,
64649,
8159,
6376,
11,
323,
17208,
24493,
287,
198,
262,
11911,
389,
12946,
6376,
382,
262,
25585,
50677,
286,
53361,
2865,
5891,
69014,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
1034,
633,
262,
13688,
50677,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
69014,
286,
1952,
12946,
3702,
690,
471,
25,
611,
2020,
6851,
27182,
4425,
30,
67,
24,
6511,
2580,
198,
286,
1952,
12946,
5725,
690,
471,
25,
611,
2020,
6851,
27182,
1773,
24,
6511,
2580,
4425,
271,
14711,
6075,
512,
755,
1118,
39182,
5698,
997,
262,
3270,
262,
10523,
264,
11096,
1853,
449,
279,
64649,
8159,
6376,
11,
323,
17208,
24493,
287,
198,
262,
11911,
389,
12946,
6376,
382,
262,
25585,
50677,
286,
53361,
2865,
5891,
69014,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
1034,
633,
262,
13688,
50677,
286,
53361,
1118,
39182,
330,
5254,
27182,
4425,
1,
69014,
286,
1952,
12946,
3702,
690,
471,
25,
611,
2020,
6851,
27182,
4425,
30,
67,
24,
6511,
2580,
198,
286,
1952,
12946,
5725,
690,
471,
25,
611,
2020,
6851,
27182,
1773,
24,
6511,
2580,
4425,
198,
262,
3270,
262,
1118,
2703,
284,
23977,
1997,
10341,
31115,
5698,
696,
262,
422,
374,
15810,
4019,
286,
471,
3567,
2975,
28710,
2703,
696,
262,
471,
5788,
2975,
5698,
11,
1118,
2703,
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
] |
kensho-technologies/graphql-compiler | graphql_compiler/compiler/expressions.py | BinaryComposition.to_match | def to_match(self):
"""Return a unicode object with the MATCH representation of this BinaryComposition."""
self.validate()
# The MATCH versions of some operators require an inverted order of arguments.
# pylint: disable=unused-variable
regular_operator_format = '(%(left)s %(operator)s %(right)s)'
inverted_operator_format = '(%(right)s %(operator)s %(left)s)' # noqa
intersects_operator_format = '(%(operator)s(%(left)s, %(right)s).asList().size() > 0)'
# pylint: enable=unused-variable
# Null literals use 'is/is not' as (in)equality operators, while other values use '=/<>'.
if any((isinstance(self.left, Literal) and self.left.value is None,
isinstance(self.right, Literal) and self.right.value is None)):
translation_table = {
u'=': (u'IS', regular_operator_format),
u'!=': (u'IS NOT', regular_operator_format),
}
else:
translation_table = {
u'=': (u'=', regular_operator_format),
u'!=': (u'<>', regular_operator_format),
u'>=': (u'>=', regular_operator_format),
u'<=': (u'<=', regular_operator_format),
u'>': (u'>', regular_operator_format),
u'<': (u'<', regular_operator_format),
u'+': (u'+', regular_operator_format),
u'||': (u'OR', regular_operator_format),
u'&&': (u'AND', regular_operator_format),
u'contains': (u'CONTAINS', regular_operator_format),
u'intersects': (u'intersect', intersects_operator_format),
u'has_substring': (None, None), # must be lowered into compatible form using LIKE
# MATCH-specific operators
u'LIKE': (u'LIKE', regular_operator_format),
u'INSTANCEOF': (u'INSTANCEOF', regular_operator_format),
}
match_operator, format_spec = translation_table.get(self.operator, (None, None))
if not match_operator:
raise AssertionError(u'Unrecognized operator used: '
u'{} {}'.format(self.operator, self))
return format_spec % dict(operator=match_operator,
left=self.left.to_match(),
right=self.right.to_match()) | python | def to_match(self):
"""Return a unicode object with the MATCH representation of this BinaryComposition."""
self.validate()
# The MATCH versions of some operators require an inverted order of arguments.
# pylint: disable=unused-variable
regular_operator_format = '(%(left)s %(operator)s %(right)s)'
inverted_operator_format = '(%(right)s %(operator)s %(left)s)' # noqa
intersects_operator_format = '(%(operator)s(%(left)s, %(right)s).asList().size() > 0)'
# pylint: enable=unused-variable
# Null literals use 'is/is not' as (in)equality operators, while other values use '=/<>'.
if any((isinstance(self.left, Literal) and self.left.value is None,
isinstance(self.right, Literal) and self.right.value is None)):
translation_table = {
u'=': (u'IS', regular_operator_format),
u'!=': (u'IS NOT', regular_operator_format),
}
else:
translation_table = {
u'=': (u'=', regular_operator_format),
u'!=': (u'<>', regular_operator_format),
u'>=': (u'>=', regular_operator_format),
u'<=': (u'<=', regular_operator_format),
u'>': (u'>', regular_operator_format),
u'<': (u'<', regular_operator_format),
u'+': (u'+', regular_operator_format),
u'||': (u'OR', regular_operator_format),
u'&&': (u'AND', regular_operator_format),
u'contains': (u'CONTAINS', regular_operator_format),
u'intersects': (u'intersect', intersects_operator_format),
u'has_substring': (None, None), # must be lowered into compatible form using LIKE
# MATCH-specific operators
u'LIKE': (u'LIKE', regular_operator_format),
u'INSTANCEOF': (u'INSTANCEOF', regular_operator_format),
}
match_operator, format_spec = translation_table.get(self.operator, (None, None))
if not match_operator:
raise AssertionError(u'Unrecognized operator used: '
u'{} {}'.format(self.operator, self))
return format_spec % dict(operator=match_operator,
left=self.left.to_match(),
right=self.right.to_match()) | [
"def",
"to_match",
"(",
"self",
")",
":",
"self",
".",
"validate",
"(",
")",
"# The MATCH versions of some operators require an inverted order of arguments.",
"# pylint: disable=unused-variable",
"regular_operator_format",
"=",
"'(%(left)s %(operator)s %(right)s)'",
"inverted_operator_format",
"=",
"'(%(right)s %(operator)s %(left)s)'",
"# noqa",
"intersects_operator_format",
"=",
"'(%(operator)s(%(left)s, %(right)s).asList().size() > 0)'",
"# pylint: enable=unused-variable",
"# Null literals use 'is/is not' as (in)equality operators, while other values use '=/<>'.",
"if",
"any",
"(",
"(",
"isinstance",
"(",
"self",
".",
"left",
",",
"Literal",
")",
"and",
"self",
".",
"left",
".",
"value",
"is",
"None",
",",
"isinstance",
"(",
"self",
".",
"right",
",",
"Literal",
")",
"and",
"self",
".",
"right",
".",
"value",
"is",
"None",
")",
")",
":",
"translation_table",
"=",
"{",
"u'='",
":",
"(",
"u'IS'",
",",
"regular_operator_format",
")",
",",
"u'!='",
":",
"(",
"u'IS NOT'",
",",
"regular_operator_format",
")",
",",
"}",
"else",
":",
"translation_table",
"=",
"{",
"u'='",
":",
"(",
"u'='",
",",
"regular_operator_format",
")",
",",
"u'!='",
":",
"(",
"u'<>'",
",",
"regular_operator_format",
")",
",",
"u'>='",
":",
"(",
"u'>='",
",",
"regular_operator_format",
")",
",",
"u'<='",
":",
"(",
"u'<='",
",",
"regular_operator_format",
")",
",",
"u'>'",
":",
"(",
"u'>'",
",",
"regular_operator_format",
")",
",",
"u'<'",
":",
"(",
"u'<'",
",",
"regular_operator_format",
")",
",",
"u'+'",
":",
"(",
"u'+'",
",",
"regular_operator_format",
")",
",",
"u'||'",
":",
"(",
"u'OR'",
",",
"regular_operator_format",
")",
",",
"u'&&'",
":",
"(",
"u'AND'",
",",
"regular_operator_format",
")",
",",
"u'contains'",
":",
"(",
"u'CONTAINS'",
",",
"regular_operator_format",
")",
",",
"u'intersects'",
":",
"(",
"u'intersect'",
",",
"intersects_operator_format",
")",
",",
"u'has_substring'",
":",
"(",
"None",
",",
"None",
")",
",",
"# must be lowered into compatible form using LIKE",
"# MATCH-specific operators",
"u'LIKE'",
":",
"(",
"u'LIKE'",
",",
"regular_operator_format",
")",
",",
"u'INSTANCEOF'",
":",
"(",
"u'INSTANCEOF'",
",",
"regular_operator_format",
")",
",",
"}",
"match_operator",
",",
"format_spec",
"=",
"translation_table",
".",
"get",
"(",
"self",
".",
"operator",
",",
"(",
"None",
",",
"None",
")",
")",
"if",
"not",
"match_operator",
":",
"raise",
"AssertionError",
"(",
"u'Unrecognized operator used: '",
"u'{} {}'",
".",
"format",
"(",
"self",
".",
"operator",
",",
"self",
")",
")",
"return",
"format_spec",
"%",
"dict",
"(",
"operator",
"=",
"match_operator",
",",
"left",
"=",
"self",
".",
"left",
".",
"to_match",
"(",
")",
",",
"right",
"=",
"self",
".",
"right",
".",
"to_match",
"(",
")",
")"
] | Return a unicode object with the MATCH representation of this BinaryComposition. | [
"Return",
"a",
"unicode",
"object",
"with",
"the",
"MATCH",
"representation",
"of",
"this",
"BinaryComposition",
"."
] | train | https://github.com/kensho-technologies/graphql-compiler/blob/f6079c6d10f64932f6b3af309b79bcea2123ca8f/graphql_compiler/compiler/expressions.py#L791-L836 | <|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 a unicode object with the MATCH representation of this BinaryComposition.
### Response:
def to_match(self):
"""Return a unicode object with the MATCH representation of this BinaryComposition."""
self.validate()
# The MATCH versions of some operators require an inverted order of arguments.
# pylint: disable=unused-variable
regular_operator_format = '(%(left)s %(operator)s %(right)s)'
inverted_operator_format = '(%(right)s %(operator)s %(left)s)' # noqa
intersects_operator_format = '(%(operator)s(%(left)s, %(right)s).asList().size() > 0)'
# pylint: enable=unused-variable
# Null literals use 'is/is not' as (in)equality operators, while other values use '=/<>'.
if any((isinstance(self.left, Literal) and self.left.value is None,
isinstance(self.right, Literal) and self.right.value is None)):
translation_table = {
u'=': (u'IS', regular_operator_format),
u'!=': (u'IS NOT', regular_operator_format),
}
else:
translation_table = {
u'=': (u'=', regular_operator_format),
u'!=': (u'<>', regular_operator_format),
u'>=': (u'>=', regular_operator_format),
u'<=': (u'<=', regular_operator_format),
u'>': (u'>', regular_operator_format),
u'<': (u'<', regular_operator_format),
u'+': (u'+', regular_operator_format),
u'||': (u'OR', regular_operator_format),
u'&&': (u'AND', regular_operator_format),
u'contains': (u'CONTAINS', regular_operator_format),
u'intersects': (u'intersect', intersects_operator_format),
u'has_substring': (None, None), # must be lowered into compatible form using LIKE
# MATCH-specific operators
u'LIKE': (u'LIKE', regular_operator_format),
u'INSTANCEOF': (u'INSTANCEOF', regular_operator_format),
}
match_operator, format_spec = translation_table.get(self.operator, (None, None))
if not match_operator:
raise AssertionError(u'Unrecognized operator used: '
u'{} {}'.format(self.operator, self))
return format_spec % dict(operator=match_operator,
left=self.left.to_match(),
right=self.right.to_match())
<|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,
264,
27169,
1665,
449,
279,
49271,
13340,
315,
420,
18188,
76783,
382,
14711,
6075,
512,
755,
311,
10938,
1214,
997,
286,
4304,
5715,
264,
27169,
1665,
449,
279,
49271,
13340,
315,
420,
18188,
76783,
14781,
286,
659,
20090,
2892,
286,
674,
578,
49271,
11028,
315,
1063,
20197,
1397,
459,
47801,
2015,
315,
6105,
627,
286,
674,
51471,
25,
11404,
28,
25743,
39889,
198,
286,
5912,
41694,
9132,
284,
364,
15595,
7,
2414,
16871,
21921,
8043,
16871,
21921,
1315,
16871,
40667,
286,
47801,
41694,
9132,
284,
364,
15595,
7,
1315,
16871,
21921,
8043,
16871,
21921,
2414,
16871,
22367,
220,
674,
46721,
198,
286,
89284,
41694,
9132,
284,
364,
15595,
7,
8043,
16871,
15595,
7,
2414,
16871,
11,
21921,
1315,
16871,
570,
300,
861,
1020,
2190,
368,
871,
220,
15,
40667,
286,
674,
51471,
25,
7431,
28,
25743,
39889,
271,
286,
674,
18576,
76375,
1005,
364,
285,
47527,
539,
6,
439,
320,
258,
53021,
10692,
20197,
11,
1418,
1023,
2819,
1005,
56081,
23875,
64820,
286,
422,
904,
1209,
285,
4956,
1214,
8436,
11,
50774,
8,
323,
659,
8436,
2894,
374,
2290,
345,
394,
11656,
1214,
9707,
11,
50774,
8,
323,
659,
9707,
2894,
374,
2290,
10162,
310,
14807,
5350,
284,
341,
394,
577,
6,
1151,
25,
320,
84,
6,
1669,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
26055,
25,
320,
84,
6,
1669,
4276,
518,
5912,
41694,
9132,
1350,
310,
457,
286,
775,
512,
310,
14807,
5350,
284,
341,
394,
577,
6,
1151,
25,
320,
84,
6,
18123,
5912,
41694,
9132,
1350,
394,
577,
6,
26055,
25,
320,
84,
22248,
20150,
5912,
41694,
9132,
1350,
394,
577,
6404,
1151,
25,
320,
84,
6404,
18123,
5912,
41694,
9132,
1350,
394,
577,
22248,
1151,
25,
320,
84,
6,
8367,
518,
5912,
41694,
9132,
1350,
394,
577,
6404,
1232,
320,
84,
6404,
518,
5912,
41694,
9132,
1350,
394,
577,
22248,
1232,
320,
84,
22248,
518,
5912,
41694,
9132,
1350,
394,
577,
8296,
1232,
320,
84,
8296,
518,
5912,
41694,
9132,
1350,
394,
577,
72357,
1232,
320,
84,
6,
878,
518,
5912,
41694,
9132,
1350,
394,
577,
90210,
1232,
320,
84,
6,
4064,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
13676,
1232,
320,
84,
6,
24194,
73991,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
2295,
55529,
1232,
320,
84,
6,
97118,
518,
89284,
41694,
9132,
1350,
394,
577,
6,
4752,
5341,
928,
1232,
320,
4155,
11,
2290,
705,
220,
674,
2011,
387,
39920,
1139,
18641,
1376,
1701,
21170,
271,
394,
674,
49271,
19440,
20197,
198,
394,
577,
6,
62648,
1232,
320,
84,
6,
62648,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
36453,
12766,
1232,
320,
84,
6,
36453,
12766,
518,
5912,
41694,
9132,
1350,
310,
557,
286,
2489,
41694,
11,
3645,
13908,
284,
14807,
5350,
673,
1214,
52277,
11,
320,
4155,
11,
2290,
1192,
286,
422,
539,
2489,
41694,
512,
310,
4933,
67326,
8317
] | [
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
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,
5715,
264,
27169,
1665,
449,
279,
49271,
13340,
315,
420,
18188,
76783,
382,
14711,
6075,
512,
755,
311,
10938,
1214,
997,
286,
4304,
5715,
264,
27169,
1665,
449,
279,
49271,
13340,
315,
420,
18188,
76783,
14781,
286,
659,
20090,
2892,
286,
674,
578,
49271,
11028,
315,
1063,
20197,
1397,
459,
47801,
2015,
315,
6105,
627,
286,
674,
51471,
25,
11404,
28,
25743,
39889,
198,
286,
5912,
41694,
9132,
284,
364,
15595,
7,
2414,
16871,
21921,
8043,
16871,
21921,
1315,
16871,
40667,
286,
47801,
41694,
9132,
284,
364,
15595,
7,
1315,
16871,
21921,
8043,
16871,
21921,
2414,
16871,
22367,
220,
674,
46721,
198,
286,
89284,
41694,
9132,
284,
364,
15595,
7,
8043,
16871,
15595,
7,
2414,
16871,
11,
21921,
1315,
16871,
570,
300,
861,
1020,
2190,
368,
871,
220,
15,
40667,
286,
674,
51471,
25,
7431,
28,
25743,
39889,
271,
286,
674,
18576,
76375,
1005,
364,
285,
47527,
539,
6,
439,
320,
258,
53021,
10692,
20197,
11,
1418,
1023,
2819,
1005,
56081,
23875,
64820,
286,
422,
904,
1209,
285,
4956,
1214,
8436,
11,
50774,
8,
323,
659,
8436,
2894,
374,
2290,
345,
394,
11656,
1214,
9707,
11,
50774,
8,
323,
659,
9707,
2894,
374,
2290,
10162,
310,
14807,
5350,
284,
341,
394,
577,
6,
1151,
25,
320,
84,
6,
1669,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
26055,
25,
320,
84,
6,
1669,
4276,
518,
5912,
41694,
9132,
1350,
310,
457,
286,
775,
512,
310,
14807,
5350,
284,
341,
394,
577,
6,
1151,
25,
320,
84,
6,
18123,
5912,
41694,
9132,
1350,
394,
577,
6,
26055,
25,
320,
84,
22248,
20150,
5912,
41694,
9132,
1350,
394,
577,
6404,
1151,
25,
320,
84,
6404,
18123,
5912,
41694,
9132,
1350,
394,
577,
22248,
1151,
25,
320,
84,
6,
8367,
518,
5912,
41694,
9132,
1350,
394,
577,
6404,
1232,
320,
84,
6404,
518,
5912,
41694,
9132,
1350,
394,
577,
22248,
1232,
320,
84,
22248,
518,
5912,
41694,
9132,
1350,
394,
577,
8296,
1232,
320,
84,
8296,
518,
5912,
41694,
9132,
1350,
394,
577,
72357,
1232,
320,
84,
6,
878,
518,
5912,
41694,
9132,
1350,
394,
577,
90210,
1232,
320,
84,
6,
4064,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
13676,
1232,
320,
84,
6,
24194,
73991,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
2295,
55529,
1232,
320,
84,
6,
97118,
518,
89284,
41694,
9132,
1350,
394,
577,
6,
4752,
5341,
928,
1232,
320,
4155,
11,
2290,
705,
220,
674,
2011,
387,
39920,
1139,
18641,
1376,
1701,
21170,
271,
394,
674,
49271,
19440,
20197,
198,
394,
577,
6,
62648,
1232,
320,
84,
6,
62648,
518,
5912,
41694,
9132,
1350,
394,
577,
6,
36453,
12766,
1232,
320,
84,
6,
36453,
12766,
518,
5912,
41694,
9132,
1350,
310,
557,
286,
2489,
41694,
11,
3645,
13908,
284,
14807,
5350,
673,
1214,
52277,
11,
320,
4155,
11,
2290,
1192,
286,
422,
539,
2489,
41694,
512,
310,
4933,
67326,
8317
] |
heuer/segno | segno/__init__.py | QRCodeSequence.save | def save(self, out, kind=None, **kw):
"""\
Saves the sequence of QR Code to `out`.
If `out` is a filename, this method modifies the filename and adds
``<Number of QR Codes>-<Current QR Code>`` to it.
``structured-append.svg`` becomes (if the sequence contains two QR Codes):
``structured-append-02-01.svg`` and ``structured-append-02-02.svg``
Please note that using a file or file-like object may result into an
invalid serialization format since all QR Codes are written to the same
output.
See :py:meth:`QRCode.save()` for a detailed enumeration of options.
"""
m = len(self)
def prepare_fn_noop(o, n):
"""\
Function to enumerate file names, does nothing by default
"""
return o
def prepare_filename(o, n):
"""\
Function to enumerate file names.
"""
return o.format(m, n)
prepare_fn = prepare_fn_noop
if m > 1 and isinstance(out, str_type):
dot_idx = out.rfind('.')
if dot_idx > -1:
out = out[:dot_idx] + '-{0:02d}-{1:02d}' + out[dot_idx:]
prepare_fn = prepare_filename
for n, qrcode in enumerate(self, start=1):
qrcode.save(prepare_fn(out, n), kind=kind, **kw) | python | def save(self, out, kind=None, **kw):
"""\
Saves the sequence of QR Code to `out`.
If `out` is a filename, this method modifies the filename and adds
``<Number of QR Codes>-<Current QR Code>`` to it.
``structured-append.svg`` becomes (if the sequence contains two QR Codes):
``structured-append-02-01.svg`` and ``structured-append-02-02.svg``
Please note that using a file or file-like object may result into an
invalid serialization format since all QR Codes are written to the same
output.
See :py:meth:`QRCode.save()` for a detailed enumeration of options.
"""
m = len(self)
def prepare_fn_noop(o, n):
"""\
Function to enumerate file names, does nothing by default
"""
return o
def prepare_filename(o, n):
"""\
Function to enumerate file names.
"""
return o.format(m, n)
prepare_fn = prepare_fn_noop
if m > 1 and isinstance(out, str_type):
dot_idx = out.rfind('.')
if dot_idx > -1:
out = out[:dot_idx] + '-{0:02d}-{1:02d}' + out[dot_idx:]
prepare_fn = prepare_filename
for n, qrcode in enumerate(self, start=1):
qrcode.save(prepare_fn(out, n), kind=kind, **kw) | [
"def",
"save",
"(",
"self",
",",
"out",
",",
"kind",
"=",
"None",
",",
"*",
"*",
"kw",
")",
":",
"m",
"=",
"len",
"(",
"self",
")",
"def",
"prepare_fn_noop",
"(",
"o",
",",
"n",
")",
":",
"\"\"\"\\\n Function to enumerate file names, does nothing by default\n \"\"\"",
"return",
"o",
"def",
"prepare_filename",
"(",
"o",
",",
"n",
")",
":",
"\"\"\"\\\n Function to enumerate file names.\n \"\"\"",
"return",
"o",
".",
"format",
"(",
"m",
",",
"n",
")",
"prepare_fn",
"=",
"prepare_fn_noop",
"if",
"m",
">",
"1",
"and",
"isinstance",
"(",
"out",
",",
"str_type",
")",
":",
"dot_idx",
"=",
"out",
".",
"rfind",
"(",
"'.'",
")",
"if",
"dot_idx",
">",
"-",
"1",
":",
"out",
"=",
"out",
"[",
":",
"dot_idx",
"]",
"+",
"'-{0:02d}-{1:02d}'",
"+",
"out",
"[",
"dot_idx",
":",
"]",
"prepare_fn",
"=",
"prepare_filename",
"for",
"n",
",",
"qrcode",
"in",
"enumerate",
"(",
"self",
",",
"start",
"=",
"1",
")",
":",
"qrcode",
".",
"save",
"(",
"prepare_fn",
"(",
"out",
",",
"n",
")",
",",
"kind",
"=",
"kind",
",",
"*",
"*",
"kw",
")"
] | \
Saves the sequence of QR Code to `out`.
If `out` is a filename, this method modifies the filename and adds
``<Number of QR Codes>-<Current QR Code>`` to it.
``structured-append.svg`` becomes (if the sequence contains two QR Codes):
``structured-append-02-01.svg`` and ``structured-append-02-02.svg``
Please note that using a file or file-like object may result into an
invalid serialization format since all QR Codes are written to the same
output.
See :py:meth:`QRCode.save()` for a detailed enumeration of options. | [
"\\",
"Saves",
"the",
"sequence",
"of",
"QR",
"Code",
"to",
"out",
"."
] | train | https://github.com/heuer/segno/blob/64d912a2bd17d0b5ff3e8b5d37098edfc663c2b3/segno/__init__.py#L769-L805 | <|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:
\
Saves the sequence of QR Code to `out`.
If `out` is a filename, this method modifies the filename and adds
``<Number of QR Codes>-<Current QR Code>`` to it.
``structured-append.svg`` becomes (if the sequence contains two QR Codes):
``structured-append-02-01.svg`` and ``structured-append-02-02.svg``
Please note that using a file or file-like object may result into an
invalid serialization format since all QR Codes are written to the same
output.
See :py:meth:`QRCode.save()` for a detailed enumeration of options.
### Response:
def save(self, out, kind=None, **kw):
"""\
Saves the sequence of QR Code to `out`.
If `out` is a filename, this method modifies the filename and adds
``<Number of QR Codes>-<Current QR Code>`` to it.
``structured-append.svg`` becomes (if the sequence contains two QR Codes):
``structured-append-02-01.svg`` and ``structured-append-02-02.svg``
Please note that using a file or file-like object may result into an
invalid serialization format since all QR Codes are written to the same
output.
See :py:meth:`QRCode.save()` for a detailed enumeration of options.
"""
m = len(self)
def prepare_fn_noop(o, n):
"""\
Function to enumerate file names, does nothing by default
"""
return o
def prepare_filename(o, n):
"""\
Function to enumerate file names.
"""
return o.format(m, n)
prepare_fn = prepare_fn_noop
if m > 1 and isinstance(out, str_type):
dot_idx = out.rfind('.')
if dot_idx > -1:
out = out[:dot_idx] + '-{0:02d}-{1:02d}' + out[dot_idx:]
prepare_fn = prepare_filename
for n, qrcode in enumerate(self, start=1):
qrcode.save(prepare_fn(out, n), kind=kind, **kw)
<|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,
5779,
286,
66667,
279,
8668,
315,
39799,
6247,
311,
1595,
412,
63438,
286,
1442,
1595,
412,
63,
374,
264,
3986,
11,
420,
1749,
84049,
279,
3986,
323,
11621,
198,
286,
10103,
27,
2903,
315,
39799,
41661,
39743,
27,
5520,
39799,
6247,
29,
14196,
311,
433,
627,
286,
10103,
52243,
89329,
15585,
14196,
9221,
320,
333,
279,
8668,
5727,
1403,
39799,
41661,
997,
286,
10103,
52243,
89329,
12,
2437,
12,
1721,
15585,
14196,
323,
10103,
52243,
89329,
12,
2437,
12,
2437,
15585,
14196,
271,
286,
5321,
5296,
430,
1701,
264,
1052,
477,
1052,
12970,
1665,
1253,
1121,
1139,
459,
198,
286,
8482,
48543,
3645,
2533,
682,
39799,
41661,
527,
5439,
311,
279,
1890,
198,
286,
2612,
382,
286,
3580,
551,
3368,
31386,
774,
19258,
31565,
2123,
5799,
55358,
369,
264,
11944,
52678,
315,
2671,
382,
14711,
6075,
512,
755,
3665,
1214,
11,
704,
11,
3169,
5980,
11,
3146,
29700,
997,
286,
4304,
5779,
286,
66667,
279,
8668,
315,
39799,
6247,
311,
1595,
412,
63438,
286,
1442,
1595,
412,
63,
374,
264,
3986,
11,
420,
1749,
84049,
279,
3986,
323,
11621,
198,
286,
10103,
27,
2903,
315,
39799,
41661,
39743,
27,
5520,
39799,
6247,
29,
14196,
311,
433,
627,
286,
10103,
52243,
89329,
15585,
14196,
9221,
320,
333,
279,
8668,
5727,
1403,
39799,
41661,
997,
286,
10103,
52243,
89329,
12,
2437,
12,
1721,
15585,
14196,
323,
10103,
52243,
89329,
12,
2437,
12,
2437,
15585,
14196,
271,
286,
5321,
5296,
430,
1701,
264,
1052,
477,
1052,
12970,
1665,
1253,
1121,
1139,
459,
198,
286,
8482,
48543,
3645,
2533,
682,
39799,
41661,
527,
5439,
311,
279,
1890,
198,
286,
2612,
382,
286,
3580,
551,
3368,
31386,
774,
19258,
31565,
2123,
5799,
55358,
369,
264,
11944,
52678,
315,
2671,
627,
286,
3270,
286,
296,
284,
2479,
1214,
696,
286,
711,
10772,
15604,
6673,
454,
10316,
11,
308,
997,
310,
4304,
5779,
310,
5830,
311,
13555,
1052,
5144,
11,
1587,
4400,
555,
1670,
198,
310,
3270,
310,
471,
297,
271,
286,
711,
10772,
13626,
10316,
11,
308,
997,
310,
4304,
5779,
310,
5830,
311,
13555,
1052,
5144,
627,
310,
3270,
310,
471,
297,
8180,
1278,
11,
308,
696,
286,
10772,
15604,
284,
10772,
15604,
6673,
454,
198,
286,
422,
296,
871,
220,
16,
323,
11656,
10029,
11,
610,
1857,
997,
310,
13046,
7406,
284,
704,
1783,
3990,
99755,
310,
422,
13046,
7406,
871,
482,
16,
512,
394,
704,
284,
704,
3530,
16510,
7406,
60,
489,
7944,
90,
15,
25,
2437,
67,
73113,
16,
25,
2437,
67,
11923,
489,
704,
58,
16510,
7406,
25106,
394,
10772,
15604,
284,
10772,
13626,
198,
286,
369,
308,
11,
2874,
55896,
304,
13555,
1214,
11,
1212,
28,
16,
997,
310,
2874,
55896,
5799,
28759,
3462,
15604,
10029,
11,
308,
705,
3169,
28,
15674,
11,
3146,
29700,
340,
27,
91,
8862,
728,
428,
91,
29,
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,
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,
1,
1,
1,
1,
1,
1,
1,
1,
1,
1,
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,
5779,
286,
66667,
279,
8668,
315,
39799,
6247,
311,
1595,
412,
63438,
286,
1442,
1595,
412,
63,
374,
264,
3986,
11,
420,
1749,
84049,
279,
3986,
323,
11621,
198,
286,
10103,
27,
2903,
315,
39799,
41661,
39743,
27,
5520,
39799,
6247,
29,
14196,
311,
433,
627,
286,
10103,
52243,
89329,
15585,
14196,
9221,
320,
333,
279,
8668,
5727,
1403,
39799,
41661,
997,
286,
10103,
52243,
89329,
12,
2437,
12,
1721,
15585,
14196,
323,
10103,
52243,
89329,
12,
2437,
12,
2437,
15585,
14196,
271,
286,
5321,
5296,
430,
1701,
264,
1052,
477,
1052,
12970,
1665,
1253,
1121,
1139,
459,
198,
286,
8482,
48543,
3645,
2533,
682,
39799,
41661,
527,
5439,
311,
279,
1890,
198,
286,
2612,
382,
286,
3580,
551,
3368,
31386,
774,
19258,
31565,
2123,
5799,
55358,
369,
264,
11944,
52678,
315,
2671,
382,
14711,
6075,
512,
755,
3665,
1214,
11,
704,
11,
3169,
5980,
11,
3146,
29700,
997,
286,
4304,
5779,
286,
66667,
279,
8668,
315,
39799,
6247,
311,
1595,
412,
63438,
286,
1442,
1595,
412,
63,
374,
264,
3986,
11,
420,
1749,
84049,
279,
3986,
323,
11621,
198,
286,
10103,
27,
2903,
315,
39799,
41661,
39743,
27,
5520,
39799,
6247,
29,
14196,
311,
433,
627,
286,
10103,
52243,
89329,
15585,
14196,
9221,
320,
333,
279,
8668,
5727,
1403,
39799,
41661,
997,
286,
10103,
52243,
89329,
12,
2437,
12,
1721,
15585,
14196,
323,
10103,
52243,
89329,
12,
2437,
12,
2437,
15585,
14196,
271,
286,
5321,
5296,
430,
1701,
264,
1052,
477,
1052,
12970,
1665,
1253,
1121,
1139,
459,
198,
286,
8482,
48543,
3645,
2533,
682,
39799,
41661,
527,
5439,
311,
279,
1890,
198,
286,
2612,
382,
286,
3580,
551,
3368,
31386,
774,
19258,
31565,
2123,
5799,
55358,
369,
264,
11944,
52678,
315,
2671,
627,
286,
3270,
286,
296,
284,
2479,
1214,
696,
286,
711,
10772,
15604,
6673,
454,
10316,
11,
308,
997,
310,
4304,
5779,
310,
5830,
311,
13555,
1052,
5144,
11,
1587,
4400,
555,
1670,
198,
310,
3270,
310,
471,
297,
271,
286,
711,
10772,
13626,
10316,
11,
308,
997,
310,
4304,
5779,
310,
5830,
311,
13555,
1052,
5144,
627,
310,
3270,
310,
471,
297,
8180,
1278,
11,
308,
696,
286,
10772,
15604,
284,
10772,
15604,
6673,
454,
198,
286,
422,
296,
871,
220,
16,
323,
11656,
10029,
11,
610,
1857,
997,
310,
13046,
7406,
284,
704,
1783,
3990,
99755,
310,
422,
13046,
7406,
871,
482,
16,
512,
394,
704,
284,
704,
3530,
16510,
7406,
60,
489,
7944,
90,
15,
25,
2437,
67,
73113,
16,
25,
2437,
67,
11923,
489,
704,
58,
16510,
7406,
25106,
394,
10772,
15604,
284,
10772,
13626,
198,
286,
369,
308,
11,
2874,
55896,
304,
13555,
1214,
11,
1212,
28,
16,
997,
310,
2874,
55896,
5799,
28759,
3462,
15604,
10029,
11,
308,
705,
3169,
28,
15674,
11,
3146,
29700,
340,
27,
91,
8862,
728,
428,
91,
29,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
heikomuller/sco-models | scomodels/__init__.py | DefaultModelRegistry.from_json | def from_json(self, document):
"""Create a model database object from a given Json document.
Parameters
----------
document : JSON
Json representation of the object
Returns
ModelHandle
"""
# The timestamp is optional (e.g., in cases where model definitions are
# loaded from file).
if 'timestamp' in document:
timestamp = datetime.datetime.strptime(
document['timestamp'],
'%Y-%m-%dT%H:%M:%S.%f'
)
else:
timestamp = None
# Create handle for database object
return ModelHandle(
document['_id'],
document['properties'],
[AttributeDefinition.from_json(el) for el in document['parameters']],
ModelOutputs.from_json(document['outputs']),
timestamp=timestamp
) | python | def from_json(self, document):
"""Create a model database object from a given Json document.
Parameters
----------
document : JSON
Json representation of the object
Returns
ModelHandle
"""
# The timestamp is optional (e.g., in cases where model definitions are
# loaded from file).
if 'timestamp' in document:
timestamp = datetime.datetime.strptime(
document['timestamp'],
'%Y-%m-%dT%H:%M:%S.%f'
)
else:
timestamp = None
# Create handle for database object
return ModelHandle(
document['_id'],
document['properties'],
[AttributeDefinition.from_json(el) for el in document['parameters']],
ModelOutputs.from_json(document['outputs']),
timestamp=timestamp
) | [
"def",
"from_json",
"(",
"self",
",",
"document",
")",
":",
"# The timestamp is optional (e.g., in cases where model definitions are",
"# loaded from file).",
"if",
"'timestamp'",
"in",
"document",
":",
"timestamp",
"=",
"datetime",
".",
"datetime",
".",
"strptime",
"(",
"document",
"[",
"'timestamp'",
"]",
",",
"'%Y-%m-%dT%H:%M:%S.%f'",
")",
"else",
":",
"timestamp",
"=",
"None",
"# Create handle for database object",
"return",
"ModelHandle",
"(",
"document",
"[",
"'_id'",
"]",
",",
"document",
"[",
"'properties'",
"]",
",",
"[",
"AttributeDefinition",
".",
"from_json",
"(",
"el",
")",
"for",
"el",
"in",
"document",
"[",
"'parameters'",
"]",
"]",
",",
"ModelOutputs",
".",
"from_json",
"(",
"document",
"[",
"'outputs'",
"]",
")",
",",
"timestamp",
"=",
"timestamp",
")"
] | Create a model database object from a given Json document.
Parameters
----------
document : JSON
Json representation of the object
Returns
ModelHandle | [
"Create",
"a",
"model",
"database",
"object",
"from",
"a",
"given",
"Json",
"document",
"."
] | train | https://github.com/heikomuller/sco-models/blob/0584322a50ae16d5c32c224e8bca516bd363371f/scomodels/__init__.py#L225-L252 | <|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:
Create a model database object from a given Json document.
Parameters
----------
document : JSON
Json representation of the object
Returns
ModelHandle
### Response:
def from_json(self, document):
"""Create a model database object from a given Json document.
Parameters
----------
document : JSON
Json representation of the object
Returns
ModelHandle
"""
# The timestamp is optional (e.g., in cases where model definitions are
# loaded from file).
if 'timestamp' in document:
timestamp = datetime.datetime.strptime(
document['timestamp'],
'%Y-%m-%dT%H:%M:%S.%f'
)
else:
timestamp = None
# Create handle for database object
return ModelHandle(
document['_id'],
document['properties'],
[AttributeDefinition.from_json(el) for el in document['parameters']],
ModelOutputs.from_json(document['outputs']),
timestamp=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,
4110,
264,
1646,
4729,
1665,
505,
264,
2728,
8472,
2246,
382,
286,
13831,
198,
286,
31423,
286,
2246,
551,
4823,
198,
310,
8472,
13340,
315,
279,
1665,
271,
286,
5295,
198,
286,
5008,
7144,
271,
14711,
6075,
512,
755,
505,
9643,
1214,
11,
2246,
997,
286,
4304,
4110,
264,
1646,
4729,
1665,
505,
264,
2728,
8472,
2246,
382,
286,
13831,
198,
286,
31423,
286,
2246,
551,
4823,
198,
310,
8472,
13340,
315,
279,
1665,
271,
286,
5295,
198,
286,
5008,
7144,
198,
286,
3270,
286,
674,
578,
11695,
374,
10309,
320,
68,
1326,
2637,
304,
5157,
1405,
1646,
17931,
527,
198,
286,
674,
6799,
505,
1052,
4390,
286,
422,
364,
13333,
6,
304,
2246,
512,
310,
11695,
284,
9050,
20296,
48533,
1021,
394,
2246,
681,
13333,
4479,
394,
7832,
56,
11316,
76,
11316,
91463,
77931,
7685,
44,
7685,
50,
23253,
69,
1270,
310,
1763,
286,
775,
512,
310,
11695,
284,
2290,
198,
286,
674,
4324,
3790,
369,
4729,
1665,
198,
286,
471,
5008,
7144,
1021,
310,
2246,
28301,
307,
4479,
310,
2246,
681,
13495,
4479,
310,
510,
3994,
10614,
6521,
9643,
19096,
8,
369,
658,
304,
2246,
681,
14105,
53764,
310,
5008,
62538,
6521,
9643,
15649,
681,
42106,
30340,
310,
11695,
28,
13333,
198,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
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,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
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,
4110,
264,
1646,
4729,
1665,
505,
264,
2728,
8472,
2246,
382,
286,
13831,
198,
286,
31423,
286,
2246,
551,
4823,
198,
310,
8472,
13340,
315,
279,
1665,
271,
286,
5295,
198,
286,
5008,
7144,
271,
14711,
6075,
512,
755,
505,
9643,
1214,
11,
2246,
997,
286,
4304,
4110,
264,
1646,
4729,
1665,
505,
264,
2728,
8472,
2246,
382,
286,
13831,
198,
286,
31423,
286,
2246,
551,
4823,
198,
310,
8472,
13340,
315,
279,
1665,
271,
286,
5295,
198,
286,
5008,
7144,
198,
286,
3270,
286,
674,
578,
11695,
374,
10309,
320,
68,
1326,
2637,
304,
5157,
1405,
1646,
17931,
527,
198,
286,
674,
6799,
505,
1052,
4390,
286,
422,
364,
13333,
6,
304,
2246,
512,
310,
11695,
284,
9050,
20296,
48533,
1021,
394,
2246,
681,
13333,
4479,
394,
7832,
56,
11316,
76,
11316,
91463,
77931,
7685,
44,
7685,
50,
23253,
69,
1270,
310,
1763,
286,
775,
512,
310,
11695,
284,
2290,
198,
286,
674,
4324,
3790,
369,
4729,
1665,
198,
286,
471,
5008,
7144,
1021,
310,
2246,
28301,
307,
4479,
310,
2246,
681,
13495,
4479,
310,
510,
3994,
10614,
6521,
9643,
19096,
8,
369,
658,
304,
2246,
681,
14105,
53764,
310,
5008,
62538,
6521,
9643,
15649,
681,
42106,
30340,
310,
11695,
28,
13333,
198,
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,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009,
128009
] |
fr33jc/bang | bang/providers/hpcloud/v12/__init__.py | fix_hp_addrs | def fix_hp_addrs(server):
"""
Works around hpcloud's peculiar "all ip addresses are returned as private
even though one is public" bug. This is also what the official hpfog gem
does in the ``Fog::Compute::HP::Server#public_ip_address`` method.
:param dict server: Contains the server ID, a list of public IP addresses,
and a list of private IP addresses.
"""
fixed = {A.server.ID: server[A.server.ID]}
both = server.get(A.server.PRIVATE_IPS)
if both:
fixed[A.server.PUBLIC_IPS] = [both[1]]
fixed[A.server.PRIVATE_IPS] = [both[0]]
return fixed | python | def fix_hp_addrs(server):
"""
Works around hpcloud's peculiar "all ip addresses are returned as private
even though one is public" bug. This is also what the official hpfog gem
does in the ``Fog::Compute::HP::Server#public_ip_address`` method.
:param dict server: Contains the server ID, a list of public IP addresses,
and a list of private IP addresses.
"""
fixed = {A.server.ID: server[A.server.ID]}
both = server.get(A.server.PRIVATE_IPS)
if both:
fixed[A.server.PUBLIC_IPS] = [both[1]]
fixed[A.server.PRIVATE_IPS] = [both[0]]
return fixed | [
"def",
"fix_hp_addrs",
"(",
"server",
")",
":",
"fixed",
"=",
"{",
"A",
".",
"server",
".",
"ID",
":",
"server",
"[",
"A",
".",
"server",
".",
"ID",
"]",
"}",
"both",
"=",
"server",
".",
"get",
"(",
"A",
".",
"server",
".",
"PRIVATE_IPS",
")",
"if",
"both",
":",
"fixed",
"[",
"A",
".",
"server",
".",
"PUBLIC_IPS",
"]",
"=",
"[",
"both",
"[",
"1",
"]",
"]",
"fixed",
"[",
"A",
".",
"server",
".",
"PRIVATE_IPS",
"]",
"=",
"[",
"both",
"[",
"0",
"]",
"]",
"return",
"fixed"
] | Works around hpcloud's peculiar "all ip addresses are returned as private
even though one is public" bug. This is also what the official hpfog gem
does in the ``Fog::Compute::HP::Server#public_ip_address`` method.
:param dict server: Contains the server ID, a list of public IP addresses,
and a list of private IP addresses. | [
"Works",
"around",
"hpcloud",
"s",
"peculiar",
"all",
"ip",
"addresses",
"are",
"returned",
"as",
"private",
"even",
"though",
"one",
"is",
"public",
"bug",
".",
"This",
"is",
"also",
"what",
"the",
"official",
"hpfog",
"gem",
"does",
"in",
"the",
"Fog",
"::",
"Compute",
"::",
"HP",
"::",
"Server#public_ip_address",
"method",
"."
] | train | https://github.com/fr33jc/bang/blob/8f000713f88d2a9a8c1193b63ca10a6578560c16/bang/providers/hpcloud/v12/__init__.py#L22-L37 | <|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:
Works around hpcloud's peculiar "all ip addresses are returned as private
even though one is public" bug. This is also what the official hpfog gem
does in the ``Fog::Compute::HP::Server#public_ip_address`` method.
:param dict server: Contains the server ID, a list of public IP addresses,
and a list of private IP addresses.
### Response:
def fix_hp_addrs(server):
"""
Works around hpcloud's peculiar "all ip addresses are returned as private
even though one is public" bug. This is also what the official hpfog gem
does in the ``Fog::Compute::HP::Server#public_ip_address`` method.
:param dict server: Contains the server ID, a list of public IP addresses,
and a list of private IP addresses.
"""
fixed = {A.server.ID: server[A.server.ID]}
both = server.get(A.server.PRIVATE_IPS)
if both:
fixed[A.server.PUBLIC_IPS] = [both[1]]
fixed[A.server.PRIVATE_IPS] = [both[0]]
return fixed
<|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,
38783,
2212,
21280,
12641,
596,
44797,
330,
543,
6125,
14564,
527,
6052,
439,
879,
198,
262,
1524,
3582,
832,
374,
586,
1,
10077,
13,
220,
1115,
374,
1101,
1148,
279,
4033,
305,
16276,
540,
19269,
198,
262,
1587,
304,
279,
10103,
37,
540,
487,
47354,
487,
6748,
487,
5592,
2,
898,
10601,
6886,
14196,
1749,
382,
262,
551,
913,
6587,
3622,
25,
220,
31911,
279,
3622,
3110,
11,
264,
1160,
315,
586,
6933,
14564,
345,
286,
323,
264,
1160,
315,
879,
6933,
14564,
382,
14711,
6075,
512,
755,
5155,
49578,
2962,
5544,
22136,
997,
262,
3270,
262,
21785,
2212,
21280,
12641,
596,
44797,
330,
543,
6125,
14564,
527,
6052,
439,
879,
198,
262,
1524,
3582,
832,
374,
586,
1,
10077,
13,
220,
1115,
374,
1101,
1148,
279,
4033,
305,
16276,
540,
19269,
198,
262,
1587,
304,
279,
10103,
37,
540,
487,
47354,
487,
6748,
487,
5592,
2,
898,
10601,
6886,
14196,
1749,
382,
262,
551,
913,
6587,
3622,
25,
220,
31911,
279,
3622,
3110,
11,
264,
1160,
315,
586,
6933,
14564,
345,
286,
323,
264,
1160,
315,
879,
6933,
14564,
382,
262,
3270,
262,
8521,
284,
314,
32,
12926,
10111,
25,
3622,
23335,
12926,
10111,
24333,
262,
2225,
284,
3622,
673,
4444,
12926,
66553,
20032,
17018,
50,
340,
262,
422,
2225,
512,
286,
8521,
23335,
12926,
1087,
17594,
17018,
50,
60,
284,
510,
21704,
58,
16,
14623,
286,
8521,
23335,
12926,
66553,
20032,
17018,
50,
60,
284,
510,
21704,
58,
15,
14623,
262,
471,
8521,
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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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
] | [
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,
38783,
2212,
21280,
12641,
596,
44797,
330,
543,
6125,
14564,
527,
6052,
439,
879,
198,
262,
1524,
3582,
832,
374,
586,
1,
10077,
13,
220,
1115,
374,
1101,
1148,
279,
4033,
305,
16276,
540,
19269,
198,
262,
1587,
304,
279,
10103,
37,
540,
487,
47354,
487,
6748,
487,
5592,
2,
898,
10601,
6886,
14196,
1749,
382,
262,
551,
913,
6587,
3622,
25,
220,
31911,
279,
3622,
3110,
11,
264,
1160,
315,
586,
6933,
14564,
345,
286,
323,
264,
1160,
315,
879,
6933,
14564,
382,
14711,
6075,
512,
755,
5155,
49578,
2962,
5544,
22136,
997,
262,
3270,
262,
21785,
2212,
21280,
12641,
596,
44797,
330,
543,
6125,
14564,
527,
6052,
439,
879,
198,
262,
1524,
3582,
832,
374,
586,
1,
10077,
13,
220,
1115,
374,
1101,
1148,
279,
4033,
305,
16276,
540,
19269,
198,
262,
1587,
304,
279,
10103,
37,
540,
487,
47354,
487,
6748,
487,
5592,
2,
898,
10601,
6886,
14196,
1749,
382,
262,
551,
913,
6587,
3622,
25,
220,
31911,
279,
3622,
3110,
11,
264,
1160,
315,
586,
6933,
14564,
345,
286,
323,
264,
1160,
315,
879,
6933,
14564,
382,
262,
3270,
262,
8521,
284,
314,
32,
12926,
10111,
25,
3622,
23335,
12926,
10111,
24333,
262,
2225,
284,
3622,
673,
4444,
12926,
66553,
20032,
17018,
50,
340,
262,
422,
2225,
512,
286,
8521,
23335,
12926,
1087,
17594,
17018,
50,
60,
284,
510,
21704,
58,
16,
14623,
286,
8521,
23335,
12926,
66553,
20032,
17018,
50,
60,
284,
510,
21704,
58,
15,
14623,
262,
471,
8521,
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
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.