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
signaturit/python-sdk
signaturit_sdk/signaturit_client.py
SignaturitClient.remove_user
def remove_user(self, user_id): """ Remove a user from your team :param user_id: Id of user """ url = self.TEAM_USERS_ID_URL % user_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
python
def remove_user(self, user_id): """ Remove a user from your team :param user_id: Id of user """ url = self.TEAM_USERS_ID_URL % user_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request()
[ "def", "remove_user", "(", "self", ",", "user_id", ")", ":", "url", "=", "self", ".", "TEAM_USERS_ID_URL", "%", "user_id", "connection", "=", "Connection", "(", "self", ".", "token", ")", "connection", ".", "set_url", "(", "self", ".", "production", ",", "url", ")", "return", "connection", ".", "delete_request", "(", ")" ]
Remove a user from your team :param user_id: Id of user
[ "Remove", "a", "user", "from", "your", "team", ":", "param", "user_id", ":", "Id", "of", "user" ]
train
https://github.com/signaturit/python-sdk/blob/2419c6d9675d901244f807ae360dc58aa46109a9/signaturit_sdk/signaturit_client.py#L546-L557
<|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: Remove a user from your team :param user_id: Id of user ### Response: def remove_user(self, user_id): """ Remove a user from your team :param user_id: Id of user """ url = self.TEAM_USERS_ID_URL % user_id connection = Connection(self.token) connection.set_url(self.production, url) return connection.delete_request() <|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, 13319, 264, 1217, 505, 701, 2128, 198, 286, 551, 913, 1217, 851, 25, 5336, 315, 1217, 271, 14711, 6075, 512, 755, 4148, 3398, 1214, 11, 1217, 851, 997, 286, 3270, 286, 11016, 264, 1217, 505, 701, 2128, 198, 286, 551, 913, 1217, 851, 25, 5336, 315, 1217, 198, 286, 12713, 286, 2576, 284, 659, 844, 36, 1428, 53975, 3533, 8159, 1034, 1217, 851, 271, 286, 3717, 284, 11278, 1214, 14754, 340, 286, 3717, 995, 2975, 1214, 69580, 11, 2576, 696, 286, 471, 3717, 7592, 8052, 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, 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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 13319, 264, 1217, 505, 701, 2128, 198, 286, 551, 913, 1217, 851, 25, 5336, 315, 1217, 271, 14711, 6075, 512, 755, 4148, 3398, 1214, 11, 1217, 851, 997, 286, 3270, 286, 11016, 264, 1217, 505, 701, 2128, 198, 286, 551, 913, 1217, 851, 25, 5336, 315, 1217, 198, 286, 12713, 286, 2576, 284, 659, 844, 36, 1428, 53975, 3533, 8159, 1034, 1217, 851, 271, 286, 3717, 284, 11278, 1214, 14754, 340, 286, 3717, 995, 2975, 1214, 69580, 11, 2576, 696, 286, 471, 3717, 7592, 8052, 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 ]
jilljenn/tryalgo
tryalgo/laser_mirrors.py
solve
def solve(succ, orien, i, direc): """Can a laser leaving mirror i in direction direc reach exit ? :param i: mirror index :param direc: direction leaving mirror i :param orient: orient[i]=orientation of mirror i :param succ: succ[i][direc]=succ mirror reached when leaving i in direction direc """ assert orien[i] is not None j = succ[i][direc] if j is None: # basic case return False if j == len(orien) - 1: return True if orien[j] is None: # try both orientations for x in [0, 1]: orien[j] = x if solve(succ, orien, j, reflex[direc][x]): return True orien[j] = None return False else: return solve(succ, orien, j, reflex[direc][orien[j]])
python
def solve(succ, orien, i, direc): """Can a laser leaving mirror i in direction direc reach exit ? :param i: mirror index :param direc: direction leaving mirror i :param orient: orient[i]=orientation of mirror i :param succ: succ[i][direc]=succ mirror reached when leaving i in direction direc """ assert orien[i] is not None j = succ[i][direc] if j is None: # basic case return False if j == len(orien) - 1: return True if orien[j] is None: # try both orientations for x in [0, 1]: orien[j] = x if solve(succ, orien, j, reflex[direc][x]): return True orien[j] = None return False else: return solve(succ, orien, j, reflex[direc][orien[j]])
[ "def", "solve", "(", "succ", ",", "orien", ",", "i", ",", "direc", ")", ":", "assert", "orien", "[", "i", "]", "is", "not", "None", "j", "=", "succ", "[", "i", "]", "[", "direc", "]", "if", "j", "is", "None", ":", "# basic case", "return", "False", "if", "j", "==", "len", "(", "orien", ")", "-", "1", ":", "return", "True", "if", "orien", "[", "j", "]", "is", "None", ":", "# try both orientations", "for", "x", "in", "[", "0", ",", "1", "]", ":", "orien", "[", "j", "]", "=", "x", "if", "solve", "(", "succ", ",", "orien", ",", "j", ",", "reflex", "[", "direc", "]", "[", "x", "]", ")", ":", "return", "True", "orien", "[", "j", "]", "=", "None", "return", "False", "else", ":", "return", "solve", "(", "succ", ",", "orien", ",", "j", ",", "reflex", "[", "direc", "]", "[", "orien", "[", "j", "]", "]", ")" ]
Can a laser leaving mirror i in direction direc reach exit ? :param i: mirror index :param direc: direction leaving mirror i :param orient: orient[i]=orientation of mirror i :param succ: succ[i][direc]=succ mirror reached when leaving i in direction direc
[ "Can", "a", "laser", "leaving", "mirror", "i", "in", "direction", "direc", "reach", "exit", "?" ]
train
https://github.com/jilljenn/tryalgo/blob/89a4dd9655e7b6b0a176f72b4c60d0196420dfe1/tryalgo/laser_mirrors.py#L57-L80
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Can a laser leaving mirror i in direction direc reach exit ? :param i: mirror index :param direc: direction leaving mirror i :param orient: orient[i]=orientation of mirror i :param succ: succ[i][direc]=succ mirror reached when leaving i in direction direc ### Response: def solve(succ, orien, i, direc): """Can a laser leaving mirror i in direction direc reach exit ? :param i: mirror index :param direc: direction leaving mirror i :param orient: orient[i]=orientation of mirror i :param succ: succ[i][direc]=succ mirror reached when leaving i in direction direc """ assert orien[i] is not None j = succ[i][direc] if j is None: # basic case return False if j == len(orien) - 1: return True if orien[j] is None: # try both orientations for x in [0, 1]: orien[j] = x if solve(succ, orien, j, reflex[direc][x]): return True orien[j] = None return False else: return solve(succ, orien, j, reflex[direc][orien[j]]) <|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, 6854, 264, 21120, 9564, 18327, 602, 304, 5216, 13510, 66, 5662, 4974, 24688, 262, 551, 913, 602, 25, 18327, 1963, 198, 262, 551, 913, 13510, 66, 25, 5216, 9564, 18327, 602, 198, 262, 551, 913, 11744, 25, 11744, 1004, 4938, 25280, 315, 18327, 602, 198, 262, 551, 913, 20639, 25, 20639, 1004, 1483, 64684, 66, 4938, 65541, 18327, 8813, 198, 338, 994, 9564, 602, 304, 5216, 13510, 66, 271, 14711, 6075, 512, 755, 11886, 1161, 14912, 11, 477, 3675, 11, 602, 11, 13510, 66, 997, 262, 4304, 6854, 264, 21120, 9564, 18327, 602, 304, 5216, 13510, 66, 5662, 4974, 24688, 262, 551, 913, 602, 25, 18327, 1963, 198, 262, 551, 913, 13510, 66, 25, 5216, 9564, 18327, 602, 198, 262, 551, 913, 11744, 25, 11744, 1004, 4938, 25280, 315, 18327, 602, 198, 262, 551, 913, 20639, 25, 20639, 1004, 1483, 64684, 66, 4938, 65541, 18327, 8813, 198, 338, 994, 9564, 602, 304, 5216, 13510, 66, 198, 262, 3270, 262, 2105, 477, 3675, 1004, 60, 374, 539, 2290, 198, 262, 503, 284, 20639, 1004, 1483, 64684, 66, 933, 262, 422, 503, 374, 2290, 25, 692, 674, 6913, 1162, 198, 286, 471, 3641, 198, 262, 422, 503, 624, 2479, 81020, 3675, 8, 482, 220, 16, 512, 286, 471, 3082, 198, 262, 422, 477, 3675, 3894, 60, 374, 2290, 25, 256, 674, 1456, 2225, 89935, 198, 286, 369, 865, 304, 510, 15, 11, 220, 16, 10556, 310, 477, 3675, 3894, 60, 284, 865, 198, 310, 422, 11886, 1161, 14912, 11, 477, 3675, 11, 503, 11, 33766, 22142, 556, 66, 1483, 87, 22953, 394, 471, 3082, 198, 286, 477, 3675, 3894, 60, 284, 2290, 198, 286, 471, 3641, 198, 262, 775, 512, 286, 471, 11886, 1161, 14912, 11, 477, 3675, 11, 503, 11, 33766, 22142, 556, 66, 1483, 269, 3675, 3894, 27829, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 6854, 264, 21120, 9564, 18327, 602, 304, 5216, 13510, 66, 5662, 4974, 24688, 262, 551, 913, 602, 25, 18327, 1963, 198, 262, 551, 913, 13510, 66, 25, 5216, 9564, 18327, 602, 198, 262, 551, 913, 11744, 25, 11744, 1004, 4938, 25280, 315, 18327, 602, 198, 262, 551, 913, 20639, 25, 20639, 1004, 1483, 64684, 66, 4938, 65541, 18327, 8813, 198, 338, 994, 9564, 602, 304, 5216, 13510, 66, 271, 14711, 6075, 512, 755, 11886, 1161, 14912, 11, 477, 3675, 11, 602, 11, 13510, 66, 997, 262, 4304, 6854, 264, 21120, 9564, 18327, 602, 304, 5216, 13510, 66, 5662, 4974, 24688, 262, 551, 913, 602, 25, 18327, 1963, 198, 262, 551, 913, 13510, 66, 25, 5216, 9564, 18327, 602, 198, 262, 551, 913, 11744, 25, 11744, 1004, 4938, 25280, 315, 18327, 602, 198, 262, 551, 913, 20639, 25, 20639, 1004, 1483, 64684, 66, 4938, 65541, 18327, 8813, 198, 338, 994, 9564, 602, 304, 5216, 13510, 66, 198, 262, 3270, 262, 2105, 477, 3675, 1004, 60, 374, 539, 2290, 198, 262, 503, 284, 20639, 1004, 1483, 64684, 66, 933, 262, 422, 503, 374, 2290, 25, 692, 674, 6913, 1162, 198, 286, 471, 3641, 198, 262, 422, 503, 624, 2479, 81020, 3675, 8, 482, 220, 16, 512, 286, 471, 3082, 198, 262, 422, 477, 3675, 3894, 60, 374, 2290, 25, 256, 674, 1456, 2225, 89935, 198, 286, 369, 865, 304, 510, 15, 11, 220, 16, 10556, 310, 477, 3675, 3894, 60, 284, 865, 198, 310, 422, 11886, 1161, 14912, 11, 477, 3675, 11, 503, 11, 33766, 22142, 556, 66, 1483, 87, 22953, 394, 471, 3082, 198, 286, 477, 3675, 3894, 60, 284, 2290, 198, 286, 471, 3641, 198, 262, 775, 512, 286, 471, 11886, 1161, 14912, 11, 477, 3675, 11, 503, 11, 33766, 22142, 556, 66, 1483, 269, 3675, 3894, 27829, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
fprimex/zdesk
zdesk/zdesk_api.py
ZendeskAPI.community_post_create
def community_post_create(self, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/help_center/posts#create-post" api_path = "/api/v2/community/posts.json" return self.call(api_path, method="POST", data=data, **kwargs)
python
def community_post_create(self, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/help_center/posts#create-post" api_path = "/api/v2/community/posts.json" return self.call(api_path, method="POST", data=data, **kwargs)
[ "def", "community_post_create", "(", "self", ",", "data", ",", "*", "*", "kwargs", ")", ":", "api_path", "=", "\"/api/v2/community/posts.json\"", "return", "self", ".", "call", "(", "api_path", ",", "method", "=", "\"POST\"", ",", "data", "=", "data", ",", "*", "*", "kwargs", ")" ]
https://developer.zendesk.com/rest_api/docs/help_center/posts#create-post
[ "https", ":", "//", "developer", ".", "zendesk", ".", "com", "/", "rest_api", "/", "docs", "/", "help_center", "/", "posts#create", "-", "post" ]
train
https://github.com/fprimex/zdesk/blob/851611c13b4d530e9df31390b3ec709baf0a0188/zdesk/zdesk_api.py#L822-L825
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: https://developer.zendesk.com/rest_api/docs/help_center/posts#create-post ### Response: def community_post_create(self, data, **kwargs): "https://developer.zendesk.com/rest_api/docs/help_center/posts#create-post" api_path = "/api/v2/community/posts.json" return self.call(api_path, method="POST", data=data, **kwargs) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 2485, 1129, 35501, 4025, 408, 67919, 916, 46365, 11959, 27057, 80030, 21767, 52411, 79137, 25414, 271, 14711, 6075, 512, 755, 4029, 6467, 8827, 1214, 11, 828, 11, 3146, 9872, 997, 286, 330, 2485, 1129, 35501, 4025, 408, 67919, 916, 46365, 11959, 27057, 80030, 21767, 52411, 79137, 25414, 702, 286, 6464, 2703, 284, 3605, 2113, 5574, 17, 93577, 52411, 4421, 702, 286, 471, 659, 8692, 25865, 2703, 11, 1749, 429, 3019, 498, 828, 23686, 11, 3146, 9872, 340, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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,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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 2485, 1129, 35501, 4025, 408, 67919, 916, 46365, 11959, 27057, 80030, 21767, 52411, 79137, 25414, 271, 14711, 6075, 512, 755, 4029, 6467, 8827, 1214, 11, 828, 11, 3146, 9872, 997, 286, 330, 2485, 1129, 35501, 4025, 408, 67919, 916, 46365, 11959, 27057, 80030, 21767, 52411, 79137, 25414, 702, 286, 6464, 2703, 284, 3605, 2113, 5574, 17, 93577, 52411, 4421, 702, 286, 471, 659, 8692, 25865, 2703, 11, 1749, 429, 3019, 498, 828, 23686, 11, 3146, 9872, 340, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
Sanji-IO/sanji
sanji/message.py
Message.to_dict
def to_dict(self): """ to_dict will clean all protected and private properties """ return dict( (k, self.__dict__[k]) for k in self.__dict__ if k.find("_") != 0)
python
def to_dict(self): """ to_dict will clean all protected and private properties """ return dict( (k, self.__dict__[k]) for k in self.__dict__ if k.find("_") != 0)
[ "def", "to_dict", "(", "self", ")", ":", "return", "dict", "(", "(", "k", ",", "self", ".", "__dict__", "[", "k", "]", ")", "for", "k", "in", "self", ".", "__dict__", "if", "k", ".", "find", "(", "\"_\"", ")", "!=", "0", ")" ]
to_dict will clean all protected and private properties
[ "to_dict", "will", "clean", "all", "protected", "and", "private", "properties" ]
train
https://github.com/Sanji-IO/sanji/blob/5c54cc2772bdfeae3337f785de1957237b828b34/sanji/message.py#L160-L165
<|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: to_dict will clean all protected and private properties ### Response: def to_dict(self): """ to_dict will clean all protected and private properties """ return dict( (k, self.__dict__[k]) for k in self.__dict__ if k.find("_") != 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, 998, 5356, 690, 4335, 682, 2682, 323, 879, 6012, 271, 14711, 6075, 512, 755, 311, 5356, 1214, 997, 286, 3270, 286, 311, 5356, 690, 4335, 682, 2682, 323, 879, 6012, 198, 286, 3270, 286, 471, 6587, 1021, 310, 320, 74, 11, 659, 4952, 8644, 67290, 74, 2526, 369, 597, 304, 659, 4952, 8644, 565, 422, 597, 2725, 17405, 909, 976, 220, 15, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 998, 5356, 690, 4335, 682, 2682, 323, 879, 6012, 271, 14711, 6075, 512, 755, 311, 5356, 1214, 997, 286, 3270, 286, 311, 5356, 690, 4335, 682, 2682, 323, 879, 6012, 198, 286, 3270, 286, 471, 6587, 1021, 310, 320, 74, 11, 659, 4952, 8644, 67290, 74, 2526, 369, 597, 304, 659, 4952, 8644, 565, 422, 597, 2725, 17405, 909, 976, 220, 15, 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 ]
non-Jedi/gyr
gyr/matrix_objects.py
Event.user
def user(self): """Creates a User object when requested.""" try: return self._user except AttributeError: self._user = MatrixUser(self.mxid, self.Api(identity=self.mxid)) return self._user
python
def user(self): """Creates a User object when requested.""" try: return self._user except AttributeError: self._user = MatrixUser(self.mxid, self.Api(identity=self.mxid)) return self._user
[ "def", "user", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_user", "except", "AttributeError", ":", "self", ".", "_user", "=", "MatrixUser", "(", "self", ".", "mxid", ",", "self", ".", "Api", "(", "identity", "=", "self", ".", "mxid", ")", ")", "return", "self", ".", "_user" ]
Creates a User object when requested.
[ "Creates", "a", "User", "object", "when", "requested", "." ]
train
https://github.com/non-Jedi/gyr/blob/9f7bfe033b9d3bbfd3a9e8aea02e35526b53125e/gyr/matrix_objects.py#L49-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: Creates a User object when requested. ### Response: def user(self): """Creates a User object when requested.""" try: return self._user except AttributeError: self._user = MatrixUser(self.mxid, self.Api(identity=self.mxid)) return self._user <|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, 55968, 264, 2724, 1665, 994, 11472, 382, 14711, 6075, 512, 755, 1217, 1214, 997, 286, 4304, 55968, 264, 2724, 1665, 994, 11472, 14781, 286, 1456, 512, 310, 471, 659, 1462, 882, 198, 286, 3734, 54731, 512, 310, 659, 1462, 882, 284, 11892, 1502, 1214, 72533, 307, 11, 659, 21721, 87943, 7822, 72533, 307, 1192, 310, 471, 659, 1462, 882, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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,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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 55968, 264, 2724, 1665, 994, 11472, 382, 14711, 6075, 512, 755, 1217, 1214, 997, 286, 4304, 55968, 264, 2724, 1665, 994, 11472, 14781, 286, 1456, 512, 310, 471, 659, 1462, 882, 198, 286, 3734, 54731, 512, 310, 659, 1462, 882, 284, 11892, 1502, 1214, 72533, 307, 11, 659, 21721, 87943, 7822, 72533, 307, 1192, 310, 471, 659, 1462, 882, 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 ]
ApproxEng/approxeng.input
src/python/approxeng/input/__init__.py
TriggerAxis._input_to_raw_value
def _input_to_raw_value(self, value: int) -> float: """ Convert the value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, linearly interpolating between those two points. """ return (float(value) - self.min_raw_value) / self.max_raw_value
python
def _input_to_raw_value(self, value: int) -> float: """ Convert the value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, linearly interpolating between those two points. """ return (float(value) - self.min_raw_value) / self.max_raw_value
[ "def", "_input_to_raw_value", "(", "self", ",", "value", ":", "int", ")", "->", "float", ":", "return", "(", "float", "(", "value", ")", "-", "self", ".", "min_raw_value", ")", "/", "self", ".", "max_raw_value" ]
Convert the value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, linearly interpolating between those two points.
[ "Convert", "the", "value", "read", "from", "evdev", "to", "a", "0", ".", "0", "to", "1", ".", "0", "range", "." ]
train
https://github.com/ApproxEng/approxeng.input/blob/0cdf8eed6bfd26ca3b20b4478f352787f60ae8ef/src/python/approxeng/input/__init__.py#L513-L524
<|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 value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, linearly interpolating between those two points. ### Response: def _input_to_raw_value(self, value: int) -> float: """ Convert the value read from evdev to a 0.0 to 1.0 range. :internal: :param value: a value ranging from the defined minimum to the defined maximum value. :return: 0.0 at minimum, 1.0 at maximum, linearly interpolating between those two points. """ return (float(value) - self.min_raw_value) / self.max_raw_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, 12281, 279, 907, 1373, 505, 3721, 3667, 311, 264, 220, 15, 13, 15, 311, 220, 16, 13, 15, 2134, 382, 286, 551, 10701, 1473, 286, 551, 913, 907, 512, 310, 264, 907, 24950, 505, 279, 4613, 8187, 311, 279, 4613, 7340, 907, 627, 286, 551, 693, 512, 310, 220, 15, 13, 15, 520, 8187, 11, 220, 16, 13, 15, 520, 7340, 11, 13790, 398, 23725, 1113, 1990, 1884, 1403, 3585, 382, 14711, 6075, 512, 755, 721, 1379, 2401, 16453, 3220, 1214, 11, 907, 25, 528, 8, 1492, 2273, 512, 286, 3270, 286, 7316, 279, 907, 1373, 505, 3721, 3667, 311, 264, 220, 15, 13, 15, 311, 220, 16, 13, 15, 2134, 382, 286, 551, 10701, 1473, 286, 551, 913, 907, 512, 310, 264, 907, 24950, 505, 279, 4613, 8187, 311, 279, 4613, 7340, 907, 627, 286, 551, 693, 512, 310, 220, 15, 13, 15, 520, 8187, 11, 220, 16, 13, 15, 520, 7340, 11, 13790, 398, 23725, 1113, 1990, 1884, 1403, 3585, 627, 286, 3270, 286, 471, 320, 3733, 3764, 8, 482, 659, 4456, 16453, 3220, 8, 611, 659, 6817, 16453, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 907, 1373, 505, 3721, 3667, 311, 264, 220, 15, 13, 15, 311, 220, 16, 13, 15, 2134, 382, 286, 551, 10701, 1473, 286, 551, 913, 907, 512, 310, 264, 907, 24950, 505, 279, 4613, 8187, 311, 279, 4613, 7340, 907, 627, 286, 551, 693, 512, 310, 220, 15, 13, 15, 520, 8187, 11, 220, 16, 13, 15, 520, 7340, 11, 13790, 398, 23725, 1113, 1990, 1884, 1403, 3585, 382, 14711, 6075, 512, 755, 721, 1379, 2401, 16453, 3220, 1214, 11, 907, 25, 528, 8, 1492, 2273, 512, 286, 3270, 286, 7316, 279, 907, 1373, 505, 3721, 3667, 311, 264, 220, 15, 13, 15, 311, 220, 16, 13, 15, 2134, 382, 286, 551, 10701, 1473, 286, 551, 913, 907, 512, 310, 264, 907, 24950, 505, 279, 4613, 8187, 311, 279, 4613, 7340, 907, 627, 286, 551, 693, 512, 310, 220, 15, 13, 15, 520, 8187, 11, 220, 16, 13, 15, 520, 7340, 11, 13790, 398, 23725, 1113, 1990, 1884, 1403, 3585, 627, 286, 3270, 286, 471, 320, 3733, 3764, 8, 482, 659, 4456, 16453, 3220, 8, 611, 659, 6817, 16453, 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 ]
ga4gh/ga4gh-server
ga4gh/server/datarepo.py
AbstractDataRepository.getOntologyByName
def getOntologyByName(self, name): """ Returns an ontology by name """ if name not in self._ontologyNameMap: raise exceptions.OntologyNameNotFoundException(name) return self._ontologyNameMap[name]
python
def getOntologyByName(self, name): """ Returns an ontology by name """ if name not in self._ontologyNameMap: raise exceptions.OntologyNameNotFoundException(name) return self._ontologyNameMap[name]
[ "def", "getOntologyByName", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "_ontologyNameMap", ":", "raise", "exceptions", ".", "OntologyNameNotFoundException", "(", "name", ")", "return", "self", ".", "_ontologyNameMap", "[", "name", "]" ]
Returns an ontology by name
[ "Returns", "an", "ontology", "by", "name" ]
train
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datarepo.py#L162-L168
<|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 an ontology by name ### Response: def getOntologyByName(self, name): """ Returns an ontology by name """ if name not in self._ontologyNameMap: raise exceptions.OntologyNameNotFoundException(name) return self._ontologyNameMap[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, 16851, 459, 84369, 555, 836, 271, 14711, 6075, 512, 755, 636, 67403, 2508, 17325, 1214, 11, 836, 997, 286, 3270, 286, 5295, 459, 84369, 555, 836, 198, 286, 3270, 286, 422, 836, 539, 304, 659, 1462, 63333, 678, 2276, 512, 310, 4933, 20157, 8548, 406, 2508, 678, 14920, 3232, 340, 286, 471, 659, 1462, 63333, 678, 2276, 11174, 933, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 16851, 459, 84369, 555, 836, 271, 14711, 6075, 512, 755, 636, 67403, 2508, 17325, 1214, 11, 836, 997, 286, 3270, 286, 5295, 459, 84369, 555, 836, 198, 286, 3270, 286, 422, 836, 539, 304, 659, 1462, 63333, 678, 2276, 512, 310, 4933, 20157, 8548, 406, 2508, 678, 14920, 3232, 340, 286, 471, 659, 1462, 63333, 678, 2276, 11174, 933, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
AgeOfLearning/coeus-unity-python-framework
coeus_unity/commands.py
await_any_transforms_exist
def await_any_transforms_exist(cli, transform_paths, does_exist=DEFAULT_TRANSFORM_EXISTS, timeout_seconds=DEFAULT_TIMEOUT_SECONDS): """ Waits for a transform to exist based on does_exist. :param cli: :param transform_paths: An array of transform paths [...] :param does_exist: Whether or not to await for exist state (True | False) :param timeout_seconds: How long until this returns with failure :return: bool """ message_payload = { "transform_paths": transform_paths, "do_exist": does_exist, "match_mode": "Any", "timeout": timeout_seconds } msg = message.Message("await.unity.transform.exists", message_payload) cli.send_message(msg) response = cli.read_message() verify_response(response) return bool(response['payload']['success'])
python
def await_any_transforms_exist(cli, transform_paths, does_exist=DEFAULT_TRANSFORM_EXISTS, timeout_seconds=DEFAULT_TIMEOUT_SECONDS): """ Waits for a transform to exist based on does_exist. :param cli: :param transform_paths: An array of transform paths [...] :param does_exist: Whether or not to await for exist state (True | False) :param timeout_seconds: How long until this returns with failure :return: bool """ message_payload = { "transform_paths": transform_paths, "do_exist": does_exist, "match_mode": "Any", "timeout": timeout_seconds } msg = message.Message("await.unity.transform.exists", message_payload) cli.send_message(msg) response = cli.read_message() verify_response(response) return bool(response['payload']['success'])
[ "def", "await_any_transforms_exist", "(", "cli", ",", "transform_paths", ",", "does_exist", "=", "DEFAULT_TRANSFORM_EXISTS", ",", "timeout_seconds", "=", "DEFAULT_TIMEOUT_SECONDS", ")", ":", "message_payload", "=", "{", "\"transform_paths\"", ":", "transform_paths", ",", "\"do_exist\"", ":", "does_exist", ",", "\"match_mode\"", ":", "\"Any\"", ",", "\"timeout\"", ":", "timeout_seconds", "}", "msg", "=", "message", ".", "Message", "(", "\"await.unity.transform.exists\"", ",", "message_payload", ")", "cli", ".", "send_message", "(", "msg", ")", "response", "=", "cli", ".", "read_message", "(", ")", "verify_response", "(", "response", ")", "return", "bool", "(", "response", "[", "'payload'", "]", "[", "'success'", "]", ")" ]
Waits for a transform to exist based on does_exist. :param cli: :param transform_paths: An array of transform paths [...] :param does_exist: Whether or not to await for exist state (True | False) :param timeout_seconds: How long until this returns with failure :return: bool
[ "Waits", "for", "a", "transform", "to", "exist", "based", "on", "does_exist", ".", ":", "param", "cli", ":", ":", "param", "transform_paths", ":", "An", "array", "of", "transform", "paths", "[", "...", "]", ":", "param", "does_exist", ":", "Whether", "or", "not", "to", "await", "for", "exist", "state", "(", "True", "|", "False", ")", ":", "param", "timeout_seconds", ":", "How", "long", "until", "this", "returns", "with", "failure", ":", "return", ":", "bool" ]
train
https://github.com/AgeOfLearning/coeus-unity-python-framework/blob/cf8ca6800ace1425d917ea2628dbd05ed959fdd7/coeus_unity/commands.py#L52-L72
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Waits for a transform to exist based on does_exist. :param cli: :param transform_paths: An array of transform paths [...] :param does_exist: Whether or not to await for exist state (True | False) :param timeout_seconds: How long until this returns with failure :return: bool ### Response: def await_any_transforms_exist(cli, transform_paths, does_exist=DEFAULT_TRANSFORM_EXISTS, timeout_seconds=DEFAULT_TIMEOUT_SECONDS): """ Waits for a transform to exist based on does_exist. :param cli: :param transform_paths: An array of transform paths [...] :param does_exist: Whether or not to await for exist state (True | False) :param timeout_seconds: How long until this returns with failure :return: bool """ message_payload = { "transform_paths": transform_paths, "do_exist": does_exist, "match_mode": "Any", "timeout": timeout_seconds } msg = message.Message("await.unity.transform.exists", message_payload) cli.send_message(msg) response = cli.read_message() verify_response(response) return bool(response['payload']['success']) <|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, 54, 57579, 369, 264, 5276, 311, 3073, 3196, 389, 1587, 37006, 627, 262, 551, 913, 22059, 512, 262, 551, 913, 5276, 25124, 25, 1556, 1358, 315, 5276, 13006, 16702, 933, 262, 551, 913, 1587, 37006, 25, 13440, 477, 539, 311, 2597, 369, 3073, 1614, 320, 2575, 765, 3641, 340, 262, 551, 913, 9829, 35925, 25, 2650, 1317, 3156, 420, 4780, 449, 8060, 198, 262, 551, 693, 25, 1845, 271, 14711, 6075, 512, 755, 2597, 38348, 18956, 82, 37006, 71349, 11, 5276, 25124, 11, 1587, 37006, 28, 17733, 93721, 71142, 11, 9829, 35925, 28, 17733, 24303, 76451, 997, 262, 3270, 262, 29614, 1220, 369, 264, 5276, 311, 3073, 3196, 389, 1587, 37006, 627, 262, 551, 913, 22059, 512, 262, 551, 913, 5276, 25124, 25, 1556, 1358, 315, 5276, 13006, 16702, 933, 262, 551, 913, 1587, 37006, 25, 13440, 477, 539, 311, 2597, 369, 3073, 1614, 320, 2575, 765, 3641, 340, 262, 551, 913, 9829, 35925, 25, 2650, 1317, 3156, 420, 4780, 449, 8060, 198, 262, 551, 693, 25, 1845, 198, 262, 3270, 262, 1984, 33913, 284, 341, 286, 330, 4806, 25124, 794, 5276, 25124, 345, 286, 330, 3055, 37006, 794, 1587, 37006, 345, 286, 330, 6481, 7450, 794, 330, 8780, 761, 286, 330, 14482, 794, 9829, 35925, 198, 262, 457, 262, 3835, 284, 1984, 8639, 446, 11675, 13, 2498, 8297, 12347, 498, 1984, 33913, 340, 262, 22059, 5331, 6598, 8282, 696, 262, 2077, 284, 22059, 4217, 6598, 746, 262, 10356, 9852, 5802, 340, 262, 471, 1845, 5802, 681, 19992, 4274, 5748, 7519, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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,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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 54, 57579, 369, 264, 5276, 311, 3073, 3196, 389, 1587, 37006, 627, 262, 551, 913, 22059, 512, 262, 551, 913, 5276, 25124, 25, 1556, 1358, 315, 5276, 13006, 16702, 933, 262, 551, 913, 1587, 37006, 25, 13440, 477, 539, 311, 2597, 369, 3073, 1614, 320, 2575, 765, 3641, 340, 262, 551, 913, 9829, 35925, 25, 2650, 1317, 3156, 420, 4780, 449, 8060, 198, 262, 551, 693, 25, 1845, 271, 14711, 6075, 512, 755, 2597, 38348, 18956, 82, 37006, 71349, 11, 5276, 25124, 11, 1587, 37006, 28, 17733, 93721, 71142, 11, 9829, 35925, 28, 17733, 24303, 76451, 997, 262, 3270, 262, 29614, 1220, 369, 264, 5276, 311, 3073, 3196, 389, 1587, 37006, 627, 262, 551, 913, 22059, 512, 262, 551, 913, 5276, 25124, 25, 1556, 1358, 315, 5276, 13006, 16702, 933, 262, 551, 913, 1587, 37006, 25, 13440, 477, 539, 311, 2597, 369, 3073, 1614, 320, 2575, 765, 3641, 340, 262, 551, 913, 9829, 35925, 25, 2650, 1317, 3156, 420, 4780, 449, 8060, 198, 262, 551, 693, 25, 1845, 198, 262, 3270, 262, 1984, 33913, 284, 341, 286, 330, 4806, 25124, 794, 5276, 25124, 345, 286, 330, 3055, 37006, 794, 1587, 37006, 345, 286, 330, 6481, 7450, 794, 330, 8780, 761, 286, 330, 14482, 794, 9829, 35925, 198, 262, 457, 262, 3835, 284, 1984, 8639, 446, 11675, 13, 2498, 8297, 12347, 498, 1984, 33913, 340, 262, 22059, 5331, 6598, 8282, 696, 262, 2077, 284, 22059, 4217, 6598, 746, 262, 10356, 9852, 5802, 340, 262, 471, 1845, 5802, 681, 19992, 4274, 5748, 7519, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
buildbot/buildbot
master/buildbot/plugins/db.py
_PluginDB.add_namespace
def add_namespace(self, namespace, interface=None, check_extras=True, load_now=False): """ register given namespace in global database of plugins in case it's already registered, return the registration """ tempo = self._namespaces.get(namespace) if tempo is None: tempo = _Plugins(namespace, interface, check_extras) self._namespaces[namespace] = tempo if load_now: tempo.load() return tempo
python
def add_namespace(self, namespace, interface=None, check_extras=True, load_now=False): """ register given namespace in global database of plugins in case it's already registered, return the registration """ tempo = self._namespaces.get(namespace) if tempo is None: tempo = _Plugins(namespace, interface, check_extras) self._namespaces[namespace] = tempo if load_now: tempo.load() return tempo
[ "def", "add_namespace", "(", "self", ",", "namespace", ",", "interface", "=", "None", ",", "check_extras", "=", "True", ",", "load_now", "=", "False", ")", ":", "tempo", "=", "self", ".", "_namespaces", ".", "get", "(", "namespace", ")", "if", "tempo", "is", "None", ":", "tempo", "=", "_Plugins", "(", "namespace", ",", "interface", ",", "check_extras", ")", "self", ".", "_namespaces", "[", "namespace", "]", "=", "tempo", "if", "load_now", ":", "tempo", ".", "load", "(", ")", "return", "tempo" ]
register given namespace in global database of plugins in case it's already registered, return the registration
[ "register", "given", "namespace", "in", "global", "database", "of", "plugins" ]
train
https://github.com/buildbot/buildbot/blob/5df3cfae6d760557d99156633c32b1822a1e130c/master/buildbot/plugins/db.py#L287-L303
<|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 given namespace in global database of plugins in case it's already registered, return the registration ### Response: def add_namespace(self, namespace, interface=None, check_extras=True, load_now=False): """ register given namespace in global database of plugins in case it's already registered, return the registration """ tempo = self._namespaces.get(namespace) if tempo is None: tempo = _Plugins(namespace, interface, check_extras) self._namespaces[namespace] = tempo if load_now: tempo.load() return tempo <|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, 6477, 2728, 4573, 304, 3728, 4729, 315, 17658, 271, 286, 304, 1162, 433, 596, 2736, 9879, 11, 471, 279, 12506, 271, 14711, 6075, 512, 755, 923, 42671, 1214, 11, 4573, 11, 3834, 5980, 11, 1817, 2769, 13811, 3702, 345, 2611, 2865, 21480, 5725, 997, 286, 3270, 286, 4254, 2728, 4573, 304, 3728, 4729, 315, 17658, 271, 286, 304, 1162, 433, 596, 2736, 9879, 11, 471, 279, 12506, 198, 286, 3270, 286, 24108, 284, 659, 1462, 11654, 28438, 673, 53497, 696, 286, 422, 24108, 374, 2290, 512, 310, 24108, 284, 721, 46478, 53497, 11, 3834, 11, 1817, 2769, 13811, 340, 310, 659, 1462, 11654, 28438, 58, 2280, 60, 284, 24108, 271, 286, 422, 2865, 21480, 512, 310, 24108, 5214, 2892, 286, 471, 24108, 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, 128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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 6477, 2728, 4573, 304, 3728, 4729, 315, 17658, 271, 286, 304, 1162, 433, 596, 2736, 9879, 11, 471, 279, 12506, 271, 14711, 6075, 512, 755, 923, 42671, 1214, 11, 4573, 11, 3834, 5980, 11, 1817, 2769, 13811, 3702, 345, 2611, 2865, 21480, 5725, 997, 286, 3270, 286, 4254, 2728, 4573, 304, 3728, 4729, 315, 17658, 271, 286, 304, 1162, 433, 596, 2736, 9879, 11, 471, 279, 12506, 198, 286, 3270, 286, 24108, 284, 659, 1462, 11654, 28438, 673, 53497, 696, 286, 422, 24108, 374, 2290, 512, 310, 24108, 284, 721, 46478, 53497, 11, 3834, 11, 1817, 2769, 13811, 340, 310, 659, 1462, 11654, 28438, 58, 2280, 60, 284, 24108, 271, 286, 422, 2865, 21480, 512, 310, 24108, 5214, 2892, 286, 471, 24108, 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 ]
KelSolaar/Umbra
umbra/ui/visual_accelerators.py
highlight_current_line
def highlight_current_line(editor): """ Highlights given editor current line. :param editor: Document editor. :type editor: QWidget :return: Method success. :rtype: bool """ format = editor.language.theme.get("accelerator.line") if not format: return False extra_selections = editor.extraSelections() or [] if not editor.isReadOnly(): selection = QTextEdit.ExtraSelection() selection.format.setBackground(format.background()) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = editor.textCursor() selection.cursor.clearSelection() extra_selections.append(selection) editor.setExtraSelections(extra_selections) return True
python
def highlight_current_line(editor): """ Highlights given editor current line. :param editor: Document editor. :type editor: QWidget :return: Method success. :rtype: bool """ format = editor.language.theme.get("accelerator.line") if not format: return False extra_selections = editor.extraSelections() or [] if not editor.isReadOnly(): selection = QTextEdit.ExtraSelection() selection.format.setBackground(format.background()) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = editor.textCursor() selection.cursor.clearSelection() extra_selections.append(selection) editor.setExtraSelections(extra_selections) return True
[ "def", "highlight_current_line", "(", "editor", ")", ":", "format", "=", "editor", ".", "language", ".", "theme", ".", "get", "(", "\"accelerator.line\"", ")", "if", "not", "format", ":", "return", "False", "extra_selections", "=", "editor", ".", "extraSelections", "(", ")", "or", "[", "]", "if", "not", "editor", ".", "isReadOnly", "(", ")", ":", "selection", "=", "QTextEdit", ".", "ExtraSelection", "(", ")", "selection", ".", "format", ".", "setBackground", "(", "format", ".", "background", "(", ")", ")", "selection", ".", "format", ".", "setProperty", "(", "QTextFormat", ".", "FullWidthSelection", ",", "True", ")", "selection", ".", "cursor", "=", "editor", ".", "textCursor", "(", ")", "selection", ".", "cursor", ".", "clearSelection", "(", ")", "extra_selections", ".", "append", "(", "selection", ")", "editor", ".", "setExtraSelections", "(", "extra_selections", ")", "return", "True" ]
Highlights given editor current line. :param editor: Document editor. :type editor: QWidget :return: Method success. :rtype: bool
[ "Highlights", "given", "editor", "current", "line", "." ]
train
https://github.com/KelSolaar/Umbra/blob/66f45f08d9d723787f1191989f8b0dda84b412ce/umbra/ui/visual_accelerators.py#L42-L65
<|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: Highlights given editor current line. :param editor: Document editor. :type editor: QWidget :return: Method success. :rtype: bool ### Response: def highlight_current_line(editor): """ Highlights given editor current line. :param editor: Document editor. :type editor: QWidget :return: Method success. :rtype: bool """ format = editor.language.theme.get("accelerator.line") if not format: return False extra_selections = editor.extraSelections() or [] if not editor.isReadOnly(): selection = QTextEdit.ExtraSelection() selection.format.setBackground(format.background()) selection.format.setProperty(QTextFormat.FullWidthSelection, True) selection.cursor = editor.textCursor() selection.cursor.clearSelection() extra_selections.append(selection) editor.setExtraSelections(extra_selections) 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, 97406, 2728, 6576, 1510, 1584, 382, 262, 551, 913, 6576, 25, 12051, 6576, 627, 262, 551, 1337, 6576, 25, 37378, 198, 262, 551, 693, 25, 6872, 2450, 627, 262, 551, 33613, 25, 1845, 271, 14711, 6075, 512, 755, 11415, 11327, 6665, 58064, 997, 262, 3270, 262, 53300, 2728, 6576, 1510, 1584, 382, 262, 551, 913, 6576, 25, 12051, 6576, 627, 262, 551, 1337, 6576, 25, 37378, 198, 262, 551, 693, 25, 6872, 2450, 627, 262, 551, 33613, 25, 1845, 198, 262, 12713, 262, 3645, 284, 6576, 32733, 30551, 673, 446, 44988, 40622, 11172, 1158, 262, 422, 539, 3645, 512, 286, 471, 3641, 271, 262, 5066, 24596, 82, 284, 6576, 49897, 11425, 82, 368, 477, 4260, 262, 422, 539, 6576, 2124, 21584, 4019, 286, 6727, 284, 66918, 4126, 5231, 2221, 11425, 746, 286, 6727, 8180, 22189, 21355, 11979, 2455, 286, 6727, 8180, 32333, 6386, 1199, 4152, 33138, 3408, 11425, 11, 3082, 340, 286, 6727, 21361, 284, 6576, 2858, 14885, 746, 286, 6727, 21361, 7578, 11425, 746, 286, 5066, 24596, 82, 2102, 57461, 340, 262, 6576, 995, 11873, 11425, 82, 84890, 24596, 82, 340, 262, 471, 3082, 198, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 97406, 2728, 6576, 1510, 1584, 382, 262, 551, 913, 6576, 25, 12051, 6576, 627, 262, 551, 1337, 6576, 25, 37378, 198, 262, 551, 693, 25, 6872, 2450, 627, 262, 551, 33613, 25, 1845, 271, 14711, 6075, 512, 755, 11415, 11327, 6665, 58064, 997, 262, 3270, 262, 53300, 2728, 6576, 1510, 1584, 382, 262, 551, 913, 6576, 25, 12051, 6576, 627, 262, 551, 1337, 6576, 25, 37378, 198, 262, 551, 693, 25, 6872, 2450, 627, 262, 551, 33613, 25, 1845, 198, 262, 12713, 262, 3645, 284, 6576, 32733, 30551, 673, 446, 44988, 40622, 11172, 1158, 262, 422, 539, 3645, 512, 286, 471, 3641, 271, 262, 5066, 24596, 82, 284, 6576, 49897, 11425, 82, 368, 477, 4260, 262, 422, 539, 6576, 2124, 21584, 4019, 286, 6727, 284, 66918, 4126, 5231, 2221, 11425, 746, 286, 6727, 8180, 22189, 21355, 11979, 2455, 286, 6727, 8180, 32333, 6386, 1199, 4152, 33138, 3408, 11425, 11, 3082, 340, 286, 6727, 21361, 284, 6576, 2858, 14885, 746, 286, 6727, 21361, 7578, 11425, 746, 286, 5066, 24596, 82, 2102, 57461, 340, 262, 6576, 995, 11873, 11425, 82, 84890, 24596, 82, 340, 262, 471, 3082, 198, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
bwohlberg/sporco
sporco/cnvrep.py
Pcn
def Pcn(x, dsz, Nv, dimN=2, dimC=1, crp=False, zm=False): """Constraint set projection for convolutional dictionary update problem. Parameters ---------- x : array_like Input array dsz : tuple Filter support size(s), specified using the same format as the `dsz` parameter of :func:`bcrop` Nv : tuple Sizes of problem spatial indices dimN : int, optional (default 2) Number of problem spatial indices dimC : int, optional (default 1) Number of problem channel indices crp : bool, optional (default False) Flag indicating whether the result should be cropped to the support of the largest filter in the dictionary. zm : bool, optional (default False) Flag indicating whether the projection function should include filter mean subtraction Returns ------- y : ndarray Projection of input onto constraint set """ if crp: def zpadfn(x): return x else: def zpadfn(x): return zpad(x, Nv) if zm: def zmeanfn(x): return zeromean(x, dsz, dimN) else: def zmeanfn(x): return x return normalise(zmeanfn(zpadfn(bcrop(x, dsz, dimN))), dimN + dimC)
python
def Pcn(x, dsz, Nv, dimN=2, dimC=1, crp=False, zm=False): """Constraint set projection for convolutional dictionary update problem. Parameters ---------- x : array_like Input array dsz : tuple Filter support size(s), specified using the same format as the `dsz` parameter of :func:`bcrop` Nv : tuple Sizes of problem spatial indices dimN : int, optional (default 2) Number of problem spatial indices dimC : int, optional (default 1) Number of problem channel indices crp : bool, optional (default False) Flag indicating whether the result should be cropped to the support of the largest filter in the dictionary. zm : bool, optional (default False) Flag indicating whether the projection function should include filter mean subtraction Returns ------- y : ndarray Projection of input onto constraint set """ if crp: def zpadfn(x): return x else: def zpadfn(x): return zpad(x, Nv) if zm: def zmeanfn(x): return zeromean(x, dsz, dimN) else: def zmeanfn(x): return x return normalise(zmeanfn(zpadfn(bcrop(x, dsz, dimN))), dimN + dimC)
[ "def", "Pcn", "(", "x", ",", "dsz", ",", "Nv", ",", "dimN", "=", "2", ",", "dimC", "=", "1", ",", "crp", "=", "False", ",", "zm", "=", "False", ")", ":", "if", "crp", ":", "def", "zpadfn", "(", "x", ")", ":", "return", "x", "else", ":", "def", "zpadfn", "(", "x", ")", ":", "return", "zpad", "(", "x", ",", "Nv", ")", "if", "zm", ":", "def", "zmeanfn", "(", "x", ")", ":", "return", "zeromean", "(", "x", ",", "dsz", ",", "dimN", ")", "else", ":", "def", "zmeanfn", "(", "x", ")", ":", "return", "x", "return", "normalise", "(", "zmeanfn", "(", "zpadfn", "(", "bcrop", "(", "x", ",", "dsz", ",", "dimN", ")", ")", ")", ",", "dimN", "+", "dimC", ")" ]
Constraint set projection for convolutional dictionary update problem. Parameters ---------- x : array_like Input array dsz : tuple Filter support size(s), specified using the same format as the `dsz` parameter of :func:`bcrop` Nv : tuple Sizes of problem spatial indices dimN : int, optional (default 2) Number of problem spatial indices dimC : int, optional (default 1) Number of problem channel indices crp : bool, optional (default False) Flag indicating whether the result should be cropped to the support of the largest filter in the dictionary. zm : bool, optional (default False) Flag indicating whether the projection function should include filter mean subtraction Returns ------- y : ndarray Projection of input onto constraint set
[ "Constraint", "set", "projection", "for", "convolutional", "dictionary", "update", "problem", "." ]
train
https://github.com/bwohlberg/sporco/blob/8946a04331106f4e39904fbdf2dc7351900baa04/sporco/cnvrep.py#L842-L886
<|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: Constraint set projection for convolutional dictionary update problem. Parameters ---------- x : array_like Input array dsz : tuple Filter support size(s), specified using the same format as the `dsz` parameter of :func:`bcrop` Nv : tuple Sizes of problem spatial indices dimN : int, optional (default 2) Number of problem spatial indices dimC : int, optional (default 1) Number of problem channel indices crp : bool, optional (default False) Flag indicating whether the result should be cropped to the support of the largest filter in the dictionary. zm : bool, optional (default False) Flag indicating whether the projection function should include filter mean subtraction Returns ------- y : ndarray Projection of input onto constraint set ### Response: def Pcn(x, dsz, Nv, dimN=2, dimC=1, crp=False, zm=False): """Constraint set projection for convolutional dictionary update problem. Parameters ---------- x : array_like Input array dsz : tuple Filter support size(s), specified using the same format as the `dsz` parameter of :func:`bcrop` Nv : tuple Sizes of problem spatial indices dimN : int, optional (default 2) Number of problem spatial indices dimC : int, optional (default 1) Number of problem channel indices crp : bool, optional (default False) Flag indicating whether the result should be cropped to the support of the largest filter in the dictionary. zm : bool, optional (default False) Flag indicating whether the projection function should include filter mean subtraction Returns ------- y : ndarray Projection of input onto constraint set """ if crp: def zpadfn(x): return x else: def zpadfn(x): return zpad(x, Nv) if zm: def zmeanfn(x): return zeromean(x, dsz, dimN) else: def zmeanfn(x): return x return normalise(zmeanfn(zpadfn(bcrop(x, dsz, dimN))), dimN + dimC) <|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, 18372, 743, 22343, 369, 56812, 278, 11240, 2713, 198, 262, 3575, 382, 262, 13831, 198, 262, 31423, 262, 865, 220, 551, 1358, 26616, 198, 415, 5688, 1358, 198, 262, 11729, 89, 551, 14743, 198, 415, 12619, 1862, 1404, 1161, 705, 5300, 1701, 279, 1890, 3645, 439, 279, 1595, 5469, 89, 4077, 415, 5852, 315, 551, 2900, 19258, 9081, 897, 4077, 262, 452, 85, 551, 14743, 198, 415, 71282, 315, 3575, 29079, 15285, 198, 262, 5213, 45, 551, 528, 11, 10309, 320, 2309, 220, 17, 340, 415, 5742, 315, 3575, 29079, 15285, 198, 262, 5213, 34, 551, 528, 11, 10309, 320, 2309, 220, 16, 340, 415, 5742, 315, 3575, 5613, 15285, 198, 262, 1589, 79, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 1121, 1288, 387, 61243, 311, 279, 1862, 198, 415, 315, 279, 7928, 4141, 304, 279, 11240, 627, 262, 48229, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 22343, 734, 1288, 2997, 198, 415, 4141, 3152, 76340, 271, 262, 5295, 198, 262, 39707, 262, 379, 551, 67983, 198, 415, 70415, 315, 1988, 8800, 22295, 743, 271, 14711, 6075, 512, 755, 393, 14606, 2120, 11, 11729, 89, 11, 452, 85, 11, 5213, 45, 28, 17, 11, 5213, 34, 28, 16, 11, 1589, 79, 5725, 11, 48229, 5725, 997, 262, 4304, 18372, 743, 22343, 369, 56812, 278, 11240, 2713, 198, 262, 3575, 382, 262, 13831, 198, 262, 31423, 262, 865, 220, 551, 1358, 26616, 198, 415, 5688, 1358, 198, 262, 11729, 89, 551, 14743, 198, 415, 12619, 1862, 1404, 1161, 705, 5300, 1701, 279, 1890, 3645, 439, 279, 1595, 5469, 89, 4077, 415, 5852, 315, 551, 2900, 19258, 9081, 897, 4077, 262, 452, 85, 551, 14743, 198, 415, 71282, 315, 3575, 29079, 15285, 198, 262, 5213, 45, 551, 528, 11, 10309, 320, 2309, 220, 17, 340, 415, 5742, 315, 3575, 29079, 15285, 198, 262, 5213, 34, 551, 528, 11, 10309, 320, 2309, 220, 16, 340, 415, 5742, 315, 3575, 5613, 15285, 198, 262, 1589, 79, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 1121, 1288, 387, 61243, 311, 279, 1862, 198, 415, 315, 279, 7928, 4141, 304, 279, 11240, 627, 262, 48229, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 22343, 734, 1288, 2997, 198, 415, 4141, 3152, 76340, 271, 262, 5295, 198, 262, 39707, 262, 379, 551, 67983, 198, 415, 70415, 315, 1988, 8800, 22295, 743, 198, 262, 12713, 262, 422, 1589, 79, 512, 286, 711, 1167, 13545, 8998, 2120, 997, 310, 471, 865, 198, 262, 775, 512, 286, 711, 1167, 13545, 8998, 2120, 997, 310, 471, 1167, 13545, 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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 18372, 743, 22343, 369, 56812, 278, 11240, 2713, 198, 262, 3575, 382, 262, 13831, 198, 262, 31423, 262, 865, 220, 551, 1358, 26616, 198, 415, 5688, 1358, 198, 262, 11729, 89, 551, 14743, 198, 415, 12619, 1862, 1404, 1161, 705, 5300, 1701, 279, 1890, 3645, 439, 279, 1595, 5469, 89, 4077, 415, 5852, 315, 551, 2900, 19258, 9081, 897, 4077, 262, 452, 85, 551, 14743, 198, 415, 71282, 315, 3575, 29079, 15285, 198, 262, 5213, 45, 551, 528, 11, 10309, 320, 2309, 220, 17, 340, 415, 5742, 315, 3575, 29079, 15285, 198, 262, 5213, 34, 551, 528, 11, 10309, 320, 2309, 220, 16, 340, 415, 5742, 315, 3575, 5613, 15285, 198, 262, 1589, 79, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 1121, 1288, 387, 61243, 311, 279, 1862, 198, 415, 315, 279, 7928, 4141, 304, 279, 11240, 627, 262, 48229, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 22343, 734, 1288, 2997, 198, 415, 4141, 3152, 76340, 271, 262, 5295, 198, 262, 39707, 262, 379, 551, 67983, 198, 415, 70415, 315, 1988, 8800, 22295, 743, 271, 14711, 6075, 512, 755, 393, 14606, 2120, 11, 11729, 89, 11, 452, 85, 11, 5213, 45, 28, 17, 11, 5213, 34, 28, 16, 11, 1589, 79, 5725, 11, 48229, 5725, 997, 262, 4304, 18372, 743, 22343, 369, 56812, 278, 11240, 2713, 198, 262, 3575, 382, 262, 13831, 198, 262, 31423, 262, 865, 220, 551, 1358, 26616, 198, 415, 5688, 1358, 198, 262, 11729, 89, 551, 14743, 198, 415, 12619, 1862, 1404, 1161, 705, 5300, 1701, 279, 1890, 3645, 439, 279, 1595, 5469, 89, 4077, 415, 5852, 315, 551, 2900, 19258, 9081, 897, 4077, 262, 452, 85, 551, 14743, 198, 415, 71282, 315, 3575, 29079, 15285, 198, 262, 5213, 45, 551, 528, 11, 10309, 320, 2309, 220, 17, 340, 415, 5742, 315, 3575, 29079, 15285, 198, 262, 5213, 34, 551, 528, 11, 10309, 320, 2309, 220, 16, 340, 415, 5742, 315, 3575, 5613, 15285, 198, 262, 1589, 79, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 1121, 1288, 387, 61243, 311, 279, 1862, 198, 415, 315, 279, 7928, 4141, 304, 279, 11240, 627, 262, 48229, 551, 1845, 11, 10309, 320, 2309, 3641, 340, 415, 23497, 19392, 3508, 279, 22343, 734, 1288, 2997, 198, 415, 4141, 3152, 76340, 271, 262, 5295, 198, 262, 39707, 262, 379, 551, 67983, 198, 415, 70415, 315, 1988, 8800, 22295, 743, 198, 262, 12713, 262, 422, 1589, 79, 512, 286, 711, 1167, 13545, 8998, 2120, 997, 310, 471, 865, 198, 262, 775, 512, 286, 711, 1167, 13545, 8998, 2120, 997, 310, 471, 1167, 13545, 2120, 11, 452, 85, 696, 262, 422, 48229, 512, 286, 711, 1167, 14622, 8998, 2120, 997, 310, 471, 77278, 638, 276, 2120, 11, 11729, 89, 11, 5213, 45, 340, 262, 775, 512, 286, 711 ]
AmesCornish/buttersink
buttersink/Store.py
Volume.writeInfo
def writeInfo(self, stream): """ Write information about diffs into a file stream for use later. """ for (fromUUID, size) in Diff.theKnownSizes[self.uuid].iteritems(): self.writeInfoLine(stream, fromUUID, size)
python
def writeInfo(self, stream): """ Write information about diffs into a file stream for use later. """ for (fromUUID, size) in Diff.theKnownSizes[self.uuid].iteritems(): self.writeInfoLine(stream, fromUUID, size)
[ "def", "writeInfo", "(", "self", ",", "stream", ")", ":", "for", "(", "fromUUID", ",", "size", ")", "in", "Diff", ".", "theKnownSizes", "[", "self", ".", "uuid", "]", ".", "iteritems", "(", ")", ":", "self", ".", "writeInfoLine", "(", "stream", ",", "fromUUID", ",", "size", ")" ]
Write information about diffs into a file stream for use later.
[ "Write", "information", "about", "diffs", "into", "a", "file", "stream", "for", "use", "later", "." ]
train
https://github.com/AmesCornish/buttersink/blob/5cc37e30d9f8071fcf3497dca8b8a91b910321ea/buttersink/Store.py#L438-L441
<|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: Write information about diffs into a file stream for use later. ### Response: def writeInfo(self, stream): """ Write information about diffs into a file stream for use later. """ for (fromUUID, size) in Diff.theKnownSizes[self.uuid].iteritems(): self.writeInfoLine(stream, fromUUID, size) <|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, 8144, 2038, 922, 88047, 1139, 264, 1052, 4365, 369, 1005, 3010, 382, 14711, 6075, 512, 755, 3350, 1767, 1214, 11, 4365, 997, 286, 4304, 9842, 2038, 922, 88047, 1139, 264, 1052, 4365, 369, 1005, 3010, 13, 3270, 286, 369, 320, 1527, 25786, 11, 1404, 8, 304, 29469, 42901, 49306, 36030, 14664, 32247, 948, 2058, 3699, 4019, 310, 659, 3921, 1767, 2519, 21217, 11, 505, 25786, 11, 1404, 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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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 8144, 2038, 922, 88047, 1139, 264, 1052, 4365, 369, 1005, 3010, 382, 14711, 6075, 512, 755, 3350, 1767, 1214, 11, 4365, 997, 286, 4304, 9842, 2038, 922, 88047, 1139, 264, 1052, 4365, 369, 1005, 3010, 13, 3270, 286, 369, 320, 1527, 25786, 11, 1404, 8, 304, 29469, 42901, 49306, 36030, 14664, 32247, 948, 2058, 3699, 4019, 310, 659, 3921, 1767, 2519, 21217, 11, 505, 25786, 11, 1404, 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 ]
uranusjr/django-gunicorn
djgunicorn/config.py
post_worker_init
def post_worker_init(worker): """Hook into Gunicorn to display message after launching. This mimics the behaviour of Django's stock runserver command. """ quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C' sys.stdout.write( "Django version {djangover}, Gunicorn version {gunicornver}, " "using settings {settings!r}\n" "Starting development server at {urls}\n" "Quit the server with {quit_command}.\n".format( djangover=django.get_version(), gunicornver=gunicorn.__version__, settings=os.environ.get('DJANGO_SETTINGS_MODULE'), urls=', '.join('http://{0}/'.format(b) for b in worker.cfg.bind), quit_command=quit_command, ), )
python
def post_worker_init(worker): """Hook into Gunicorn to display message after launching. This mimics the behaviour of Django's stock runserver command. """ quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C' sys.stdout.write( "Django version {djangover}, Gunicorn version {gunicornver}, " "using settings {settings!r}\n" "Starting development server at {urls}\n" "Quit the server with {quit_command}.\n".format( djangover=django.get_version(), gunicornver=gunicorn.__version__, settings=os.environ.get('DJANGO_SETTINGS_MODULE'), urls=', '.join('http://{0}/'.format(b) for b in worker.cfg.bind), quit_command=quit_command, ), )
[ "def", "post_worker_init", "(", "worker", ")", ":", "quit_command", "=", "'CTRL-BREAK'", "if", "sys", ".", "platform", "==", "'win32'", "else", "'CONTROL-C'", "sys", ".", "stdout", ".", "write", "(", "\"Django version {djangover}, Gunicorn version {gunicornver}, \"", "\"using settings {settings!r}\\n\"", "\"Starting development server at {urls}\\n\"", "\"Quit the server with {quit_command}.\\n\"", ".", "format", "(", "djangover", "=", "django", ".", "get_version", "(", ")", ",", "gunicornver", "=", "gunicorn", ".", "__version__", ",", "settings", "=", "os", ".", "environ", ".", "get", "(", "'DJANGO_SETTINGS_MODULE'", ")", ",", "urls", "=", "', '", ".", "join", "(", "'http://{0}/'", ".", "format", "(", "b", ")", "for", "b", "in", "worker", ".", "cfg", ".", "bind", ")", ",", "quit_command", "=", "quit_command", ",", ")", ",", ")" ]
Hook into Gunicorn to display message after launching. This mimics the behaviour of Django's stock runserver command.
[ "Hook", "into", "Gunicorn", "to", "display", "message", "after", "launching", "." ]
train
https://github.com/uranusjr/django-gunicorn/blob/4fb16f48048ff5fff8f889a007f376236646497b/djgunicorn/config.py#L18-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: Hook into Gunicorn to display message after launching. This mimics the behaviour of Django's stock runserver command. ### Response: def post_worker_init(worker): """Hook into Gunicorn to display message after launching. This mimics the behaviour of Django's stock runserver command. """ quit_command = 'CTRL-BREAK' if sys.platform == 'win32' else 'CONTROL-C' sys.stdout.write( "Django version {djangover}, Gunicorn version {gunicornver}, " "using settings {settings!r}\n" "Starting development server at {urls}\n" "Quit the server with {quit_command}.\n".format( djangover=django.get_version(), gunicornver=gunicorn.__version__, settings=os.environ.get('DJANGO_SETTINGS_MODULE'), urls=', '.join('http://{0}/'.format(b) for b in worker.cfg.bind), quit_command=quit_command, ), ) <|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, 32779, 1139, 480, 93457, 311, 3113, 1984, 1306, 28818, 382, 262, 1115, 28003, 1233, 279, 17432, 315, 53704, 596, 5708, 1629, 4120, 3290, 382, 14711, 6075, 512, 755, 1772, 41485, 6265, 74848, 997, 262, 4304, 32779, 1139, 480, 93457, 311, 3113, 1984, 1306, 28818, 382, 262, 1115, 28003, 1233, 279, 17432, 315, 53704, 596, 5708, 1629, 4120, 3290, 627, 262, 3270, 262, 17257, 11045, 284, 364, 35540, 7826, 33882, 6, 422, 5826, 25723, 624, 364, 7678, 843, 6, 775, 364, 69995, 7813, 1270, 262, 5826, 25880, 3921, 1021, 286, 330, 35, 5970, 2373, 314, 67, 38627, 2017, 2186, 480, 93457, 2373, 314, 70, 93457, 424, 2186, 6360, 286, 330, 985, 5110, 314, 6648, 0, 81, 11281, 77, 702, 286, 330, 25639, 4500, 3622, 520, 314, 21141, 11281, 77, 702, 286, 330, 43956, 279, 3622, 449, 314, 32637, 11045, 92, 7255, 77, 3343, 2293, 1021, 310, 294, 38627, 2017, 28, 13887, 673, 9625, 3227, 310, 342, 93457, 424, 38262, 93457, 4952, 4464, 49666, 310, 5110, 51964, 24656, 673, 493, 54372, 75269, 35289, 14280, 3379, 310, 31084, 18123, 6389, 6115, 493, 1277, 82876, 15, 4572, 4527, 2293, 1921, 8, 369, 293, 304, 12128, 31581, 6218, 1350, 310, 17257, 11045, 28, 32637, 11045, 345, 286, 2907, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 32779, 1139, 480, 93457, 311, 3113, 1984, 1306, 28818, 382, 262, 1115, 28003, 1233, 279, 17432, 315, 53704, 596, 5708, 1629, 4120, 3290, 382, 14711, 6075, 512, 755, 1772, 41485, 6265, 74848, 997, 262, 4304, 32779, 1139, 480, 93457, 311, 3113, 1984, 1306, 28818, 382, 262, 1115, 28003, 1233, 279, 17432, 315, 53704, 596, 5708, 1629, 4120, 3290, 627, 262, 3270, 262, 17257, 11045, 284, 364, 35540, 7826, 33882, 6, 422, 5826, 25723, 624, 364, 7678, 843, 6, 775, 364, 69995, 7813, 1270, 262, 5826, 25880, 3921, 1021, 286, 330, 35, 5970, 2373, 314, 67, 38627, 2017, 2186, 480, 93457, 2373, 314, 70, 93457, 424, 2186, 6360, 286, 330, 985, 5110, 314, 6648, 0, 81, 11281, 77, 702, 286, 330, 25639, 4500, 3622, 520, 314, 21141, 11281, 77, 702, 286, 330, 43956, 279, 3622, 449, 314, 32637, 11045, 92, 7255, 77, 3343, 2293, 1021, 310, 294, 38627, 2017, 28, 13887, 673, 9625, 3227, 310, 342, 93457, 424, 38262, 93457, 4952, 4464, 49666, 310, 5110, 51964, 24656, 673, 493, 54372, 75269, 35289, 14280, 3379, 310, 31084, 18123, 6389, 6115, 493, 1277, 82876, 15, 4572, 4527, 2293, 1921, 8, 369, 293, 304, 12128, 31581, 6218, 1350, 310, 17257, 11045, 28, 32637, 11045, 345, 286, 2907, 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 ]
xenon-middleware/pyxenon
xenon/server.py
find_free_port
def find_free_port(): """Finds a free port.""" with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: sock.bind(('', 0)) return sock.getsockname()[1]
python
def find_free_port(): """Finds a free port.""" with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: sock.bind(('', 0)) return sock.getsockname()[1]
[ "def", "find_free_port", "(", ")", ":", "with", "closing", "(", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", ")", "as", "sock", ":", "sock", ".", "bind", "(", "(", "''", ",", "0", ")", ")", "return", "sock", ".", "getsockname", "(", ")", "[", "1", "]" ]
Finds a free port.
[ "Finds", "a", "free", "port", "." ]
train
https://github.com/xenon-middleware/pyxenon/blob/d61109ad339ee9bb9f0723471d532727b0f235ad/xenon/server.py#L39-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: Finds a free port. ### Response: def find_free_port(): """Finds a free port.""" with closing(socket.socket(socket.AF_INET, socket.SOCK_STREAM)) as sock: sock.bind(('', 0)) return sock.getsockname()[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, 37, 8843, 264, 1949, 2700, 382, 14711, 6075, 512, 755, 1505, 9082, 8889, 4019, 262, 4304, 37, 8843, 264, 1949, 2700, 14781, 262, 449, 15676, 28148, 27015, 28148, 71960, 27932, 11, 7728, 80022, 24500, 595, 439, 11334, 512, 286, 11334, 6218, 7, 24197, 220, 15, 1192, 286, 471, 11334, 673, 13501, 609, 10324, 16, 933, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 37, 8843, 264, 1949, 2700, 382, 14711, 6075, 512, 755, 1505, 9082, 8889, 4019, 262, 4304, 37, 8843, 264, 1949, 2700, 14781, 262, 449, 15676, 28148, 27015, 28148, 71960, 27932, 11, 7728, 80022, 24500, 595, 439, 11334, 512, 286, 11334, 6218, 7, 24197, 220, 15, 1192, 286, 471, 11334, 673, 13501, 609, 10324, 16, 933, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
dixudx/rtcclient
rtcclient/query.py
Query.runSavedQueryByUrl
def runSavedQueryByUrl(self, saved_query_url, returned_properties=None): """Query workitems using the saved query url :param saved_query_url: the saved query url :param returned_properties: the returned properties that you want. Refer to :class:`rtcclient.client.RTCClient` for more explanations :return: a :class:`list` that contains the queried :class:`rtcclient.workitem.Workitem` objects :rtype: list """ try: if "=" not in saved_query_url: raise exception.BadValue() saved_query_id = saved_query_url.split("=")[-1] if not saved_query_id: raise exception.BadValue() except: error_msg = "No saved query id is found in the url" self.log.error(error_msg) raise exception.BadValue(error_msg) return self._runSavedQuery(saved_query_id, returned_properties=returned_properties)
python
def runSavedQueryByUrl(self, saved_query_url, returned_properties=None): """Query workitems using the saved query url :param saved_query_url: the saved query url :param returned_properties: the returned properties that you want. Refer to :class:`rtcclient.client.RTCClient` for more explanations :return: a :class:`list` that contains the queried :class:`rtcclient.workitem.Workitem` objects :rtype: list """ try: if "=" not in saved_query_url: raise exception.BadValue() saved_query_id = saved_query_url.split("=")[-1] if not saved_query_id: raise exception.BadValue() except: error_msg = "No saved query id is found in the url" self.log.error(error_msg) raise exception.BadValue(error_msg) return self._runSavedQuery(saved_query_id, returned_properties=returned_properties)
[ "def", "runSavedQueryByUrl", "(", "self", ",", "saved_query_url", ",", "returned_properties", "=", "None", ")", ":", "try", ":", "if", "\"=\"", "not", "in", "saved_query_url", ":", "raise", "exception", ".", "BadValue", "(", ")", "saved_query_id", "=", "saved_query_url", ".", "split", "(", "\"=\"", ")", "[", "-", "1", "]", "if", "not", "saved_query_id", ":", "raise", "exception", ".", "BadValue", "(", ")", "except", ":", "error_msg", "=", "\"No saved query id is found in the url\"", "self", ".", "log", ".", "error", "(", "error_msg", ")", "raise", "exception", ".", "BadValue", "(", "error_msg", ")", "return", "self", ".", "_runSavedQuery", "(", "saved_query_id", ",", "returned_properties", "=", "returned_properties", ")" ]
Query workitems using the saved query url :param saved_query_url: the saved query url :param returned_properties: the returned properties that you want. Refer to :class:`rtcclient.client.RTCClient` for more explanations :return: a :class:`list` that contains the queried :class:`rtcclient.workitem.Workitem` objects :rtype: list
[ "Query", "workitems", "using", "the", "saved", "query", "url" ]
train
https://github.com/dixudx/rtcclient/blob/1721dd0b047478f5bdd6359b07a2c503cfafd86f/rtcclient/query.py#L184-L206
<|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: Query workitems using the saved query url :param saved_query_url: the saved query url :param returned_properties: the returned properties that you want. Refer to :class:`rtcclient.client.RTCClient` for more explanations :return: a :class:`list` that contains the queried :class:`rtcclient.workitem.Workitem` objects :rtype: list ### Response: def runSavedQueryByUrl(self, saved_query_url, returned_properties=None): """Query workitems using the saved query url :param saved_query_url: the saved query url :param returned_properties: the returned properties that you want. Refer to :class:`rtcclient.client.RTCClient` for more explanations :return: a :class:`list` that contains the queried :class:`rtcclient.workitem.Workitem` objects :rtype: list """ try: if "=" not in saved_query_url: raise exception.BadValue() saved_query_id = saved_query_url.split("=")[-1] if not saved_query_id: raise exception.BadValue() except: error_msg = "No saved query id is found in the url" self.log.error(error_msg) raise exception.BadValue(error_msg) return self._runSavedQuery(saved_query_id, returned_properties=returned_properties) <|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, 2929, 990, 3699, 1701, 279, 6924, 3319, 2576, 271, 286, 551, 913, 6924, 5857, 2975, 25, 279, 6924, 3319, 2576, 198, 286, 551, 913, 6052, 26216, 25, 279, 6052, 6012, 430, 499, 1390, 627, 310, 29734, 311, 551, 1058, 19258, 46992, 3045, 6718, 2056, 7905, 3032, 63, 369, 810, 41941, 198, 286, 551, 693, 25, 264, 551, 1058, 19258, 1638, 63, 430, 5727, 279, 79002, 198, 310, 551, 1058, 19258, 46992, 3045, 18786, 1224, 29848, 1224, 63, 6302, 198, 286, 551, 33613, 25, 1160, 271, 14711, 6075, 512, 755, 1629, 42233, 2929, 92880, 1214, 11, 6924, 5857, 2975, 11, 6052, 26216, 5980, 997, 286, 4304, 2929, 990, 3699, 1701, 279, 6924, 3319, 2576, 271, 286, 551, 913, 6924, 5857, 2975, 25, 279, 6924, 3319, 2576, 198, 286, 551, 913, 6052, 26216, 25, 279, 6052, 6012, 430, 499, 1390, 627, 310, 29734, 311, 551, 1058, 19258, 46992, 3045, 6718, 2056, 7905, 3032, 63, 369, 810, 41941, 198, 286, 551, 693, 25, 264, 551, 1058, 19258, 1638, 63, 430, 5727, 279, 79002, 198, 310, 551, 1058, 19258, 46992, 3045, 18786, 1224, 29848, 1224, 63, 6302, 198, 286, 551, 33613, 25, 1160, 198, 286, 12713, 286, 1456, 512, 310, 422, 37334, 539, 304, 6924, 5857, 2975, 512, 394, 4933, 4788, 47046, 1150, 746, 310, 6924, 5857, 851, 284, 6924, 5857, 2975, 5402, 67477, 93478, 16, 933, 310, 422, 539, 6924, 5857, 851, 512, 394, 4933, 4788, 47046, 1150, 746, 286, 3734, 512, 310, 1493, 6619, 284, 330, 2822, 6924, 3319, 887, 374, 1766, 304, 279, 2576, 702, 310, 659, 1699, 4517, 6524, 6619, 340, 310, 4933, 4788, 47046, 1150, 6524, 6619, 340, 286, 471, 659, 1462, 6236, 42233, 2929, 14551, 5857, 851, 345, 9898, 6052, 26216, 28, 78691, 26216, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 2929, 990, 3699, 1701, 279, 6924, 3319, 2576, 271, 286, 551, 913, 6924, 5857, 2975, 25, 279, 6924, 3319, 2576, 198, 286, 551, 913, 6052, 26216, 25, 279, 6052, 6012, 430, 499, 1390, 627, 310, 29734, 311, 551, 1058, 19258, 46992, 3045, 6718, 2056, 7905, 3032, 63, 369, 810, 41941, 198, 286, 551, 693, 25, 264, 551, 1058, 19258, 1638, 63, 430, 5727, 279, 79002, 198, 310, 551, 1058, 19258, 46992, 3045, 18786, 1224, 29848, 1224, 63, 6302, 198, 286, 551, 33613, 25, 1160, 271, 14711, 6075, 512, 755, 1629, 42233, 2929, 92880, 1214, 11, 6924, 5857, 2975, 11, 6052, 26216, 5980, 997, 286, 4304, 2929, 990, 3699, 1701, 279, 6924, 3319, 2576, 271, 286, 551, 913, 6924, 5857, 2975, 25, 279, 6924, 3319, 2576, 198, 286, 551, 913, 6052, 26216, 25, 279, 6052, 6012, 430, 499, 1390, 627, 310, 29734, 311, 551, 1058, 19258, 46992, 3045, 6718, 2056, 7905, 3032, 63, 369, 810, 41941, 198, 286, 551, 693, 25, 264, 551, 1058, 19258, 1638, 63, 430, 5727, 279, 79002, 198, 310, 551, 1058, 19258, 46992, 3045, 18786, 1224, 29848, 1224, 63, 6302, 198, 286, 551, 33613, 25, 1160, 198, 286, 12713, 286, 1456, 512, 310, 422, 37334, 539, 304, 6924, 5857, 2975, 512, 394, 4933, 4788, 47046, 1150, 746, 310, 6924, 5857, 851, 284, 6924, 5857, 2975, 5402, 67477, 93478, 16, 933, 310, 422, 539, 6924, 5857, 851, 512, 394, 4933, 4788, 47046, 1150, 746, 286, 3734, 512, 310, 1493, 6619, 284, 330, 2822, 6924, 3319, 887, 374, 1766, 304, 279, 2576, 702, 310, 659, 1699, 4517, 6524, 6619, 340, 310, 4933, 4788, 47046, 1150, 6524, 6619, 340, 286, 471, 659, 1462, 6236, 42233, 2929, 14551, 5857, 851, 345, 9898, 6052, 26216, 28, 78691, 26216, 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 ]
mgraffg/EvoDAG
EvoDAG/base.py
EvoDAG.predict
def predict(self, v=None, X=None): """In classification this returns the classes, in regression it is equivalent to the decision function""" if X is None: X = v v = None m = self.model(v=v) return m.predict(X)
python
def predict(self, v=None, X=None): """In classification this returns the classes, in regression it is equivalent to the decision function""" if X is None: X = v v = None m = self.model(v=v) return m.predict(X)
[ "def", "predict", "(", "self", ",", "v", "=", "None", ",", "X", "=", "None", ")", ":", "if", "X", "is", "None", ":", "X", "=", "v", "v", "=", "None", "m", "=", "self", ".", "model", "(", "v", "=", "v", ")", "return", "m", ".", "predict", "(", "X", ")" ]
In classification this returns the classes, in regression it is equivalent to the decision function
[ "In", "classification", "this", "returns", "the", "classes", "in", "regression", "it", "is", "equivalent", "to", "the", "decision", "function" ]
train
https://github.com/mgraffg/EvoDAG/blob/e11fa1fd1ca9e69cca92696c86661a3dc7b3a1d5/EvoDAG/base.py#L598-L605
<|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: In classification this returns the classes, in regression it is equivalent to the decision function ### Response: def predict(self, v=None, X=None): """In classification this returns the classes, in regression it is equivalent to the decision function""" if X is None: X = v v = None m = self.model(v=v) return m.predict(X) <|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, 644, 24790, 420, 4780, 279, 6989, 11, 304, 198, 286, 31649, 433, 374, 13890, 311, 279, 5597, 734, 271, 14711, 6075, 512, 755, 7168, 1214, 11, 348, 5980, 11, 1630, 5980, 997, 286, 4304, 644, 24790, 420, 4780, 279, 6989, 11, 304, 198, 286, 31649, 433, 374, 13890, 311, 279, 5597, 734, 7275, 286, 422, 1630, 374, 2290, 512, 310, 1630, 284, 348, 198, 310, 348, 284, 2290, 198, 286, 296, 284, 659, 3272, 3832, 40354, 340, 286, 471, 296, 24706, 7799, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 644, 24790, 420, 4780, 279, 6989, 11, 304, 198, 286, 31649, 433, 374, 13890, 311, 279, 5597, 734, 271, 14711, 6075, 512, 755, 7168, 1214, 11, 348, 5980, 11, 1630, 5980, 997, 286, 4304, 644, 24790, 420, 4780, 279, 6989, 11, 304, 198, 286, 31649, 433, 374, 13890, 311, 279, 5597, 734, 7275, 286, 422, 1630, 374, 2290, 512, 310, 1630, 284, 348, 198, 310, 348, 284, 2290, 198, 286, 296, 284, 659, 3272, 3832, 40354, 340, 286, 471, 296, 24706, 7799, 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 ]
newville/wxmplot
examples/tifffile.py
_replace_by
def _replace_by(module_function, warn=False): """Try replace decorated function by module.function.""" def decorate(func, module_function=module_function, warn=warn): sys.path.append(os.path.dirname(__file__)) try: module, function = module_function.split('.') func, oldfunc = getattr(__import__(module), function), func globals()['__old_' + func.__name__] = oldfunc except Exception: if warn: warnings.warn("failed to import %s" % module_function) sys.path.pop() return func return decorate
python
def _replace_by(module_function, warn=False): """Try replace decorated function by module.function.""" def decorate(func, module_function=module_function, warn=warn): sys.path.append(os.path.dirname(__file__)) try: module, function = module_function.split('.') func, oldfunc = getattr(__import__(module), function), func globals()['__old_' + func.__name__] = oldfunc except Exception: if warn: warnings.warn("failed to import %s" % module_function) sys.path.pop() return func return decorate
[ "def", "_replace_by", "(", "module_function", ",", "warn", "=", "False", ")", ":", "def", "decorate", "(", "func", ",", "module_function", "=", "module_function", ",", "warn", "=", "warn", ")", ":", "sys", ".", "path", ".", "append", "(", "os", ".", "path", ".", "dirname", "(", "__file__", ")", ")", "try", ":", "module", ",", "function", "=", "module_function", ".", "split", "(", "'.'", ")", "func", ",", "oldfunc", "=", "getattr", "(", "__import__", "(", "module", ")", ",", "function", ")", ",", "func", "globals", "(", ")", "[", "'__old_'", "+", "func", ".", "__name__", "]", "=", "oldfunc", "except", "Exception", ":", "if", "warn", ":", "warnings", ".", "warn", "(", "\"failed to import %s\"", "%", "module_function", ")", "sys", ".", "path", ".", "pop", "(", ")", "return", "func", "return", "decorate" ]
Try replace decorated function by module.function.
[ "Try", "replace", "decorated", "function", "by", "module", ".", "function", "." ]
train
https://github.com/newville/wxmplot/blob/8e0dc037453e5cdf18c968dc5a3d29efd761edee/examples/tifffile.py#L1517-L1531
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Try replace decorated function by module.function. ### Response: def _replace_by(module_function, warn=False): """Try replace decorated function by module.function.""" def decorate(func, module_function=module_function, warn=warn): sys.path.append(os.path.dirname(__file__)) try: module, function = module_function.split('.') func, oldfunc = getattr(__import__(module), function), func globals()['__old_' + func.__name__] = oldfunc except Exception: if warn: warnings.warn("failed to import %s" % module_function) sys.path.pop() return func return decorate <|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, 22170, 8454, 37109, 734, 555, 4793, 20687, 382, 14711, 6075, 512, 755, 721, 8319, 3795, 19669, 9353, 11, 8985, 5725, 997, 262, 4304, 22170, 8454, 37109, 734, 555, 4793, 20687, 14781, 262, 711, 57681, 19062, 11, 4793, 9353, 28, 4450, 9353, 11, 8985, 28, 34581, 997, 286, 5826, 3960, 2102, 9835, 3960, 21803, 5630, 1213, 65213, 286, 1456, 512, 310, 4793, 11, 734, 284, 4793, 9353, 5402, 99755, 310, 2988, 11, 2362, 2900, 284, 31097, 5630, 475, 3889, 4450, 705, 734, 705, 2988, 198, 310, 38885, 39715, 565, 820, 19893, 489, 2988, 4952, 609, 565, 60, 284, 2362, 2900, 198, 286, 3734, 4204, 512, 310, 422, 8985, 512, 394, 19530, 22123, 446, 16479, 311, 1179, 1034, 82, 1, 1034, 4793, 9353, 340, 286, 5826, 3960, 8452, 746, 286, 471, 2988, 271, 262, 471, 57681, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 22170, 8454, 37109, 734, 555, 4793, 20687, 382, 14711, 6075, 512, 755, 721, 8319, 3795, 19669, 9353, 11, 8985, 5725, 997, 262, 4304, 22170, 8454, 37109, 734, 555, 4793, 20687, 14781, 262, 711, 57681, 19062, 11, 4793, 9353, 28, 4450, 9353, 11, 8985, 28, 34581, 997, 286, 5826, 3960, 2102, 9835, 3960, 21803, 5630, 1213, 65213, 286, 1456, 512, 310, 4793, 11, 734, 284, 4793, 9353, 5402, 99755, 310, 2988, 11, 2362, 2900, 284, 31097, 5630, 475, 3889, 4450, 705, 734, 705, 2988, 198, 310, 38885, 39715, 565, 820, 19893, 489, 2988, 4952, 609, 565, 60, 284, 2362, 2900, 198, 286, 3734, 4204, 512, 310, 422, 8985, 512, 394, 19530, 22123, 446, 16479, 311, 1179, 1034, 82, 1, 1034, 4793, 9353, 340, 286, 5826, 3960, 8452, 746, 286, 471, 2988, 271, 262, 471, 57681, 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 ]
mbedmicro/pyOCD
pyocd/utility/conversion.py
u64_to_hex16le
def u64_to_hex16le(val): """! @brief Create 16-digit hexadecimal string from 64-bit register value""" return ''.join("%02x" % (x & 0xFF) for x in ( val, val >> 8, val >> 16, val >> 24, val >> 32, val >> 40, val >> 48, val >> 56, ))
python
def u64_to_hex16le(val): """! @brief Create 16-digit hexadecimal string from 64-bit register value""" return ''.join("%02x" % (x & 0xFF) for x in ( val, val >> 8, val >> 16, val >> 24, val >> 32, val >> 40, val >> 48, val >> 56, ))
[ "def", "u64_to_hex16le", "(", "val", ")", ":", "return", "''", ".", "join", "(", "\"%02x\"", "%", "(", "x", "&", "0xFF", ")", "for", "x", "in", "(", "val", ",", "val", ">>", "8", ",", "val", ">>", "16", ",", "val", ">>", "24", ",", "val", ">>", "32", ",", "val", ">>", "40", ",", "val", ">>", "48", ",", "val", ">>", "56", ",", ")", ")" ]
! @brief Create 16-digit hexadecimal string from 64-bit register value
[ "!" ]
train
https://github.com/mbedmicro/pyOCD/blob/41a174718a9739f3cbe785c2ba21cb7fd1310c6f/pyocd/utility/conversion.py#L92-L103
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: ! @brief Create 16-digit hexadecimal string from 64-bit register value ### Response: def u64_to_hex16le(val): """! @brief Create 16-digit hexadecimal string from 64-bit register value""" return ''.join("%02x" % (x & 0xFF) for x in ( val, val >> 8, val >> 16, val >> 24, val >> 32, val >> 40, val >> 48, val >> 56, )) <|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, 0, 571, 6796, 4324, 220, 845, 49442, 70822, 925, 505, 220, 1227, 15615, 4254, 907, 271, 14711, 6075, 512, 755, 577, 1227, 2401, 33755, 845, 273, 9276, 997, 262, 4304, 0, 571, 6796, 4324, 220, 845, 49442, 70822, 925, 505, 220, 1227, 15615, 4254, 907, 7275, 262, 471, 43963, 6115, 4530, 2437, 87, 1, 1034, 320, 87, 612, 220, 15, 9448, 8, 369, 865, 304, 2456, 286, 1062, 345, 286, 1062, 3662, 220, 23, 345, 286, 1062, 3662, 220, 845, 345, 286, 1062, 3662, 220, 1187, 345, 286, 1062, 3662, 220, 843, 345, 286, 1062, 3662, 220, 1272, 345, 286, 1062, 3662, 220, 2166, 345, 286, 1062, 3662, 220, 3487, 345, 262, 19800, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 0, 571, 6796, 4324, 220, 845, 49442, 70822, 925, 505, 220, 1227, 15615, 4254, 907, 271, 14711, 6075, 512, 755, 577, 1227, 2401, 33755, 845, 273, 9276, 997, 262, 4304, 0, 571, 6796, 4324, 220, 845, 49442, 70822, 925, 505, 220, 1227, 15615, 4254, 907, 7275, 262, 471, 43963, 6115, 4530, 2437, 87, 1, 1034, 320, 87, 612, 220, 15, 9448, 8, 369, 865, 304, 2456, 286, 1062, 345, 286, 1062, 3662, 220, 23, 345, 286, 1062, 3662, 220, 845, 345, 286, 1062, 3662, 220, 1187, 345, 286, 1062, 3662, 220, 843, 345, 286, 1062, 3662, 220, 1272, 345, 286, 1062, 3662, 220, 2166, 345, 286, 1062, 3662, 220, 3487, 345, 262, 19800, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
jsvine/spectra
spectra/grapefruit.py
Color.RgbToWebSafe
def RgbToWebSafe(r, g, b, alt=False): '''Convert the color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color instead of the nearest one. Can be used for dithering. Returns: The color as an (r, g, b) tuple in the range: the range: r[0...1], g[0...1], b[0...1] >>> '(%g, %g, %g)' % Color.RgbToWebSafe(1, 0.55, 0.0) '(1, 0.6, 0)' ''' webSafeComponent = Color._WebSafeComponent return tuple((webSafeComponent(v, alt) for v in (r, g, b)))
python
def RgbToWebSafe(r, g, b, alt=False): '''Convert the color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color instead of the nearest one. Can be used for dithering. Returns: The color as an (r, g, b) tuple in the range: the range: r[0...1], g[0...1], b[0...1] >>> '(%g, %g, %g)' % Color.RgbToWebSafe(1, 0.55, 0.0) '(1, 0.6, 0)' ''' webSafeComponent = Color._WebSafeComponent return tuple((webSafeComponent(v, alt) for v in (r, g, b)))
[ "def", "RgbToWebSafe", "(", "r", ",", "g", ",", "b", ",", "alt", "=", "False", ")", ":", "webSafeComponent", "=", "Color", ".", "_WebSafeComponent", "return", "tuple", "(", "(", "webSafeComponent", "(", "v", ",", "alt", ")", "for", "v", "in", "(", "r", ",", "g", ",", "b", ")", ")", ")" ]
Convert the color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color instead of the nearest one. Can be used for dithering. Returns: The color as an (r, g, b) tuple in the range: the range: r[0...1], g[0...1], b[0...1] >>> '(%g, %g, %g)' % Color.RgbToWebSafe(1, 0.55, 0.0) '(1, 0.6, 0)'
[ "Convert", "the", "color", "from", "RGB", "to", "web", "safe", "RGB" ]
train
https://github.com/jsvine/spectra/blob/2269a0ae9b5923154b15bd661fb81179608f7ec2/spectra/grapefruit.py#L1080-L1106
<|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 color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color instead of the nearest one. Can be used for dithering. Returns: The color as an (r, g, b) tuple in the range: the range: r[0...1], g[0...1], b[0...1] >>> '(%g, %g, %g)' % Color.RgbToWebSafe(1, 0.55, 0.0) '(1, 0.6, 0)' ### Response: def RgbToWebSafe(r, g, b, alt=False): '''Convert the color from RGB to 'web safe' RGB Parameters: :r: The Red component value [0...1] :g: The Green component value [0...1] :b: The Blue component value [0...1] :alt: If True, use the alternative color instead of the nearest one. Can be used for dithering. Returns: The color as an (r, g, b) tuple in the range: the range: r[0...1], g[0...1], b[0...1] >>> '(%g, %g, %g)' % Color.RgbToWebSafe(1, 0.55, 0.0) '(1, 0.6, 0)' ''' webSafeComponent = Color._WebSafeComponent return tuple((webSafeComponent(v, alt) for v in (r, g, b))) <|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, 1933, 505, 21653, 311, 364, 2984, 6220, 6, 21653, 271, 262, 13831, 512, 415, 551, 81, 512, 286, 578, 3816, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 70, 512, 286, 578, 7997, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 65, 512, 286, 578, 8868, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 3223, 512, 286, 1442, 3082, 11, 1005, 279, 10778, 1933, 4619, 315, 279, 24379, 832, 627, 286, 3053, 387, 1511, 369, 294, 2544, 287, 382, 262, 5295, 512, 415, 578, 1933, 439, 459, 320, 81, 11, 342, 11, 293, 8, 14743, 304, 279, 2134, 512, 415, 279, 2134, 512, 415, 436, 58, 15, 1131, 16, 1282, 415, 342, 58, 15, 1131, 16, 1282, 415, 293, 58, 15, 1131, 16, 2595, 262, 12382, 364, 15595, 70, 11, 1034, 70, 11, 1034, 70, 22367, 1034, 3562, 2056, 9701, 1271, 6109, 26747, 7, 16, 11, 220, 15, 13, 2131, 11, 220, 15, 13, 15, 340, 262, 22796, 16, 11, 220, 15, 13, 21, 11, 220, 15, 8, 3961, 14711, 6075, 512, 755, 432, 9701, 1271, 6109, 26747, 2666, 11, 342, 11, 293, 11, 4902, 5725, 997, 262, 11712, 12281, 279, 1933, 505, 21653, 311, 364, 2984, 6220, 6, 21653, 271, 262, 13831, 512, 415, 551, 81, 512, 286, 578, 3816, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 70, 512, 286, 578, 7997, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 65, 512, 286, 578, 8868, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 3223, 512, 286, 1442, 3082, 11, 1005, 279, 10778, 1933, 4619, 315, 279, 24379, 832, 627, 286, 3053, 387, 1511, 369, 294, 2544, 287, 382, 262, 5295, 512, 415, 578, 1933, 439, 459, 320, 81, 11, 342, 11, 293, 8, 14743, 304, 279, 2134, 512, 415, 279, 2134, 512, 415, 436, 58, 15, 1131, 16, 1282, 415, 342, 58, 15, 1131, 16, 1282, 415, 293, 58, 15, 1131, 16, 2595, 262, 12382, 364, 15595, 70, 11, 1034, 70, 11, 1034, 70, 22367, 1034, 3562, 2056, 9701, 1271, 6109, 26747, 7, 16, 11, 220, 15, 13, 2131, 11, 220, 15, 13, 15, 340, 262, 22796, 16, 11, 220, 15, 13, 21, 11, 220, 15, 8, 3961, 262, 11414, 262, 3566, 26747, 2238, 284, 3562, 1462, 6109, 26747, 2238, 198, 262, 471, 14743, 1209, 2984, 26747, 2238, 3832, 11, 4902, 8, 369, 348, 304, 320, 81, 11, 342, 11, 293, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 279, 1933, 505, 21653, 311, 364, 2984, 6220, 6, 21653, 271, 262, 13831, 512, 415, 551, 81, 512, 286, 578, 3816, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 70, 512, 286, 578, 7997, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 65, 512, 286, 578, 8868, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 3223, 512, 286, 1442, 3082, 11, 1005, 279, 10778, 1933, 4619, 315, 279, 24379, 832, 627, 286, 3053, 387, 1511, 369, 294, 2544, 287, 382, 262, 5295, 512, 415, 578, 1933, 439, 459, 320, 81, 11, 342, 11, 293, 8, 14743, 304, 279, 2134, 512, 415, 279, 2134, 512, 415, 436, 58, 15, 1131, 16, 1282, 415, 342, 58, 15, 1131, 16, 1282, 415, 293, 58, 15, 1131, 16, 2595, 262, 12382, 364, 15595, 70, 11, 1034, 70, 11, 1034, 70, 22367, 1034, 3562, 2056, 9701, 1271, 6109, 26747, 7, 16, 11, 220, 15, 13, 2131, 11, 220, 15, 13, 15, 340, 262, 22796, 16, 11, 220, 15, 13, 21, 11, 220, 15, 8, 3961, 14711, 6075, 512, 755, 432, 9701, 1271, 6109, 26747, 2666, 11, 342, 11, 293, 11, 4902, 5725, 997, 262, 11712, 12281, 279, 1933, 505, 21653, 311, 364, 2984, 6220, 6, 21653, 271, 262, 13831, 512, 415, 551, 81, 512, 286, 578, 3816, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 70, 512, 286, 578, 7997, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 65, 512, 286, 578, 8868, 3777, 907, 510, 15, 1131, 16, 933, 415, 551, 3223, 512, 286, 1442, 3082, 11, 1005, 279, 10778, 1933, 4619, 315, 279, 24379, 832, 627, 286, 3053, 387, 1511, 369, 294, 2544, 287, 382, 262, 5295, 512, 415, 578, 1933, 439, 459, 320, 81, 11, 342, 11, 293, 8, 14743, 304, 279, 2134, 512, 415, 279, 2134, 512, 415, 436, 58, 15, 1131, 16, 1282, 415, 342, 58, 15, 1131, 16, 1282, 415, 293, 58, 15, 1131, 16, 2595, 262, 12382, 364, 15595, 70, 11, 1034, 70, 11, 1034, 70, 22367, 1034, 3562, 2056, 9701, 1271, 6109, 26747, 7, 16, 11, 220, 15, 13, 2131, 11, 220, 15, 13, 15, 340, 262, 22796, 16, 11, 220, 15, 13, 21, 11, 220, 15, 8, 3961, 262, 11414, 262, 3566, 26747, 2238, 284, 3562, 1462, 6109, 26747, 2238, 198, 262, 471, 14743, 1209, 2984, 26747, 2238, 3832, 11, 4902, 8, 369, 348, 304, 320, 81, 11, 342, 11, 293, 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 ]
aio-libs/aiohttp
aiohttp/web_protocol.py
RequestHandler.handle_error
def handle_error(self, request: BaseRequest, status: int=500, exc: Optional[BaseException]=None, message: Optional[str]=None) -> StreamResponse: """Handle errors. Returns HTTP response with specific status code. Logs additional information. It always closes current connection.""" self.log_exception("Error handling request", exc_info=exc) ct = 'text/plain' if status == HTTPStatus.INTERNAL_SERVER_ERROR: title = '{0.value} {0.phrase}'.format( HTTPStatus.INTERNAL_SERVER_ERROR ) msg = HTTPStatus.INTERNAL_SERVER_ERROR.description tb = None if self.debug: with suppress(Exception): tb = traceback.format_exc() if 'text/html' in request.headers.get('Accept', ''): if tb: tb = html_escape(tb) msg = '<h2>Traceback:</h2>\n<pre>{}</pre>'.format(tb) message = ( "<html><head>" "<title>{title}</title>" "</head><body>\n<h1>{title}</h1>" "\n{msg}\n</body></html>\n" ).format(title=title, msg=msg) ct = 'text/html' else: if tb: msg = tb message = title + '\n\n' + msg resp = Response(status=status, text=message, content_type=ct) resp.force_close() # some data already got sent, connection is broken if request.writer.output_size > 0 or self.transport is None: self.force_close() return resp
python
def handle_error(self, request: BaseRequest, status: int=500, exc: Optional[BaseException]=None, message: Optional[str]=None) -> StreamResponse: """Handle errors. Returns HTTP response with specific status code. Logs additional information. It always closes current connection.""" self.log_exception("Error handling request", exc_info=exc) ct = 'text/plain' if status == HTTPStatus.INTERNAL_SERVER_ERROR: title = '{0.value} {0.phrase}'.format( HTTPStatus.INTERNAL_SERVER_ERROR ) msg = HTTPStatus.INTERNAL_SERVER_ERROR.description tb = None if self.debug: with suppress(Exception): tb = traceback.format_exc() if 'text/html' in request.headers.get('Accept', ''): if tb: tb = html_escape(tb) msg = '<h2>Traceback:</h2>\n<pre>{}</pre>'.format(tb) message = ( "<html><head>" "<title>{title}</title>" "</head><body>\n<h1>{title}</h1>" "\n{msg}\n</body></html>\n" ).format(title=title, msg=msg) ct = 'text/html' else: if tb: msg = tb message = title + '\n\n' + msg resp = Response(status=status, text=message, content_type=ct) resp.force_close() # some data already got sent, connection is broken if request.writer.output_size > 0 or self.transport is None: self.force_close() return resp
[ "def", "handle_error", "(", "self", ",", "request", ":", "BaseRequest", ",", "status", ":", "int", "=", "500", ",", "exc", ":", "Optional", "[", "BaseException", "]", "=", "None", ",", "message", ":", "Optional", "[", "str", "]", "=", "None", ")", "->", "StreamResponse", ":", "self", ".", "log_exception", "(", "\"Error handling request\"", ",", "exc_info", "=", "exc", ")", "ct", "=", "'text/plain'", "if", "status", "==", "HTTPStatus", ".", "INTERNAL_SERVER_ERROR", ":", "title", "=", "'{0.value} {0.phrase}'", ".", "format", "(", "HTTPStatus", ".", "INTERNAL_SERVER_ERROR", ")", "msg", "=", "HTTPStatus", ".", "INTERNAL_SERVER_ERROR", ".", "description", "tb", "=", "None", "if", "self", ".", "debug", ":", "with", "suppress", "(", "Exception", ")", ":", "tb", "=", "traceback", ".", "format_exc", "(", ")", "if", "'text/html'", "in", "request", ".", "headers", ".", "get", "(", "'Accept'", ",", "''", ")", ":", "if", "tb", ":", "tb", "=", "html_escape", "(", "tb", ")", "msg", "=", "'<h2>Traceback:</h2>\\n<pre>{}</pre>'", ".", "format", "(", "tb", ")", "message", "=", "(", "\"<html><head>\"", "\"<title>{title}</title>\"", "\"</head><body>\\n<h1>{title}</h1>\"", "\"\\n{msg}\\n</body></html>\\n\"", ")", ".", "format", "(", "title", "=", "title", ",", "msg", "=", "msg", ")", "ct", "=", "'text/html'", "else", ":", "if", "tb", ":", "msg", "=", "tb", "message", "=", "title", "+", "'\\n\\n'", "+", "msg", "resp", "=", "Response", "(", "status", "=", "status", ",", "text", "=", "message", ",", "content_type", "=", "ct", ")", "resp", ".", "force_close", "(", ")", "# some data already got sent, connection is broken", "if", "request", ".", "writer", ".", "output_size", ">", "0", "or", "self", ".", "transport", "is", "None", ":", "self", ".", "force_close", "(", ")", "return", "resp" ]
Handle errors. Returns HTTP response with specific status code. Logs additional information. It always closes current connection.
[ "Handle", "errors", "." ]
train
https://github.com/aio-libs/aiohttp/blob/9504fe2affaaff673fa4f3754c1c44221f8ba47d/aiohttp/web_protocol.py#L511-L556
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Handle errors. Returns HTTP response with specific status code. Logs additional information. It always closes current connection. ### Response: def handle_error(self, request: BaseRequest, status: int=500, exc: Optional[BaseException]=None, message: Optional[str]=None) -> StreamResponse: """Handle errors. Returns HTTP response with specific status code. Logs additional information. It always closes current connection.""" self.log_exception("Error handling request", exc_info=exc) ct = 'text/plain' if status == HTTPStatus.INTERNAL_SERVER_ERROR: title = '{0.value} {0.phrase}'.format( HTTPStatus.INTERNAL_SERVER_ERROR ) msg = HTTPStatus.INTERNAL_SERVER_ERROR.description tb = None if self.debug: with suppress(Exception): tb = traceback.format_exc() if 'text/html' in request.headers.get('Accept', ''): if tb: tb = html_escape(tb) msg = '<h2>Traceback:</h2>\n<pre>{}</pre>'.format(tb) message = ( "<html><head>" "<title>{title}</title>" "</head><body>\n<h1>{title}</h1>" "\n{msg}\n</body></html>\n" ).format(title=title, msg=msg) ct = 'text/html' else: if tb: msg = tb message = title + '\n\n' + msg resp = Response(status=status, text=message, content_type=ct) resp.force_close() # some data already got sent, connection is broken if request.writer.output_size > 0 or self.transport is None: self.force_close() return resp <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 7144, 6103, 382, 286, 5295, 10339, 2077, 449, 3230, 2704, 2082, 13, 55670, 5217, 198, 286, 2038, 13, 1102, 2744, 34350, 1510, 3717, 382, 14711, 6075, 512, 755, 3790, 4188, 1214, 345, 3909, 1715, 25, 5464, 1939, 345, 3909, 2704, 25, 528, 28, 2636, 345, 3909, 3521, 25, 12536, 58, 4066, 1378, 4938, 4155, 345, 3909, 1984, 25, 12536, 17752, 4938, 4155, 8, 1492, 9384, 2647, 512, 286, 4304, 7144, 6103, 382, 286, 5295, 10339, 2077, 449, 3230, 2704, 2082, 13, 55670, 5217, 198, 286, 2038, 13, 1102, 2744, 34350, 1510, 3717, 14781, 286, 659, 1699, 17957, 446, 1480, 11850, 1715, 498, 3521, 3186, 28, 40541, 696, 286, 20864, 284, 364, 1342, 38071, 1270, 286, 422, 2704, 624, 10339, 2583, 84394, 20610, 5529, 512, 310, 2316, 284, 11834, 15, 2894, 92, 314, 15, 2180, 10857, 24398, 2293, 1021, 394, 10339, 2583, 84394, 20610, 5529, 198, 310, 1763, 310, 3835, 284, 10339, 2583, 84394, 20610, 5529, 13480, 198, 310, 16767, 284, 2290, 198, 310, 422, 659, 8042, 512, 394, 449, 28321, 17233, 997, 504, 16767, 284, 47158, 8180, 46747, 2892, 310, 422, 364, 1342, 14056, 6, 304, 1715, 18510, 673, 493, 17059, 518, 364, 11290, 394, 422, 16767, 512, 504, 16767, 284, 5385, 22585, 62514, 340, 504, 3835, 284, 3942, 71, 17, 29, 6687, 1445, 7920, 71, 17, 8616, 77, 10328, 7457, 5474, 1762, 45789, 2293, 62514, 340, 394, 1984, 284, 2456, 504, 4145, 1580, 1822, 2025, 19681, 504, 4145, 2150, 7457, 2150, 5474, 2150, 19681, 504, 9169, 2025, 1822, 2664, 8616, 77, 10174, 16, 7457, 2150, 5474, 71, 16, 19681, 504, 2990, 77, 90, 3316, 11281, 77, 524, 2664, 1500, 1580, 8616, 77, 702, 394, 7609, 2293, 12787, 91607, 11, 3835, 98478, 340, 394, 20864, 284, 364, 1342, 14056, 1270, 310, 775, 512, 394, 422, 16767, 512, 504, 3835, 284, 16767, 198, 394, 1984, 284, 2316, 489, 5307, 77, 1734, 6, 489, 3835, 271, 286, 9216, 284, 6075, 14159, 56218, 11, 1495, 88229, 11, 2262, 1857, 28, 302, 340, 286, 9216, 49294, 12993, 2892, 286, 674, 1063, 828, 2736, 2751, 3288, 11, 3717, 374, 11102, 198, 286, 422, 1715, 31932, 13718, 2424, 871, 220, 15, 477, 659, 53653, 374, 2290, 512, 310, 659, 49294, 12993, 2892, 286, 471, 9216, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 7144, 6103, 382, 286, 5295, 10339, 2077, 449, 3230, 2704, 2082, 13, 55670, 5217, 198, 286, 2038, 13, 1102, 2744, 34350, 1510, 3717, 382, 14711, 6075, 512, 755, 3790, 4188, 1214, 345, 3909, 1715, 25, 5464, 1939, 345, 3909, 2704, 25, 528, 28, 2636, 345, 3909, 3521, 25, 12536, 58, 4066, 1378, 4938, 4155, 345, 3909, 1984, 25, 12536, 17752, 4938, 4155, 8, 1492, 9384, 2647, 512, 286, 4304, 7144, 6103, 382, 286, 5295, 10339, 2077, 449, 3230, 2704, 2082, 13, 55670, 5217, 198, 286, 2038, 13, 1102, 2744, 34350, 1510, 3717, 14781, 286, 659, 1699, 17957, 446, 1480, 11850, 1715, 498, 3521, 3186, 28, 40541, 696, 286, 20864, 284, 364, 1342, 38071, 1270, 286, 422, 2704, 624, 10339, 2583, 84394, 20610, 5529, 512, 310, 2316, 284, 11834, 15, 2894, 92, 314, 15, 2180, 10857, 24398, 2293, 1021, 394, 10339, 2583, 84394, 20610, 5529, 198, 310, 1763, 310, 3835, 284, 10339, 2583, 84394, 20610, 5529, 13480, 198, 310, 16767, 284, 2290, 198, 310, 422, 659, 8042, 512, 394, 449, 28321, 17233, 997, 504, 16767, 284, 47158, 8180, 46747, 2892, 310, 422, 364, 1342, 14056, 6, 304, 1715, 18510, 673, 493, 17059, 518, 364, 11290, 394, 422, 16767, 512, 504, 16767, 284, 5385, 22585, 62514, 340, 504, 3835, 284, 3942, 71, 17, 29, 6687, 1445, 7920, 71, 17, 8616, 77, 10328, 7457, 5474, 1762, 45789, 2293, 62514, 340, 394, 1984, 284, 2456, 504, 4145, 1580, 1822, 2025, 19681, 504, 4145, 2150, 7457, 2150, 5474, 2150, 19681, 504, 9169, 2025, 1822, 2664, 8616, 77, 10174, 16, 7457, 2150, 5474, 71, 16, 19681, 504, 2990, 77, 90, 3316, 11281, 77, 524, 2664, 1500, 1580, 8616, 77, 702, 394, 7609, 2293, 12787, 91607, 11, 3835, 98478, 340, 394, 20864, 284, 364, 1342, 14056, 1270, 310, 775, 512, 394, 422, 16767, 512, 504, 3835, 284, 16767, 198, 394, 1984, 284, 2316, 489, 5307, 77, 1734, 6, 489, 3835, 271, 286, 9216, 284, 6075, 14159, 56218, 11, 1495, 88229, 11, 2262, 1857, 28, 302, 340, 286, 9216, 49294, 12993, 2892, 286, 674, 1063, 828, 2736, 2751, 3288, 11, 3717, 374, 11102, 198, 286, 422, 1715, 31932, 13718, 2424, 871, 220, 15, 477, 659, 53653, 374, 2290, 512, 310, 659, 49294, 12993, 2892, 286, 471, 9216, 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 ]
jbloomlab/phydms
phydmslib/models.py
ExpCM._update_B
def _update_B(self): """Update `B`.""" for param in self.freeparams: if param == 'mu': continue paramval = getattr(self, param) if isinstance(paramval, float): self.B[param] = broadcastMatrixMultiply(self.Ainv, broadcastMatrixMultiply(self.dPrxy[param], self.A)) else: assert isinstance(paramval, numpy.ndarray) and paramval.ndim == 1 for j in range(paramval.shape[0]): self.B[param][j] = broadcastMatrixMultiply(self.Ainv, broadcastMatrixMultiply(self.dPrxy[param][j], self.A))
python
def _update_B(self): """Update `B`.""" for param in self.freeparams: if param == 'mu': continue paramval = getattr(self, param) if isinstance(paramval, float): self.B[param] = broadcastMatrixMultiply(self.Ainv, broadcastMatrixMultiply(self.dPrxy[param], self.A)) else: assert isinstance(paramval, numpy.ndarray) and paramval.ndim == 1 for j in range(paramval.shape[0]): self.B[param][j] = broadcastMatrixMultiply(self.Ainv, broadcastMatrixMultiply(self.dPrxy[param][j], self.A))
[ "def", "_update_B", "(", "self", ")", ":", "for", "param", "in", "self", ".", "freeparams", ":", "if", "param", "==", "'mu'", ":", "continue", "paramval", "=", "getattr", "(", "self", ",", "param", ")", "if", "isinstance", "(", "paramval", ",", "float", ")", ":", "self", ".", "B", "[", "param", "]", "=", "broadcastMatrixMultiply", "(", "self", ".", "Ainv", ",", "broadcastMatrixMultiply", "(", "self", ".", "dPrxy", "[", "param", "]", ",", "self", ".", "A", ")", ")", "else", ":", "assert", "isinstance", "(", "paramval", ",", "numpy", ".", "ndarray", ")", "and", "paramval", ".", "ndim", "==", "1", "for", "j", "in", "range", "(", "paramval", ".", "shape", "[", "0", "]", ")", ":", "self", ".", "B", "[", "param", "]", "[", "j", "]", "=", "broadcastMatrixMultiply", "(", "self", ".", "Ainv", ",", "broadcastMatrixMultiply", "(", "self", ".", "dPrxy", "[", "param", "]", "[", "j", "]", ",", "self", ".", "A", ")", ")" ]
Update `B`.
[ "Update", "B", "." ]
train
https://github.com/jbloomlab/phydms/blob/9cdebc10bafbe543c552d79486c7f950780ed3c0/phydmslib/models.py#L774-L788
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Update `B`. ### Response: def _update_B(self): """Update `B`.""" for param in self.freeparams: if param == 'mu': continue paramval = getattr(self, param) if isinstance(paramval, float): self.B[param] = broadcastMatrixMultiply(self.Ainv, broadcastMatrixMultiply(self.dPrxy[param], self.A)) else: assert isinstance(paramval, numpy.ndarray) and paramval.ndim == 1 for j in range(paramval.shape[0]): self.B[param][j] = broadcastMatrixMultiply(self.Ainv, broadcastMatrixMultiply(self.dPrxy[param][j], self.A)) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 4387, 1595, 33, 63438, 14711, 6075, 512, 755, 721, 2443, 1702, 1214, 997, 286, 4304, 4387, 1595, 33, 63, 14781, 286, 369, 1719, 304, 659, 86653, 752, 640, 82, 512, 310, 422, 1719, 624, 364, 15479, 3730, 394, 3136, 198, 310, 1719, 838, 284, 31097, 1214, 11, 1719, 340, 310, 422, 11656, 9942, 838, 11, 2273, 997, 394, 659, 1823, 68185, 60, 284, 13195, 6828, 96255, 1214, 885, 14386, 345, 667, 13195, 6828, 96255, 1214, 962, 3617, 4223, 68185, 1145, 659, 885, 1192, 310, 775, 512, 394, 2105, 11656, 9942, 838, 11, 8760, 36649, 8, 323, 1719, 838, 82039, 624, 220, 16, 198, 394, 369, 503, 304, 2134, 9942, 838, 7201, 58, 15, 22953, 504, 659, 1823, 68185, 1483, 73, 60, 284, 13195, 6828, 96255, 1214, 885, 14386, 345, 1014, 13195, 6828, 96255, 1214, 962, 3617, 4223, 68185, 1483, 73, 1282, 1014, 659, 885, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 4387, 1595, 33, 63438, 14711, 6075, 512, 755, 721, 2443, 1702, 1214, 997, 286, 4304, 4387, 1595, 33, 63, 14781, 286, 369, 1719, 304, 659, 86653, 752, 640, 82, 512, 310, 422, 1719, 624, 364, 15479, 3730, 394, 3136, 198, 310, 1719, 838, 284, 31097, 1214, 11, 1719, 340, 310, 422, 11656, 9942, 838, 11, 2273, 997, 394, 659, 1823, 68185, 60, 284, 13195, 6828, 96255, 1214, 885, 14386, 345, 667, 13195, 6828, 96255, 1214, 962, 3617, 4223, 68185, 1145, 659, 885, 1192, 310, 775, 512, 394, 2105, 11656, 9942, 838, 11, 8760, 36649, 8, 323, 1719, 838, 82039, 624, 220, 16, 198, 394, 369, 503, 304, 2134, 9942, 838, 7201, 58, 15, 22953, 504, 659, 1823, 68185, 1483, 73, 60, 284, 13195, 6828, 96255, 1214, 885, 14386, 345, 1014, 13195, 6828, 96255, 1214, 962, 3617, 4223, 68185, 1483, 73, 1282, 1014, 659, 885, 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 ]
tornadoweb/tornado
tornado/http1connection.py
HTTP1Connection.write_headers
def write_headers( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, chunk: bytes = None, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: assert isinstance(start_line, httputil.RequestStartLine) self._request_start_line = start_line lines.append(utf8("%s %s HTTP/1.1" % (start_line[0], start_line[1]))) # Client requests with a non-empty body must have either a # Content-Length or a Transfer-Encoding. self._chunking_output = ( start_line.method in ("POST", "PUT", "PATCH") and "Content-Length" not in headers and ( "Transfer-Encoding" not in headers or headers["Transfer-Encoding"] == "chunked" ) ) else: assert isinstance(start_line, httputil.ResponseStartLine) assert self._request_start_line is not None assert self._request_headers is not None self._response_start_line = start_line lines.append(utf8("HTTP/1.1 %d %s" % (start_line[1], start_line[2]))) self._chunking_output = ( # TODO: should this use # self._request_start_line.version or # start_line.version? self._request_start_line.version == "HTTP/1.1" # 1xx, 204 and 304 responses have no body (not even a zero-length # body), and so should not have either Content-Length or # Transfer-Encoding headers. and start_line.code not in (204, 304) and (start_line.code < 100 or start_line.code >= 200) # No need to chunk the output if a Content-Length is specified. and "Content-Length" not in headers # Applications are discouraged from touching Transfer-Encoding, # but if they do, leave it alone. and "Transfer-Encoding" not in headers ) # If connection to a 1.1 client will be closed, inform client if ( self._request_start_line.version == "HTTP/1.1" and self._disconnect_on_finish ): headers["Connection"] = "close" # If a 1.0 client asked for keep-alive, add the header. if ( self._request_start_line.version == "HTTP/1.0" and self._request_headers.get("Connection", "").lower() == "keep-alive" ): headers["Connection"] = "Keep-Alive" if self._chunking_output: headers["Transfer-Encoding"] = "chunked" if not self.is_client and ( self._request_start_line.method == "HEAD" or cast(httputil.ResponseStartLine, start_line).code == 304 ): self._expected_content_remaining = 0 elif "Content-Length" in headers: self._expected_content_remaining = int(headers["Content-Length"]) else: self._expected_content_remaining = None # TODO: headers are supposed to be of type str, but we still have some # cases that let bytes slip through. Remove these native_str calls when those # are fixed. header_lines = ( native_str(n) + ": " + native_str(v) for n, v in headers.get_all() ) lines.extend(l.encode("latin1") for l in header_lines) for line in lines: if b"\n" in line: raise ValueError("Newline in header: " + repr(line)) future = None if self.stream.closed(): future = self._write_future = Future() future.set_exception(iostream.StreamClosedError()) future.exception() else: future = self._write_future = Future() data = b"\r\n".join(lines) + b"\r\n\r\n" if chunk: data += self._format_chunk(chunk) self._pending_write = self.stream.write(data) future_add_done_callback(self._pending_write, self._on_write_complete) return future
python
def write_headers( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, chunk: bytes = None, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: assert isinstance(start_line, httputil.RequestStartLine) self._request_start_line = start_line lines.append(utf8("%s %s HTTP/1.1" % (start_line[0], start_line[1]))) # Client requests with a non-empty body must have either a # Content-Length or a Transfer-Encoding. self._chunking_output = ( start_line.method in ("POST", "PUT", "PATCH") and "Content-Length" not in headers and ( "Transfer-Encoding" not in headers or headers["Transfer-Encoding"] == "chunked" ) ) else: assert isinstance(start_line, httputil.ResponseStartLine) assert self._request_start_line is not None assert self._request_headers is not None self._response_start_line = start_line lines.append(utf8("HTTP/1.1 %d %s" % (start_line[1], start_line[2]))) self._chunking_output = ( # TODO: should this use # self._request_start_line.version or # start_line.version? self._request_start_line.version == "HTTP/1.1" # 1xx, 204 and 304 responses have no body (not even a zero-length # body), and so should not have either Content-Length or # Transfer-Encoding headers. and start_line.code not in (204, 304) and (start_line.code < 100 or start_line.code >= 200) # No need to chunk the output if a Content-Length is specified. and "Content-Length" not in headers # Applications are discouraged from touching Transfer-Encoding, # but if they do, leave it alone. and "Transfer-Encoding" not in headers ) # If connection to a 1.1 client will be closed, inform client if ( self._request_start_line.version == "HTTP/1.1" and self._disconnect_on_finish ): headers["Connection"] = "close" # If a 1.0 client asked for keep-alive, add the header. if ( self._request_start_line.version == "HTTP/1.0" and self._request_headers.get("Connection", "").lower() == "keep-alive" ): headers["Connection"] = "Keep-Alive" if self._chunking_output: headers["Transfer-Encoding"] = "chunked" if not self.is_client and ( self._request_start_line.method == "HEAD" or cast(httputil.ResponseStartLine, start_line).code == 304 ): self._expected_content_remaining = 0 elif "Content-Length" in headers: self._expected_content_remaining = int(headers["Content-Length"]) else: self._expected_content_remaining = None # TODO: headers are supposed to be of type str, but we still have some # cases that let bytes slip through. Remove these native_str calls when those # are fixed. header_lines = ( native_str(n) + ": " + native_str(v) for n, v in headers.get_all() ) lines.extend(l.encode("latin1") for l in header_lines) for line in lines: if b"\n" in line: raise ValueError("Newline in header: " + repr(line)) future = None if self.stream.closed(): future = self._write_future = Future() future.set_exception(iostream.StreamClosedError()) future.exception() else: future = self._write_future = Future() data = b"\r\n".join(lines) + b"\r\n\r\n" if chunk: data += self._format_chunk(chunk) self._pending_write = self.stream.write(data) future_add_done_callback(self._pending_write, self._on_write_complete) return future
[ "def", "write_headers", "(", "self", ",", "start_line", ":", "Union", "[", "httputil", ".", "RequestStartLine", ",", "httputil", ".", "ResponseStartLine", "]", ",", "headers", ":", "httputil", ".", "HTTPHeaders", ",", "chunk", ":", "bytes", "=", "None", ",", ")", "->", "\"Future[None]\"", ":", "lines", "=", "[", "]", "if", "self", ".", "is_client", ":", "assert", "isinstance", "(", "start_line", ",", "httputil", ".", "RequestStartLine", ")", "self", ".", "_request_start_line", "=", "start_line", "lines", ".", "append", "(", "utf8", "(", "\"%s %s HTTP/1.1\"", "%", "(", "start_line", "[", "0", "]", ",", "start_line", "[", "1", "]", ")", ")", ")", "# Client requests with a non-empty body must have either a", "# Content-Length or a Transfer-Encoding.", "self", ".", "_chunking_output", "=", "(", "start_line", ".", "method", "in", "(", "\"POST\"", ",", "\"PUT\"", ",", "\"PATCH\"", ")", "and", "\"Content-Length\"", "not", "in", "headers", "and", "(", "\"Transfer-Encoding\"", "not", "in", "headers", "or", "headers", "[", "\"Transfer-Encoding\"", "]", "==", "\"chunked\"", ")", ")", "else", ":", "assert", "isinstance", "(", "start_line", ",", "httputil", ".", "ResponseStartLine", ")", "assert", "self", ".", "_request_start_line", "is", "not", "None", "assert", "self", ".", "_request_headers", "is", "not", "None", "self", ".", "_response_start_line", "=", "start_line", "lines", ".", "append", "(", "utf8", "(", "\"HTTP/1.1 %d %s\"", "%", "(", "start_line", "[", "1", "]", ",", "start_line", "[", "2", "]", ")", ")", ")", "self", ".", "_chunking_output", "=", "(", "# TODO: should this use", "# self._request_start_line.version or", "# start_line.version?", "self", ".", "_request_start_line", ".", "version", "==", "\"HTTP/1.1\"", "# 1xx, 204 and 304 responses have no body (not even a zero-length", "# body), and so should not have either Content-Length or", "# Transfer-Encoding headers.", "and", "start_line", ".", "code", "not", "in", "(", "204", ",", "304", ")", "and", "(", "start_line", ".", "code", "<", "100", "or", "start_line", ".", "code", ">=", "200", ")", "# No need to chunk the output if a Content-Length is specified.", "and", "\"Content-Length\"", "not", "in", "headers", "# Applications are discouraged from touching Transfer-Encoding,", "# but if they do, leave it alone.", "and", "\"Transfer-Encoding\"", "not", "in", "headers", ")", "# If connection to a 1.1 client will be closed, inform client", "if", "(", "self", ".", "_request_start_line", ".", "version", "==", "\"HTTP/1.1\"", "and", "self", ".", "_disconnect_on_finish", ")", ":", "headers", "[", "\"Connection\"", "]", "=", "\"close\"", "# If a 1.0 client asked for keep-alive, add the header.", "if", "(", "self", ".", "_request_start_line", ".", "version", "==", "\"HTTP/1.0\"", "and", "self", ".", "_request_headers", ".", "get", "(", "\"Connection\"", ",", "\"\"", ")", ".", "lower", "(", ")", "==", "\"keep-alive\"", ")", ":", "headers", "[", "\"Connection\"", "]", "=", "\"Keep-Alive\"", "if", "self", ".", "_chunking_output", ":", "headers", "[", "\"Transfer-Encoding\"", "]", "=", "\"chunked\"", "if", "not", "self", ".", "is_client", "and", "(", "self", ".", "_request_start_line", ".", "method", "==", "\"HEAD\"", "or", "cast", "(", "httputil", ".", "ResponseStartLine", ",", "start_line", ")", ".", "code", "==", "304", ")", ":", "self", ".", "_expected_content_remaining", "=", "0", "elif", "\"Content-Length\"", "in", "headers", ":", "self", ".", "_expected_content_remaining", "=", "int", "(", "headers", "[", "\"Content-Length\"", "]", ")", "else", ":", "self", ".", "_expected_content_remaining", "=", "None", "# TODO: headers are supposed to be of type str, but we still have some", "# cases that let bytes slip through. Remove these native_str calls when those", "# are fixed.", "header_lines", "=", "(", "native_str", "(", "n", ")", "+", "\": \"", "+", "native_str", "(", "v", ")", "for", "n", ",", "v", "in", "headers", ".", "get_all", "(", ")", ")", "lines", ".", "extend", "(", "l", ".", "encode", "(", "\"latin1\"", ")", "for", "l", "in", "header_lines", ")", "for", "line", "in", "lines", ":", "if", "b\"\\n\"", "in", "line", ":", "raise", "ValueError", "(", "\"Newline in header: \"", "+", "repr", "(", "line", ")", ")", "future", "=", "None", "if", "self", ".", "stream", ".", "closed", "(", ")", ":", "future", "=", "self", ".", "_write_future", "=", "Future", "(", ")", "future", ".", "set_exception", "(", "iostream", ".", "StreamClosedError", "(", ")", ")", "future", ".", "exception", "(", ")", "else", ":", "future", "=", "self", ".", "_write_future", "=", "Future", "(", ")", "data", "=", "b\"\\r\\n\"", ".", "join", "(", "lines", ")", "+", "b\"\\r\\n\\r\\n\"", "if", "chunk", ":", "data", "+=", "self", ".", "_format_chunk", "(", "chunk", ")", "self", ".", "_pending_write", "=", "self", ".", "stream", ".", "write", "(", "data", ")", "future_add_done_callback", "(", "self", ".", "_pending_write", ",", "self", ".", "_on_write_complete", ")", "return", "future" ]
Implements `.HTTPConnection.write_headers`.
[ "Implements", ".", "HTTPConnection", ".", "write_headers", "." ]
train
https://github.com/tornadoweb/tornado/blob/b8b481770bcdb333a69afde5cce7eaa449128326/tornado/http1connection.py#L376-L465
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Implements `.HTTPConnection.write_headers`. ### Response: def write_headers( self, start_line: Union[httputil.RequestStartLine, httputil.ResponseStartLine], headers: httputil.HTTPHeaders, chunk: bytes = None, ) -> "Future[None]": """Implements `.HTTPConnection.write_headers`.""" lines = [] if self.is_client: assert isinstance(start_line, httputil.RequestStartLine) self._request_start_line = start_line lines.append(utf8("%s %s HTTP/1.1" % (start_line[0], start_line[1]))) # Client requests with a non-empty body must have either a # Content-Length or a Transfer-Encoding. self._chunking_output = ( start_line.method in ("POST", "PUT", "PATCH") and "Content-Length" not in headers and ( "Transfer-Encoding" not in headers or headers["Transfer-Encoding"] == "chunked" ) ) else: assert isinstance(start_line, httputil.ResponseStartLine) assert self._request_start_line is not None assert self._request_headers is not None self._response_start_line = start_line lines.append(utf8("HTTP/1.1 %d %s" % (start_line[1], start_line[2]))) self._chunking_output = ( # TODO: should this use # self._request_start_line.version or # start_line.version? self._request_start_line.version == "HTTP/1.1" # 1xx, 204 and 304 responses have no body (not even a zero-length # body), and so should not have either Content-Length or # Transfer-Encoding headers. and start_line.code not in (204, 304) and (start_line.code < 100 or start_line.code >= 200) # No need to chunk the output if a Content-Length is specified. and "Content-Length" not in headers # Applications are discouraged from touching Transfer-Encoding, # but if they do, leave it alone. and "Transfer-Encoding" not in headers ) # If connection to a 1.1 client will be closed, inform client if ( self._request_start_line.version == "HTTP/1.1" and self._disconnect_on_finish ): headers["Connection"] = "close" # If a 1.0 client asked for keep-alive, add the header. if ( self._request_start_line.version == "HTTP/1.0" and self._request_headers.get("Connection", "").lower() == "keep-alive" ): headers["Connection"] = "Keep-Alive" if self._chunking_output: headers["Transfer-Encoding"] = "chunked" if not self.is_client and ( self._request_start_line.method == "HEAD" or cast(httputil.ResponseStartLine, start_line).code == 304 ): self._expected_content_remaining = 0 elif "Content-Length" in headers: self._expected_content_remaining = int(headers["Content-Length"]) else: self._expected_content_remaining = None # TODO: headers are supposed to be of type str, but we still have some # cases that let bytes slip through. Remove these native_str calls when those # are fixed. header_lines = ( native_str(n) + ": " + native_str(v) for n, v in headers.get_all() ) lines.extend(l.encode("latin1") for l in header_lines) for line in lines: if b"\n" in line: raise ValueError("Newline in header: " + repr(line)) future = None if self.stream.closed(): future = self._write_future = Future() future.set_exception(iostream.StreamClosedError()) future.exception() else: future = self._write_future = Future() data = b"\r\n".join(lines) + b"\r\n\r\n" if chunk: data += self._format_chunk(chunk) self._pending_write = self.stream.write(data) future_add_done_callback(self._pending_write, self._on_write_complete) return future <|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, 1453, 4779, 75190, 9412, 4627, 3921, 27817, 63438, 14711, 6075, 512, 755, 3350, 27817, 1021, 286, 659, 345, 286, 1212, 6665, 25, 9323, 58, 97436, 631, 321, 9856, 3563, 2519, 11, 55420, 631, 321, 12859, 3563, 2519, 1282, 286, 7247, 25, 55420, 631, 321, 28458, 10797, 345, 286, 12143, 25, 5943, 284, 2290, 345, 262, 883, 1492, 330, 25184, 58, 4155, 60, 4764, 286, 4304, 1453, 4779, 75190, 9412, 4627, 3921, 27817, 63, 14781, 286, 5238, 284, 4260, 286, 422, 659, 2124, 8342, 512, 310, 2105, 11656, 10865, 6665, 11, 55420, 631, 321, 9856, 3563, 2519, 340, 310, 659, 1462, 2079, 5011, 6665, 284, 1212, 6665, 198, 310, 5238, 2102, 86377, 23, 4530, 82, 1034, 82, 10339, 14, 16, 13, 16, 1, 1034, 320, 2527, 6665, 58, 15, 1145, 1212, 6665, 58, 16, 57879, 310, 674, 8589, 7540, 449, 264, 2536, 40533, 2547, 2011, 617, 3060, 264, 198, 310, 674, 9059, 53593, 477, 264, 24078, 68458, 627, 310, 659, 1462, 27069, 287, 7800, 284, 2456, 394, 1212, 6665, 13204, 304, 3573, 3019, 498, 330, 6353, 498, 330, 32265, 1158, 394, 323, 330, 2831, 53593, 1, 539, 304, 7247, 198, 394, 323, 2456, 504, 330, 22737, 68458, 1, 539, 304, 7247, 198, 504, 477, 7247, 1204, 22737, 68458, 1365, 624, 330, 27069, 291, 702, 394, 1763, 310, 1763, 286, 775, 512, 310, 2105, 11656, 10865, 6665, 11, 55420, 631, 321, 12859, 3563, 2519, 340, 310, 2105, 659, 1462, 2079, 5011, 6665, 374, 539, 2290, 198, 310, 2105, 659, 1462, 2079, 27817, 374, 539, 2290, 198, 310, 659, 1462, 2376, 5011, 6665, 284, 1212, 6665, 198, 310, 5238, 2102, 86377, 23, 446, 9412, 14, 16, 13, 16, 1034, 67, 1034, 82, 1, 1034, 320, 2527, 6665, 58, 16, 1145, 1212, 6665, 58, 17, 57879, 310, 659, 1462, 27069, 287, 7800, 284, 2456, 394, 674, 5456, 25, 1288, 420, 1005, 198, 394, 674, 659, 1462, 2079, 5011, 6665, 20049, 477, 198, 394, 674, 1212, 6665, 20049, 5380, 394, 659, 1462, 2079, 5011, 6665, 20049, 624, 330, 9412, 14, 16, 13, 16, 702, 394, 674, 220, 16, 4239, 11, 220, 7854, 323, 220, 12166, 14847, 617, 912, 2547, 320, 1962, 1524, 264, 7315, 30425, 198, 394, 674, 2547, 705, 323, 779, 1288, 539, 617, 3060, 9059, 53593, 477, 198, 394, 674, 24078, 68458, 7247, 627, 394, 323, 1212, 6665, 10421, 539, 304, 320, 7854, 11, 220, 12166, 340, 394, 323, 320, 2527, 6665, 10421, 366, 220, 1041, 477, 1212, 6665, 10421, 2669, 220, 1049, 340, 394, 674, 2360, 1205, 311, 12143, 279, 2612, 422, 264, 9059, 53593, 374, 5300, 627, 394, 323, 330, 2831, 53593, 1, 539, 304, 7247, 198, 394, 674, 32625, 527, 64770, 505, 31687, 24078, 68458, 345, 394, 674, 719, 422, 814, 656, 11, 5387, 433, 7636, 627, 394, 323, 330, 22737, 68458, 1, 539, 304, 7247, 198, 310, 1763, 310, 674, 1442, 3717 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 1453, 4779, 75190, 9412, 4627, 3921, 27817, 63438, 14711, 6075, 512, 755, 3350, 27817, 1021, 286, 659, 345, 286, 1212, 6665, 25, 9323, 58, 97436, 631, 321, 9856, 3563, 2519, 11, 55420, 631, 321, 12859, 3563, 2519, 1282, 286, 7247, 25, 55420, 631, 321, 28458, 10797, 345, 286, 12143, 25, 5943, 284, 2290, 345, 262, 883, 1492, 330, 25184, 58, 4155, 60, 4764, 286, 4304, 1453, 4779, 75190, 9412, 4627, 3921, 27817, 63, 14781, 286, 5238, 284, 4260, 286, 422, 659, 2124, 8342, 512, 310, 2105, 11656, 10865, 6665, 11, 55420, 631, 321, 9856, 3563, 2519, 340, 310, 659, 1462, 2079, 5011, 6665, 284, 1212, 6665, 198, 310, 5238, 2102, 86377, 23, 4530, 82, 1034, 82, 10339, 14, 16, 13, 16, 1, 1034, 320, 2527, 6665, 58, 15, 1145, 1212, 6665, 58, 16, 57879, 310, 674, 8589, 7540, 449, 264, 2536, 40533, 2547, 2011, 617, 3060, 264, 198, 310, 674, 9059, 53593, 477, 264, 24078, 68458, 627, 310, 659, 1462, 27069, 287, 7800, 284, 2456, 394, 1212, 6665, 13204, 304, 3573, 3019, 498, 330, 6353, 498, 330, 32265, 1158, 394, 323, 330, 2831, 53593, 1, 539, 304, 7247, 198, 394, 323, 2456, 504, 330, 22737, 68458, 1, 539, 304, 7247, 198, 504, 477, 7247, 1204, 22737, 68458, 1365, 624, 330, 27069, 291, 702, 394, 1763, 310, 1763, 286, 775, 512, 310, 2105, 11656, 10865, 6665, 11, 55420, 631, 321, 12859, 3563, 2519, 340, 310, 2105, 659, 1462, 2079, 5011, 6665, 374, 539, 2290, 198, 310, 2105, 659, 1462, 2079, 27817, 374, 539, 2290, 198, 310, 659, 1462, 2376, 5011, 6665, 284, 1212, 6665, 198, 310, 5238, 2102, 86377, 23, 446, 9412, 14, 16, 13, 16, 1034, 67, 1034, 82, 1, 1034, 320, 2527, 6665, 58, 16, 1145, 1212, 6665, 58, 17, 57879, 310, 659, 1462, 27069, 287, 7800, 284, 2456, 394, 674, 5456, 25, 1288, 420, 1005, 198, 394, 674, 659, 1462, 2079, 5011, 6665, 20049, 477, 198, 394, 674, 1212, 6665, 20049, 5380, 394, 659, 1462, 2079, 5011, 6665, 20049, 624, 330, 9412, 14, 16, 13, 16, 702, 394, 674, 220, 16, 4239, 11, 220, 7854, 323, 220, 12166, 14847, 617, 912, 2547, 320, 1962, 1524, 264, 7315, 30425, 198, 394, 674, 2547, 705, 323, 779, 1288, 539, 617, 3060, 9059, 53593, 477, 198, 394, 674, 24078, 68458, 7247, 627, 394, 323, 1212, 6665, 10421, 539, 304, 320, 7854, 11, 220, 12166, 340, 394, 323, 320, 2527, 6665, 10421, 366, 220, 1041, 477, 1212, 6665, 10421, 2669, 220, 1049, 340, 394, 674, 2360, 1205, 311, 12143, 279, 2612, 422, 264, 9059, 53593, 374, 5300, 627, 394, 323, 330, 2831, 53593, 1, 539, 304, 7247, 198, 394, 674, 32625, 527, 64770, 505, 31687, 24078, 68458, 345, 394, 674, 719, 422, 814, 656, 11, 5387, 433, 7636, 627, 394, 323, 330, 22737, 68458, 1, 539, 304, 7247, 198, 310, 1763, 310, 674, 1442, 3717 ]
chaoss/grimoirelab-sortinghat
sortinghat/parser.py
create_organizations_parser
def create_organizations_parser(stream): """Create an organizations parser for the given stream. Factory function that creates an organizations parser for the given stream. The stream is only used to guess the type of the required parser. :param stream: stream used to guess the type of the parser :returns: an organizations parser :raise InvalidFormatError: raised when no one of the available parsers can parse the given stream """ import sortinghat.parsing as parsing # First, try with default parser for p in parsing.SORTINGHAT_ORGS_PARSERS: klass = parsing.SORTINGHAT_ORGS_PARSERS[p] parser = klass() if parser.check(stream): return parser raise InvalidFormatError(cause=INVALID_FORMAT_MSG)
python
def create_organizations_parser(stream): """Create an organizations parser for the given stream. Factory function that creates an organizations parser for the given stream. The stream is only used to guess the type of the required parser. :param stream: stream used to guess the type of the parser :returns: an organizations parser :raise InvalidFormatError: raised when no one of the available parsers can parse the given stream """ import sortinghat.parsing as parsing # First, try with default parser for p in parsing.SORTINGHAT_ORGS_PARSERS: klass = parsing.SORTINGHAT_ORGS_PARSERS[p] parser = klass() if parser.check(stream): return parser raise InvalidFormatError(cause=INVALID_FORMAT_MSG)
[ "def", "create_organizations_parser", "(", "stream", ")", ":", "import", "sortinghat", ".", "parsing", "as", "parsing", "# First, try with default parser", "for", "p", "in", "parsing", ".", "SORTINGHAT_ORGS_PARSERS", ":", "klass", "=", "parsing", ".", "SORTINGHAT_ORGS_PARSERS", "[", "p", "]", "parser", "=", "klass", "(", ")", "if", "parser", ".", "check", "(", "stream", ")", ":", "return", "parser", "raise", "InvalidFormatError", "(", "cause", "=", "INVALID_FORMAT_MSG", ")" ]
Create an organizations parser for the given stream. Factory function that creates an organizations parser for the given stream. The stream is only used to guess the type of the required parser. :param stream: stream used to guess the type of the parser :returns: an organizations parser :raise InvalidFormatError: raised when no one of the available parsers can parse the given stream
[ "Create", "an", "organizations", "parser", "for", "the", "given", "stream", "." ]
train
https://github.com/chaoss/grimoirelab-sortinghat/blob/391cd37a75fea26311dc6908bc1c953c540a8e04/sortinghat/parser.py#L44-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: Create an organizations parser for the given stream. Factory function that creates an organizations parser for the given stream. The stream is only used to guess the type of the required parser. :param stream: stream used to guess the type of the parser :returns: an organizations parser :raise InvalidFormatError: raised when no one of the available parsers can parse the given stream ### Response: def create_organizations_parser(stream): """Create an organizations parser for the given stream. Factory function that creates an organizations parser for the given stream. The stream is only used to guess the type of the required parser. :param stream: stream used to guess the type of the parser :returns: an organizations parser :raise InvalidFormatError: raised when no one of the available parsers can parse the given stream """ import sortinghat.parsing as parsing # First, try with default parser for p in parsing.SORTINGHAT_ORGS_PARSERS: klass = parsing.SORTINGHAT_ORGS_PARSERS[p] parser = klass() if parser.check(stream): return parser raise InvalidFormatError(cause=INVALID_FORMAT_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, 4110, 459, 11351, 6871, 369, 279, 2728, 4365, 382, 262, 17367, 734, 430, 11705, 459, 11351, 6871, 369, 279, 198, 262, 2728, 4365, 13, 578, 4365, 374, 1193, 1511, 311, 8101, 279, 955, 315, 279, 198, 262, 2631, 6871, 382, 262, 551, 913, 4365, 25, 4365, 1511, 311, 8101, 279, 955, 315, 279, 6871, 271, 262, 551, 4310, 25, 459, 11351, 6871, 271, 262, 551, 19223, 14204, 4152, 1480, 25, 9408, 994, 912, 832, 315, 279, 2561, 198, 286, 88173, 649, 4820, 279, 2728, 4365, 271, 14711, 6075, 512, 755, 1893, 62, 70353, 19024, 21217, 997, 262, 4304, 4110, 459, 11351, 6871, 369, 279, 2728, 4365, 382, 262, 17367, 734, 430, 11705, 459, 11351, 6871, 369, 279, 198, 262, 2728, 4365, 13, 578, 4365, 374, 1193, 1511, 311, 8101, 279, 955, 315, 279, 198, 262, 2631, 6871, 382, 262, 551, 913, 4365, 25, 4365, 1511, 311, 8101, 279, 955, 315, 279, 6871, 271, 262, 551, 4310, 25, 459, 11351, 6871, 271, 262, 551, 19223, 14204, 4152, 1480, 25, 9408, 994, 912, 832, 315, 279, 2561, 198, 286, 88173, 649, 4820, 279, 2728, 4365, 198, 262, 3270, 262, 1179, 29373, 9379, 558, 29698, 439, 23115, 271, 262, 674, 5629, 11, 1456, 449, 1670, 6871, 198, 262, 369, 281, 304, 23115, 815, 2938, 1753, 39, 835, 20424, 16929, 1106, 17485, 4419, 512, 286, 39055, 284, 23115, 815, 2938, 1753, 39, 835, 20424, 16929, 1106, 17485, 4419, 11661, 2595, 286, 6871, 284, 39055, 2892, 286, 422, 6871, 9271, 21217, 997, 310, 471, 6871, 198, 262, 4933, 14204, 4152, 1480, 7, 1593, 28, 47959, 15309, 14709, 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 ]
[ 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, 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, 459, 11351, 6871, 369, 279, 2728, 4365, 382, 262, 17367, 734, 430, 11705, 459, 11351, 6871, 369, 279, 198, 262, 2728, 4365, 13, 578, 4365, 374, 1193, 1511, 311, 8101, 279, 955, 315, 279, 198, 262, 2631, 6871, 382, 262, 551, 913, 4365, 25, 4365, 1511, 311, 8101, 279, 955, 315, 279, 6871, 271, 262, 551, 4310, 25, 459, 11351, 6871, 271, 262, 551, 19223, 14204, 4152, 1480, 25, 9408, 994, 912, 832, 315, 279, 2561, 198, 286, 88173, 649, 4820, 279, 2728, 4365, 271, 14711, 6075, 512, 755, 1893, 62, 70353, 19024, 21217, 997, 262, 4304, 4110, 459, 11351, 6871, 369, 279, 2728, 4365, 382, 262, 17367, 734, 430, 11705, 459, 11351, 6871, 369, 279, 198, 262, 2728, 4365, 13, 578, 4365, 374, 1193, 1511, 311, 8101, 279, 955, 315, 279, 198, 262, 2631, 6871, 382, 262, 551, 913, 4365, 25, 4365, 1511, 311, 8101, 279, 955, 315, 279, 6871, 271, 262, 551, 4310, 25, 459, 11351, 6871, 271, 262, 551, 19223, 14204, 4152, 1480, 25, 9408, 994, 912, 832, 315, 279, 2561, 198, 286, 88173, 649, 4820, 279, 2728, 4365, 198, 262, 3270, 262, 1179, 29373, 9379, 558, 29698, 439, 23115, 271, 262, 674, 5629, 11, 1456, 449, 1670, 6871, 198, 262, 369, 281, 304, 23115, 815, 2938, 1753, 39, 835, 20424, 16929, 1106, 17485, 4419, 512, 286, 39055, 284, 23115, 815, 2938, 1753, 39, 835, 20424, 16929, 1106, 17485, 4419, 11661, 2595, 286, 6871, 284, 39055, 2892, 286, 422, 6871, 9271, 21217, 997, 310, 471, 6871, 198, 262, 4933, 14204, 4152, 1480, 7, 1593, 28, 47959, 15309, 14709, 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 ]
jkwill87/teletype
teletype/components/config.py
set_char
def set_char(key, value): """ Updates charters used to render components. """ global _chars category = _get_char_category(key) if not category: raise KeyError _chars[category][key] = value
python
def set_char(key, value): """ Updates charters used to render components. """ global _chars category = _get_char_category(key) if not category: raise KeyError _chars[category][key] = value
[ "def", "set_char", "(", "key", ",", "value", ")", ":", "global", "_chars", "category", "=", "_get_char_category", "(", "key", ")", "if", "not", "category", ":", "raise", "KeyError", "_chars", "[", "category", "]", "[", "key", "]", "=", "value" ]
Updates charters used to render components.
[ "Updates", "charters", "used", "to", "render", "components", "." ]
train
https://github.com/jkwill87/teletype/blob/8ba95c56dcb5e4d7f6ae155eb6cdabfdfaf346cf/teletype/components/config.py#L40-L47
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Updates charters used to render components. ### Response: def set_char(key, value): """ Updates charters used to render components. """ global _chars category = _get_char_category(key) if not category: raise KeyError _chars[category][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, 38191, 9676, 388, 1511, 311, 3219, 6956, 382, 14711, 6075, 512, 755, 743, 9415, 4962, 11, 907, 997, 262, 4304, 28600, 9676, 388, 1511, 311, 3219, 6956, 627, 262, 3270, 262, 3728, 721, 19811, 198, 262, 5699, 284, 721, 456, 9415, 12110, 4962, 340, 262, 422, 539, 5699, 512, 286, 4933, 39194, 198, 262, 721, 19811, 58, 5588, 1483, 798, 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, 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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 38191, 9676, 388, 1511, 311, 3219, 6956, 382, 14711, 6075, 512, 755, 743, 9415, 4962, 11, 907, 997, 262, 4304, 28600, 9676, 388, 1511, 311, 3219, 6956, 627, 262, 3270, 262, 3728, 721, 19811, 198, 262, 5699, 284, 721, 456, 9415, 12110, 4962, 340, 262, 422, 539, 5699, 512, 286, 4933, 39194, 198, 262, 721, 19811, 58, 5588, 1483, 798, 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 ]
cockroachdb/cockroachdb-python
cockroachdb/sqlalchemy/transaction.py
run_transaction
def run_transaction(transactor, callback): """Run a transaction with retries. ``callback()`` will be called with one argument to execute the transaction. ``callback`` may be called more than once; it should have no side effects other than writes to the database on the given connection. ``callback`` should not call ``commit()` or ``rollback()``; these will be called automatically. The ``transactor`` argument may be one of the following types: * `sqlalchemy.engine.Connection`: the same connection is passed to the callback. * `sqlalchemy.engine.Engine`: a connection is created and passed to the callback. * `sqlalchemy.orm.sessionmaker`: a session is created and passed to the callback. """ if isinstance(transactor, sqlalchemy.engine.Connection): return _txn_retry_loop(transactor, callback) elif isinstance(transactor, sqlalchemy.engine.Engine): with transactor.connect() as connection: return _txn_retry_loop(connection, callback) elif isinstance(transactor, sqlalchemy.orm.sessionmaker): session = transactor(autocommit=True) return _txn_retry_loop(session, callback) else: raise TypeError("don't know how to run a transaction on %s", type(transactor))
python
def run_transaction(transactor, callback): """Run a transaction with retries. ``callback()`` will be called with one argument to execute the transaction. ``callback`` may be called more than once; it should have no side effects other than writes to the database on the given connection. ``callback`` should not call ``commit()` or ``rollback()``; these will be called automatically. The ``transactor`` argument may be one of the following types: * `sqlalchemy.engine.Connection`: the same connection is passed to the callback. * `sqlalchemy.engine.Engine`: a connection is created and passed to the callback. * `sqlalchemy.orm.sessionmaker`: a session is created and passed to the callback. """ if isinstance(transactor, sqlalchemy.engine.Connection): return _txn_retry_loop(transactor, callback) elif isinstance(transactor, sqlalchemy.engine.Engine): with transactor.connect() as connection: return _txn_retry_loop(connection, callback) elif isinstance(transactor, sqlalchemy.orm.sessionmaker): session = transactor(autocommit=True) return _txn_retry_loop(session, callback) else: raise TypeError("don't know how to run a transaction on %s", type(transactor))
[ "def", "run_transaction", "(", "transactor", ",", "callback", ")", ":", "if", "isinstance", "(", "transactor", ",", "sqlalchemy", ".", "engine", ".", "Connection", ")", ":", "return", "_txn_retry_loop", "(", "transactor", ",", "callback", ")", "elif", "isinstance", "(", "transactor", ",", "sqlalchemy", ".", "engine", ".", "Engine", ")", ":", "with", "transactor", ".", "connect", "(", ")", "as", "connection", ":", "return", "_txn_retry_loop", "(", "connection", ",", "callback", ")", "elif", "isinstance", "(", "transactor", ",", "sqlalchemy", ".", "orm", ".", "sessionmaker", ")", ":", "session", "=", "transactor", "(", "autocommit", "=", "True", ")", "return", "_txn_retry_loop", "(", "session", ",", "callback", ")", "else", ":", "raise", "TypeError", "(", "\"don't know how to run a transaction on %s\"", ",", "type", "(", "transactor", ")", ")" ]
Run a transaction with retries. ``callback()`` will be called with one argument to execute the transaction. ``callback`` may be called more than once; it should have no side effects other than writes to the database on the given connection. ``callback`` should not call ``commit()` or ``rollback()``; these will be called automatically. The ``transactor`` argument may be one of the following types: * `sqlalchemy.engine.Connection`: the same connection is passed to the callback. * `sqlalchemy.engine.Engine`: a connection is created and passed to the callback. * `sqlalchemy.orm.sessionmaker`: a session is created and passed to the callback.
[ "Run", "a", "transaction", "with", "retries", "." ]
train
https://github.com/cockroachdb/cockroachdb-python/blob/5a23e5fb4dc4386828fd147155becba58f0a7c4f/cockroachdb/sqlalchemy/transaction.py#L10-L33
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Run a transaction with retries. ``callback()`` will be called with one argument to execute the transaction. ``callback`` may be called more than once; it should have no side effects other than writes to the database on the given connection. ``callback`` should not call ``commit()` or ``rollback()``; these will be called automatically. The ``transactor`` argument may be one of the following types: * `sqlalchemy.engine.Connection`: the same connection is passed to the callback. * `sqlalchemy.engine.Engine`: a connection is created and passed to the callback. * `sqlalchemy.orm.sessionmaker`: a session is created and passed to the callback. ### Response: def run_transaction(transactor, callback): """Run a transaction with retries. ``callback()`` will be called with one argument to execute the transaction. ``callback`` may be called more than once; it should have no side effects other than writes to the database on the given connection. ``callback`` should not call ``commit()` or ``rollback()``; these will be called automatically. The ``transactor`` argument may be one of the following types: * `sqlalchemy.engine.Connection`: the same connection is passed to the callback. * `sqlalchemy.engine.Engine`: a connection is created and passed to the callback. * `sqlalchemy.orm.sessionmaker`: a session is created and passed to the callback. """ if isinstance(transactor, sqlalchemy.engine.Connection): return _txn_retry_loop(transactor, callback) elif isinstance(transactor, sqlalchemy.engine.Engine): with transactor.connect() as connection: return _txn_retry_loop(connection, callback) elif isinstance(transactor, sqlalchemy.orm.sessionmaker): session = transactor(autocommit=True) return _txn_retry_loop(session, callback) else: raise TypeError("don't know how to run a transaction on %s", type(transactor)) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 6869, 264, 7901, 449, 61701, 382, 262, 10103, 13802, 368, 14196, 690, 387, 2663, 449, 832, 5811, 311, 9203, 279, 198, 262, 7901, 13, 10103, 13802, 14196, 1253, 387, 2663, 810, 1109, 3131, 26, 433, 1288, 617, 198, 262, 912, 3185, 6372, 1023, 1109, 14238, 311, 279, 4729, 389, 279, 2728, 198, 262, 3717, 13, 10103, 13802, 14196, 1288, 539, 1650, 10103, 17869, 55358, 477, 10103, 34659, 368, 14196, 280, 262, 1521, 690, 387, 2663, 9651, 382, 262, 578, 10103, 1485, 5739, 14196, 5811, 1253, 387, 832, 315, 279, 2768, 4595, 512, 262, 353, 1595, 3628, 36005, 25421, 17921, 45722, 279, 1890, 3717, 374, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 25421, 55524, 45722, 264, 3717, 374, 3549, 323, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 48849, 10387, 26850, 45722, 264, 3882, 374, 3549, 323, 5946, 311, 279, 4927, 382, 14711, 6075, 512, 755, 1629, 29984, 34189, 5739, 11, 4927, 997, 262, 4304, 6869, 264, 7901, 449, 61701, 382, 262, 10103, 13802, 368, 14196, 690, 387, 2663, 449, 832, 5811, 311, 9203, 279, 198, 262, 7901, 13, 10103, 13802, 14196, 1253, 387, 2663, 810, 1109, 3131, 26, 433, 1288, 617, 198, 262, 912, 3185, 6372, 1023, 1109, 14238, 311, 279, 4729, 389, 279, 2728, 198, 262, 3717, 13, 10103, 13802, 14196, 1288, 539, 1650, 10103, 17869, 55358, 477, 10103, 34659, 368, 14196, 280, 262, 1521, 690, 387, 2663, 9651, 382, 262, 578, 10103, 1485, 5739, 14196, 5811, 1253, 387, 832, 315, 279, 2768, 4595, 512, 262, 353, 1595, 3628, 36005, 25421, 17921, 45722, 279, 1890, 3717, 374, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 25421, 55524, 45722, 264, 3717, 374, 3549, 323, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 48849, 10387, 26850, 45722, 264, 3882, 374, 3549, 323, 5946, 311, 279, 4927, 627, 262, 3270, 262, 422, 11656, 34189, 5739, 11, 43275, 25421, 17921, 997, 286, 471, 721, 74470, 63845, 17641, 34189, 5739, 11, 4927, 340, 262, 4508, 11656, 34189, 5739, 11, 43275, 25421, 55524, 997, 286, 449, 1380, 5739, 11034, 368, 439, 3717, 512, 310, 471, 721, 74470, 63845, 17641, 25119, 11, 4927, 340, 262, 4508, 11656, 34189, 5739, 11, 43275, 48849, 10387, 26850, 997, 286, 3882, 284, 1380, 5739, 7, 2784, 12255, 1800, 3702, 340, 286, 471, 721, 74470, 63845, 17641, 16663, 11, 4927, 340, 262, 775, 512, 286, 4933, 26082, 446, 15357, 956, 1440, 1268, 311, 1629, 264, 7901, 389, 1034, 82, 498, 955, 34189, 5739, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 6869, 264, 7901, 449, 61701, 382, 262, 10103, 13802, 368, 14196, 690, 387, 2663, 449, 832, 5811, 311, 9203, 279, 198, 262, 7901, 13, 10103, 13802, 14196, 1253, 387, 2663, 810, 1109, 3131, 26, 433, 1288, 617, 198, 262, 912, 3185, 6372, 1023, 1109, 14238, 311, 279, 4729, 389, 279, 2728, 198, 262, 3717, 13, 10103, 13802, 14196, 1288, 539, 1650, 10103, 17869, 55358, 477, 10103, 34659, 368, 14196, 280, 262, 1521, 690, 387, 2663, 9651, 382, 262, 578, 10103, 1485, 5739, 14196, 5811, 1253, 387, 832, 315, 279, 2768, 4595, 512, 262, 353, 1595, 3628, 36005, 25421, 17921, 45722, 279, 1890, 3717, 374, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 25421, 55524, 45722, 264, 3717, 374, 3549, 323, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 48849, 10387, 26850, 45722, 264, 3882, 374, 3549, 323, 5946, 311, 279, 4927, 382, 14711, 6075, 512, 755, 1629, 29984, 34189, 5739, 11, 4927, 997, 262, 4304, 6869, 264, 7901, 449, 61701, 382, 262, 10103, 13802, 368, 14196, 690, 387, 2663, 449, 832, 5811, 311, 9203, 279, 198, 262, 7901, 13, 10103, 13802, 14196, 1253, 387, 2663, 810, 1109, 3131, 26, 433, 1288, 617, 198, 262, 912, 3185, 6372, 1023, 1109, 14238, 311, 279, 4729, 389, 279, 2728, 198, 262, 3717, 13, 10103, 13802, 14196, 1288, 539, 1650, 10103, 17869, 55358, 477, 10103, 34659, 368, 14196, 280, 262, 1521, 690, 387, 2663, 9651, 382, 262, 578, 10103, 1485, 5739, 14196, 5811, 1253, 387, 832, 315, 279, 2768, 4595, 512, 262, 353, 1595, 3628, 36005, 25421, 17921, 45722, 279, 1890, 3717, 374, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 25421, 55524, 45722, 264, 3717, 374, 3549, 323, 5946, 311, 279, 4927, 627, 262, 353, 1595, 3628, 36005, 48849, 10387, 26850, 45722, 264, 3882, 374, 3549, 323, 5946, 311, 279, 4927, 627, 262, 3270, 262, 422, 11656, 34189, 5739, 11, 43275, 25421, 17921, 997, 286, 471, 721, 74470, 63845, 17641, 34189, 5739, 11, 4927, 340, 262, 4508, 11656, 34189, 5739, 11, 43275, 25421, 55524, 997, 286, 449, 1380, 5739, 11034, 368, 439, 3717, 512, 310, 471, 721, 74470, 63845, 17641, 25119, 11, 4927, 340, 262, 4508, 11656, 34189, 5739, 11, 43275, 48849, 10387, 26850, 997, 286, 3882, 284, 1380, 5739, 7, 2784, 12255, 1800, 3702, 340, 286, 471, 721, 74470, 63845, 17641, 16663, 11, 4927, 340, 262, 775, 512, 286, 4933, 26082, 446, 15357, 956, 1440, 1268, 311, 1629, 264, 7901, 389, 1034, 82, 498, 955, 34189, 5739, 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 ]
inveniosoftware/invenio-collections
invenio_collections/ext.py
_AppState.collections
def collections(self, values): """Set list of collections.""" # if cache server is configured, save collection list if self.cache: self.cache.set( self.app.config['COLLECTIONS_CACHE_KEY'], values)
python
def collections(self, values): """Set list of collections.""" # if cache server is configured, save collection list if self.cache: self.cache.set( self.app.config['COLLECTIONS_CACHE_KEY'], values)
[ "def", "collections", "(", "self", ",", "values", ")", ":", "# if cache server is configured, save collection list", "if", "self", ".", "cache", ":", "self", ".", "cache", ".", "set", "(", "self", ".", "app", ".", "config", "[", "'COLLECTIONS_CACHE_KEY'", "]", ",", "values", ")" ]
Set list of collections.
[ "Set", "list", "of", "collections", "." ]
train
https://github.com/inveniosoftware/invenio-collections/blob/f3adca45c6d00a4dbf1f48fd501e8a68fe347f2f/invenio_collections/ext.py#L63-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: Set list of collections. ### Response: def collections(self, values): """Set list of collections.""" # if cache server is configured, save collection list if self.cache: self.cache.set( self.app.config['COLLECTIONS_CACHE_KEY'], 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, 1681, 1160, 315, 15661, 382, 14711, 6075, 512, 755, 15661, 1214, 11, 2819, 997, 286, 4304, 1681, 1160, 315, 15661, 14781, 286, 674, 422, 6636, 3622, 374, 20336, 11, 3665, 4526, 1160, 198, 286, 422, 659, 20688, 512, 310, 659, 20688, 995, 1021, 394, 659, 1632, 5539, 681, 19924, 29117, 50, 30238, 6738, 4181, 2819, 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,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 1681, 1160, 315, 15661, 382, 14711, 6075, 512, 755, 15661, 1214, 11, 2819, 997, 286, 4304, 1681, 1160, 315, 15661, 14781, 286, 674, 422, 6636, 3622, 374, 20336, 11, 3665, 4526, 1160, 198, 286, 422, 659, 20688, 512, 310, 659, 20688, 995, 1021, 394, 659, 1632, 5539, 681, 19924, 29117, 50, 30238, 6738, 4181, 2819, 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 ]
oceanprotocol/squid-py
squid_py/ocean/ocean_assets.py
OceanAssets.create
def create(self, metadata, publisher_account, service_descriptors=None, providers=None, use_secret_store=True): """ Register an asset in both the keeper's DIDRegistry (on-chain) and in the Metadata store ( Aquarius). :param metadata: dict conforming to the Metadata accepted by Ocean Protocol. :param publisher_account: Account of the publisher registering this asset :param service_descriptors: list of ServiceDescriptor tuples of length 2. The first item must be one of ServiceTypes and the second item is a dict of parameters and values required by the service :param providers: list of addresses of providers of this asset (a provider is an ethereum account that is authorized to provide asset services) :return: DDO instance """ assert isinstance(metadata, dict), f'Expected metadata of type dict, got {type(metadata)}' if not metadata or not Metadata.validate(metadata): raise OceanInvalidMetadata('Metadata seems invalid. Please make sure' ' the required metadata values are filled in.') # copy metadata so we don't change the original metadata_copy = copy.deepcopy(metadata) # Create a DDO object did = DID.did() logger.debug(f'Generating new did: {did}') # Check if it's already registered first! if did in self._get_aquarius().list_assets(): raise OceanDIDAlreadyExist( f'Asset id {did} is already registered to another asset.') ddo = DDO(did) # Add public key and authentication ddo.add_public_key(did, publisher_account.address) ddo.add_authentication(did, PUBLIC_KEY_TYPE_RSA) # Setup metadata service # First replace `files` with encrypted `files` assert metadata_copy['base'][ 'files'], 'files is required in the metadata base attributes.' assert Metadata.validate(metadata), 'metadata seems invalid.' logger.debug('Encrypting content urls in the metadata.') brizo = BrizoProvider.get_brizo() if not use_secret_store: encrypt_endpoint = brizo.get_encrypt_endpoint(self._config) files_encrypted = brizo.encrypt_files_dict( metadata_copy['base']['files'], encrypt_endpoint, ddo.asset_id, publisher_account.address, self._keeper.sign_hash(ddo.asset_id, publisher_account) ) else: files_encrypted = self._get_secret_store(publisher_account) \ .encrypt_document( did_to_id(did), json.dumps(metadata_copy['base']['files']), ) metadata_copy['base']['checksum'] = ddo.generate_checksum(did, metadata) ddo.add_proof(metadata_copy['base']['checksum'], publisher_account, self._keeper) # only assign if the encryption worked if files_encrypted: logger.info(f'Content urls encrypted successfully {files_encrypted}') index = 0 for file in metadata_copy['base']['files']: file['index'] = index index = index + 1 del file['url'] metadata_copy['base']['encryptedFiles'] = files_encrypted else: raise AssertionError('Encrypting the files failed. Make sure the secret store is' ' setup properly in your config file.') # DDO url and `Metadata` service ddo_service_endpoint = self._get_aquarius().get_service_endpoint(did) metadata_service_desc = ServiceDescriptor.metadata_service_descriptor(metadata_copy, ddo_service_endpoint) if not service_descriptors: service_descriptors = [ServiceDescriptor.authorization_service_descriptor( self._config.secret_store_url)] brizo = BrizoProvider.get_brizo() service_descriptors += [ServiceDescriptor.access_service_descriptor( metadata[MetadataBase.KEY]['price'], brizo.get_consume_endpoint(self._config), brizo.get_service_endpoint(self._config), 3600, self._keeper.escrow_access_secretstore_template.address )] else: service_types = set(map(lambda x: x[0], service_descriptors)) if ServiceTypes.AUTHORIZATION not in service_types: service_descriptors += [ServiceDescriptor.authorization_service_descriptor( self._config.secret_store_url)] else: brizo = BrizoProvider.get_brizo() service_descriptors += [ServiceDescriptor.access_service_descriptor( metadata[MetadataBase.KEY]['price'], brizo.get_consume_endpoint(self._config), brizo.get_service_endpoint(self._config), 3600, self._keeper.escrow_access_secretstore_template.address )] # Add all services to ddo service_descriptors = service_descriptors + [metadata_service_desc] for service in ServiceFactory.build_services(did, service_descriptors): ddo.add_service(service) logger.debug( f'Generated ddo and services, DID is {ddo.did},' f' metadata service @{ddo_service_endpoint}, ' f'`Access` service initialize @{ddo.services[0].endpoints.service}.') response = None # register on-chain registered_on_chain = self._keeper.did_registry.register( did, checksum=Web3Provider.get_web3().sha3(text=metadata_copy['base']['checksum']), url=ddo_service_endpoint, account=publisher_account, providers=providers ) if registered_on_chain is False: logger.warning(f'Registering {did} on-chain failed.') return None logger.info(f'DDO with DID {did} successfully registered on chain.') try: # publish the new ddo in ocean-db/Aquarius response = self._get_aquarius().publish_asset_ddo(ddo) logger.debug('Asset/ddo published successfully in aquarius.') except ValueError as ve: raise ValueError(f'Invalid value to publish in the metadata: {str(ve)}') except Exception as e: logger.error(f'Publish asset in aquarius failed: {str(e)}') if not response: return None return ddo
python
def create(self, metadata, publisher_account, service_descriptors=None, providers=None, use_secret_store=True): """ Register an asset in both the keeper's DIDRegistry (on-chain) and in the Metadata store ( Aquarius). :param metadata: dict conforming to the Metadata accepted by Ocean Protocol. :param publisher_account: Account of the publisher registering this asset :param service_descriptors: list of ServiceDescriptor tuples of length 2. The first item must be one of ServiceTypes and the second item is a dict of parameters and values required by the service :param providers: list of addresses of providers of this asset (a provider is an ethereum account that is authorized to provide asset services) :return: DDO instance """ assert isinstance(metadata, dict), f'Expected metadata of type dict, got {type(metadata)}' if not metadata or not Metadata.validate(metadata): raise OceanInvalidMetadata('Metadata seems invalid. Please make sure' ' the required metadata values are filled in.') # copy metadata so we don't change the original metadata_copy = copy.deepcopy(metadata) # Create a DDO object did = DID.did() logger.debug(f'Generating new did: {did}') # Check if it's already registered first! if did in self._get_aquarius().list_assets(): raise OceanDIDAlreadyExist( f'Asset id {did} is already registered to another asset.') ddo = DDO(did) # Add public key and authentication ddo.add_public_key(did, publisher_account.address) ddo.add_authentication(did, PUBLIC_KEY_TYPE_RSA) # Setup metadata service # First replace `files` with encrypted `files` assert metadata_copy['base'][ 'files'], 'files is required in the metadata base attributes.' assert Metadata.validate(metadata), 'metadata seems invalid.' logger.debug('Encrypting content urls in the metadata.') brizo = BrizoProvider.get_brizo() if not use_secret_store: encrypt_endpoint = brizo.get_encrypt_endpoint(self._config) files_encrypted = brizo.encrypt_files_dict( metadata_copy['base']['files'], encrypt_endpoint, ddo.asset_id, publisher_account.address, self._keeper.sign_hash(ddo.asset_id, publisher_account) ) else: files_encrypted = self._get_secret_store(publisher_account) \ .encrypt_document( did_to_id(did), json.dumps(metadata_copy['base']['files']), ) metadata_copy['base']['checksum'] = ddo.generate_checksum(did, metadata) ddo.add_proof(metadata_copy['base']['checksum'], publisher_account, self._keeper) # only assign if the encryption worked if files_encrypted: logger.info(f'Content urls encrypted successfully {files_encrypted}') index = 0 for file in metadata_copy['base']['files']: file['index'] = index index = index + 1 del file['url'] metadata_copy['base']['encryptedFiles'] = files_encrypted else: raise AssertionError('Encrypting the files failed. Make sure the secret store is' ' setup properly in your config file.') # DDO url and `Metadata` service ddo_service_endpoint = self._get_aquarius().get_service_endpoint(did) metadata_service_desc = ServiceDescriptor.metadata_service_descriptor(metadata_copy, ddo_service_endpoint) if not service_descriptors: service_descriptors = [ServiceDescriptor.authorization_service_descriptor( self._config.secret_store_url)] brizo = BrizoProvider.get_brizo() service_descriptors += [ServiceDescriptor.access_service_descriptor( metadata[MetadataBase.KEY]['price'], brizo.get_consume_endpoint(self._config), brizo.get_service_endpoint(self._config), 3600, self._keeper.escrow_access_secretstore_template.address )] else: service_types = set(map(lambda x: x[0], service_descriptors)) if ServiceTypes.AUTHORIZATION not in service_types: service_descriptors += [ServiceDescriptor.authorization_service_descriptor( self._config.secret_store_url)] else: brizo = BrizoProvider.get_brizo() service_descriptors += [ServiceDescriptor.access_service_descriptor( metadata[MetadataBase.KEY]['price'], brizo.get_consume_endpoint(self._config), brizo.get_service_endpoint(self._config), 3600, self._keeper.escrow_access_secretstore_template.address )] # Add all services to ddo service_descriptors = service_descriptors + [metadata_service_desc] for service in ServiceFactory.build_services(did, service_descriptors): ddo.add_service(service) logger.debug( f'Generated ddo and services, DID is {ddo.did},' f' metadata service @{ddo_service_endpoint}, ' f'`Access` service initialize @{ddo.services[0].endpoints.service}.') response = None # register on-chain registered_on_chain = self._keeper.did_registry.register( did, checksum=Web3Provider.get_web3().sha3(text=metadata_copy['base']['checksum']), url=ddo_service_endpoint, account=publisher_account, providers=providers ) if registered_on_chain is False: logger.warning(f'Registering {did} on-chain failed.') return None logger.info(f'DDO with DID {did} successfully registered on chain.') try: # publish the new ddo in ocean-db/Aquarius response = self._get_aquarius().publish_asset_ddo(ddo) logger.debug('Asset/ddo published successfully in aquarius.') except ValueError as ve: raise ValueError(f'Invalid value to publish in the metadata: {str(ve)}') except Exception as e: logger.error(f'Publish asset in aquarius failed: {str(e)}') if not response: return None return ddo
[ "def", "create", "(", "self", ",", "metadata", ",", "publisher_account", ",", "service_descriptors", "=", "None", ",", "providers", "=", "None", ",", "use_secret_store", "=", "True", ")", ":", "assert", "isinstance", "(", "metadata", ",", "dict", ")", ",", "f'Expected metadata of type dict, got {type(metadata)}'", "if", "not", "metadata", "or", "not", "Metadata", ".", "validate", "(", "metadata", ")", ":", "raise", "OceanInvalidMetadata", "(", "'Metadata seems invalid. Please make sure'", "' the required metadata values are filled in.'", ")", "# copy metadata so we don't change the original", "metadata_copy", "=", "copy", ".", "deepcopy", "(", "metadata", ")", "# Create a DDO object", "did", "=", "DID", ".", "did", "(", ")", "logger", ".", "debug", "(", "f'Generating new did: {did}'", ")", "# Check if it's already registered first!", "if", "did", "in", "self", ".", "_get_aquarius", "(", ")", ".", "list_assets", "(", ")", ":", "raise", "OceanDIDAlreadyExist", "(", "f'Asset id {did} is already registered to another asset.'", ")", "ddo", "=", "DDO", "(", "did", ")", "# Add public key and authentication", "ddo", ".", "add_public_key", "(", "did", ",", "publisher_account", ".", "address", ")", "ddo", ".", "add_authentication", "(", "did", ",", "PUBLIC_KEY_TYPE_RSA", ")", "# Setup metadata service", "# First replace `files` with encrypted `files`", "assert", "metadata_copy", "[", "'base'", "]", "[", "'files'", "]", ",", "'files is required in the metadata base attributes.'", "assert", "Metadata", ".", "validate", "(", "metadata", ")", ",", "'metadata seems invalid.'", "logger", ".", "debug", "(", "'Encrypting content urls in the metadata.'", ")", "brizo", "=", "BrizoProvider", ".", "get_brizo", "(", ")", "if", "not", "use_secret_store", ":", "encrypt_endpoint", "=", "brizo", ".", "get_encrypt_endpoint", "(", "self", ".", "_config", ")", "files_encrypted", "=", "brizo", ".", "encrypt_files_dict", "(", "metadata_copy", "[", "'base'", "]", "[", "'files'", "]", ",", "encrypt_endpoint", ",", "ddo", ".", "asset_id", ",", "publisher_account", ".", "address", ",", "self", ".", "_keeper", ".", "sign_hash", "(", "ddo", ".", "asset_id", ",", "publisher_account", ")", ")", "else", ":", "files_encrypted", "=", "self", ".", "_get_secret_store", "(", "publisher_account", ")", ".", "encrypt_document", "(", "did_to_id", "(", "did", ")", ",", "json", ".", "dumps", "(", "metadata_copy", "[", "'base'", "]", "[", "'files'", "]", ")", ",", ")", "metadata_copy", "[", "'base'", "]", "[", "'checksum'", "]", "=", "ddo", ".", "generate_checksum", "(", "did", ",", "metadata", ")", "ddo", ".", "add_proof", "(", "metadata_copy", "[", "'base'", "]", "[", "'checksum'", "]", ",", "publisher_account", ",", "self", ".", "_keeper", ")", "# only assign if the encryption worked", "if", "files_encrypted", ":", "logger", ".", "info", "(", "f'Content urls encrypted successfully {files_encrypted}'", ")", "index", "=", "0", "for", "file", "in", "metadata_copy", "[", "'base'", "]", "[", "'files'", "]", ":", "file", "[", "'index'", "]", "=", "index", "index", "=", "index", "+", "1", "del", "file", "[", "'url'", "]", "metadata_copy", "[", "'base'", "]", "[", "'encryptedFiles'", "]", "=", "files_encrypted", "else", ":", "raise", "AssertionError", "(", "'Encrypting the files failed. Make sure the secret store is'", "' setup properly in your config file.'", ")", "# DDO url and `Metadata` service", "ddo_service_endpoint", "=", "self", ".", "_get_aquarius", "(", ")", ".", "get_service_endpoint", "(", "did", ")", "metadata_service_desc", "=", "ServiceDescriptor", ".", "metadata_service_descriptor", "(", "metadata_copy", ",", "ddo_service_endpoint", ")", "if", "not", "service_descriptors", ":", "service_descriptors", "=", "[", "ServiceDescriptor", ".", "authorization_service_descriptor", "(", "self", ".", "_config", ".", "secret_store_url", ")", "]", "brizo", "=", "BrizoProvider", ".", "get_brizo", "(", ")", "service_descriptors", "+=", "[", "ServiceDescriptor", ".", "access_service_descriptor", "(", "metadata", "[", "MetadataBase", ".", "KEY", "]", "[", "'price'", "]", ",", "brizo", ".", "get_consume_endpoint", "(", "self", ".", "_config", ")", ",", "brizo", ".", "get_service_endpoint", "(", "self", ".", "_config", ")", ",", "3600", ",", "self", ".", "_keeper", ".", "escrow_access_secretstore_template", ".", "address", ")", "]", "else", ":", "service_types", "=", "set", "(", "map", "(", "lambda", "x", ":", "x", "[", "0", "]", ",", "service_descriptors", ")", ")", "if", "ServiceTypes", ".", "AUTHORIZATION", "not", "in", "service_types", ":", "service_descriptors", "+=", "[", "ServiceDescriptor", ".", "authorization_service_descriptor", "(", "self", ".", "_config", ".", "secret_store_url", ")", "]", "else", ":", "brizo", "=", "BrizoProvider", ".", "get_brizo", "(", ")", "service_descriptors", "+=", "[", "ServiceDescriptor", ".", "access_service_descriptor", "(", "metadata", "[", "MetadataBase", ".", "KEY", "]", "[", "'price'", "]", ",", "brizo", ".", "get_consume_endpoint", "(", "self", ".", "_config", ")", ",", "brizo", ".", "get_service_endpoint", "(", "self", ".", "_config", ")", ",", "3600", ",", "self", ".", "_keeper", ".", "escrow_access_secretstore_template", ".", "address", ")", "]", "# Add all services to ddo", "service_descriptors", "=", "service_descriptors", "+", "[", "metadata_service_desc", "]", "for", "service", "in", "ServiceFactory", ".", "build_services", "(", "did", ",", "service_descriptors", ")", ":", "ddo", ".", "add_service", "(", "service", ")", "logger", ".", "debug", "(", "f'Generated ddo and services, DID is {ddo.did},'", "f' metadata service @{ddo_service_endpoint}, '", "f'`Access` service initialize @{ddo.services[0].endpoints.service}.'", ")", "response", "=", "None", "# register on-chain", "registered_on_chain", "=", "self", ".", "_keeper", ".", "did_registry", ".", "register", "(", "did", ",", "checksum", "=", "Web3Provider", ".", "get_web3", "(", ")", ".", "sha3", "(", "text", "=", "metadata_copy", "[", "'base'", "]", "[", "'checksum'", "]", ")", ",", "url", "=", "ddo_service_endpoint", ",", "account", "=", "publisher_account", ",", "providers", "=", "providers", ")", "if", "registered_on_chain", "is", "False", ":", "logger", ".", "warning", "(", "f'Registering {did} on-chain failed.'", ")", "return", "None", "logger", ".", "info", "(", "f'DDO with DID {did} successfully registered on chain.'", ")", "try", ":", "# publish the new ddo in ocean-db/Aquarius", "response", "=", "self", ".", "_get_aquarius", "(", ")", ".", "publish_asset_ddo", "(", "ddo", ")", "logger", ".", "debug", "(", "'Asset/ddo published successfully in aquarius.'", ")", "except", "ValueError", "as", "ve", ":", "raise", "ValueError", "(", "f'Invalid value to publish in the metadata: {str(ve)}'", ")", "except", "Exception", "as", "e", ":", "logger", ".", "error", "(", "f'Publish asset in aquarius failed: {str(e)}'", ")", "if", "not", "response", ":", "return", "None", "return", "ddo" ]
Register an asset in both the keeper's DIDRegistry (on-chain) and in the Metadata store ( Aquarius). :param metadata: dict conforming to the Metadata accepted by Ocean Protocol. :param publisher_account: Account of the publisher registering this asset :param service_descriptors: list of ServiceDescriptor tuples of length 2. The first item must be one of ServiceTypes and the second item is a dict of parameters and values required by the service :param providers: list of addresses of providers of this asset (a provider is an ethereum account that is authorized to provide asset services) :return: DDO instance
[ "Register", "an", "asset", "in", "both", "the", "keeper", "s", "DIDRegistry", "(", "on", "-", "chain", ")", "and", "in", "the", "Metadata", "store", "(", "Aquarius", ")", "." ]
train
https://github.com/oceanprotocol/squid-py/blob/43a5b7431627e4c9ab7382ed9eb8153e96ed4483/squid_py/ocean/ocean_assets.py#L56-L195
<|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 an asset in both the keeper's DIDRegistry (on-chain) and in the Metadata store ( Aquarius). :param metadata: dict conforming to the Metadata accepted by Ocean Protocol. :param publisher_account: Account of the publisher registering this asset :param service_descriptors: list of ServiceDescriptor tuples of length 2. The first item must be one of ServiceTypes and the second item is a dict of parameters and values required by the service :param providers: list of addresses of providers of this asset (a provider is an ethereum account that is authorized to provide asset services) :return: DDO instance ### Response: def create(self, metadata, publisher_account, service_descriptors=None, providers=None, use_secret_store=True): """ Register an asset in both the keeper's DIDRegistry (on-chain) and in the Metadata store ( Aquarius). :param metadata: dict conforming to the Metadata accepted by Ocean Protocol. :param publisher_account: Account of the publisher registering this asset :param service_descriptors: list of ServiceDescriptor tuples of length 2. The first item must be one of ServiceTypes and the second item is a dict of parameters and values required by the service :param providers: list of addresses of providers of this asset (a provider is an ethereum account that is authorized to provide asset services) :return: DDO instance """ assert isinstance(metadata, dict), f'Expected metadata of type dict, got {type(metadata)}' if not metadata or not Metadata.validate(metadata): raise OceanInvalidMetadata('Metadata seems invalid. Please make sure' ' the required metadata values are filled in.') # copy metadata so we don't change the original metadata_copy = copy.deepcopy(metadata) # Create a DDO object did = DID.did() logger.debug(f'Generating new did: {did}') # Check if it's already registered first! if did in self._get_aquarius().list_assets(): raise OceanDIDAlreadyExist( f'Asset id {did} is already registered to another asset.') ddo = DDO(did) # Add public key and authentication ddo.add_public_key(did, publisher_account.address) ddo.add_authentication(did, PUBLIC_KEY_TYPE_RSA) # Setup metadata service # First replace `files` with encrypted `files` assert metadata_copy['base'][ 'files'], 'files is required in the metadata base attributes.' assert Metadata.validate(metadata), 'metadata seems invalid.' logger.debug('Encrypting content urls in the metadata.') brizo = BrizoProvider.get_brizo() if not use_secret_store: encrypt_endpoint = brizo.get_encrypt_endpoint(self._config) files_encrypted = brizo.encrypt_files_dict( metadata_copy['base']['files'], encrypt_endpoint, ddo.asset_id, publisher_account.address, self._keeper.sign_hash(ddo.asset_id, publisher_account) ) else: files_encrypted = self._get_secret_store(publisher_account) \ .encrypt_document( did_to_id(did), json.dumps(metadata_copy['base']['files']), ) metadata_copy['base']['checksum'] = ddo.generate_checksum(did, metadata) ddo.add_proof(metadata_copy['base']['checksum'], publisher_account, self._keeper) # only assign if the encryption worked if files_encrypted: logger.info(f'Content urls encrypted successfully {files_encrypted}') index = 0 for file in metadata_copy['base']['files']: file['index'] = index index = index + 1 del file['url'] metadata_copy['base']['encryptedFiles'] = files_encrypted else: raise AssertionError('Encrypting the files failed. Make sure the secret store is' ' setup properly in your config file.') # DDO url and `Metadata` service ddo_service_endpoint = self._get_aquarius().get_service_endpoint(did) metadata_service_desc = ServiceDescriptor.metadata_service_descriptor(metadata_copy, ddo_service_endpoint) if not service_descriptors: service_descriptors = [ServiceDescriptor.authorization_service_descriptor( self._config.secret_store_url)] brizo = BrizoProvider.get_brizo() service_descriptors += [ServiceDescriptor.access_service_descriptor( metadata[MetadataBase.KEY]['price'], brizo.get_consume_endpoint(self._config), brizo.get_service_endpoint(self._config), 3600, self._keeper.escrow_access_secretstore_template.address )] else: service_types = set(map(lambda x: x[0], service_descriptors)) if ServiceTypes.AUTHORIZATION not in service_types: service_descriptors += [ServiceDescriptor.authorization_service_descriptor( self._config.secret_store_url)] else: brizo = BrizoProvider.get_brizo() service_descriptors += [ServiceDescriptor.access_service_descriptor( metadata[MetadataBase.KEY]['price'], brizo.get_consume_endpoint(self._config), brizo.get_service_endpoint(self._config), 3600, self._keeper.escrow_access_secretstore_template.address )] # Add all services to ddo service_descriptors = service_descriptors + [metadata_service_desc] for service in ServiceFactory.build_services(did, service_descriptors): ddo.add_service(service) logger.debug( f'Generated ddo and services, DID is {ddo.did},' f' metadata service @{ddo_service_endpoint}, ' f'`Access` service initialize @{ddo.services[0].endpoints.service}.') response = None # register on-chain registered_on_chain = self._keeper.did_registry.register( did, checksum=Web3Provider.get_web3().sha3(text=metadata_copy['base']['checksum']), url=ddo_service_endpoint, account=publisher_account, providers=providers ) if registered_on_chain is False: logger.warning(f'Registering {did} on-chain failed.') return None logger.info(f'DDO with DID {did} successfully registered on chain.') try: # publish the new ddo in ocean-db/Aquarius response = self._get_aquarius().publish_asset_ddo(ddo) logger.debug('Asset/ddo published successfully in aquarius.') except ValueError as ve: raise ValueError(f'Invalid value to publish in the metadata: {str(ve)}') except Exception as e: logger.error(f'Publish asset in aquarius failed: {str(e)}') if not response: return None return ddo <|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, 459, 9513, 304, 2225, 279, 54516, 596, 60219, 15976, 320, 263, 66286, 8, 323, 304, 279, 34689, 3637, 2456, 286, 23815, 41321, 3677, 286, 551, 913, 11408, 25, 6587, 26965, 287, 311, 279, 34689, 11928, 555, 22302, 25590, 627, 286, 551, 913, 21959, 13808, 25, 8785, 315, 279, 21959, 39829, 420, 9513, 198, 286, 551, 913, 2532, 16145, 26789, 25, 1160, 315, 5475, 11971, 46325, 315, 3160, 220, 17, 627, 310, 578, 1176, 1537, 2011, 387, 832, 315, 5475, 4266, 323, 279, 2132, 198, 310, 1537, 374, 264, 6587, 315, 5137, 323, 2819, 2631, 555, 279, 2532, 198, 286, 551, 913, 12850, 25, 1160, 315, 14564, 315, 12850, 315, 420, 9513, 320, 64, 9287, 374, 198, 310, 459, 85622, 2759, 430, 374, 19144, 311, 3493, 9513, 3600, 340, 286, 551, 693, 25, 423, 5989, 2937, 271, 14711, 6075, 512, 755, 1893, 1214, 11, 11408, 11, 21959, 13808, 345, 2342, 2532, 16145, 26789, 5980, 11, 12850, 5980, 345, 2342, 1005, 22729, 15153, 3702, 997, 286, 3270, 286, 8618, 459, 9513, 304, 2225, 279, 54516, 596, 60219, 15976, 320, 263, 66286, 8, 323, 304, 279, 34689, 3637, 2456, 286, 23815, 41321, 3677, 286, 551, 913, 11408, 25, 6587, 26965, 287, 311, 279, 34689, 11928, 555, 22302, 25590, 627, 286, 551, 913, 21959, 13808, 25, 8785, 315, 279, 21959, 39829, 420, 9513, 198, 286, 551, 913, 2532, 16145, 26789, 25, 1160, 315, 5475, 11971, 46325, 315, 3160, 220, 17, 627, 310, 578, 1176, 1537, 2011, 387, 832, 315, 5475, 4266, 323, 279, 2132, 198, 310, 1537, 374, 264, 6587, 315, 5137, 323, 2819, 2631, 555, 279, 2532, 198, 286, 551, 913, 12850, 25, 1160, 315, 14564, 315, 12850, 315, 420, 9513, 320, 64, 9287, 374, 198, 310, 459, 85622, 2759, 430, 374, 19144, 311, 3493, 9513, 3600, 340, 286, 551, 693, 25, 423, 5989, 2937, 198, 286, 3270, 286, 2105, 11656, 55536, 11, 6587, 705, 282, 6, 19430, 11408, 315, 955, 6587, 11, 2751, 314, 1337, 55536, 9317, 1270, 286, 422, 539, 11408, 477, 539, 34689, 20090, 55536, 997, 310, 4933, 22302, 8087, 14952, 493, 14952, 5084, 8482, 13, 5321, 1304, 2771, 1270, 11317, 364, 279, 2631, 11408, 2819, 527, 10409, 304, 49420, 286, 674, 3048, 11408, 779, 584, 1541, 956, 2349, 279, 4113, 198, 286, 11408, 16486, 284, 3048, 52748, 55536, 696, 286, 674, 4324, 264, 423, 5989, 1665, 198, 286, 1550, 284, 60219, 49054, 746, 286, 6050, 8042, 968, 6, 74414, 502, 1550, 25, 314, 23770, 33968, 286, 674, 4343, 422, 433, 596, 2736, 9879, 1176, 4999, 286, 422, 1550, 304, 659, 1462, 456, 4404, 447, 41321, 1020, 1638, 54399, 4019, 310, 4933, 22302, 35, 926, 39470, 26695, 1021, 394, 282, 6, 17015, 887, 314, 23770, 92, 374, 2736, 9879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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 459, 9513, 304, 2225, 279, 54516, 596, 60219, 15976, 320, 263, 66286, 8, 323, 304, 279, 34689, 3637, 2456, 286, 23815, 41321, 3677, 286, 551, 913, 11408, 25, 6587, 26965, 287, 311, 279, 34689, 11928, 555, 22302, 25590, 627, 286, 551, 913, 21959, 13808, 25, 8785, 315, 279, 21959, 39829, 420, 9513, 198, 286, 551, 913, 2532, 16145, 26789, 25, 1160, 315, 5475, 11971, 46325, 315, 3160, 220, 17, 627, 310, 578, 1176, 1537, 2011, 387, 832, 315, 5475, 4266, 323, 279, 2132, 198, 310, 1537, 374, 264, 6587, 315, 5137, 323, 2819, 2631, 555, 279, 2532, 198, 286, 551, 913, 12850, 25, 1160, 315, 14564, 315, 12850, 315, 420, 9513, 320, 64, 9287, 374, 198, 310, 459, 85622, 2759, 430, 374, 19144, 311, 3493, 9513, 3600, 340, 286, 551, 693, 25, 423, 5989, 2937, 271, 14711, 6075, 512, 755, 1893, 1214, 11, 11408, 11, 21959, 13808, 345, 2342, 2532, 16145, 26789, 5980, 11, 12850, 5980, 345, 2342, 1005, 22729, 15153, 3702, 997, 286, 3270, 286, 8618, 459, 9513, 304, 2225, 279, 54516, 596, 60219, 15976, 320, 263, 66286, 8, 323, 304, 279, 34689, 3637, 2456, 286, 23815, 41321, 3677, 286, 551, 913, 11408, 25, 6587, 26965, 287, 311, 279, 34689, 11928, 555, 22302, 25590, 627, 286, 551, 913, 21959, 13808, 25, 8785, 315, 279, 21959, 39829, 420, 9513, 198, 286, 551, 913, 2532, 16145, 26789, 25, 1160, 315, 5475, 11971, 46325, 315, 3160, 220, 17, 627, 310, 578, 1176, 1537, 2011, 387, 832, 315, 5475, 4266, 323, 279, 2132, 198, 310, 1537, 374, 264, 6587, 315, 5137, 323, 2819, 2631, 555, 279, 2532, 198, 286, 551, 913, 12850, 25, 1160, 315, 14564, 315, 12850, 315, 420, 9513, 320, 64, 9287, 374, 198, 310, 459, 85622, 2759, 430, 374, 19144, 311, 3493, 9513, 3600, 340, 286, 551, 693, 25, 423, 5989, 2937, 198, 286, 3270, 286, 2105, 11656, 55536, 11, 6587, 705, 282, 6, 19430, 11408, 315, 955, 6587, 11, 2751, 314, 1337, 55536, 9317, 1270, 286, 422, 539, 11408, 477, 539, 34689, 20090, 55536, 997, 310, 4933, 22302, 8087, 14952, 493, 14952, 5084, 8482, 13, 5321, 1304, 2771, 1270, 11317, 364, 279, 2631, 11408, 2819, 527, 10409, 304, 49420, 286, 674, 3048, 11408, 779, 584, 1541, 956, 2349, 279, 4113, 198, 286, 11408, 16486, 284, 3048, 52748, 55536, 696, 286, 674, 4324, 264, 423, 5989, 1665, 198, 286, 1550, 284, 60219, 49054, 746, 286, 6050, 8042, 968, 6, 74414, 502, 1550, 25, 314, 23770, 33968, 286, 674, 4343, 422, 433, 596, 2736, 9879, 1176, 4999, 286, 422, 1550, 304, 659, 1462, 456, 4404, 447, 41321, 1020, 1638, 54399, 4019, 310, 4933, 22302, 35, 926, 39470, 26695, 1021, 394, 282, 6, 17015, 887, 314, 23770, 92, 374, 2736, 9879, 311, 2500, 9513, 49420, 286, 294, 3055, 284, 423, 5989, 1528, 307, 696, 286, 674, 2758, 586, 1401, 323, 17066, 198, 286, 294 ]
StackStorm/pybind
pybind/slxos/v17r_1_01a/cfm_state/__init__.py
cfm_state._set_dmm
def _set_dmm(self, v, load=False): """ Setter method for dmm, mapped from YANG variable /cfm_state/dmm (container) If this variable is read-only (config: false) in the source YANG file, then _set_dmm is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_dmm() directly. YANG Description: CFM Y1731 DM Details """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass(v,base=dmm.dmm, is_container='container', presence=False, yang_name="dmm", rest_name="dmm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'callpoint': u'dot1ag-dmm', u'cli-suppress-show-path': None}}, namespace='urn:brocade.com:mgmt:brocade-dot1ag-operational', defining_module='brocade-dot1ag-operational', yang_type='container', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """dmm must be of a type compatible with container""", 'defined-type': "container", 'generated-type': """YANGDynClass(base=dmm.dmm, is_container='container', presence=False, yang_name="dmm", rest_name="dmm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'callpoint': u'dot1ag-dmm', u'cli-suppress-show-path': None}}, namespace='urn:brocade.com:mgmt:brocade-dot1ag-operational', defining_module='brocade-dot1ag-operational', yang_type='container', is_config=False)""", }) self.__dmm = t if hasattr(self, '_set'): self._set()
python
def _set_dmm(self, v, load=False): """ Setter method for dmm, mapped from YANG variable /cfm_state/dmm (container) If this variable is read-only (config: false) in the source YANG file, then _set_dmm is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_dmm() directly. YANG Description: CFM Y1731 DM Details """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass(v,base=dmm.dmm, is_container='container', presence=False, yang_name="dmm", rest_name="dmm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'callpoint': u'dot1ag-dmm', u'cli-suppress-show-path': None}}, namespace='urn:brocade.com:mgmt:brocade-dot1ag-operational', defining_module='brocade-dot1ag-operational', yang_type='container', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """dmm must be of a type compatible with container""", 'defined-type': "container", 'generated-type': """YANGDynClass(base=dmm.dmm, is_container='container', presence=False, yang_name="dmm", rest_name="dmm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'callpoint': u'dot1ag-dmm', u'cli-suppress-show-path': None}}, namespace='urn:brocade.com:mgmt:brocade-dot1ag-operational', defining_module='brocade-dot1ag-operational', yang_type='container', is_config=False)""", }) self.__dmm = t if hasattr(self, '_set'): self._set()
[ "def", "_set_dmm", "(", "self", ",", "v", ",", "load", "=", "False", ")", ":", "if", "hasattr", "(", "v", ",", "\"_utype\"", ")", ":", "v", "=", "v", ".", "_utype", "(", "v", ")", "try", ":", "t", "=", "YANGDynClass", "(", "v", ",", "base", "=", "dmm", ".", "dmm", ",", "is_container", "=", "'container'", ",", "presence", "=", "False", ",", "yang_name", "=", "\"dmm\"", ",", "rest_name", "=", "\"dmm\"", ",", "parent", "=", "self", ",", "path_helper", "=", "self", ".", "_path_helper", ",", "extmethods", "=", "self", ".", "_extmethods", ",", "register_paths", "=", "True", ",", "extensions", "=", "{", "u'tailf-common'", ":", "{", "u'callpoint'", ":", "u'dot1ag-dmm'", ",", "u'cli-suppress-show-path'", ":", "None", "}", "}", ",", "namespace", "=", "'urn:brocade.com:mgmt:brocade-dot1ag-operational'", ",", "defining_module", "=", "'brocade-dot1ag-operational'", ",", "yang_type", "=", "'container'", ",", "is_config", "=", "False", ")", "except", "(", "TypeError", ",", "ValueError", ")", ":", "raise", "ValueError", "(", "{", "'error-string'", ":", "\"\"\"dmm must be of a type compatible with container\"\"\"", ",", "'defined-type'", ":", "\"container\"", ",", "'generated-type'", ":", "\"\"\"YANGDynClass(base=dmm.dmm, is_container='container', presence=False, yang_name=\"dmm\", rest_name=\"dmm\", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'callpoint': u'dot1ag-dmm', u'cli-suppress-show-path': None}}, namespace='urn:brocade.com:mgmt:brocade-dot1ag-operational', defining_module='brocade-dot1ag-operational', yang_type='container', is_config=False)\"\"\"", ",", "}", ")", "self", ".", "__dmm", "=", "t", "if", "hasattr", "(", "self", ",", "'_set'", ")", ":", "self", ".", "_set", "(", ")" ]
Setter method for dmm, mapped from YANG variable /cfm_state/dmm (container) If this variable is read-only (config: false) in the source YANG file, then _set_dmm is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_dmm() directly. YANG Description: CFM Y1731 DM Details
[ "Setter", "method", "for", "dmm", "mapped", "from", "YANG", "variable", "/", "cfm_state", "/", "dmm", "(", "container", ")", "If", "this", "variable", "is", "read", "-", "only", "(", "config", ":", "false", ")", "in", "the", "source", "YANG", "file", "then", "_set_dmm", "is", "considered", "as", "a", "private", "method", ".", "Backends", "looking", "to", "populate", "this", "variable", "should", "do", "so", "via", "calling", "thisObj", ".", "_set_dmm", "()", "directly", "." ]
train
https://github.com/StackStorm/pybind/blob/44c467e71b2b425be63867aba6e6fa28b2cfe7fb/pybind/slxos/v17r_1_01a/cfm_state/__init__.py#L252-L275
<|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: Setter method for dmm, mapped from YANG variable /cfm_state/dmm (container) If this variable is read-only (config: false) in the source YANG file, then _set_dmm is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_dmm() directly. YANG Description: CFM Y1731 DM Details ### Response: def _set_dmm(self, v, load=False): """ Setter method for dmm, mapped from YANG variable /cfm_state/dmm (container) If this variable is read-only (config: false) in the source YANG file, then _set_dmm is considered as a private method. Backends looking to populate this variable should do so via calling thisObj._set_dmm() directly. YANG Description: CFM Y1731 DM Details """ if hasattr(v, "_utype"): v = v._utype(v) try: t = YANGDynClass(v,base=dmm.dmm, is_container='container', presence=False, yang_name="dmm", rest_name="dmm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'callpoint': u'dot1ag-dmm', u'cli-suppress-show-path': None}}, namespace='urn:brocade.com:mgmt:brocade-dot1ag-operational', defining_module='brocade-dot1ag-operational', yang_type='container', is_config=False) except (TypeError, ValueError): raise ValueError({ 'error-string': """dmm must be of a type compatible with container""", 'defined-type': "container", 'generated-type': """YANGDynClass(base=dmm.dmm, is_container='container', presence=False, yang_name="dmm", rest_name="dmm", parent=self, path_helper=self._path_helper, extmethods=self._extmethods, register_paths=True, extensions={u'tailf-common': {u'callpoint': u'dot1ag-dmm', u'cli-suppress-show-path': None}}, namespace='urn:brocade.com:mgmt:brocade-dot1ag-operational', defining_module='brocade-dot1ag-operational', yang_type='container', is_config=False)""", }) self.__dmm = t if hasattr(self, '_set'): self._set() <|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, 45394, 1749, 369, 294, 3906, 11, 24784, 505, 816, 5330, 3977, 611, 9991, 76, 4486, 3529, 3906, 320, 3670, 340, 262, 1442, 420, 3977, 374, 1373, 15744, 320, 1710, 25, 905, 8, 304, 279, 198, 262, 2592, 816, 5330, 1052, 11, 1243, 721, 751, 821, 3906, 374, 6646, 439, 264, 879, 198, 262, 1749, 13, 6984, 1438, 3411, 311, 31546, 420, 3977, 1288, 198, 262, 656, 779, 4669, 8260, 420, 5374, 1462, 751, 821, 3906, 368, 6089, 382, 262, 816, 5330, 7817, 25, 21459, 44, 816, 11908, 16, 20804, 12589, 271, 14711, 6075, 512, 755, 721, 751, 821, 3906, 1214, 11, 348, 11, 2865, 5725, 997, 262, 3270, 262, 70364, 1749, 369, 294, 3906, 11, 24784, 505, 816, 5330, 3977, 611, 9991, 76, 4486, 3529, 3906, 320, 3670, 340, 262, 1442, 420, 3977, 374, 1373, 15744, 320, 1710, 25, 905, 8, 304, 279, 198, 262, 2592, 816, 5330, 1052, 11, 1243, 721, 751, 821, 3906, 374, 6646, 439, 264, 879, 198, 262, 1749, 13, 6984, 1438, 3411, 311, 31546, 420, 3977, 1288, 198, 262, 656, 779, 4669, 8260, 420, 5374, 1462, 751, 821, 3906, 368, 6089, 382, 262, 816, 5330, 7817, 25, 21459, 44, 816, 11908, 16, 20804, 12589, 198, 262, 3270, 262, 422, 32156, 3832, 11, 9177, 332, 500, 15497, 415, 348, 284, 348, 1462, 332, 500, 3832, 340, 262, 1456, 512, 415, 259, 284, 816, 5330, 96809, 1999, 3832, 11, 3231, 26477, 3906, 962, 3906, 11, 374, 16226, 1151, 3670, 518, 9546, 5725, 11, 10587, 1292, 429, 67, 3906, 498, 2800, 1292, 429, 67, 3906, 498, 2748, 7822, 11, 1853, 10635, 7822, 1462, 2398, 10635, 11, 1327, 36842, 7822, 1462, 428, 36842, 11, 4254, 25124, 3702, 11, 20300, 1185, 84, 956, 607, 69, 46145, 1232, 314, 84, 6, 6797, 2837, 1232, 577, 4265, 354, 16, 351, 1773, 3906, 518, 577, 6, 20091, 59615, 1911, 31637, 34195, 1232, 2290, 39254, 4573, 1151, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 82002, 16, 351, 59655, 1697, 518, 27409, 10983, 1151, 15222, 33896, 82002, 16, 351, 59655, 1697, 518, 10587, 1857, 1151, 3670, 518, 374, 5445, 5725, 340, 262, 3734, 320, 81176, 11, 15764, 997, 415, 4933, 15764, 2313, 692, 364, 850, 31981, 1232, 4304, 67, 3906, 2011, 387, 315, 264, 955, 18641, 449, 5593, 75834, 692, 364, 9910, 10827, 1232, 330, 3670, 761, 692, 364, 16583, 10827, 1232, 4304, 56, 5330, 96809, 1999, 12952, 26477, 3906, 962, 3906, 11, 374, 16226, 1151, 3670, 518, 9546, 5725, 11, 10587, 1292, 429, 67, 3906, 498, 2800, 1292, 429, 67, 3906, 498, 2748, 7822, 11, 1853, 10635, 7822, 1462, 2398, 10635, 11, 1327, 36842, 7822, 1462, 428, 36842, 11, 4254, 25124, 3702, 11, 20300, 1185, 84, 956, 607, 69, 46145, 1232, 314, 84, 6, 6797, 2837, 1232, 577, 4265, 354, 16, 351, 1773, 3906, 518, 577, 6, 20091, 59615, 1911, 31637, 34195, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 45394, 1749, 369, 294, 3906, 11, 24784, 505, 816, 5330, 3977, 611, 9991, 76, 4486, 3529, 3906, 320, 3670, 340, 262, 1442, 420, 3977, 374, 1373, 15744, 320, 1710, 25, 905, 8, 304, 279, 198, 262, 2592, 816, 5330, 1052, 11, 1243, 721, 751, 821, 3906, 374, 6646, 439, 264, 879, 198, 262, 1749, 13, 6984, 1438, 3411, 311, 31546, 420, 3977, 1288, 198, 262, 656, 779, 4669, 8260, 420, 5374, 1462, 751, 821, 3906, 368, 6089, 382, 262, 816, 5330, 7817, 25, 21459, 44, 816, 11908, 16, 20804, 12589, 271, 14711, 6075, 512, 755, 721, 751, 821, 3906, 1214, 11, 348, 11, 2865, 5725, 997, 262, 3270, 262, 70364, 1749, 369, 294, 3906, 11, 24784, 505, 816, 5330, 3977, 611, 9991, 76, 4486, 3529, 3906, 320, 3670, 340, 262, 1442, 420, 3977, 374, 1373, 15744, 320, 1710, 25, 905, 8, 304, 279, 198, 262, 2592, 816, 5330, 1052, 11, 1243, 721, 751, 821, 3906, 374, 6646, 439, 264, 879, 198, 262, 1749, 13, 6984, 1438, 3411, 311, 31546, 420, 3977, 1288, 198, 262, 656, 779, 4669, 8260, 420, 5374, 1462, 751, 821, 3906, 368, 6089, 382, 262, 816, 5330, 7817, 25, 21459, 44, 816, 11908, 16, 20804, 12589, 198, 262, 3270, 262, 422, 32156, 3832, 11, 9177, 332, 500, 15497, 415, 348, 284, 348, 1462, 332, 500, 3832, 340, 262, 1456, 512, 415, 259, 284, 816, 5330, 96809, 1999, 3832, 11, 3231, 26477, 3906, 962, 3906, 11, 374, 16226, 1151, 3670, 518, 9546, 5725, 11, 10587, 1292, 429, 67, 3906, 498, 2800, 1292, 429, 67, 3906, 498, 2748, 7822, 11, 1853, 10635, 7822, 1462, 2398, 10635, 11, 1327, 36842, 7822, 1462, 428, 36842, 11, 4254, 25124, 3702, 11, 20300, 1185, 84, 956, 607, 69, 46145, 1232, 314, 84, 6, 6797, 2837, 1232, 577, 4265, 354, 16, 351, 1773, 3906, 518, 577, 6, 20091, 59615, 1911, 31637, 34195, 1232, 2290, 39254, 4573, 1151, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 82002, 16, 351, 59655, 1697, 518, 27409, 10983, 1151, 15222, 33896, 82002, 16, 351, 59655, 1697, 518, 10587, 1857, 1151, 3670, 518, 374, 5445, 5725, 340, 262, 3734, 320, 81176, 11, 15764, 997, 415, 4933, 15764, 2313, 692, 364, 850, 31981, 1232, 4304, 67, 3906, 2011, 387, 315, 264, 955, 18641, 449, 5593, 75834, 692, 364, 9910, 10827, 1232, 330, 3670, 761, 692, 364, 16583, 10827, 1232, 4304, 56, 5330, 96809, 1999, 12952, 26477, 3906, 962, 3906, 11, 374, 16226, 1151, 3670, 518, 9546, 5725, 11, 10587, 1292, 429, 67, 3906, 498, 2800, 1292, 429, 67, 3906, 498, 2748, 7822, 11, 1853, 10635, 7822, 1462, 2398, 10635, 11, 1327, 36842, 7822, 1462, 428, 36842, 11, 4254, 25124, 3702, 11, 20300, 1185, 84, 956, 607, 69, 46145, 1232, 314, 84, 6, 6797, 2837, 1232, 577, 4265, 354, 16, 351, 1773, 3906, 518, 577, 6, 20091, 59615, 1911, 31637, 34195, 1232 ]
ktbyers/netmiko
netmiko/cisco/cisco_ios.py
InLineTransfer.config_md5
def config_md5(self, source_config): """Compute MD5 hash of file.""" file_contents = source_config + "\n" # Cisco IOS automatically adds this file_contents = file_contents.encode("UTF-8") return hashlib.md5(file_contents).hexdigest()
python
def config_md5(self, source_config): """Compute MD5 hash of file.""" file_contents = source_config + "\n" # Cisco IOS automatically adds this file_contents = file_contents.encode("UTF-8") return hashlib.md5(file_contents).hexdigest()
[ "def", "config_md5", "(", "self", ",", "source_config", ")", ":", "file_contents", "=", "source_config", "+", "\"\\n\"", "# Cisco IOS automatically adds this", "file_contents", "=", "file_contents", ".", "encode", "(", "\"UTF-8\"", ")", "return", "hashlib", ".", "md5", "(", "file_contents", ")", ".", "hexdigest", "(", ")" ]
Compute MD5 hash of file.
[ "Compute", "MD5", "hash", "of", "file", "." ]
train
https://github.com/ktbyers/netmiko/blob/54e6116c0b4664de2123081937e0a9a27bdfdfea/netmiko/cisco/cisco_ios.py#L174-L178
<|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 MD5 hash of file. ### Response: def config_md5(self, source_config): """Compute MD5 hash of file.""" file_contents = source_config + "\n" # Cisco IOS automatically adds this file_contents = file_contents.encode("UTF-8") return hashlib.md5(file_contents).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, 47354, 14306, 20, 5286, 315, 1052, 382, 14711, 6075, 512, 755, 2242, 34094, 20, 1214, 11, 2592, 5445, 997, 286, 4304, 47354, 14306, 20, 5286, 315, 1052, 14781, 286, 1052, 17096, 284, 2592, 5445, 489, 2990, 77, 1, 220, 674, 43234, 65180, 9651, 11621, 420, 198, 286, 1052, 17096, 284, 1052, 17096, 17762, 446, 8729, 12, 23, 1158, 286, 471, 55595, 22030, 20, 4971, 17096, 570, 98324, 746, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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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20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 47354, 14306, 20, 5286, 315, 1052, 382, 14711, 6075, 512, 755, 2242, 34094, 20, 1214, 11, 2592, 5445, 997, 286, 4304, 47354, 14306, 20, 5286, 315, 1052, 14781, 286, 1052, 17096, 284, 2592, 5445, 489, 2990, 77, 1, 220, 674, 43234, 65180, 9651, 11621, 420, 198, 286, 1052, 17096, 284, 1052, 17096, 17762, 446, 8729, 12, 23, 1158, 286, 471, 55595, 22030, 20, 4971, 17096, 570, 98324, 746, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
modlinltd/django-advanced-filters
advanced_filters/forms.py
AdvancedFilterQueryForm._build_query_dict
def _build_query_dict(self, formdata=None): """ Take submitted data from form and create a query dict to be used in a Q object (or filter) """ if self.is_valid() and formdata is None: formdata = self.cleaned_data key = "{field}__{operator}".format(**formdata) if formdata['operator'] == "isnull": return {key: None} elif formdata['operator'] == "istrue": return {formdata['field']: True} elif formdata['operator'] == "isfalse": return {formdata['field']: False} return {key: formdata['value']}
python
def _build_query_dict(self, formdata=None): """ Take submitted data from form and create a query dict to be used in a Q object (or filter) """ if self.is_valid() and formdata is None: formdata = self.cleaned_data key = "{field}__{operator}".format(**formdata) if formdata['operator'] == "isnull": return {key: None} elif formdata['operator'] == "istrue": return {formdata['field']: True} elif formdata['operator'] == "isfalse": return {formdata['field']: False} return {key: formdata['value']}
[ "def", "_build_query_dict", "(", "self", ",", "formdata", "=", "None", ")", ":", "if", "self", ".", "is_valid", "(", ")", "and", "formdata", "is", "None", ":", "formdata", "=", "self", ".", "cleaned_data", "key", "=", "\"{field}__{operator}\"", ".", "format", "(", "*", "*", "formdata", ")", "if", "formdata", "[", "'operator'", "]", "==", "\"isnull\"", ":", "return", "{", "key", ":", "None", "}", "elif", "formdata", "[", "'operator'", "]", "==", "\"istrue\"", ":", "return", "{", "formdata", "[", "'field'", "]", ":", "True", "}", "elif", "formdata", "[", "'operator'", "]", "==", "\"isfalse\"", ":", "return", "{", "formdata", "[", "'field'", "]", ":", "False", "}", "return", "{", "key", ":", "formdata", "[", "'value'", "]", "}" ]
Take submitted data from form and create a query dict to be used in a Q object (or filter)
[ "Take", "submitted", "data", "from", "form", "and", "create", "a", "query", "dict", "to", "be", "used", "in", "a", "Q", "object", "(", "or", "filter", ")" ]
train
https://github.com/modlinltd/django-advanced-filters/blob/ba51e6946d1652796a82b2b95cceffbe1190a227/advanced_filters/forms.py#L86-L100
<|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: Take submitted data from form and create a query dict to be used in a Q object (or filter) ### Response: def _build_query_dict(self, formdata=None): """ Take submitted data from form and create a query dict to be used in a Q object (or filter) """ if self.is_valid() and formdata is None: formdata = self.cleaned_data key = "{field}__{operator}".format(**formdata) if formdata['operator'] == "isnull": return {key: None} elif formdata['operator'] == "istrue": return {formdata['field']: True} elif formdata['operator'] == "isfalse": return {formdata['field']: False} return {key: formdata['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, 18293, 14976, 828, 505, 1376, 323, 1893, 264, 3319, 6587, 311, 387, 198, 286, 1511, 304, 264, 1229, 1665, 320, 269, 4141, 696, 14711, 6075, 512, 755, 721, 5957, 5857, 5356, 1214, 11, 1376, 695, 5980, 997, 286, 3270, 286, 12040, 14976, 828, 505, 1376, 323, 1893, 264, 3319, 6587, 311, 387, 198, 286, 1511, 304, 264, 1229, 1665, 320, 269, 4141, 340, 286, 3270, 286, 422, 659, 2124, 8501, 368, 323, 1376, 695, 374, 2290, 512, 310, 1376, 695, 284, 659, 41506, 1807, 198, 286, 1401, 284, 14190, 2630, 92, 565, 90, 8043, 22664, 2293, 22551, 630, 695, 340, 286, 422, 1376, 695, 681, 8043, 663, 624, 330, 285, 2994, 4764, 310, 471, 314, 798, 25, 2290, 534, 286, 4508, 1376, 695, 681, 8043, 663, 624, 330, 3843, 361, 4764, 310, 471, 314, 630, 695, 681, 2630, 44520, 3082, 534, 286, 4508, 1376, 695, 681, 8043, 663, 624, 330, 285, 3934, 4764, 310, 471, 314, 630, 695, 681, 2630, 44520, 3641, 534, 286, 471, 314, 798, 25, 1376, 695, 681, 970, 63987, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 18293, 14976, 828, 505, 1376, 323, 1893, 264, 3319, 6587, 311, 387, 198, 286, 1511, 304, 264, 1229, 1665, 320, 269, 4141, 696, 14711, 6075, 512, 755, 721, 5957, 5857, 5356, 1214, 11, 1376, 695, 5980, 997, 286, 3270, 286, 12040, 14976, 828, 505, 1376, 323, 1893, 264, 3319, 6587, 311, 387, 198, 286, 1511, 304, 264, 1229, 1665, 320, 269, 4141, 340, 286, 3270, 286, 422, 659, 2124, 8501, 368, 323, 1376, 695, 374, 2290, 512, 310, 1376, 695, 284, 659, 41506, 1807, 198, 286, 1401, 284, 14190, 2630, 92, 565, 90, 8043, 22664, 2293, 22551, 630, 695, 340, 286, 422, 1376, 695, 681, 8043, 663, 624, 330, 285, 2994, 4764, 310, 471, 314, 798, 25, 2290, 534, 286, 4508, 1376, 695, 681, 8043, 663, 624, 330, 3843, 361, 4764, 310, 471, 314, 630, 695, 681, 2630, 44520, 3082, 534, 286, 4508, 1376, 695, 681, 8043, 663, 624, 330, 285, 3934, 4764, 310, 471, 314, 630, 695, 681, 2630, 44520, 3641, 534, 286, 471, 314, 798, 25, 1376, 695, 681, 970, 63987, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
huyingxi/Synonyms
synonyms/utils.py
deaccent
def deaccent(text): """ Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal postou bily prasek' """ if not isinstance(text, unicode): # assume utf8 for byte strings, use default (strict) error handling text = text.decode('utf8') norm = unicodedata.normalize("NFD", text) result = u('').join(ch for ch in norm if unicodedata.category(ch) != 'Mn') return unicodedata.normalize("NFC", result)
python
def deaccent(text): """ Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal postou bily prasek' """ if not isinstance(text, unicode): # assume utf8 for byte strings, use default (strict) error handling text = text.decode('utf8') norm = unicodedata.normalize("NFD", text) result = u('').join(ch for ch in norm if unicodedata.category(ch) != 'Mn') return unicodedata.normalize("NFC", result)
[ "def", "deaccent", "(", "text", ")", ":", "if", "not", "isinstance", "(", "text", ",", "unicode", ")", ":", "# assume utf8 for byte strings, use default (strict) error handling", "text", "=", "text", ".", "decode", "(", "'utf8'", ")", "norm", "=", "unicodedata", ".", "normalize", "(", "\"NFD\"", ",", "text", ")", "result", "=", "u", "(", "''", ")", ".", "join", "(", "ch", "for", "ch", "in", "norm", "if", "unicodedata", ".", "category", "(", "ch", ")", "!=", "'Mn'", ")", "return", "unicodedata", ".", "normalize", "(", "\"NFC\"", ",", "result", ")" ]
Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal postou bily prasek'
[ "Remove", "accentuation", "from", "the", "given", "string", ".", "Input", "text", "is", "either", "a", "unicode", "string", "or", "utf8", "encoded", "bytestring", "." ]
train
https://github.com/huyingxi/Synonyms/blob/fe7450d51d9ad825fdba86b9377da9dc76ae26a4/synonyms/utils.py#L140-L155
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal postou bily prasek' ### Response: def deaccent(text): """ Remove accentuation from the given string. Input text is either a unicode string or utf8 encoded bytestring. Return input string with accents removed, as unicode. >>> deaccent("Šéf chomutovských komunistů dostal poštou bílý prášek") u'Sef chomutovskych komunistu dostal postou bily prasek' """ if not isinstance(text, unicode): # assume utf8 for byte strings, use default (strict) error handling text = text.decode('utf8') norm = unicodedata.normalize("NFD", text) result = u('').join(ch for ch in norm if unicodedata.category(ch) != 'Mn') return unicodedata.normalize("NFC", 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, 13319, 30200, 4090, 505, 279, 2728, 925, 13, 5688, 1495, 374, 3060, 264, 27169, 925, 477, 10871, 23, 21136, 555, 1985, 12928, 382, 262, 3494, 1988, 925, 449, 59570, 7108, 11, 439, 27169, 382, 262, 12382, 409, 78648, 446, 104907, 121597, 523, 316, 332, 869, 103052, 11129, 16156, 52353, 122011, 3273, 85578, 283, 123466, 20195, 64267, 110613, 1158, 262, 577, 13575, 830, 523, 316, 332, 869, 4991, 5759, 11129, 16156, 84, 122011, 1772, 283, 293, 1570, 550, 521, 74, 3961, 14711, 6075, 512, 755, 409, 78648, 7383, 997, 262, 3270, 262, 11016, 30200, 4090, 505, 279, 2728, 925, 13, 5688, 1495, 374, 3060, 264, 27169, 925, 477, 10871, 23, 21136, 555, 1985, 12928, 382, 262, 3494, 1988, 925, 449, 59570, 7108, 11, 439, 27169, 382, 262, 12382, 409, 78648, 446, 104907, 121597, 523, 316, 332, 869, 103052, 11129, 16156, 52353, 122011, 3273, 85578, 283, 123466, 20195, 64267, 110613, 1158, 262, 577, 13575, 830, 523, 316, 332, 869, 4991, 5759, 11129, 16156, 84, 122011, 1772, 283, 293, 1570, 550, 521, 74, 3961, 262, 3270, 262, 422, 539, 11656, 7383, 11, 27169, 997, 286, 674, 9855, 10871, 23, 369, 5027, 9246, 11, 1005, 1670, 320, 6765, 8, 1493, 11850, 198, 286, 1495, 284, 1495, 16301, 493, 4867, 23, 1329, 262, 7617, 284, 88649, 6879, 460, 45757, 446, 45, 14938, 498, 1495, 340, 262, 1121, 284, 577, 81491, 6115, 7672, 369, 523, 304, 7617, 422, 88649, 6879, 460, 18898, 7672, 8, 976, 364, 44, 77, 1329, 262, 471, 88649, 6879, 460, 45757, 446, 45, 6897, 498, 1121, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 13319, 30200, 4090, 505, 279, 2728, 925, 13, 5688, 1495, 374, 3060, 264, 27169, 925, 477, 10871, 23, 21136, 555, 1985, 12928, 382, 262, 3494, 1988, 925, 449, 59570, 7108, 11, 439, 27169, 382, 262, 12382, 409, 78648, 446, 104907, 121597, 523, 316, 332, 869, 103052, 11129, 16156, 52353, 122011, 3273, 85578, 283, 123466, 20195, 64267, 110613, 1158, 262, 577, 13575, 830, 523, 316, 332, 869, 4991, 5759, 11129, 16156, 84, 122011, 1772, 283, 293, 1570, 550, 521, 74, 3961, 14711, 6075, 512, 755, 409, 78648, 7383, 997, 262, 3270, 262, 11016, 30200, 4090, 505, 279, 2728, 925, 13, 5688, 1495, 374, 3060, 264, 27169, 925, 477, 10871, 23, 21136, 555, 1985, 12928, 382, 262, 3494, 1988, 925, 449, 59570, 7108, 11, 439, 27169, 382, 262, 12382, 409, 78648, 446, 104907, 121597, 523, 316, 332, 869, 103052, 11129, 16156, 52353, 122011, 3273, 85578, 283, 123466, 20195, 64267, 110613, 1158, 262, 577, 13575, 830, 523, 316, 332, 869, 4991, 5759, 11129, 16156, 84, 122011, 1772, 283, 293, 1570, 550, 521, 74, 3961, 262, 3270, 262, 422, 539, 11656, 7383, 11, 27169, 997, 286, 674, 9855, 10871, 23, 369, 5027, 9246, 11, 1005, 1670, 320, 6765, 8, 1493, 11850, 198, 286, 1495, 284, 1495, 16301, 493, 4867, 23, 1329, 262, 7617, 284, 88649, 6879, 460, 45757, 446, 45, 14938, 498, 1495, 340, 262, 1121, 284, 577, 81491, 6115, 7672, 369, 523, 304, 7617, 422, 88649, 6879, 460, 18898, 7672, 8, 976, 364, 44, 77, 1329, 262, 471, 88649, 6879, 460, 45757, 446, 45, 6897, 498, 1121, 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 ]
pantsbuild/pants
src/python/pants/pantsd/service/scheduler_service.py
SchedulerService.run
def run(self): """Main service entrypoint.""" while not self._state.is_terminating: self._process_event_queue() self._state.maybe_pause()
python
def run(self): """Main service entrypoint.""" while not self._state.is_terminating: self._process_event_queue() self._state.maybe_pause()
[ "def", "run", "(", "self", ")", ":", "while", "not", "self", ".", "_state", ".", "is_terminating", ":", "self", ".", "_process_event_queue", "(", ")", "self", ".", "_state", ".", "maybe_pause", "(", ")" ]
Main service entrypoint.
[ "Main", "service", "entrypoint", "." ]
train
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/pantsd/service/scheduler_service.py#L238-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: Main service entrypoint. ### Response: def run(self): """Main service entrypoint.""" while not self._state.is_terminating: self._process_event_queue() self._state.maybe_pause() <|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, 6334, 2532, 4441, 2837, 382, 14711, 6075, 512, 755, 1629, 1214, 997, 262, 4304, 6334, 2532, 4441, 2837, 14781, 262, 1418, 539, 659, 1462, 2513, 2124, 62, 23827, 1113, 512, 415, 659, 1462, 4734, 6891, 11078, 746, 415, 659, 1462, 2513, 749, 50891, 61089, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 6334, 2532, 4441, 2837, 382, 14711, 6075, 512, 755, 1629, 1214, 997, 262, 4304, 6334, 2532, 4441, 2837, 14781, 262, 1418, 539, 659, 1462, 2513, 2124, 62, 23827, 1113, 512, 415, 659, 1462, 4734, 6891, 11078, 746, 415, 659, 1462, 2513, 749, 50891, 61089, 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 ]
Kozea/pygal
pygal/util.py
round_to_float
def round_to_float(number, precision): """Round a float to a precision""" rounded = Decimal(str(floor((number + precision / 2) // precision)) ) * Decimal(str(precision)) return float(rounded)
python
def round_to_float(number, precision): """Round a float to a precision""" rounded = Decimal(str(floor((number + precision / 2) // precision)) ) * Decimal(str(precision)) return float(rounded)
[ "def", "round_to_float", "(", "number", ",", "precision", ")", ":", "rounded", "=", "Decimal", "(", "str", "(", "floor", "(", "(", "number", "+", "precision", "/", "2", ")", "//", "precision", ")", ")", ")", "*", "Decimal", "(", "str", "(", "precision", ")", ")", "return", "float", "(", "rounded", ")" ]
Round a float to a precision
[ "Round", "a", "float", "to", "a", "precision" ]
train
https://github.com/Kozea/pygal/blob/5e25c98a59a0642eecd9fcc5dbfeeb2190fbb5e7/pygal/util.py#L68-L72
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Round a float to a precision ### Response: def round_to_float(number, precision): """Round a float to a precision""" rounded = Decimal(str(floor((number + precision / 2) // precision)) ) * Decimal(str(precision)) return float(rounded) <|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, 28597, 264, 2273, 311, 264, 16437, 271, 14711, 6075, 512, 755, 4883, 2401, 18047, 18401, 11, 16437, 997, 262, 4304, 28597, 264, 2273, 311, 264, 16437, 7275, 262, 18460, 284, 27826, 4293, 88194, 1209, 4174, 489, 16437, 611, 220, 17, 8, 443, 16437, 1192, 2611, 883, 353, 27826, 4293, 1319, 21759, 1192, 262, 471, 2273, 33456, 291, 340, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 28597, 264, 2273, 311, 264, 16437, 271, 14711, 6075, 512, 755, 4883, 2401, 18047, 18401, 11, 16437, 997, 262, 4304, 28597, 264, 2273, 311, 264, 16437, 7275, 262, 18460, 284, 27826, 4293, 88194, 1209, 4174, 489, 16437, 611, 220, 17, 8, 443, 16437, 1192, 2611, 883, 353, 27826, 4293, 1319, 21759, 1192, 262, 471, 2273, 33456, 291, 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 ]
LogicalDash/LiSE
LiSE/LiSE/cache.py
NodeContentsCache.truncate_loc
def truncate_loc(self, character, location, branch, turn, tick): """Remove future data about a particular location Return True if I deleted anything, False otherwise. """ r = False branches_turns = self.branches[character, location][branch] branches_turns.truncate(turn) if turn in branches_turns: bttrn = branches_turns[turn] if bttrn.future(tick): bttrn.truncate(tick) r = True keyses = self.keys[character, location] for keysbranches in keyses.values(): if branch not in keysbranches: continue keysbranch = keysbranches[branch] if keysbranch.future(turn): keysbranch.truncate(turn) r = True if turn in keysbranch: keysbranchturn = keysbranch[turn] if keysbranchturn.future(tick): keysbranchturn.truncate(tick) r = True if branch in self.settings: for sets in (self.settings, self.presettings): sets_branch = sets[branch] if turn in sets_branch: sets_turn = sets_branch[turn] for tic, setting in list(sets_turn.future(tick).items()): if setting[:2] == (character, location): del sets_turn[tic] r = True if not sets_turn: del sets_branch[turn] assert r, "Found an empty cache when I didn't delete anything" for trn, tics in list(sets_branch.future(turn).items()): for tic, setting in list(tics.future(tick).items()): if setting[:2] == (character, location): del tics[tic] r = True if not tics: del sets_branch[trn] assert r, "Found an empty cache when I didn't delete anything" if not sets_branch: del sets[branch] assert r, "Found an empty cache when I didn't delete anything" self.shallowest = OrderedDict() return r
python
def truncate_loc(self, character, location, branch, turn, tick): """Remove future data about a particular location Return True if I deleted anything, False otherwise. """ r = False branches_turns = self.branches[character, location][branch] branches_turns.truncate(turn) if turn in branches_turns: bttrn = branches_turns[turn] if bttrn.future(tick): bttrn.truncate(tick) r = True keyses = self.keys[character, location] for keysbranches in keyses.values(): if branch not in keysbranches: continue keysbranch = keysbranches[branch] if keysbranch.future(turn): keysbranch.truncate(turn) r = True if turn in keysbranch: keysbranchturn = keysbranch[turn] if keysbranchturn.future(tick): keysbranchturn.truncate(tick) r = True if branch in self.settings: for sets in (self.settings, self.presettings): sets_branch = sets[branch] if turn in sets_branch: sets_turn = sets_branch[turn] for tic, setting in list(sets_turn.future(tick).items()): if setting[:2] == (character, location): del sets_turn[tic] r = True if not sets_turn: del sets_branch[turn] assert r, "Found an empty cache when I didn't delete anything" for trn, tics in list(sets_branch.future(turn).items()): for tic, setting in list(tics.future(tick).items()): if setting[:2] == (character, location): del tics[tic] r = True if not tics: del sets_branch[trn] assert r, "Found an empty cache when I didn't delete anything" if not sets_branch: del sets[branch] assert r, "Found an empty cache when I didn't delete anything" self.shallowest = OrderedDict() return r
[ "def", "truncate_loc", "(", "self", ",", "character", ",", "location", ",", "branch", ",", "turn", ",", "tick", ")", ":", "r", "=", "False", "branches_turns", "=", "self", ".", "branches", "[", "character", ",", "location", "]", "[", "branch", "]", "branches_turns", ".", "truncate", "(", "turn", ")", "if", "turn", "in", "branches_turns", ":", "bttrn", "=", "branches_turns", "[", "turn", "]", "if", "bttrn", ".", "future", "(", "tick", ")", ":", "bttrn", ".", "truncate", "(", "tick", ")", "r", "=", "True", "keyses", "=", "self", ".", "keys", "[", "character", ",", "location", "]", "for", "keysbranches", "in", "keyses", ".", "values", "(", ")", ":", "if", "branch", "not", "in", "keysbranches", ":", "continue", "keysbranch", "=", "keysbranches", "[", "branch", "]", "if", "keysbranch", ".", "future", "(", "turn", ")", ":", "keysbranch", ".", "truncate", "(", "turn", ")", "r", "=", "True", "if", "turn", "in", "keysbranch", ":", "keysbranchturn", "=", "keysbranch", "[", "turn", "]", "if", "keysbranchturn", ".", "future", "(", "tick", ")", ":", "keysbranchturn", ".", "truncate", "(", "tick", ")", "r", "=", "True", "if", "branch", "in", "self", ".", "settings", ":", "for", "sets", "in", "(", "self", ".", "settings", ",", "self", ".", "presettings", ")", ":", "sets_branch", "=", "sets", "[", "branch", "]", "if", "turn", "in", "sets_branch", ":", "sets_turn", "=", "sets_branch", "[", "turn", "]", "for", "tic", ",", "setting", "in", "list", "(", "sets_turn", ".", "future", "(", "tick", ")", ".", "items", "(", ")", ")", ":", "if", "setting", "[", ":", "2", "]", "==", "(", "character", ",", "location", ")", ":", "del", "sets_turn", "[", "tic", "]", "r", "=", "True", "if", "not", "sets_turn", ":", "del", "sets_branch", "[", "turn", "]", "assert", "r", ",", "\"Found an empty cache when I didn't delete anything\"", "for", "trn", ",", "tics", "in", "list", "(", "sets_branch", ".", "future", "(", "turn", ")", ".", "items", "(", ")", ")", ":", "for", "tic", ",", "setting", "in", "list", "(", "tics", ".", "future", "(", "tick", ")", ".", "items", "(", ")", ")", ":", "if", "setting", "[", ":", "2", "]", "==", "(", "character", ",", "location", ")", ":", "del", "tics", "[", "tic", "]", "r", "=", "True", "if", "not", "tics", ":", "del", "sets_branch", "[", "trn", "]", "assert", "r", ",", "\"Found an empty cache when I didn't delete anything\"", "if", "not", "sets_branch", ":", "del", "sets", "[", "branch", "]", "assert", "r", ",", "\"Found an empty cache when I didn't delete anything\"", "self", ".", "shallowest", "=", "OrderedDict", "(", ")", "return", "r" ]
Remove future data about a particular location Return True if I deleted anything, False otherwise.
[ "Remove", "future", "data", "about", "a", "particular", "location" ]
train
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/cache.py#L635-L686
<|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: Remove future data about a particular location Return True if I deleted anything, False otherwise. ### Response: def truncate_loc(self, character, location, branch, turn, tick): """Remove future data about a particular location Return True if I deleted anything, False otherwise. """ r = False branches_turns = self.branches[character, location][branch] branches_turns.truncate(turn) if turn in branches_turns: bttrn = branches_turns[turn] if bttrn.future(tick): bttrn.truncate(tick) r = True keyses = self.keys[character, location] for keysbranches in keyses.values(): if branch not in keysbranches: continue keysbranch = keysbranches[branch] if keysbranch.future(turn): keysbranch.truncate(turn) r = True if turn in keysbranch: keysbranchturn = keysbranch[turn] if keysbranchturn.future(tick): keysbranchturn.truncate(tick) r = True if branch in self.settings: for sets in (self.settings, self.presettings): sets_branch = sets[branch] if turn in sets_branch: sets_turn = sets_branch[turn] for tic, setting in list(sets_turn.future(tick).items()): if setting[:2] == (character, location): del sets_turn[tic] r = True if not sets_turn: del sets_branch[turn] assert r, "Found an empty cache when I didn't delete anything" for trn, tics in list(sets_branch.future(turn).items()): for tic, setting in list(tics.future(tick).items()): if setting[:2] == (character, location): del tics[tic] r = True if not tics: del sets_branch[trn] assert r, "Found an empty cache when I didn't delete anything" if not sets_branch: del sets[branch] assert r, "Found an empty cache when I didn't delete anything" self.shallowest = OrderedDict() return r <|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, 13319, 3938, 828, 922, 264, 4040, 3813, 271, 286, 3494, 3082, 422, 358, 11309, 4205, 11, 3641, 6062, 382, 14711, 6075, 512, 755, 57872, 13705, 1214, 11, 3752, 11, 3813, 11, 9046, 11, 2543, 11, 9525, 997, 286, 4304, 13319, 3938, 828, 922, 264, 4040, 3813, 271, 286, 3494, 3082, 422, 358, 11309, 4205, 11, 3641, 6062, 382, 286, 3270, 286, 436, 284, 3641, 198, 286, 23962, 38374, 82, 284, 659, 53660, 288, 58, 19740, 11, 3813, 1483, 18424, 933, 286, 23962, 38374, 82, 5543, 27998, 94992, 340, 286, 422, 2543, 304, 23962, 38374, 82, 512, 310, 20164, 376, 77, 284, 23962, 38374, 82, 58, 413, 933, 310, 422, 20164, 376, 77, 98793, 1175, 875, 997, 394, 20164, 376, 77, 5543, 27998, 1175, 875, 340, 394, 436, 284, 3082, 198, 286, 7039, 288, 284, 659, 9301, 58, 19740, 11, 3813, 933, 286, 369, 7039, 68939, 304, 7039, 288, 10883, 4019, 310, 422, 9046, 539, 304, 7039, 68939, 512, 394, 3136, 198, 310, 7039, 18424, 284, 7039, 68939, 58, 18424, 933, 310, 422, 7039, 18424, 98793, 94992, 997, 394, 7039, 18424, 5543, 27998, 94992, 340, 394, 436, 284, 3082, 198, 310, 422, 2543, 304, 7039, 18424, 512, 394, 7039, 18424, 413, 284, 7039, 18424, 58, 413, 933, 394, 422, 7039, 18424, 413, 98793, 1175, 875, 997, 504, 7039, 18424, 413, 5543, 27998, 1175, 875, 340, 504, 436, 284, 3082, 198, 286, 422, 9046, 304, 659, 16728, 512, 310, 369, 7437, 304, 320, 726, 16728, 11, 659, 558, 9915, 2110, 997, 394, 7437, 29131, 284, 7437, 58, 18424, 933, 394, 422, 2543, 304, 7437, 29131, 512, 504, 7437, 38374, 284, 7437, 29131, 58, 413, 933, 504, 369, 62547, 11, 6376, 304, 1160, 7, 5022, 38374, 98793, 1175, 875, 570, 3699, 34257, 667, 422, 6376, 3530, 17, 60, 624, 320, 19740, 11, 3813, 997, 1014, 1624, 7437, 38374, 14527, 292, 933, 1014, 436, 284, 3082, 198, 504, 422, 539, 7437, 38374, 512, 667, 1624, 7437, 29131, 58, 413, 933, 667, 2105, 436, 11, 330, 6788, 459, 4384, 6636, 994, 358, 3287, 956, 3783, 4205, 702, 394, 369, 490, 77, 11, 259, 1233, 304, 1160, 7, 5022, 29131, 98793, 94992, 570, 3699, 34257, 504, 369, 62547, 11, 6376, 304, 1160, 1175, 1233, 98793, 1175, 875, 570, 3699, 34257, 667, 422, 6376, 3530, 17, 60, 624, 320, 19740, 11, 3813, 997, 1014, 1624, 259, 1233, 14527, 292, 933, 1014, 436, 284, 3082, 198, 504, 422, 539, 259, 1233, 512, 667, 1624, 7437, 29131, 58, 376, 77, 933, 667, 2105, 436, 11, 330, 6788, 459, 4384, 6636, 994, 358, 3287, 956, 3783, 4205, 702, 394, 422, 539, 7437, 29131, 512, 504, 1624, 7437, 58, 18424, 933, 504, 2105, 436, 11, 330, 6788, 459, 4384, 6636, 994, 358, 3287, 956, 3783, 4205, 702, 286, 659, 2452, 7331, 478, 284, 54313, 746, 286, 471, 436, 198, 27, 91, 8862, 728, 428 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 13319, 3938, 828, 922, 264, 4040, 3813, 271, 286, 3494, 3082, 422, 358, 11309, 4205, 11, 3641, 6062, 382, 14711, 6075, 512, 755, 57872, 13705, 1214, 11, 3752, 11, 3813, 11, 9046, 11, 2543, 11, 9525, 997, 286, 4304, 13319, 3938, 828, 922, 264, 4040, 3813, 271, 286, 3494, 3082, 422, 358, 11309, 4205, 11, 3641, 6062, 382, 286, 3270, 286, 436, 284, 3641, 198, 286, 23962, 38374, 82, 284, 659, 53660, 288, 58, 19740, 11, 3813, 1483, 18424, 933, 286, 23962, 38374, 82, 5543, 27998, 94992, 340, 286, 422, 2543, 304, 23962, 38374, 82, 512, 310, 20164, 376, 77, 284, 23962, 38374, 82, 58, 413, 933, 310, 422, 20164, 376, 77, 98793, 1175, 875, 997, 394, 20164, 376, 77, 5543, 27998, 1175, 875, 340, 394, 436, 284, 3082, 198, 286, 7039, 288, 284, 659, 9301, 58, 19740, 11, 3813, 933, 286, 369, 7039, 68939, 304, 7039, 288, 10883, 4019, 310, 422, 9046, 539, 304, 7039, 68939, 512, 394, 3136, 198, 310, 7039, 18424, 284, 7039, 68939, 58, 18424, 933, 310, 422, 7039, 18424, 98793, 94992, 997, 394, 7039, 18424, 5543, 27998, 94992, 340, 394, 436, 284, 3082, 198, 310, 422, 2543, 304, 7039, 18424, 512, 394, 7039, 18424, 413, 284, 7039, 18424, 58, 413, 933, 394, 422, 7039, 18424, 413, 98793, 1175, 875, 997, 504, 7039, 18424, 413, 5543, 27998, 1175, 875, 340, 504, 436, 284, 3082, 198, 286, 422, 9046, 304, 659, 16728, 512, 310, 369, 7437, 304, 320, 726, 16728, 11, 659, 558, 9915, 2110, 997, 394, 7437, 29131, 284, 7437, 58, 18424, 933, 394, 422, 2543, 304, 7437, 29131, 512, 504, 7437, 38374, 284, 7437, 29131, 58, 413, 933, 504, 369, 62547, 11, 6376, 304, 1160, 7, 5022, 38374, 98793, 1175, 875, 570, 3699, 34257, 667, 422, 6376, 3530, 17, 60, 624, 320, 19740, 11, 3813, 997, 1014, 1624, 7437, 38374, 14527, 292, 933, 1014, 436, 284, 3082, 198, 504, 422, 539, 7437, 38374, 512, 667, 1624, 7437, 29131, 58, 413, 933, 667, 2105, 436, 11, 330, 6788, 459, 4384, 6636, 994, 358, 3287, 956, 3783, 4205, 702, 394, 369, 490, 77, 11, 259, 1233, 304, 1160, 7, 5022, 29131, 98793, 94992, 570, 3699, 34257, 504, 369, 62547, 11, 6376, 304, 1160, 1175, 1233, 98793, 1175, 875, 570, 3699, 34257, 667, 422, 6376, 3530, 17, 60, 624, 320, 19740, 11, 3813, 997, 1014, 1624, 259, 1233, 14527, 292, 933, 1014, 436, 284, 3082, 198, 504, 422, 539, 259, 1233, 512, 667, 1624, 7437, 29131, 58, 376, 77, 933, 667, 2105, 436, 11, 330, 6788, 459, 4384, 6636, 994, 358, 3287, 956, 3783, 4205, 702, 394, 422, 539, 7437, 29131, 512, 504, 1624, 7437, 58, 18424, 933, 504, 2105, 436, 11, 330, 6788, 459, 4384, 6636, 994, 358, 3287, 956, 3783, 4205, 702, 286, 659, 2452, 7331, 478, 284, 54313, 746, 286, 471, 436, 198, 27, 91, 8862, 728, 428 ]
rigetti/grove
grove/tomography/state_tomography.py
state_tomography_programs
def state_tomography_programs(state_prep, qubits=None, rotation_generator=tomography.default_rotations): """ Yield tomographic sequences that prepare a state with Quil program `state_prep` and then append tomographic rotations on the specified `qubits`. If `qubits is None`, it assumes all qubits in the program should be tomographically rotated. :param Program state_prep: The program to prepare the state to be tomographed. :param list|NoneType qubits: A list of Qubits or Numbers, to perform the tomography on. If `None`, performs it on all in state_prep. :param generator rotation_generator: A generator that yields tomography rotations to perform. :return: Program for state tomography. :rtype: Program """ if qubits is None: qubits = state_prep.get_qubits() for tomography_program in rotation_generator(*qubits): state_tomography_program = Program(Pragma("PRESERVE_BLOCK")) state_tomography_program.inst(state_prep) state_tomography_program.inst(tomography_program) state_tomography_program.inst(Pragma("END_PRESERVE_BLOCK")) yield state_tomography_program
python
def state_tomography_programs(state_prep, qubits=None, rotation_generator=tomography.default_rotations): """ Yield tomographic sequences that prepare a state with Quil program `state_prep` and then append tomographic rotations on the specified `qubits`. If `qubits is None`, it assumes all qubits in the program should be tomographically rotated. :param Program state_prep: The program to prepare the state to be tomographed. :param list|NoneType qubits: A list of Qubits or Numbers, to perform the tomography on. If `None`, performs it on all in state_prep. :param generator rotation_generator: A generator that yields tomography rotations to perform. :return: Program for state tomography. :rtype: Program """ if qubits is None: qubits = state_prep.get_qubits() for tomography_program in rotation_generator(*qubits): state_tomography_program = Program(Pragma("PRESERVE_BLOCK")) state_tomography_program.inst(state_prep) state_tomography_program.inst(tomography_program) state_tomography_program.inst(Pragma("END_PRESERVE_BLOCK")) yield state_tomography_program
[ "def", "state_tomography_programs", "(", "state_prep", ",", "qubits", "=", "None", ",", "rotation_generator", "=", "tomography", ".", "default_rotations", ")", ":", "if", "qubits", "is", "None", ":", "qubits", "=", "state_prep", ".", "get_qubits", "(", ")", "for", "tomography_program", "in", "rotation_generator", "(", "*", "qubits", ")", ":", "state_tomography_program", "=", "Program", "(", "Pragma", "(", "\"PRESERVE_BLOCK\"", ")", ")", "state_tomography_program", ".", "inst", "(", "state_prep", ")", "state_tomography_program", ".", "inst", "(", "tomography_program", ")", "state_tomography_program", ".", "inst", "(", "Pragma", "(", "\"END_PRESERVE_BLOCK\"", ")", ")", "yield", "state_tomography_program" ]
Yield tomographic sequences that prepare a state with Quil program `state_prep` and then append tomographic rotations on the specified `qubits`. If `qubits is None`, it assumes all qubits in the program should be tomographically rotated. :param Program state_prep: The program to prepare the state to be tomographed. :param list|NoneType qubits: A list of Qubits or Numbers, to perform the tomography on. If `None`, performs it on all in state_prep. :param generator rotation_generator: A generator that yields tomography rotations to perform. :return: Program for state tomography. :rtype: Program
[ "Yield", "tomographic", "sequences", "that", "prepare", "a", "state", "with", "Quil", "program", "state_prep", "and", "then", "append", "tomographic", "rotations", "on", "the", "specified", "qubits", ".", "If", "qubits", "is", "None", "it", "assumes", "all", "qubits", "in", "the", "program", "should", "be", "tomographically", "rotated", "." ]
train
https://github.com/rigetti/grove/blob/dc6bf6ec63e8c435fe52b1e00f707d5ce4cdb9b3/grove/tomography/state_tomography.py#L223-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: Yield tomographic sequences that prepare a state with Quil program `state_prep` and then append tomographic rotations on the specified `qubits`. If `qubits is None`, it assumes all qubits in the program should be tomographically rotated. :param Program state_prep: The program to prepare the state to be tomographed. :param list|NoneType qubits: A list of Qubits or Numbers, to perform the tomography on. If `None`, performs it on all in state_prep. :param generator rotation_generator: A generator that yields tomography rotations to perform. :return: Program for state tomography. :rtype: Program ### Response: def state_tomography_programs(state_prep, qubits=None, rotation_generator=tomography.default_rotations): """ Yield tomographic sequences that prepare a state with Quil program `state_prep` and then append tomographic rotations on the specified `qubits`. If `qubits is None`, it assumes all qubits in the program should be tomographically rotated. :param Program state_prep: The program to prepare the state to be tomographed. :param list|NoneType qubits: A list of Qubits or Numbers, to perform the tomography on. If `None`, performs it on all in state_prep. :param generator rotation_generator: A generator that yields tomography rotations to perform. :return: Program for state tomography. :rtype: Program """ if qubits is None: qubits = state_prep.get_qubits() for tomography_program in rotation_generator(*qubits): state_tomography_program = Program(Pragma("PRESERVE_BLOCK")) state_tomography_program.inst(state_prep) state_tomography_program.inst(tomography_program) state_tomography_program.inst(Pragma("END_PRESERVE_BLOCK")) yield state_tomography_program <|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, 56, 823, 10390, 12968, 24630, 430, 10772, 264, 1614, 449, 3489, 321, 2068, 1595, 2513, 84894, 63, 323, 1243, 8911, 198, 262, 10390, 12968, 70301, 389, 279, 5300, 1595, 80, 82502, 29687, 1442, 1595, 80, 82502, 374, 2290, 7964, 433, 22204, 682, 2874, 82502, 304, 198, 262, 279, 2068, 1288, 387, 10390, 65031, 46720, 382, 262, 551, 913, 6826, 1614, 84894, 25, 578, 2068, 311, 10772, 279, 1614, 311, 387, 10390, 91673, 627, 262, 551, 913, 1160, 91, 4155, 941, 2874, 82502, 25, 362, 1160, 315, 1229, 82502, 477, 35813, 11, 311, 2804, 279, 10390, 5814, 389, 13, 1442, 198, 262, 1595, 4155, 7964, 27772, 433, 389, 682, 304, 1614, 84894, 627, 262, 551, 913, 14143, 12984, 26898, 25, 362, 14143, 430, 36508, 10390, 5814, 70301, 311, 2804, 627, 262, 551, 693, 25, 6826, 369, 1614, 10390, 5814, 627, 262, 551, 33613, 25, 6826, 271, 14711, 6075, 512, 755, 1614, 530, 316, 5814, 26152, 82, 8556, 84894, 11, 2874, 82502, 5980, 345, 4700, 12984, 26898, 24957, 316, 5814, 8939, 39356, 811, 997, 262, 3270, 262, 78478, 10390, 12968, 24630, 430, 10772, 264, 1614, 449, 3489, 321, 2068, 1595, 2513, 84894, 63, 323, 1243, 8911, 198, 262, 10390, 12968, 70301, 389, 279, 5300, 1595, 80, 82502, 29687, 1442, 1595, 80, 82502, 374, 2290, 7964, 433, 22204, 682, 2874, 82502, 304, 198, 262, 279, 2068, 1288, 387, 10390, 65031, 46720, 382, 262, 551, 913, 6826, 1614, 84894, 25, 578, 2068, 311, 10772, 279, 1614, 311, 387, 10390, 91673, 627, 262, 551, 913, 1160, 91, 4155, 941, 2874, 82502, 25, 362, 1160, 315, 1229, 82502, 477, 35813, 11, 311, 2804, 279, 10390, 5814, 389, 13, 1442, 198, 262, 1595, 4155, 7964, 27772, 433, 389, 682, 304, 1614, 84894, 627, 262, 551, 913, 14143, 12984, 26898, 25, 362, 14143, 430, 36508, 10390, 5814, 70301, 311, 2804, 627, 262, 551, 693, 25, 6826, 369, 1614, 10390, 5814, 627, 262, 551, 33613, 25, 6826, 198, 262, 3270, 262, 422, 2874, 82502, 374, 2290, 512, 286, 2874, 82502, 284, 1614, 84894, 673, 9153, 82502, 746, 262, 369, 10390, 5814, 26152, 304, 12984, 26898, 4163, 80, 82502, 997, 286, 1614, 530, 316, 5814, 26152, 284, 6826, 7, 94118, 446, 47, 7157, 77179, 19281, 5572, 286, 1614, 530, 316, 5814, 26152, 28300, 8556, 84894, 340, 286, 1614, 530, 316, 5814, 26152, 28300, 1175, 316, 5814, 26152, 340, 286, 1614, 530, 316, 5814, 26152, 28300, 7, 94118, 446, 4794, 1106, 7157, 77179, 19281, 5572, 286, 7692, 1614, 530, 316, 5814, 26152, 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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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 56, 823, 10390, 12968, 24630, 430, 10772, 264, 1614, 449, 3489, 321, 2068, 1595, 2513, 84894, 63, 323, 1243, 8911, 198, 262, 10390, 12968, 70301, 389, 279, 5300, 1595, 80, 82502, 29687, 1442, 1595, 80, 82502, 374, 2290, 7964, 433, 22204, 682, 2874, 82502, 304, 198, 262, 279, 2068, 1288, 387, 10390, 65031, 46720, 382, 262, 551, 913, 6826, 1614, 84894, 25, 578, 2068, 311, 10772, 279, 1614, 311, 387, 10390, 91673, 627, 262, 551, 913, 1160, 91, 4155, 941, 2874, 82502, 25, 362, 1160, 315, 1229, 82502, 477, 35813, 11, 311, 2804, 279, 10390, 5814, 389, 13, 1442, 198, 262, 1595, 4155, 7964, 27772, 433, 389, 682, 304, 1614, 84894, 627, 262, 551, 913, 14143, 12984, 26898, 25, 362, 14143, 430, 36508, 10390, 5814, 70301, 311, 2804, 627, 262, 551, 693, 25, 6826, 369, 1614, 10390, 5814, 627, 262, 551, 33613, 25, 6826, 271, 14711, 6075, 512, 755, 1614, 530, 316, 5814, 26152, 82, 8556, 84894, 11, 2874, 82502, 5980, 345, 4700, 12984, 26898, 24957, 316, 5814, 8939, 39356, 811, 997, 262, 3270, 262, 78478, 10390, 12968, 24630, 430, 10772, 264, 1614, 449, 3489, 321, 2068, 1595, 2513, 84894, 63, 323, 1243, 8911, 198, 262, 10390, 12968, 70301, 389, 279, 5300, 1595, 80, 82502, 29687, 1442, 1595, 80, 82502, 374, 2290, 7964, 433, 22204, 682, 2874, 82502, 304, 198, 262, 279, 2068, 1288, 387, 10390, 65031, 46720, 382, 262, 551, 913, 6826, 1614, 84894, 25, 578, 2068, 311, 10772, 279, 1614, 311, 387, 10390, 91673, 627, 262, 551, 913, 1160, 91, 4155, 941, 2874, 82502, 25, 362, 1160, 315, 1229, 82502, 477, 35813, 11, 311, 2804, 279, 10390, 5814, 389, 13, 1442, 198, 262, 1595, 4155, 7964, 27772, 433, 389, 682, 304, 1614, 84894, 627, 262, 551, 913, 14143, 12984, 26898, 25, 362, 14143, 430, 36508, 10390, 5814, 70301, 311, 2804, 627, 262, 551, 693, 25, 6826, 369, 1614, 10390, 5814, 627, 262, 551, 33613, 25, 6826, 198, 262, 3270, 262, 422, 2874, 82502, 374, 2290, 512, 286, 2874, 82502, 284, 1614, 84894, 673, 9153, 82502, 746, 262, 369, 10390, 5814, 26152, 304, 12984, 26898, 4163, 80, 82502, 997, 286, 1614, 530, 316, 5814, 26152, 284, 6826, 7, 94118, 446, 47, 7157, 77179, 19281, 5572, 286, 1614, 530, 316, 5814, 26152, 28300, 8556, 84894, 340, 286, 1614, 530, 316, 5814, 26152, 28300, 1175, 316, 5814, 26152, 340, 286, 1614, 530, 316, 5814, 26152, 28300, 7, 94118, 446, 4794, 1106, 7157, 77179, 19281, 5572, 286, 7692, 1614, 530, 316, 5814, 26152, 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 ]
sdispater/orator
orator/migrations/database_migration_repository.py
DatabaseMigrationRepository.log
def log(self, file, batch): """ Log that a migration was run. :type file: str :type batch: int """ record = {"migration": file, "batch": batch} self.table().insert(**record)
python
def log(self, file, batch): """ Log that a migration was run. :type file: str :type batch: int """ record = {"migration": file, "batch": batch} self.table().insert(**record)
[ "def", "log", "(", "self", ",", "file", ",", "batch", ")", ":", "record", "=", "{", "\"migration\"", ":", "file", ",", "\"batch\"", ":", "batch", "}", "self", ".", "table", "(", ")", ".", "insert", "(", "*", "*", "record", ")" ]
Log that a migration was run. :type file: str :type batch: int
[ "Log", "that", "a", "migration", "was", "run", "." ]
train
https://github.com/sdispater/orator/blob/bd90bf198ee897751848f9a92e49d18e60a74136/orator/migrations/database_migration_repository.py#L34-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: Log that a migration was run. :type file: str :type batch: int ### Response: def log(self, file, batch): """ Log that a migration was run. :type file: str :type batch: int """ record = {"migration": file, "batch": batch} self.table().insert(**record) <|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, 2250, 430, 264, 12172, 574, 1629, 382, 286, 551, 1337, 1052, 25, 610, 198, 286, 551, 1337, 7309, 25, 528, 271, 14711, 6075, 512, 755, 1515, 1214, 11, 1052, 11, 7309, 997, 286, 3270, 286, 2905, 430, 264, 12172, 574, 1629, 382, 286, 551, 1337, 1052, 25, 610, 198, 286, 551, 1337, 7309, 25, 528, 198, 286, 3270, 286, 3335, 284, 5324, 81327, 794, 1052, 11, 330, 14377, 794, 7309, 633, 286, 659, 10549, 1020, 4302, 22551, 8716, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 2250, 430, 264, 12172, 574, 1629, 382, 286, 551, 1337, 1052, 25, 610, 198, 286, 551, 1337, 7309, 25, 528, 271, 14711, 6075, 512, 755, 1515, 1214, 11, 1052, 11, 7309, 997, 286, 3270, 286, 2905, 430, 264, 12172, 574, 1629, 382, 286, 551, 1337, 1052, 25, 610, 198, 286, 551, 1337, 7309, 25, 528, 198, 286, 3270, 286, 3335, 284, 5324, 81327, 794, 1052, 11, 330, 14377, 794, 7309, 633, 286, 659, 10549, 1020, 4302, 22551, 8716, 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 ]
getsentry/sentry-python
sentry_sdk/utils.py
event_hint_with_exc_info
def event_hint_with_exc_info(exc_info=None): # type: (ExcInfo) -> Dict[str, Optional[ExcInfo]] """Creates a hint with the exc info filled in.""" if exc_info is None: exc_info = sys.exc_info() else: exc_info = exc_info_from_error(exc_info) if exc_info[0] is None: exc_info = None return {"exc_info": exc_info}
python
def event_hint_with_exc_info(exc_info=None): # type: (ExcInfo) -> Dict[str, Optional[ExcInfo]] """Creates a hint with the exc info filled in.""" if exc_info is None: exc_info = sys.exc_info() else: exc_info = exc_info_from_error(exc_info) if exc_info[0] is None: exc_info = None return {"exc_info": exc_info}
[ "def", "event_hint_with_exc_info", "(", "exc_info", "=", "None", ")", ":", "# type: (ExcInfo) -> Dict[str, Optional[ExcInfo]]", "if", "exc_info", "is", "None", ":", "exc_info", "=", "sys", ".", "exc_info", "(", ")", "else", ":", "exc_info", "=", "exc_info_from_error", "(", "exc_info", ")", "if", "exc_info", "[", "0", "]", "is", "None", ":", "exc_info", "=", "None", "return", "{", "\"exc_info\"", ":", "exc_info", "}" ]
Creates a hint with the exc info filled in.
[ "Creates", "a", "hint", "with", "the", "exc", "info", "filled", "in", "." ]
train
https://github.com/getsentry/sentry-python/blob/a1d77722bdce0b94660ebf50b5c4a4645916d084/sentry_sdk/utils.py#L81-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: Creates a hint with the exc info filled in. ### Response: def event_hint_with_exc_info(exc_info=None): # type: (ExcInfo) -> Dict[str, Optional[ExcInfo]] """Creates a hint with the exc info filled in.""" if exc_info is None: exc_info = sys.exc_info() else: exc_info = exc_info_from_error(exc_info) if exc_info[0] is None: exc_info = None return {"exc_info": exc_info} <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 55968, 264, 13310, 449, 279, 3521, 3630, 10409, 304, 382, 14711, 6075, 512, 755, 1567, 46925, 6753, 46747, 3186, 73955, 3186, 5980, 997, 262, 674, 955, 25, 320, 42821, 1767, 8, 1492, 30226, 17752, 11, 12536, 58, 42821, 1767, 14623, 262, 4304, 55968, 264, 13310, 449, 279, 3521, 3630, 10409, 304, 14781, 262, 422, 3521, 3186, 374, 2290, 512, 286, 3521, 3186, 284, 5826, 65828, 3186, 746, 262, 775, 512, 286, 3521, 3186, 284, 3521, 3186, 5791, 4188, 73955, 3186, 340, 262, 422, 3521, 3186, 58, 15, 60, 374, 2290, 512, 286, 3521, 3186, 284, 2290, 198, 262, 471, 5324, 40541, 3186, 794, 3521, 3186, 534, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 55968, 264, 13310, 449, 279, 3521, 3630, 10409, 304, 382, 14711, 6075, 512, 755, 1567, 46925, 6753, 46747, 3186, 73955, 3186, 5980, 997, 262, 674, 955, 25, 320, 42821, 1767, 8, 1492, 30226, 17752, 11, 12536, 58, 42821, 1767, 14623, 262, 4304, 55968, 264, 13310, 449, 279, 3521, 3630, 10409, 304, 14781, 262, 422, 3521, 3186, 374, 2290, 512, 286, 3521, 3186, 284, 5826, 65828, 3186, 746, 262, 775, 512, 286, 3521, 3186, 284, 3521, 3186, 5791, 4188, 73955, 3186, 340, 262, 422, 3521, 3186, 58, 15, 60, 374, 2290, 512, 286, 3521, 3186, 284, 2290, 198, 262, 471, 5324, 40541, 3186, 794, 3521, 3186, 534, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
riga/law
law/cli/software.py
remove_software_cache
def remove_software_cache(sw_dir=None): """ Removes the software cache directory at *sw_dir* which is evaluated with :py:func:`get_sw_dir`. """ sw_dir = get_sw_dir(sw_dir) if os.path.exists(sw_dir): shutil.rmtree(sw_dir)
python
def remove_software_cache(sw_dir=None): """ Removes the software cache directory at *sw_dir* which is evaluated with :py:func:`get_sw_dir`. """ sw_dir = get_sw_dir(sw_dir) if os.path.exists(sw_dir): shutil.rmtree(sw_dir)
[ "def", "remove_software_cache", "(", "sw_dir", "=", "None", ")", ":", "sw_dir", "=", "get_sw_dir", "(", "sw_dir", ")", "if", "os", ".", "path", ".", "exists", "(", "sw_dir", ")", ":", "shutil", ".", "rmtree", "(", "sw_dir", ")" ]
Removes the software cache directory at *sw_dir* which is evaluated with :py:func:`get_sw_dir`.
[ "Removes", "the", "software", "cache", "directory", "at", "*", "sw_dir", "*", "which", "is", "evaluated", "with", ":", "py", ":", "func", ":", "get_sw_dir", "." ]
train
https://github.com/riga/law/blob/479f84ce06ecf3bafe9d33cb7b8fc52e39fb80a1/law/cli/software.py#L89-L95
<|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 the software cache directory at *sw_dir* which is evaluated with :py:func:`get_sw_dir`. ### Response: def remove_software_cache(sw_dir=None): """ Removes the software cache directory at *sw_dir* which is evaluated with :py:func:`get_sw_dir`. """ sw_dir = get_sw_dir(sw_dir) if os.path.exists(sw_dir): shutil.rmtree(sw_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, 6728, 10296, 279, 3241, 6636, 6352, 520, 353, 2332, 4432, 9, 902, 374, 26126, 449, 551, 3368, 25, 2900, 19258, 456, 33681, 4432, 63438, 14711, 6075, 512, 755, 4148, 40933, 2158, 11790, 60002, 4432, 5980, 997, 262, 3270, 262, 39875, 279, 3241, 6636, 6352, 520, 353, 2332, 4432, 9, 902, 374, 26126, 449, 551, 3368, 25, 2900, 19258, 456, 33681, 4432, 19154, 262, 3270, 262, 2064, 4432, 284, 636, 33681, 4432, 60002, 4432, 340, 262, 422, 2709, 3960, 12347, 60002, 4432, 997, 286, 35060, 82306, 60002, 4432, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 279, 3241, 6636, 6352, 520, 353, 2332, 4432, 9, 902, 374, 26126, 449, 551, 3368, 25, 2900, 19258, 456, 33681, 4432, 63438, 14711, 6075, 512, 755, 4148, 40933, 2158, 11790, 60002, 4432, 5980, 997, 262, 3270, 262, 39875, 279, 3241, 6636, 6352, 520, 353, 2332, 4432, 9, 902, 374, 26126, 449, 551, 3368, 25, 2900, 19258, 456, 33681, 4432, 19154, 262, 3270, 262, 2064, 4432, 284, 636, 33681, 4432, 60002, 4432, 340, 262, 422, 2709, 3960, 12347, 60002, 4432, 997, 286, 35060, 82306, 60002, 4432, 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 ]
wecatch/app-turbo
turbo/util.py
to_basestring
def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user supplied. In python3, the two types are not interchangeable, so this method is needed to convert byte strings to unicode. """ if isinstance(value, _BASESTRING_TYPES): return value if not isinstance(value, bytes): raise TypeError( "Expected bytes, unicode, or None; got %r" % type(value) ) return value.decode("utf-8")
python
def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user supplied. In python3, the two types are not interchangeable, so this method is needed to convert byte strings to unicode. """ if isinstance(value, _BASESTRING_TYPES): return value if not isinstance(value, bytes): raise TypeError( "Expected bytes, unicode, or None; got %r" % type(value) ) return value.decode("utf-8")
[ "def", "to_basestring", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "_BASESTRING_TYPES", ")", ":", "return", "value", "if", "not", "isinstance", "(", "value", ",", "bytes", ")", ":", "raise", "TypeError", "(", "\"Expected bytes, unicode, or None; got %r\"", "%", "type", "(", "value", ")", ")", "return", "value", ".", "decode", "(", "\"utf-8\"", ")" ]
Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user supplied. In python3, the two types are not interchangeable, so this method is needed to convert byte strings to unicode.
[ "Converts", "a", "string", "argument", "to", "a", "subclass", "of", "basestring", "." ]
train
https://github.com/wecatch/app-turbo/blob/75faf97371a9a138c53f92168d0a486636cb8a9c/turbo/util.py#L364-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: Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user supplied. In python3, the two types are not interchangeable, so this method is needed to convert byte strings to unicode. ### Response: def to_basestring(value): """Converts a string argument to a subclass of basestring. In python2, byte and unicode strings are mostly interchangeable, so functions that deal with a user-supplied argument in combination with ascii string constants can use either and should return the type the user supplied. In python3, the two types are not interchangeable, so this method is needed to convert byte strings to unicode. """ if isinstance(value, _BASESTRING_TYPES): return value if not isinstance(value, bytes): raise TypeError( "Expected bytes, unicode, or None; got %r" % type(value) ) return value.decode("utf-8") <|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, 925, 5811, 311, 264, 38290, 315, 3122, 66140, 382, 262, 763, 10344, 17, 11, 5027, 323, 27169, 9246, 527, 10213, 91229, 345, 262, 779, 5865, 430, 3568, 449, 264, 1217, 59615, 3523, 5811, 304, 10824, 198, 262, 449, 48220, 925, 18508, 649, 1005, 3060, 323, 1288, 471, 279, 955, 198, 262, 279, 1217, 17665, 13, 220, 763, 10344, 18, 11, 279, 1403, 4595, 527, 539, 91229, 345, 262, 779, 420, 1749, 374, 4460, 311, 5625, 5027, 9246, 311, 27169, 382, 14711, 6075, 512, 755, 311, 890, 300, 66140, 3764, 997, 262, 4304, 12281, 82, 264, 925, 5811, 311, 264, 38290, 315, 3122, 66140, 382, 262, 763, 10344, 17, 11, 5027, 323, 27169, 9246, 527, 10213, 91229, 345, 262, 779, 5865, 430, 3568, 449, 264, 1217, 59615, 3523, 5811, 304, 10824, 198, 262, 449, 48220, 925, 18508, 649, 1005, 3060, 323, 1288, 471, 279, 955, 198, 262, 279, 1217, 17665, 13, 220, 763, 10344, 18, 11, 279, 1403, 4595, 527, 539, 91229, 345, 262, 779, 420, 1749, 374, 4460, 311, 5625, 5027, 9246, 311, 27169, 627, 262, 3270, 262, 422, 11656, 3764, 11, 721, 18957, 16873, 26879, 997, 286, 471, 907, 198, 262, 422, 539, 11656, 3764, 11, 5943, 997, 286, 4933, 26082, 1021, 310, 330, 19430, 5943, 11, 27169, 11, 477, 2290, 26, 2751, 1034, 81, 1, 1034, 955, 3764, 340, 286, 1763, 262, 471, 907, 16301, 446, 4867, 12, 23, 1158, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 12281, 82, 264, 925, 5811, 311, 264, 38290, 315, 3122, 66140, 382, 262, 763, 10344, 17, 11, 5027, 323, 27169, 9246, 527, 10213, 91229, 345, 262, 779, 5865, 430, 3568, 449, 264, 1217, 59615, 3523, 5811, 304, 10824, 198, 262, 449, 48220, 925, 18508, 649, 1005, 3060, 323, 1288, 471, 279, 955, 198, 262, 279, 1217, 17665, 13, 220, 763, 10344, 18, 11, 279, 1403, 4595, 527, 539, 91229, 345, 262, 779, 420, 1749, 374, 4460, 311, 5625, 5027, 9246, 311, 27169, 382, 14711, 6075, 512, 755, 311, 890, 300, 66140, 3764, 997, 262, 4304, 12281, 82, 264, 925, 5811, 311, 264, 38290, 315, 3122, 66140, 382, 262, 763, 10344, 17, 11, 5027, 323, 27169, 9246, 527, 10213, 91229, 345, 262, 779, 5865, 430, 3568, 449, 264, 1217, 59615, 3523, 5811, 304, 10824, 198, 262, 449, 48220, 925, 18508, 649, 1005, 3060, 323, 1288, 471, 279, 955, 198, 262, 279, 1217, 17665, 13, 220, 763, 10344, 18, 11, 279, 1403, 4595, 527, 539, 91229, 345, 262, 779, 420, 1749, 374, 4460, 311, 5625, 5027, 9246, 311, 27169, 627, 262, 3270, 262, 422, 11656, 3764, 11, 721, 18957, 16873, 26879, 997, 286, 471, 907, 198, 262, 422, 539, 11656, 3764, 11, 5943, 997, 286, 4933, 26082, 1021, 310, 330, 19430, 5943, 11, 27169, 11, 477, 2290, 26, 2751, 1034, 81, 1, 1034, 955, 3764, 340, 286, 1763, 262, 471, 907, 16301, 446, 4867, 12, 23, 1158, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
ga4gh/ga4gh-server
ga4gh/server/datarepo.py
SqlDataRepository.insertDataset
def insertDataset(self, dataset): """ Inserts the specified dataset into this repository. """ try: models.Dataset.create( id=dataset.getId(), name=dataset.getLocalId(), description=dataset.getDescription(), attributes=json.dumps(dataset.getAttributes())) except Exception: raise exceptions.DuplicateNameException( dataset.getLocalId())
python
def insertDataset(self, dataset): """ Inserts the specified dataset into this repository. """ try: models.Dataset.create( id=dataset.getId(), name=dataset.getLocalId(), description=dataset.getDescription(), attributes=json.dumps(dataset.getAttributes())) except Exception: raise exceptions.DuplicateNameException( dataset.getLocalId())
[ "def", "insertDataset", "(", "self", ",", "dataset", ")", ":", "try", ":", "models", ".", "Dataset", ".", "create", "(", "id", "=", "dataset", ".", "getId", "(", ")", ",", "name", "=", "dataset", ".", "getLocalId", "(", ")", ",", "description", "=", "dataset", ".", "getDescription", "(", ")", ",", "attributes", "=", "json", ".", "dumps", "(", "dataset", ".", "getAttributes", "(", ")", ")", ")", "except", "Exception", ":", "raise", "exceptions", ".", "DuplicateNameException", "(", "dataset", ".", "getLocalId", "(", ")", ")" ]
Inserts the specified dataset into this repository.
[ "Inserts", "the", "specified", "dataset", "into", "this", "repository", "." ]
train
https://github.com/ga4gh/ga4gh-server/blob/1aa18922ef136db8604f6f098cb1732cba6f2a76/ga4gh/server/datarepo.py#L848-L860
<|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: Inserts the specified dataset into this repository. ### Response: def insertDataset(self, dataset): """ Inserts the specified dataset into this repository. """ try: models.Dataset.create( id=dataset.getId(), name=dataset.getLocalId(), description=dataset.getDescription(), attributes=json.dumps(dataset.getAttributes())) except Exception: raise exceptions.DuplicateNameException( dataset.getLocalId()) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 14099, 82, 279, 5300, 10550, 1139, 420, 12827, 382, 14711, 6075, 512, 755, 5774, 34463, 1214, 11, 10550, 997, 286, 3270, 286, 85853, 279, 5300, 10550, 1139, 420, 12827, 627, 286, 3270, 286, 1456, 512, 310, 4211, 80456, 2581, 1021, 394, 887, 28, 22090, 11121, 3227, 394, 836, 28, 22090, 67041, 769, 3227, 394, 4096, 28, 22090, 58564, 3227, 394, 8365, 38607, 22252, 31635, 673, 10738, 12419, 286, 3734, 4204, 512, 310, 4933, 20157, 920, 14399, 678, 1378, 1021, 394, 10550, 67041, 769, 2455, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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,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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 14099, 82, 279, 5300, 10550, 1139, 420, 12827, 382, 14711, 6075, 512, 755, 5774, 34463, 1214, 11, 10550, 997, 286, 3270, 286, 85853, 279, 5300, 10550, 1139, 420, 12827, 627, 286, 3270, 286, 1456, 512, 310, 4211, 80456, 2581, 1021, 394, 887, 28, 22090, 11121, 3227, 394, 836, 28, 22090, 67041, 769, 3227, 394, 4096, 28, 22090, 58564, 3227, 394, 8365, 38607, 22252, 31635, 673, 10738, 12419, 286, 3734, 4204, 512, 310, 4933, 20157, 920, 14399, 678, 1378, 1021, 394, 10550, 67041, 769, 2455, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
3ll3d00d/vibe
backend/src/analyser/common/targetcontroller.py
TargetController.storeFromHinge
def storeFromHinge(self, name, hingePoints): """ Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored. """ if name not in self._cache: if self._valid(hingePoints): self._cache[name] = {'name': name, 'type': 'hinge', 'hinge': hingePoints} self.writeCache() return True return False
python
def storeFromHinge(self, name, hingePoints): """ Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored. """ if name not in self._cache: if self._valid(hingePoints): self._cache[name] = {'name': name, 'type': 'hinge', 'hinge': hingePoints} self.writeCache() return True return False
[ "def", "storeFromHinge", "(", "self", ",", "name", ",", "hingePoints", ")", ":", "if", "name", "not", "in", "self", ".", "_cache", ":", "if", "self", ".", "_valid", "(", "hingePoints", ")", ":", "self", ".", "_cache", "[", "name", "]", "=", "{", "'name'", ":", "name", ",", "'type'", ":", "'hinge'", ",", "'hinge'", ":", "hingePoints", "}", "self", ".", "writeCache", "(", ")", "return", "True", "return", "False" ]
Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored.
[ "Stores", "a", "new", "item", "in", "the", "cache", "if", "it", "is", "allowed", "in", ".", ":", "param", "name", ":", "the", "name", ".", ":", "param", "hingePoints", ":", "the", "hinge", "points", ".", ":", "return", ":", "true", "if", "it", "is", "stored", "." ]
train
https://github.com/3ll3d00d/vibe/blob/124b029f13ac746723e92cb47e9cb56edd2e54b5/backend/src/analyser/common/targetcontroller.py#L23-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: Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored. ### Response: def storeFromHinge(self, name, hingePoints): """ Stores a new item in the cache if it is allowed in. :param name: the name. :param hingePoints: the hinge points. :return: true if it is stored. """ if name not in self._cache: if self._valid(hingePoints): self._cache[name] = {'name': name, 'type': 'hinge', 'hinge': hingePoints} self.writeCache() return True 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, 70126, 264, 502, 1537, 304, 279, 6636, 422, 433, 374, 5535, 304, 627, 286, 551, 913, 836, 25, 279, 836, 627, 286, 551, 913, 76693, 11665, 25, 279, 76693, 3585, 13, 720, 286, 551, 693, 25, 837, 422, 433, 374, 9967, 382, 14711, 6075, 512, 755, 3637, 3915, 39, 18177, 1214, 11, 836, 11, 76693, 11665, 997, 286, 3270, 286, 39402, 264, 502, 1537, 304, 279, 6636, 422, 433, 374, 5535, 304, 627, 286, 551, 913, 836, 25, 279, 836, 627, 286, 551, 913, 76693, 11665, 25, 279, 76693, 3585, 13, 720, 286, 551, 693, 25, 837, 422, 433, 374, 9967, 627, 286, 3270, 286, 422, 836, 539, 304, 659, 1462, 9544, 512, 310, 422, 659, 1462, 1930, 3283, 18177, 11665, 997, 394, 659, 1462, 9544, 11174, 60, 284, 5473, 609, 1232, 836, 11, 364, 1337, 1232, 364, 71, 18177, 518, 364, 71, 18177, 1232, 76693, 11665, 534, 394, 659, 3921, 8397, 746, 394, 471, 3082, 198, 286, 471, 3641, 198, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 70126, 264, 502, 1537, 304, 279, 6636, 422, 433, 374, 5535, 304, 627, 286, 551, 913, 836, 25, 279, 836, 627, 286, 551, 913, 76693, 11665, 25, 279, 76693, 3585, 13, 720, 286, 551, 693, 25, 837, 422, 433, 374, 9967, 382, 14711, 6075, 512, 755, 3637, 3915, 39, 18177, 1214, 11, 836, 11, 76693, 11665, 997, 286, 3270, 286, 39402, 264, 502, 1537, 304, 279, 6636, 422, 433, 374, 5535, 304, 627, 286, 551, 913, 836, 25, 279, 836, 627, 286, 551, 913, 76693, 11665, 25, 279, 76693, 3585, 13, 720, 286, 551, 693, 25, 837, 422, 433, 374, 9967, 627, 286, 3270, 286, 422, 836, 539, 304, 659, 1462, 9544, 512, 310, 422, 659, 1462, 1930, 3283, 18177, 11665, 997, 394, 659, 1462, 9544, 11174, 60, 284, 5473, 609, 1232, 836, 11, 364, 1337, 1232, 364, 71, 18177, 518, 364, 71, 18177, 1232, 76693, 11665, 534, 394, 659, 3921, 8397, 746, 394, 471, 3082, 198, 286, 471, 3641, 198, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
Desiiii/weeb.py
weeb/client.py
Client.generate_waifu_insult
async def generate_waifu_insult(self, avatar): """Generate a waifu insult image. This function is a coroutine. Parameters: avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image Return Type: image data""" if not isinstance(avatar, str): raise TypeError("type of 'avatar' must be str.") async with aiohttp.ClientSession() as session: async with session.post("https://api.weeb.sh/auto-image/waifu-insult", headers=self.__headers, data={"avatar": avatar}) as resp: if resp.status == 200: return await resp.read() else: raise Exception((await resp.json())['message'])
python
async def generate_waifu_insult(self, avatar): """Generate a waifu insult image. This function is a coroutine. Parameters: avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image Return Type: image data""" if not isinstance(avatar, str): raise TypeError("type of 'avatar' must be str.") async with aiohttp.ClientSession() as session: async with session.post("https://api.weeb.sh/auto-image/waifu-insult", headers=self.__headers, data={"avatar": avatar}) as resp: if resp.status == 200: return await resp.read() else: raise Exception((await resp.json())['message'])
[ "async", "def", "generate_waifu_insult", "(", "self", ",", "avatar", ")", ":", "if", "not", "isinstance", "(", "avatar", ",", "str", ")", ":", "raise", "TypeError", "(", "\"type of 'avatar' must be str.\"", ")", "async", "with", "aiohttp", ".", "ClientSession", "(", ")", "as", "session", ":", "async", "with", "session", ".", "post", "(", "\"https://api.weeb.sh/auto-image/waifu-insult\"", ",", "headers", "=", "self", ".", "__headers", ",", "data", "=", "{", "\"avatar\"", ":", "avatar", "}", ")", "as", "resp", ":", "if", "resp", ".", "status", "==", "200", ":", "return", "await", "resp", ".", "read", "(", ")", "else", ":", "raise", "Exception", "(", "(", "await", "resp", ".", "json", "(", ")", ")", "[", "'message'", "]", ")" ]
Generate a waifu insult image. This function is a coroutine. Parameters: avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image Return Type: image data
[ "Generate", "a", "waifu", "insult", "image", "." ]
train
https://github.com/Desiiii/weeb.py/blob/5174c22e0cd34cb77f69ad18fbe87ee1fad51859/weeb/client.py#L131-L147
<|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 a waifu insult image. This function is a coroutine. Parameters: avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image Return Type: image data ### Response: async def generate_waifu_insult(self, avatar): """Generate a waifu insult image. This function is a coroutine. Parameters: avatar: str - http/s url pointing to an image, has to have proper headers and be a direct link to an image Return Type: image data""" if not isinstance(avatar, str): raise TypeError("type of 'avatar' must be str.") async with aiohttp.ClientSession() as session: async with session.post("https://api.weeb.sh/auto-image/waifu-insult", headers=self.__headers, data={"avatar": avatar}) as resp: if resp.status == 200: return await resp.read() else: raise Exception((await resp.json())['message']) <|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, 264, 10667, 21519, 27224, 2217, 382, 286, 1115, 734, 374, 264, 78899, 382, 286, 13831, 512, 310, 21359, 25, 610, 482, 1795, 2754, 2576, 22364, 311, 459, 2217, 11, 706, 311, 617, 6300, 7247, 323, 387, 264, 2167, 2723, 311, 459, 2217, 271, 286, 3494, 4078, 25, 2217, 828, 271, 14711, 6075, 512, 7847, 711, 7068, 1704, 64, 21519, 35486, 495, 1214, 11, 21359, 997, 286, 4304, 32215, 264, 10667, 21519, 27224, 2217, 382, 286, 1115, 734, 374, 264, 78899, 382, 286, 13831, 512, 310, 21359, 25, 610, 482, 1795, 2754, 2576, 22364, 311, 459, 2217, 11, 706, 311, 617, 6300, 7247, 323, 387, 264, 2167, 2723, 311, 459, 2217, 271, 286, 3494, 4078, 25, 2217, 828, 7275, 286, 422, 539, 11656, 7, 12229, 11, 610, 997, 310, 4933, 26082, 446, 1337, 315, 364, 12229, 6, 2011, 387, 610, 13352, 286, 3393, 449, 85043, 1277, 11978, 5396, 368, 439, 3882, 512, 310, 3393, 449, 3882, 6679, 446, 2485, 1129, 2113, 31339, 3141, 2452, 92350, 14064, 6458, 64, 21519, 22610, 495, 498, 7247, 7822, 4952, 7869, 11, 828, 16160, 12229, 794, 21359, 5525, 439, 9216, 512, 394, 422, 9216, 4397, 624, 220, 1049, 512, 504, 471, 2597, 9216, 4217, 746, 394, 775, 512, 504, 4933, 4204, 1209, 11675, 9216, 4421, 2189, 681, 2037, 7519, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 264, 10667, 21519, 27224, 2217, 382, 286, 1115, 734, 374, 264, 78899, 382, 286, 13831, 512, 310, 21359, 25, 610, 482, 1795, 2754, 2576, 22364, 311, 459, 2217, 11, 706, 311, 617, 6300, 7247, 323, 387, 264, 2167, 2723, 311, 459, 2217, 271, 286, 3494, 4078, 25, 2217, 828, 271, 14711, 6075, 512, 7847, 711, 7068, 1704, 64, 21519, 35486, 495, 1214, 11, 21359, 997, 286, 4304, 32215, 264, 10667, 21519, 27224, 2217, 382, 286, 1115, 734, 374, 264, 78899, 382, 286, 13831, 512, 310, 21359, 25, 610, 482, 1795, 2754, 2576, 22364, 311, 459, 2217, 11, 706, 311, 617, 6300, 7247, 323, 387, 264, 2167, 2723, 311, 459, 2217, 271, 286, 3494, 4078, 25, 2217, 828, 7275, 286, 422, 539, 11656, 7, 12229, 11, 610, 997, 310, 4933, 26082, 446, 1337, 315, 364, 12229, 6, 2011, 387, 610, 13352, 286, 3393, 449, 85043, 1277, 11978, 5396, 368, 439, 3882, 512, 310, 3393, 449, 3882, 6679, 446, 2485, 1129, 2113, 31339, 3141, 2452, 92350, 14064, 6458, 64, 21519, 22610, 495, 498, 7247, 7822, 4952, 7869, 11, 828, 16160, 12229, 794, 21359, 5525, 439, 9216, 512, 394, 422, 9216, 4397, 624, 220, 1049, 512, 504, 471, 2597, 9216, 4217, 746, 394, 775, 512, 504, 4933, 4204, 1209, 11675, 9216, 4421, 2189, 681, 2037, 7519, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
pmorissette/bt
bt/core.py
StrategyBase.close
def close(self, child): """ Close a child position - alias for rebalance(0, child). This will also flatten (close out all) the child's children. Args: * child (str): Child, specified by name. """ c = self.children[child] # flatten if children not None if c.children is not None and len(c.children) != 0: c.flatten() if c.value != 0. and not np.isnan(c.value): c.allocate(-c.value)
python
def close(self, child): """ Close a child position - alias for rebalance(0, child). This will also flatten (close out all) the child's children. Args: * child (str): Child, specified by name. """ c = self.children[child] # flatten if children not None if c.children is not None and len(c.children) != 0: c.flatten() if c.value != 0. and not np.isnan(c.value): c.allocate(-c.value)
[ "def", "close", "(", "self", ",", "child", ")", ":", "c", "=", "self", ".", "children", "[", "child", "]", "# flatten if children not None", "if", "c", ".", "children", "is", "not", "None", "and", "len", "(", "c", ".", "children", ")", "!=", "0", ":", "c", ".", "flatten", "(", ")", "if", "c", ".", "value", "!=", "0.", "and", "not", "np", ".", "isnan", "(", "c", ".", "value", ")", ":", "c", ".", "allocate", "(", "-", "c", ".", "value", ")" ]
Close a child position - alias for rebalance(0, child). This will also flatten (close out all) the child's children. Args: * child (str): Child, specified by name.
[ "Close", "a", "child", "position", "-", "alias", "for", "rebalance", "(", "0", "child", ")", ".", "This", "will", "also", "flatten", "(", "close", "out", "all", ")", "the", "child", "s", "children", "." ]
train
https://github.com/pmorissette/bt/blob/0363e6fa100d9392dd18e32e3d8379d5e83c28fa/bt/core.py#L724-L738
<|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: Close a child position - alias for rebalance(0, child). This will also flatten (close out all) the child's children. Args: * child (str): Child, specified by name. ### Response: def close(self, child): """ Close a child position - alias for rebalance(0, child). This will also flatten (close out all) the child's children. Args: * child (str): Child, specified by name. """ c = self.children[child] # flatten if children not None if c.children is not None and len(c.children) != 0: c.flatten() if c.value != 0. and not np.isnan(c.value): c.allocate(-c.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, 8084, 264, 1716, 2361, 482, 15904, 369, 12646, 5085, 7, 15, 11, 1716, 570, 1115, 690, 1101, 198, 286, 46443, 320, 5669, 704, 682, 8, 279, 1716, 596, 2911, 382, 286, 18161, 512, 310, 353, 1716, 320, 496, 1680, 9576, 11, 5300, 555, 836, 382, 14711, 6075, 512, 755, 3345, 1214, 11, 1716, 997, 286, 3270, 286, 13330, 264, 1716, 2361, 482, 15904, 369, 12646, 5085, 7, 15, 11, 1716, 570, 1115, 690, 1101, 198, 286, 46443, 320, 5669, 704, 682, 8, 279, 1716, 596, 2911, 382, 286, 18161, 512, 310, 353, 1716, 320, 496, 1680, 9576, 11, 5300, 555, 836, 627, 286, 3270, 286, 272, 284, 659, 13664, 86583, 933, 286, 674, 46443, 422, 2911, 539, 2290, 198, 286, 422, 272, 13664, 374, 539, 2290, 323, 2479, 1361, 13664, 8, 976, 220, 15, 512, 310, 272, 49298, 2892, 286, 422, 272, 2894, 976, 220, 15, 13, 323, 539, 2660, 73727, 1361, 2894, 997, 310, 272, 69826, 4172, 66, 2894, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 8084, 264, 1716, 2361, 482, 15904, 369, 12646, 5085, 7, 15, 11, 1716, 570, 1115, 690, 1101, 198, 286, 46443, 320, 5669, 704, 682, 8, 279, 1716, 596, 2911, 382, 286, 18161, 512, 310, 353, 1716, 320, 496, 1680, 9576, 11, 5300, 555, 836, 382, 14711, 6075, 512, 755, 3345, 1214, 11, 1716, 997, 286, 3270, 286, 13330, 264, 1716, 2361, 482, 15904, 369, 12646, 5085, 7, 15, 11, 1716, 570, 1115, 690, 1101, 198, 286, 46443, 320, 5669, 704, 682, 8, 279, 1716, 596, 2911, 382, 286, 18161, 512, 310, 353, 1716, 320, 496, 1680, 9576, 11, 5300, 555, 836, 627, 286, 3270, 286, 272, 284, 659, 13664, 86583, 933, 286, 674, 46443, 422, 2911, 539, 2290, 198, 286, 422, 272, 13664, 374, 539, 2290, 323, 2479, 1361, 13664, 8, 976, 220, 15, 512, 310, 272, 49298, 2892, 286, 422, 272, 2894, 976, 220, 15, 13, 323, 539, 2660, 73727, 1361, 2894, 997, 310, 272, 69826, 4172, 66, 2894, 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 ]
flaviogrossi/sockjs-cyclone
sockjs/cyclone/sessioncontainer.py
SessionContainer.add
def add(self, session): """ Add session to the container. @param session: Session object """ self._items[session.session_id] = session if session.expiry is not None: self._queue.push(session)
python
def add(self, session): """ Add session to the container. @param session: Session object """ self._items[session.session_id] = session if session.expiry is not None: self._queue.push(session)
[ "def", "add", "(", "self", ",", "session", ")", ":", "self", ".", "_items", "[", "session", ".", "session_id", "]", "=", "session", "if", "session", ".", "expiry", "is", "not", "None", ":", "self", ".", "_queue", ".", "push", "(", "session", ")" ]
Add session to the container. @param session: Session object
[ "Add", "session", "to", "the", "container", "." ]
train
https://github.com/flaviogrossi/sockjs-cyclone/blob/d3ca053ec1aa1e85f652347bff562c2319be37a2/sockjs/cyclone/sessioncontainer.py#L12-L20
<|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 session to the container. @param session: Session object ### Response: def add(self, session): """ Add session to the container. @param session: Session object """ self._items[session.session_id] = session if session.expiry is not None: self._queue.push(session) <|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, 3882, 311, 279, 5593, 382, 286, 571, 913, 3882, 25, 9343, 1665, 271, 14711, 6075, 512, 755, 923, 1214, 11, 3882, 997, 286, 4304, 2758, 3882, 311, 279, 5593, 382, 286, 571, 913, 3882, 25, 9343, 1665, 198, 286, 3270, 286, 659, 1462, 3699, 58, 6045, 10387, 851, 60, 284, 3882, 271, 286, 422, 3882, 2272, 49309, 374, 539, 2290, 512, 310, 659, 1462, 4687, 2615, 16663, 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 ]
[ 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, 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, 3882, 311, 279, 5593, 382, 286, 571, 913, 3882, 25, 9343, 1665, 271, 14711, 6075, 512, 755, 923, 1214, 11, 3882, 997, 286, 4304, 2758, 3882, 311, 279, 5593, 382, 286, 571, 913, 3882, 25, 9343, 1665, 198, 286, 3270, 286, 659, 1462, 3699, 58, 6045, 10387, 851, 60, 284, 3882, 271, 286, 422, 3882, 2272, 49309, 374, 539, 2290, 512, 310, 659, 1462, 4687, 2615, 16663, 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 ]
mailgun/talon
talon/quotations.py
remove_initial_spaces_and_mark_message_lines
def remove_initial_spaces_and_mark_message_lines(lines): """ Removes the initial spaces in each line before marking message lines. This ensures headers can be identified if they are indented with spaces. """ i = 0 while i < len(lines): lines[i] = lines[i].lstrip(' ') i += 1 return mark_message_lines(lines)
python
def remove_initial_spaces_and_mark_message_lines(lines): """ Removes the initial spaces in each line before marking message lines. This ensures headers can be identified if they are indented with spaces. """ i = 0 while i < len(lines): lines[i] = lines[i].lstrip(' ') i += 1 return mark_message_lines(lines)
[ "def", "remove_initial_spaces_and_mark_message_lines", "(", "lines", ")", ":", "i", "=", "0", "while", "i", "<", "len", "(", "lines", ")", ":", "lines", "[", "i", "]", "=", "lines", "[", "i", "]", ".", "lstrip", "(", "' '", ")", "i", "+=", "1", "return", "mark_message_lines", "(", "lines", ")" ]
Removes the initial spaces in each line before marking message lines. This ensures headers can be identified if they are indented with spaces.
[ "Removes", "the", "initial", "spaces", "in", "each", "line", "before", "marking", "message", "lines", "." ]
train
https://github.com/mailgun/talon/blob/cdd84563dd329c4f887591807870d10015e0c7a7/talon/quotations.py#L219-L229
<|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 the initial spaces in each line before marking message lines. This ensures headers can be identified if they are indented with spaces. ### Response: def remove_initial_spaces_and_mark_message_lines(lines): """ Removes the initial spaces in each line before marking message lines. This ensures headers can be identified if they are indented with spaces. """ i = 0 while i < len(lines): lines[i] = lines[i].lstrip(' ') i += 1 return mark_message_lines(lines) <|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, 279, 2926, 12908, 304, 1855, 1584, 1603, 36024, 1984, 5238, 382, 262, 1115, 26420, 7247, 649, 387, 11054, 422, 814, 527, 1280, 16243, 449, 12908, 382, 14711, 6075, 512, 755, 4148, 16186, 68983, 8543, 19460, 6598, 18828, 34252, 997, 262, 3270, 262, 39875, 279, 2926, 12908, 304, 1855, 1584, 1603, 36024, 1984, 5238, 382, 262, 1115, 26420, 7247, 649, 387, 11054, 422, 814, 527, 1280, 16243, 449, 12908, 627, 262, 3270, 262, 602, 284, 220, 15, 198, 262, 1418, 602, 366, 2479, 34252, 997, 286, 5238, 1004, 60, 284, 5238, 1004, 948, 75, 13406, 493, 22428, 286, 602, 1447, 220, 16, 198, 262, 471, 1906, 6598, 18828, 34252, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 279, 2926, 12908, 304, 1855, 1584, 1603, 36024, 1984, 5238, 382, 262, 1115, 26420, 7247, 649, 387, 11054, 422, 814, 527, 1280, 16243, 449, 12908, 382, 14711, 6075, 512, 755, 4148, 16186, 68983, 8543, 19460, 6598, 18828, 34252, 997, 262, 3270, 262, 39875, 279, 2926, 12908, 304, 1855, 1584, 1603, 36024, 1984, 5238, 382, 262, 1115, 26420, 7247, 649, 387, 11054, 422, 814, 527, 1280, 16243, 449, 12908, 627, 262, 3270, 262, 602, 284, 220, 15, 198, 262, 1418, 602, 366, 2479, 34252, 997, 286, 5238, 1004, 60, 284, 5238, 1004, 948, 75, 13406, 493, 22428, 286, 602, 1447, 220, 16, 198, 262, 471, 1906, 6598, 18828, 34252, 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 ]
Microsoft/nni
examples/trials/weight_sharing/ga_squad/train_model.py
GAG.build_char_states
def build_char_states(self, char_embed, is_training, reuse, char_ids, char_lengths): """Build char embedding network for the QA model.""" max_char_length = self.cfg.max_char_length inputs = dropout(tf.nn.embedding_lookup(char_embed, char_ids), self.cfg.dropout, is_training) inputs = tf.reshape( inputs, shape=[max_char_length, -1, self.cfg.char_embed_dim]) char_lengths = tf.reshape(char_lengths, shape=[-1]) with tf.variable_scope('char_encoding', reuse=reuse): cell_fw = XGRUCell(hidden_dim=self.cfg.char_embed_dim) cell_bw = XGRUCell(hidden_dim=self.cfg.char_embed_dim) _, (left_right, right_left) = tf.nn.bidirectional_dynamic_rnn( cell_fw=cell_fw, cell_bw=cell_bw, sequence_length=char_lengths, inputs=inputs, time_major=True, dtype=tf.float32 ) left_right = tf.reshape(left_right, shape=[-1, self.cfg.char_embed_dim]) right_left = tf.reshape(right_left, shape=[-1, self.cfg.char_embed_dim]) states = tf.concat([left_right, right_left], axis=1) out_shape = tf.shape(char_ids)[1:3] out_shape = tf.concat([out_shape, tf.constant( value=[self.cfg.char_embed_dim * 2], dtype=tf.int32)], axis=0) return tf.reshape(states, shape=out_shape)
python
def build_char_states(self, char_embed, is_training, reuse, char_ids, char_lengths): """Build char embedding network for the QA model.""" max_char_length = self.cfg.max_char_length inputs = dropout(tf.nn.embedding_lookup(char_embed, char_ids), self.cfg.dropout, is_training) inputs = tf.reshape( inputs, shape=[max_char_length, -1, self.cfg.char_embed_dim]) char_lengths = tf.reshape(char_lengths, shape=[-1]) with tf.variable_scope('char_encoding', reuse=reuse): cell_fw = XGRUCell(hidden_dim=self.cfg.char_embed_dim) cell_bw = XGRUCell(hidden_dim=self.cfg.char_embed_dim) _, (left_right, right_left) = tf.nn.bidirectional_dynamic_rnn( cell_fw=cell_fw, cell_bw=cell_bw, sequence_length=char_lengths, inputs=inputs, time_major=True, dtype=tf.float32 ) left_right = tf.reshape(left_right, shape=[-1, self.cfg.char_embed_dim]) right_left = tf.reshape(right_left, shape=[-1, self.cfg.char_embed_dim]) states = tf.concat([left_right, right_left], axis=1) out_shape = tf.shape(char_ids)[1:3] out_shape = tf.concat([out_shape, tf.constant( value=[self.cfg.char_embed_dim * 2], dtype=tf.int32)], axis=0) return tf.reshape(states, shape=out_shape)
[ "def", "build_char_states", "(", "self", ",", "char_embed", ",", "is_training", ",", "reuse", ",", "char_ids", ",", "char_lengths", ")", ":", "max_char_length", "=", "self", ".", "cfg", ".", "max_char_length", "inputs", "=", "dropout", "(", "tf", ".", "nn", ".", "embedding_lookup", "(", "char_embed", ",", "char_ids", ")", ",", "self", ".", "cfg", ".", "dropout", ",", "is_training", ")", "inputs", "=", "tf", ".", "reshape", "(", "inputs", ",", "shape", "=", "[", "max_char_length", ",", "-", "1", ",", "self", ".", "cfg", ".", "char_embed_dim", "]", ")", "char_lengths", "=", "tf", ".", "reshape", "(", "char_lengths", ",", "shape", "=", "[", "-", "1", "]", ")", "with", "tf", ".", "variable_scope", "(", "'char_encoding'", ",", "reuse", "=", "reuse", ")", ":", "cell_fw", "=", "XGRUCell", "(", "hidden_dim", "=", "self", ".", "cfg", ".", "char_embed_dim", ")", "cell_bw", "=", "XGRUCell", "(", "hidden_dim", "=", "self", ".", "cfg", ".", "char_embed_dim", ")", "_", ",", "(", "left_right", ",", "right_left", ")", "=", "tf", ".", "nn", ".", "bidirectional_dynamic_rnn", "(", "cell_fw", "=", "cell_fw", ",", "cell_bw", "=", "cell_bw", ",", "sequence_length", "=", "char_lengths", ",", "inputs", "=", "inputs", ",", "time_major", "=", "True", ",", "dtype", "=", "tf", ".", "float32", ")", "left_right", "=", "tf", ".", "reshape", "(", "left_right", ",", "shape", "=", "[", "-", "1", ",", "self", ".", "cfg", ".", "char_embed_dim", "]", ")", "right_left", "=", "tf", ".", "reshape", "(", "right_left", ",", "shape", "=", "[", "-", "1", ",", "self", ".", "cfg", ".", "char_embed_dim", "]", ")", "states", "=", "tf", ".", "concat", "(", "[", "left_right", ",", "right_left", "]", ",", "axis", "=", "1", ")", "out_shape", "=", "tf", ".", "shape", "(", "char_ids", ")", "[", "1", ":", "3", "]", "out_shape", "=", "tf", ".", "concat", "(", "[", "out_shape", ",", "tf", ".", "constant", "(", "value", "=", "[", "self", ".", "cfg", ".", "char_embed_dim", "*", "2", "]", ",", "dtype", "=", "tf", ".", "int32", ")", "]", ",", "axis", "=", "0", ")", "return", "tf", ".", "reshape", "(", "states", ",", "shape", "=", "out_shape", ")" ]
Build char embedding network for the QA model.
[ "Build", "char", "embedding", "network", "for", "the", "QA", "model", "." ]
train
https://github.com/Microsoft/nni/blob/c7cc8db32da8d2ec77a382a55089f4e17247ce41/examples/trials/weight_sharing/ga_squad/train_model.py#L234-L263
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Build char embedding network for the QA model. ### Response: def build_char_states(self, char_embed, is_training, reuse, char_ids, char_lengths): """Build char embedding network for the QA model.""" max_char_length = self.cfg.max_char_length inputs = dropout(tf.nn.embedding_lookup(char_embed, char_ids), self.cfg.dropout, is_training) inputs = tf.reshape( inputs, shape=[max_char_length, -1, self.cfg.char_embed_dim]) char_lengths = tf.reshape(char_lengths, shape=[-1]) with tf.variable_scope('char_encoding', reuse=reuse): cell_fw = XGRUCell(hidden_dim=self.cfg.char_embed_dim) cell_bw = XGRUCell(hidden_dim=self.cfg.char_embed_dim) _, (left_right, right_left) = tf.nn.bidirectional_dynamic_rnn( cell_fw=cell_fw, cell_bw=cell_bw, sequence_length=char_lengths, inputs=inputs, time_major=True, dtype=tf.float32 ) left_right = tf.reshape(left_right, shape=[-1, self.cfg.char_embed_dim]) right_left = tf.reshape(right_left, shape=[-1, self.cfg.char_embed_dim]) states = tf.concat([left_right, right_left], axis=1) out_shape = tf.shape(char_ids)[1:3] out_shape = tf.concat([out_shape, tf.constant( value=[self.cfg.char_embed_dim * 2], dtype=tf.int32)], axis=0) return tf.reshape(states, shape=out_shape) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 11313, 1181, 40188, 4009, 369, 279, 67008, 1646, 382, 14711, 6075, 512, 755, 1977, 9415, 23830, 1214, 11, 1181, 24967, 11, 374, 33991, 11, 27068, 11, 1181, 8237, 11, 1181, 55516, 997, 286, 4304, 11313, 1181, 40188, 4009, 369, 279, 67008, 1646, 14781, 286, 1973, 9415, 5228, 284, 659, 31581, 6817, 9415, 5228, 271, 286, 11374, 284, 44381, 20511, 20494, 68714, 28564, 7078, 24967, 11, 1181, 8237, 1350, 5218, 659, 31581, 61364, 11, 374, 33991, 340, 286, 11374, 284, 6543, 23967, 1021, 310, 11374, 11, 6211, 5941, 2880, 9415, 5228, 11, 482, 16, 11, 659, 31581, 11402, 24967, 11024, 2608, 286, 1181, 55516, 284, 6543, 23967, 7078, 55516, 11, 6211, 5941, 12, 16, 2608, 286, 449, 6543, 46321, 24077, 493, 1799, 38713, 518, 27068, 50752, 817, 997, 310, 2849, 58549, 284, 1630, 8796, 52, 3683, 58314, 11024, 7822, 31581, 11402, 24967, 11024, 340, 310, 2849, 65584, 284, 1630, 8796, 52, 3683, 58314, 11024, 7822, 31581, 11402, 24967, 11024, 340, 310, 8523, 320, 2414, 10762, 11, 1314, 9774, 8, 284, 6543, 20494, 95715, 45770, 47092, 99700, 1021, 394, 2849, 58549, 28, 5997, 58549, 345, 394, 2849, 65584, 28, 5997, 65584, 345, 394, 8668, 5228, 28, 1799, 55516, 345, 394, 11374, 28, 25986, 345, 394, 892, 49016, 3702, 345, 394, 13534, 34019, 16304, 843, 198, 310, 5235, 286, 2163, 10762, 284, 6543, 23967, 18139, 10762, 11, 6211, 5941, 12, 16, 11, 659, 31581, 11402, 24967, 11024, 9801, 286, 1314, 9774, 284, 6543, 23967, 28804, 9774, 11, 6211, 5941, 12, 16, 11, 659, 31581, 11402, 24967, 11024, 9801, 286, 5415, 284, 6543, 15614, 2625, 2414, 10762, 11, 1314, 9774, 1145, 8183, 28, 16, 340, 286, 704, 13911, 284, 6543, 7201, 7078, 8237, 6758, 16, 25, 18, 933, 286, 704, 13911, 284, 6543, 15614, 2625, 412, 13911, 11, 6543, 31130, 1021, 310, 907, 5941, 726, 31581, 11402, 24967, 11024, 353, 220, 17, 1145, 13534, 34019, 6537, 843, 26090, 8183, 28, 15, 340, 286, 471, 6543, 23967, 79502, 11, 6211, 86098, 13911, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 11313, 1181, 40188, 4009, 369, 279, 67008, 1646, 382, 14711, 6075, 512, 755, 1977, 9415, 23830, 1214, 11, 1181, 24967, 11, 374, 33991, 11, 27068, 11, 1181, 8237, 11, 1181, 55516, 997, 286, 4304, 11313, 1181, 40188, 4009, 369, 279, 67008, 1646, 14781, 286, 1973, 9415, 5228, 284, 659, 31581, 6817, 9415, 5228, 271, 286, 11374, 284, 44381, 20511, 20494, 68714, 28564, 7078, 24967, 11, 1181, 8237, 1350, 5218, 659, 31581, 61364, 11, 374, 33991, 340, 286, 11374, 284, 6543, 23967, 1021, 310, 11374, 11, 6211, 5941, 2880, 9415, 5228, 11, 482, 16, 11, 659, 31581, 11402, 24967, 11024, 2608, 286, 1181, 55516, 284, 6543, 23967, 7078, 55516, 11, 6211, 5941, 12, 16, 2608, 286, 449, 6543, 46321, 24077, 493, 1799, 38713, 518, 27068, 50752, 817, 997, 310, 2849, 58549, 284, 1630, 8796, 52, 3683, 58314, 11024, 7822, 31581, 11402, 24967, 11024, 340, 310, 2849, 65584, 284, 1630, 8796, 52, 3683, 58314, 11024, 7822, 31581, 11402, 24967, 11024, 340, 310, 8523, 320, 2414, 10762, 11, 1314, 9774, 8, 284, 6543, 20494, 95715, 45770, 47092, 99700, 1021, 394, 2849, 58549, 28, 5997, 58549, 345, 394, 2849, 65584, 28, 5997, 65584, 345, 394, 8668, 5228, 28, 1799, 55516, 345, 394, 11374, 28, 25986, 345, 394, 892, 49016, 3702, 345, 394, 13534, 34019, 16304, 843, 198, 310, 5235, 286, 2163, 10762, 284, 6543, 23967, 18139, 10762, 11, 6211, 5941, 12, 16, 11, 659, 31581, 11402, 24967, 11024, 9801, 286, 1314, 9774, 284, 6543, 23967, 28804, 9774, 11, 6211, 5941, 12, 16, 11, 659, 31581, 11402, 24967, 11024, 9801, 286, 5415, 284, 6543, 15614, 2625, 2414, 10762, 11, 1314, 9774, 1145, 8183, 28, 16, 340, 286, 704, 13911, 284, 6543, 7201, 7078, 8237, 6758, 16, 25, 18, 933, 286, 704, 13911, 284, 6543, 15614, 2625, 412, 13911, 11, 6543, 31130, 1021, 310, 907, 5941, 726, 31581, 11402, 24967, 11024, 353, 220, 17, 1145, 13534, 34019, 6537, 843, 26090, 8183, 28, 15, 340, 286, 471, 6543, 23967, 79502, 11, 6211, 86098, 13911, 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 ]
richardkiss/pycoin
pycoin/ecdsa/intstream.py
_from_bytes
def _from_bytes(bytes, byteorder="big", signed=False): """This is the same functionality as ``int.from_bytes`` in python 3""" return int.from_bytes(bytes, byteorder=byteorder, signed=signed)
python
def _from_bytes(bytes, byteorder="big", signed=False): """This is the same functionality as ``int.from_bytes`` in python 3""" return int.from_bytes(bytes, byteorder=byteorder, signed=signed)
[ "def", "_from_bytes", "(", "bytes", ",", "byteorder", "=", "\"big\"", ",", "signed", "=", "False", ")", ":", "return", "int", ".", "from_bytes", "(", "bytes", ",", "byteorder", "=", "byteorder", ",", "signed", "=", "signed", ")" ]
This is the same functionality as ``int.from_bytes`` in python 3
[ "This", "is", "the", "same", "functionality", "as", "int", ".", "from_bytes", "in", "python", "3" ]
train
https://github.com/richardkiss/pycoin/blob/1e8d0d9fe20ce0347b97847bb529cd1bd84c7442/pycoin/ecdsa/intstream.py#L10-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: This is the same functionality as ``int.from_bytes`` in python 3 ### Response: def _from_bytes(bytes, byteorder="big", signed=False): """This is the same functionality as ``int.from_bytes`` in python 3""" return int.from_bytes(bytes, byteorder=byteorder, signed=signed) <|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, 279, 1890, 15293, 439, 10103, 396, 6521, 12807, 14196, 304, 10344, 220, 18, 271, 14711, 6075, 512, 755, 721, 1527, 12807, 24033, 11, 5027, 1382, 429, 16548, 498, 8667, 5725, 997, 262, 4304, 2028, 374, 279, 1890, 15293, 439, 10103, 396, 6521, 12807, 14196, 304, 10344, 220, 18, 7275, 262, 471, 528, 6521, 12807, 24033, 11, 5027, 1382, 28, 3867, 1382, 11, 8667, 28, 2264, 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, 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, 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400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 2028, 374, 279, 1890, 15293, 439, 10103, 396, 6521, 12807, 14196, 304, 10344, 220, 18, 271, 14711, 6075, 512, 755, 721, 1527, 12807, 24033, 11, 5027, 1382, 429, 16548, 498, 8667, 5725, 997, 262, 4304, 2028, 374, 279, 1890, 15293, 439, 10103, 396, 6521, 12807, 14196, 304, 10344, 220, 18, 7275, 262, 471, 528, 6521, 12807, 24033, 11, 5027, 1382, 28, 3867, 1382, 11, 8667, 28, 2264, 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 ]
DLR-RM/RAFCON
source/rafcon/gui/mygaphas/tools.py
ConnectionTool._handle_temporary_connection
def _handle_temporary_connection(self, old_sink, new_sink, of_target=True): """Connect connection to new_sink If new_sink is set, the connection origin or target will be set to new_sink. The connection to old_sink is being removed. :param gaphas.aspect.ConnectionSink old_sink: Old sink (if existing) :param gaphas.aspect.ConnectionSink new_sink: New sink (if existing) :param bool of_target: Whether the origin or target will be reconnected :return: """ def sink_set_and_differs(sink_a, sink_b): if not sink_a: return False if not sink_b: return True if sink_a.port != sink_b.port: return True return False if sink_set_and_differs(old_sink, new_sink): sink_port_v = old_sink.port.port_v self._disconnect_temporarily(sink_port_v, target=of_target) if sink_set_and_differs(new_sink, old_sink): sink_port_v = new_sink.port.port_v self._connect_temporarily(sink_port_v, target=of_target)
python
def _handle_temporary_connection(self, old_sink, new_sink, of_target=True): """Connect connection to new_sink If new_sink is set, the connection origin or target will be set to new_sink. The connection to old_sink is being removed. :param gaphas.aspect.ConnectionSink old_sink: Old sink (if existing) :param gaphas.aspect.ConnectionSink new_sink: New sink (if existing) :param bool of_target: Whether the origin or target will be reconnected :return: """ def sink_set_and_differs(sink_a, sink_b): if not sink_a: return False if not sink_b: return True if sink_a.port != sink_b.port: return True return False if sink_set_and_differs(old_sink, new_sink): sink_port_v = old_sink.port.port_v self._disconnect_temporarily(sink_port_v, target=of_target) if sink_set_and_differs(new_sink, old_sink): sink_port_v = new_sink.port.port_v self._connect_temporarily(sink_port_v, target=of_target)
[ "def", "_handle_temporary_connection", "(", "self", ",", "old_sink", ",", "new_sink", ",", "of_target", "=", "True", ")", ":", "def", "sink_set_and_differs", "(", "sink_a", ",", "sink_b", ")", ":", "if", "not", "sink_a", ":", "return", "False", "if", "not", "sink_b", ":", "return", "True", "if", "sink_a", ".", "port", "!=", "sink_b", ".", "port", ":", "return", "True", "return", "False", "if", "sink_set_and_differs", "(", "old_sink", ",", "new_sink", ")", ":", "sink_port_v", "=", "old_sink", ".", "port", ".", "port_v", "self", ".", "_disconnect_temporarily", "(", "sink_port_v", ",", "target", "=", "of_target", ")", "if", "sink_set_and_differs", "(", "new_sink", ",", "old_sink", ")", ":", "sink_port_v", "=", "new_sink", ".", "port", ".", "port_v", "self", ".", "_connect_temporarily", "(", "sink_port_v", ",", "target", "=", "of_target", ")" ]
Connect connection to new_sink If new_sink is set, the connection origin or target will be set to new_sink. The connection to old_sink is being removed. :param gaphas.aspect.ConnectionSink old_sink: Old sink (if existing) :param gaphas.aspect.ConnectionSink new_sink: New sink (if existing) :param bool of_target: Whether the origin or target will be reconnected :return:
[ "Connect", "connection", "to", "new_sink" ]
train
https://github.com/DLR-RM/RAFCON/blob/24942ef1a904531f49ab8830a1dbb604441be498/source/rafcon/gui/mygaphas/tools.py#L601-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: Connect connection to new_sink If new_sink is set, the connection origin or target will be set to new_sink. The connection to old_sink is being removed. :param gaphas.aspect.ConnectionSink old_sink: Old sink (if existing) :param gaphas.aspect.ConnectionSink new_sink: New sink (if existing) :param bool of_target: Whether the origin or target will be reconnected :return: ### Response: def _handle_temporary_connection(self, old_sink, new_sink, of_target=True): """Connect connection to new_sink If new_sink is set, the connection origin or target will be set to new_sink. The connection to old_sink is being removed. :param gaphas.aspect.ConnectionSink old_sink: Old sink (if existing) :param gaphas.aspect.ConnectionSink new_sink: New sink (if existing) :param bool of_target: Whether the origin or target will be reconnected :return: """ def sink_set_and_differs(sink_a, sink_b): if not sink_a: return False if not sink_b: return True if sink_a.port != sink_b.port: return True return False if sink_set_and_differs(old_sink, new_sink): sink_port_v = old_sink.port.port_v self._disconnect_temporarily(sink_port_v, target=of_target) if sink_set_and_differs(new_sink, old_sink): sink_port_v = new_sink.port.port_v self._connect_temporarily(sink_port_v, target=of_target) <|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, 14953, 3717, 311, 502, 52667, 271, 286, 1442, 502, 52667, 374, 743, 11, 279, 3717, 6371, 477, 2218, 690, 387, 743, 311, 502, 52667, 13, 578, 3717, 311, 2362, 52667, 374, 198, 286, 1694, 7108, 382, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 2362, 52667, 25, 10846, 19868, 320, 333, 6484, 340, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 502, 52667, 25, 1561, 19868, 320, 333, 6484, 340, 286, 551, 913, 1845, 315, 11370, 25, 13440, 279, 6371, 477, 2218, 690, 387, 312, 15647, 198, 286, 551, 693, 1473, 14711, 6075, 512, 755, 721, 8355, 12033, 7746, 16245, 1214, 11, 2362, 52667, 11, 502, 52667, 11, 315, 11370, 3702, 997, 286, 4304, 14953, 3717, 311, 502, 52667, 271, 286, 1442, 502, 52667, 374, 743, 11, 279, 3717, 6371, 477, 2218, 690, 387, 743, 311, 502, 52667, 13, 578, 3717, 311, 2362, 52667, 374, 198, 286, 1694, 7108, 382, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 2362, 52667, 25, 10846, 19868, 320, 333, 6484, 340, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 502, 52667, 25, 1561, 19868, 320, 333, 6484, 340, 286, 551, 913, 1845, 315, 11370, 25, 13440, 279, 6371, 477, 2218, 690, 387, 312, 15647, 198, 286, 551, 693, 512, 286, 12713, 286, 711, 19868, 2667, 8543, 16229, 388, 1161, 771, 4404, 11, 19868, 890, 997, 310, 422, 539, 19868, 4404, 512, 394, 471, 3641, 198, 310, 422, 539, 19868, 890, 512, 394, 471, 3082, 198, 310, 422, 19868, 4404, 14940, 976, 19868, 890, 14940, 512, 394, 471, 3082, 198, 310, 471, 3641, 271, 286, 422, 19868, 2667, 8543, 16229, 388, 22739, 52667, 11, 502, 52667, 997, 310, 19868, 8889, 2325, 284, 2362, 52667, 14940, 14940, 2325, 198, 310, 659, 1462, 53092, 12033, 97254, 1161, 771, 8889, 2325, 11, 2218, 28, 1073, 11370, 696, 286, 422, 19868, 2667, 8543, 16229, 388, 1792, 52667, 11, 2362, 52667, 997, 310, 19868, 8889, 2325, 284, 502, 52667, 14940, 14940, 2325, 198, 310, 659, 1462, 6595, 12033, 97254, 1161, 771, 8889, 2325, 11, 2218, 28, 1073, 11370, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 14953, 3717, 311, 502, 52667, 271, 286, 1442, 502, 52667, 374, 743, 11, 279, 3717, 6371, 477, 2218, 690, 387, 743, 311, 502, 52667, 13, 578, 3717, 311, 2362, 52667, 374, 198, 286, 1694, 7108, 382, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 2362, 52667, 25, 10846, 19868, 320, 333, 6484, 340, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 502, 52667, 25, 1561, 19868, 320, 333, 6484, 340, 286, 551, 913, 1845, 315, 11370, 25, 13440, 279, 6371, 477, 2218, 690, 387, 312, 15647, 198, 286, 551, 693, 1473, 14711, 6075, 512, 755, 721, 8355, 12033, 7746, 16245, 1214, 11, 2362, 52667, 11, 502, 52667, 11, 315, 11370, 3702, 997, 286, 4304, 14953, 3717, 311, 502, 52667, 271, 286, 1442, 502, 52667, 374, 743, 11, 279, 3717, 6371, 477, 2218, 690, 387, 743, 311, 502, 52667, 13, 578, 3717, 311, 2362, 52667, 374, 198, 286, 1694, 7108, 382, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 2362, 52667, 25, 10846, 19868, 320, 333, 6484, 340, 286, 551, 913, 342, 1366, 300, 67079, 17921, 46194, 502, 52667, 25, 1561, 19868, 320, 333, 6484, 340, 286, 551, 913, 1845, 315, 11370, 25, 13440, 279, 6371, 477, 2218, 690, 387, 312, 15647, 198, 286, 551, 693, 512, 286, 12713, 286, 711, 19868, 2667, 8543, 16229, 388, 1161, 771, 4404, 11, 19868, 890, 997, 310, 422, 539, 19868, 4404, 512, 394, 471, 3641, 198, 310, 422, 539, 19868, 890, 512, 394, 471, 3082, 198, 310, 422, 19868, 4404, 14940, 976, 19868, 890, 14940, 512, 394, 471, 3082, 198, 310, 471, 3641, 271, 286, 422, 19868, 2667, 8543, 16229, 388, 22739, 52667, 11, 502, 52667, 997, 310, 19868, 8889, 2325, 284, 2362, 52667, 14940, 14940, 2325, 198, 310, 659, 1462, 53092, 12033, 97254, 1161, 771, 8889, 2325, 11, 2218, 28, 1073, 11370, 696, 286, 422, 19868, 2667, 8543, 16229, 388, 1792, 52667, 11, 2362, 52667, 997, 310, 19868, 8889, 2325, 284, 502, 52667, 14940, 14940, 2325, 198, 310, 659, 1462, 6595, 12033, 97254, 1161, 771, 8889, 2325, 11, 2218, 28, 1073, 11370, 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 ]
jonathf/chaospy
chaospy/poly/shaping.py
transpose
def transpose(vari): """ Transpose a shapeable quantety. Args: vari (chaospy.poly.base.Poly, numpy.ndarray): Quantety of interest. Returns: (chaospy.poly.base.Poly, numpy.ndarray): Same type as ``vari``. Examples: >>> P = chaospy.reshape(chaospy.prange(4), (2,2)) >>> print(P) [[1, q0], [q0^2, q0^3]] >>> print(chaospy.transpose(P)) [[1, q0^2], [q0, q0^3]] """ if isinstance(vari, Poly): core = vari.A.copy() for key in vari.keys: core[key] = transpose(core[key]) return Poly(core, vari.dim, vari.shape[::-1], vari.dtype) return numpy.transpose(vari)
python
def transpose(vari): """ Transpose a shapeable quantety. Args: vari (chaospy.poly.base.Poly, numpy.ndarray): Quantety of interest. Returns: (chaospy.poly.base.Poly, numpy.ndarray): Same type as ``vari``. Examples: >>> P = chaospy.reshape(chaospy.prange(4), (2,2)) >>> print(P) [[1, q0], [q0^2, q0^3]] >>> print(chaospy.transpose(P)) [[1, q0^2], [q0, q0^3]] """ if isinstance(vari, Poly): core = vari.A.copy() for key in vari.keys: core[key] = transpose(core[key]) return Poly(core, vari.dim, vari.shape[::-1], vari.dtype) return numpy.transpose(vari)
[ "def", "transpose", "(", "vari", ")", ":", "if", "isinstance", "(", "vari", ",", "Poly", ")", ":", "core", "=", "vari", ".", "A", ".", "copy", "(", ")", "for", "key", "in", "vari", ".", "keys", ":", "core", "[", "key", "]", "=", "transpose", "(", "core", "[", "key", "]", ")", "return", "Poly", "(", "core", ",", "vari", ".", "dim", ",", "vari", ".", "shape", "[", ":", ":", "-", "1", "]", ",", "vari", ".", "dtype", ")", "return", "numpy", ".", "transpose", "(", "vari", ")" ]
Transpose a shapeable quantety. Args: vari (chaospy.poly.base.Poly, numpy.ndarray): Quantety of interest. Returns: (chaospy.poly.base.Poly, numpy.ndarray): Same type as ``vari``. Examples: >>> P = chaospy.reshape(chaospy.prange(4), (2,2)) >>> print(P) [[1, q0], [q0^2, q0^3]] >>> print(chaospy.transpose(P)) [[1, q0^2], [q0, q0^3]]
[ "Transpose", "a", "shapeable", "quantety", "." ]
train
https://github.com/jonathf/chaospy/blob/25ecfa7bf5608dc10c0b31d142ded0e3755f5d74/chaospy/poly/shaping.py#L114-L139
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Transpose a shapeable quantety. Args: vari (chaospy.poly.base.Poly, numpy.ndarray): Quantety of interest. Returns: (chaospy.poly.base.Poly, numpy.ndarray): Same type as ``vari``. Examples: >>> P = chaospy.reshape(chaospy.prange(4), (2,2)) >>> print(P) [[1, q0], [q0^2, q0^3]] >>> print(chaospy.transpose(P)) [[1, q0^2], [q0, q0^3]] ### Response: def transpose(vari): """ Transpose a shapeable quantety. Args: vari (chaospy.poly.base.Poly, numpy.ndarray): Quantety of interest. Returns: (chaospy.poly.base.Poly, numpy.ndarray): Same type as ``vari``. Examples: >>> P = chaospy.reshape(chaospy.prange(4), (2,2)) >>> print(P) [[1, q0], [q0^2, q0^3]] >>> print(chaospy.transpose(P)) [[1, q0^2], [q0, q0^3]] """ if isinstance(vari, Poly): core = vari.A.copy() for key in vari.keys: core[key] = transpose(core[key]) return Poly(core, vari.dim, vari.shape[::-1], vari.dtype) return numpy.transpose(vari) <|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, 89298, 264, 6211, 481, 10484, 2676, 382, 262, 18161, 512, 286, 4244, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 32541, 2676, 315, 2802, 382, 262, 5295, 512, 286, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 26823, 955, 439, 10103, 30265, 14196, 382, 262, 26379, 512, 286, 12382, 393, 284, 28013, 3368, 23967, 7, 6583, 437, 3368, 558, 9866, 7, 19, 705, 320, 17, 11, 17, 1192, 286, 12382, 1194, 5417, 340, 286, 4416, 16, 11, 2874, 15, 1145, 510, 80, 15, 61, 17, 11, 2874, 15, 61, 18, 14623, 286, 12382, 1194, 7, 6583, 437, 3368, 36405, 5417, 1192, 286, 4416, 16, 11, 2874, 15, 61, 17, 1145, 510, 80, 15, 11, 2874, 15, 61, 18, 43550, 14711, 6075, 512, 755, 52023, 7689, 72, 997, 262, 3270, 262, 4149, 2972, 264, 6211, 481, 10484, 2676, 382, 262, 18161, 512, 286, 4244, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 32541, 2676, 315, 2802, 382, 262, 5295, 512, 286, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 26823, 955, 439, 10103, 30265, 14196, 382, 262, 26379, 512, 286, 12382, 393, 284, 28013, 3368, 23967, 7, 6583, 437, 3368, 558, 9866, 7, 19, 705, 320, 17, 11, 17, 1192, 286, 12382, 1194, 5417, 340, 286, 4416, 16, 11, 2874, 15, 1145, 510, 80, 15, 61, 17, 11, 2874, 15, 61, 18, 14623, 286, 12382, 1194, 7, 6583, 437, 3368, 36405, 5417, 1192, 286, 4416, 16, 11, 2874, 15, 61, 17, 1145, 510, 80, 15, 11, 2874, 15, 61, 18, 14623, 262, 3270, 262, 422, 11656, 7689, 72, 11, 19294, 997, 286, 6332, 284, 4244, 885, 12511, 746, 286, 369, 1401, 304, 4244, 9301, 512, 310, 6332, 8320, 60, 284, 52023, 48967, 8320, 2608, 286, 471, 19294, 48967, 11, 4244, 35365, 11, 4244, 7201, 63254, 16, 1145, 4244, 46855, 696, 262, 471, 8760, 36405, 7689, 72, 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, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 89298, 264, 6211, 481, 10484, 2676, 382, 262, 18161, 512, 286, 4244, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 32541, 2676, 315, 2802, 382, 262, 5295, 512, 286, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 26823, 955, 439, 10103, 30265, 14196, 382, 262, 26379, 512, 286, 12382, 393, 284, 28013, 3368, 23967, 7, 6583, 437, 3368, 558, 9866, 7, 19, 705, 320, 17, 11, 17, 1192, 286, 12382, 1194, 5417, 340, 286, 4416, 16, 11, 2874, 15, 1145, 510, 80, 15, 61, 17, 11, 2874, 15, 61, 18, 14623, 286, 12382, 1194, 7, 6583, 437, 3368, 36405, 5417, 1192, 286, 4416, 16, 11, 2874, 15, 61, 17, 1145, 510, 80, 15, 11, 2874, 15, 61, 18, 43550, 14711, 6075, 512, 755, 52023, 7689, 72, 997, 262, 3270, 262, 4149, 2972, 264, 6211, 481, 10484, 2676, 382, 262, 18161, 512, 286, 4244, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 32541, 2676, 315, 2802, 382, 262, 5295, 512, 286, 320, 6583, 437, 3368, 65681, 9105, 1087, 5849, 11, 8760, 36649, 997, 310, 26823, 955, 439, 10103, 30265, 14196, 382, 262, 26379, 512, 286, 12382, 393, 284, 28013, 3368, 23967, 7, 6583, 437, 3368, 558, 9866, 7, 19, 705, 320, 17, 11, 17, 1192, 286, 12382, 1194, 5417, 340, 286, 4416, 16, 11, 2874, 15, 1145, 510, 80, 15, 61, 17, 11, 2874, 15, 61, 18, 14623, 286, 12382, 1194, 7, 6583, 437, 3368, 36405, 5417, 1192, 286, 4416, 16, 11, 2874, 15, 61, 17, 1145, 510, 80, 15, 11, 2874, 15, 61, 18, 14623, 262, 3270, 262, 422, 11656, 7689, 72, 11, 19294, 997, 286, 6332, 284, 4244, 885, 12511, 746, 286, 369, 1401, 304, 4244, 9301, 512, 310, 6332, 8320, 60, 284, 52023, 48967, 8320, 2608, 286, 471, 19294, 48967, 11, 4244, 35365, 11, 4244, 7201, 63254, 16, 1145, 4244, 46855, 696, 262, 471, 8760, 36405, 7689, 72, 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 ]
pycampers/zproc
zproc/state/state.py
State.fork
def fork(self, server_address: str = None, *, namespace: str = None) -> "State": r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If no args are provided to this function, then it shall create a new :py:class:`State` object that follows the exact same semantics as this one. This is preferred over ``copy()``\ -ing a :py:class:`State` object. Useful when one needs to access 2 or more namespaces from the same code. """ if server_address is None: server_address = self.server_address if namespace is None: namespace = self.namespace return self.__class__(server_address, namespace=namespace)
python
def fork(self, server_address: str = None, *, namespace: str = None) -> "State": r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If no args are provided to this function, then it shall create a new :py:class:`State` object that follows the exact same semantics as this one. This is preferred over ``copy()``\ -ing a :py:class:`State` object. Useful when one needs to access 2 or more namespaces from the same code. """ if server_address is None: server_address = self.server_address if namespace is None: namespace = self.namespace return self.__class__(server_address, namespace=namespace)
[ "def", "fork", "(", "self", ",", "server_address", ":", "str", "=", "None", ",", "*", ",", "namespace", ":", "str", "=", "None", ")", "->", "\"State\"", ":", "if", "server_address", "is", "None", ":", "server_address", "=", "self", ".", "server_address", "if", "namespace", "is", "None", ":", "namespace", "=", "self", ".", "namespace", "return", "self", ".", "__class__", "(", "server_address", ",", "namespace", "=", "namespace", ")" ]
r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If no args are provided to this function, then it shall create a new :py:class:`State` object that follows the exact same semantics as this one. This is preferred over ``copy()``\ -ing a :py:class:`State` object. Useful when one needs to access 2 or more namespaces from the same code.
[ "r", "Forks", "this", "State", "object", "." ]
train
https://github.com/pycampers/zproc/blob/352a3c7166e2ccc3597c28385a8354b5a22afdc2/zproc/state/state.py#L183-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: r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If no args are provided to this function, then it shall create a new :py:class:`State` object that follows the exact same semantics as this one. This is preferred over ``copy()``\ -ing a :py:class:`State` object. Useful when one needs to access 2 or more namespaces from the same code. ### Response: def fork(self, server_address: str = None, *, namespace: str = None) -> "State": r""" "Forks" this State object. Takes the same args as the :py:class:`State` constructor, except that they automatically default to the values provided during the creation of this State object. If no args are provided to this function, then it shall create a new :py:class:`State` object that follows the exact same semantics as this one. This is preferred over ``copy()``\ -ing a :py:class:`State` object. Useful when one needs to access 2 or more namespaces from the same code. """ if server_address is None: server_address = self.server_address if namespace is None: namespace = self.namespace return self.__class__(server_address, namespace=namespace) <|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, 7275, 286, 330, 37, 74402, 1, 420, 3314, 1665, 382, 286, 38707, 279, 1890, 2897, 439, 279, 551, 3368, 93064, 19258, 1423, 63, 4797, 345, 286, 3734, 430, 814, 9651, 1670, 311, 279, 2819, 3984, 2391, 279, 9886, 315, 420, 3314, 1665, 382, 286, 1442, 912, 2897, 527, 3984, 311, 420, 734, 345, 286, 1243, 433, 4985, 1893, 264, 502, 551, 3368, 93064, 19258, 1423, 63, 1665, 198, 286, 430, 11263, 279, 4839, 1890, 53794, 439, 420, 832, 382, 286, 1115, 374, 15236, 927, 10103, 8728, 368, 14196, 59, 482, 287, 264, 551, 3368, 93064, 19258, 1423, 63, 1665, 382, 286, 51612, 994, 832, 3966, 311, 2680, 220, 17, 477, 810, 59191, 505, 279, 1890, 2082, 382, 14711, 6075, 512, 755, 23243, 1214, 11, 3622, 6886, 25, 610, 284, 2290, 11, 12039, 4573, 25, 610, 284, 2290, 8, 1492, 330, 1423, 4764, 286, 436, 7275, 286, 330, 37, 74402, 1, 420, 3314, 1665, 382, 286, 38707, 279, 1890, 2897, 439, 279, 551, 3368, 93064, 19258, 1423, 63, 4797, 345, 286, 3734, 430, 814, 9651, 1670, 311, 279, 2819, 3984, 2391, 279, 9886, 315, 420, 3314, 1665, 382, 286, 1442, 912, 2897, 527, 3984, 311, 420, 734, 345, 286, 1243, 433, 4985, 1893, 264, 502, 551, 3368, 93064, 19258, 1423, 63, 1665, 198, 286, 430, 11263, 279, 4839, 1890, 53794, 439, 420, 832, 382, 286, 1115, 374, 15236, 927, 10103, 8728, 368, 14196, 59, 482, 287, 264, 551, 3368, 93064, 19258, 1423, 63, 1665, 382, 286, 51612, 994, 832, 3966, 311, 2680, 220, 17, 477, 810, 59191, 505, 279, 1890, 2082, 627, 286, 3270, 286, 422, 3622, 6886, 374, 2290, 512, 310, 3622, 6886, 284, 659, 12926, 6886, 198, 286, 422, 4573, 374, 2290, 512, 310, 4573, 284, 659, 51509, 271, 286, 471, 659, 4952, 1058, 3889, 4120, 6886, 11, 4573, 28, 2280, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 81, 7275, 286, 330, 37, 74402, 1, 420, 3314, 1665, 382, 286, 38707, 279, 1890, 2897, 439, 279, 551, 3368, 93064, 19258, 1423, 63, 4797, 345, 286, 3734, 430, 814, 9651, 1670, 311, 279, 2819, 3984, 2391, 279, 9886, 315, 420, 3314, 1665, 382, 286, 1442, 912, 2897, 527, 3984, 311, 420, 734, 345, 286, 1243, 433, 4985, 1893, 264, 502, 551, 3368, 93064, 19258, 1423, 63, 1665, 198, 286, 430, 11263, 279, 4839, 1890, 53794, 439, 420, 832, 382, 286, 1115, 374, 15236, 927, 10103, 8728, 368, 14196, 59, 482, 287, 264, 551, 3368, 93064, 19258, 1423, 63, 1665, 382, 286, 51612, 994, 832, 3966, 311, 2680, 220, 17, 477, 810, 59191, 505, 279, 1890, 2082, 382, 14711, 6075, 512, 755, 23243, 1214, 11, 3622, 6886, 25, 610, 284, 2290, 11, 12039, 4573, 25, 610, 284, 2290, 8, 1492, 330, 1423, 4764, 286, 436, 7275, 286, 330, 37, 74402, 1, 420, 3314, 1665, 382, 286, 38707, 279, 1890, 2897, 439, 279, 551, 3368, 93064, 19258, 1423, 63, 4797, 345, 286, 3734, 430, 814, 9651, 1670, 311, 279, 2819, 3984, 2391, 279, 9886, 315, 420, 3314, 1665, 382, 286, 1442, 912, 2897, 527, 3984, 311, 420, 734, 345, 286, 1243, 433, 4985, 1893, 264, 502, 551, 3368, 93064, 19258, 1423, 63, 1665, 198, 286, 430, 11263, 279, 4839, 1890, 53794, 439, 420, 832, 382, 286, 1115, 374, 15236, 927, 10103, 8728, 368, 14196, 59, 482, 287, 264, 551, 3368, 93064, 19258, 1423, 63, 1665, 382, 286, 51612, 994, 832, 3966, 311, 2680, 220, 17, 477, 810, 59191, 505, 279, 1890, 2082, 627, 286, 3270, 286, 422, 3622, 6886, 374, 2290, 512, 310, 3622, 6886, 284, 659, 12926, 6886, 198, 286, 422, 4573, 374, 2290, 512, 310, 4573, 284, 659, 51509, 271, 286, 471, 659, 4952, 1058, 3889, 4120, 6886, 11, 4573, 28, 2280, 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 ]
iotile/coretools
iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/__init__.py
createProgBuilder
def createProgBuilder(env): """This is a utility function that creates the Program Builder in an Environment if it is not there already. If it is already there, we return the existing one. """ try: program = env['BUILDERS']['Program'] except KeyError: import SCons.Defaults program = SCons.Builder.Builder(action = SCons.Defaults.LinkAction, emitter = '$PROGEMITTER', prefix = '$PROGPREFIX', suffix = '$PROGSUFFIX', src_suffix = '$OBJSUFFIX', src_builder = 'Object', target_scanner = ProgramScanner) env['BUILDERS']['Program'] = program return program
python
def createProgBuilder(env): """This is a utility function that creates the Program Builder in an Environment if it is not there already. If it is already there, we return the existing one. """ try: program = env['BUILDERS']['Program'] except KeyError: import SCons.Defaults program = SCons.Builder.Builder(action = SCons.Defaults.LinkAction, emitter = '$PROGEMITTER', prefix = '$PROGPREFIX', suffix = '$PROGSUFFIX', src_suffix = '$OBJSUFFIX', src_builder = 'Object', target_scanner = ProgramScanner) env['BUILDERS']['Program'] = program return program
[ "def", "createProgBuilder", "(", "env", ")", ":", "try", ":", "program", "=", "env", "[", "'BUILDERS'", "]", "[", "'Program'", "]", "except", "KeyError", ":", "import", "SCons", ".", "Defaults", "program", "=", "SCons", ".", "Builder", ".", "Builder", "(", "action", "=", "SCons", ".", "Defaults", ".", "LinkAction", ",", "emitter", "=", "'$PROGEMITTER'", ",", "prefix", "=", "'$PROGPREFIX'", ",", "suffix", "=", "'$PROGSUFFIX'", ",", "src_suffix", "=", "'$OBJSUFFIX'", ",", "src_builder", "=", "'Object'", ",", "target_scanner", "=", "ProgramScanner", ")", "env", "[", "'BUILDERS'", "]", "[", "'Program'", "]", "=", "program", "return", "program" ]
This is a utility function that creates the Program Builder in an Environment if it is not there already. If it is already there, we return the existing one.
[ "This", "is", "a", "utility", "function", "that", "creates", "the", "Program", "Builder", "in", "an", "Environment", "if", "it", "is", "not", "there", "already", "." ]
train
https://github.com/iotile/coretools/blob/2d794f5f1346b841b0dcd16c9d284e9bf2f3c6ec/iotilebuild/iotile/build/config/scons-local-3.0.1/SCons/Tool/__init__.py#L306-L326
<|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 utility function that creates the Program Builder in an Environment if it is not there already. If it is already there, we return the existing one. ### Response: def createProgBuilder(env): """This is a utility function that creates the Program Builder in an Environment if it is not there already. If it is already there, we return the existing one. """ try: program = env['BUILDERS']['Program'] except KeyError: import SCons.Defaults program = SCons.Builder.Builder(action = SCons.Defaults.LinkAction, emitter = '$PROGEMITTER', prefix = '$PROGPREFIX', suffix = '$PROGSUFFIX', src_suffix = '$OBJSUFFIX', src_builder = 'Object', target_scanner = ProgramScanner) env['BUILDERS']['Program'] = program return program <|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, 15919, 734, 430, 11705, 279, 6826, 198, 262, 21275, 304, 459, 11847, 422, 433, 374, 539, 1070, 2736, 382, 262, 1442, 433, 374, 2736, 1070, 11, 584, 471, 279, 6484, 832, 382, 14711, 6075, 512, 755, 1893, 90635, 3377, 17409, 997, 262, 4304, 2028, 374, 264, 15919, 734, 430, 11705, 279, 6826, 198, 262, 21275, 304, 459, 11847, 422, 433, 374, 539, 1070, 2736, 382, 262, 1442, 433, 374, 2736, 1070, 11, 584, 471, 279, 6484, 832, 627, 262, 12713, 262, 1456, 512, 286, 2068, 284, 6233, 681, 48280, 4419, 4274, 10920, 4532, 262, 3734, 39194, 512, 286, 1179, 328, 15577, 13578, 82, 198, 286, 2068, 284, 328, 15577, 16015, 16015, 15665, 284, 328, 15577, 13578, 82, 23350, 2573, 345, 2623, 48363, 284, 8412, 9295, 38, 2783, 60937, 756, 2623, 9436, 284, 8412, 9295, 25434, 15133, 756, 2623, 21166, 284, 8412, 9295, 16929, 54833, 756, 2623, 2338, 38251, 284, 8412, 21257, 12830, 54833, 756, 2623, 2338, 29632, 284, 364, 1211, 756, 2623, 2218, 13473, 4992, 284, 6826, 32102, 340, 286, 6233, 681, 48280, 4419, 4274, 10920, 663, 284, 2068, 271, 262, 471, 2068, 198, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 2028, 374, 264, 15919, 734, 430, 11705, 279, 6826, 198, 262, 21275, 304, 459, 11847, 422, 433, 374, 539, 1070, 2736, 382, 262, 1442, 433, 374, 2736, 1070, 11, 584, 471, 279, 6484, 832, 382, 14711, 6075, 512, 755, 1893, 90635, 3377, 17409, 997, 262, 4304, 2028, 374, 264, 15919, 734, 430, 11705, 279, 6826, 198, 262, 21275, 304, 459, 11847, 422, 433, 374, 539, 1070, 2736, 382, 262, 1442, 433, 374, 2736, 1070, 11, 584, 471, 279, 6484, 832, 627, 262, 12713, 262, 1456, 512, 286, 2068, 284, 6233, 681, 48280, 4419, 4274, 10920, 4532, 262, 3734, 39194, 512, 286, 1179, 328, 15577, 13578, 82, 198, 286, 2068, 284, 328, 15577, 16015, 16015, 15665, 284, 328, 15577, 13578, 82, 23350, 2573, 345, 2623, 48363, 284, 8412, 9295, 38, 2783, 60937, 756, 2623, 9436, 284, 8412, 9295, 25434, 15133, 756, 2623, 21166, 284, 8412, 9295, 16929, 54833, 756, 2623, 2338, 38251, 284, 8412, 21257, 12830, 54833, 756, 2623, 2338, 29632, 284, 364, 1211, 756, 2623, 2218, 13473, 4992, 284, 6826, 32102, 340, 286, 6233, 681, 48280, 4419, 4274, 10920, 663, 284, 2068, 271, 262, 471, 2068, 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 ]
lingthio/Flask-User
flask_user/user_manager__views.py
UserManager__Views.invite_user_view
def invite_user_view(self): """ Allows users to send invitations to register an account """ invite_user_form = self.InviteUserFormClass(request.form) if request.method == 'POST' and invite_user_form.validate(): # Find User and UserEmail by email email = invite_user_form.email.data user, user_email = self.db_manager.get_user_and_user_email_by_email(email) if user: flash("User with that email has already registered", "error") return redirect(url_for('user.invite_user')) # Add UserInvitation user_invitation = self.db_manager.add_user_invitation( email=email, invited_by_user_id=current_user.id) self.db_manager.commit() try: # Send invite_user email self.email_manager.send_invite_user_email(current_user, user_invitation) except Exception as e: # delete new UserInvitation object if send fails self.db_manager.delete_object(user_invitation) self.db_manager.commit() raise # Send sent_invitation signal signals \ .user_sent_invitation \ .send(current_app._get_current_object(), user_invitation=user_invitation, form=invite_user_form) # Flash a system message flash(_('Invitation has been sent.'), 'success') # Redirect safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_INVITE_ENDPOINT) return redirect(safe_next_url) self.prepare_domain_translations() return render_template(self.USER_INVITE_USER_TEMPLATE, form=invite_user_form)
python
def invite_user_view(self): """ Allows users to send invitations to register an account """ invite_user_form = self.InviteUserFormClass(request.form) if request.method == 'POST' and invite_user_form.validate(): # Find User and UserEmail by email email = invite_user_form.email.data user, user_email = self.db_manager.get_user_and_user_email_by_email(email) if user: flash("User with that email has already registered", "error") return redirect(url_for('user.invite_user')) # Add UserInvitation user_invitation = self.db_manager.add_user_invitation( email=email, invited_by_user_id=current_user.id) self.db_manager.commit() try: # Send invite_user email self.email_manager.send_invite_user_email(current_user, user_invitation) except Exception as e: # delete new UserInvitation object if send fails self.db_manager.delete_object(user_invitation) self.db_manager.commit() raise # Send sent_invitation signal signals \ .user_sent_invitation \ .send(current_app._get_current_object(), user_invitation=user_invitation, form=invite_user_form) # Flash a system message flash(_('Invitation has been sent.'), 'success') # Redirect safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_INVITE_ENDPOINT) return redirect(safe_next_url) self.prepare_domain_translations() return render_template(self.USER_INVITE_USER_TEMPLATE, form=invite_user_form)
[ "def", "invite_user_view", "(", "self", ")", ":", "invite_user_form", "=", "self", ".", "InviteUserFormClass", "(", "request", ".", "form", ")", "if", "request", ".", "method", "==", "'POST'", "and", "invite_user_form", ".", "validate", "(", ")", ":", "# Find User and UserEmail by email", "email", "=", "invite_user_form", ".", "email", ".", "data", "user", ",", "user_email", "=", "self", ".", "db_manager", ".", "get_user_and_user_email_by_email", "(", "email", ")", "if", "user", ":", "flash", "(", "\"User with that email has already registered\"", ",", "\"error\"", ")", "return", "redirect", "(", "url_for", "(", "'user.invite_user'", ")", ")", "# Add UserInvitation", "user_invitation", "=", "self", ".", "db_manager", ".", "add_user_invitation", "(", "email", "=", "email", ",", "invited_by_user_id", "=", "current_user", ".", "id", ")", "self", ".", "db_manager", ".", "commit", "(", ")", "try", ":", "# Send invite_user email", "self", ".", "email_manager", ".", "send_invite_user_email", "(", "current_user", ",", "user_invitation", ")", "except", "Exception", "as", "e", ":", "# delete new UserInvitation object if send fails", "self", ".", "db_manager", ".", "delete_object", "(", "user_invitation", ")", "self", ".", "db_manager", ".", "commit", "(", ")", "raise", "# Send sent_invitation signal", "signals", ".", "user_sent_invitation", ".", "send", "(", "current_app", ".", "_get_current_object", "(", ")", ",", "user_invitation", "=", "user_invitation", ",", "form", "=", "invite_user_form", ")", "# Flash a system message", "flash", "(", "_", "(", "'Invitation has been sent.'", ")", ",", "'success'", ")", "# Redirect", "safe_next_url", "=", "self", ".", "_get_safe_next_url", "(", "'next'", ",", "self", ".", "USER_AFTER_INVITE_ENDPOINT", ")", "return", "redirect", "(", "safe_next_url", ")", "self", ".", "prepare_domain_translations", "(", ")", "return", "render_template", "(", "self", ".", "USER_INVITE_USER_TEMPLATE", ",", "form", "=", "invite_user_form", ")" ]
Allows users to send invitations to register an account
[ "Allows", "users", "to", "send", "invitations", "to", "register", "an", "account" ]
train
https://github.com/lingthio/Flask-User/blob/a379fa0a281789618c484b459cb41236779b95b1/flask_user/user_manager__views.py#L313-L355
<|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: Allows users to send invitations to register an account ### Response: def invite_user_view(self): """ Allows users to send invitations to register an account """ invite_user_form = self.InviteUserFormClass(request.form) if request.method == 'POST' and invite_user_form.validate(): # Find User and UserEmail by email email = invite_user_form.email.data user, user_email = self.db_manager.get_user_and_user_email_by_email(email) if user: flash("User with that email has already registered", "error") return redirect(url_for('user.invite_user')) # Add UserInvitation user_invitation = self.db_manager.add_user_invitation( email=email, invited_by_user_id=current_user.id) self.db_manager.commit() try: # Send invite_user email self.email_manager.send_invite_user_email(current_user, user_invitation) except Exception as e: # delete new UserInvitation object if send fails self.db_manager.delete_object(user_invitation) self.db_manager.commit() raise # Send sent_invitation signal signals \ .user_sent_invitation \ .send(current_app._get_current_object(), user_invitation=user_invitation, form=invite_user_form) # Flash a system message flash(_('Invitation has been sent.'), 'success') # Redirect safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_INVITE_ENDPOINT) return redirect(safe_next_url) self.prepare_domain_translations() return render_template(self.USER_INVITE_USER_TEMPLATE, form=invite_user_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, 80695, 3932, 311, 3708, 59769, 311, 4254, 459, 2759, 271, 14711, 6075, 512, 755, 22114, 3398, 7268, 1214, 997, 286, 4304, 46871, 3932, 311, 3708, 59769, 311, 4254, 459, 2759, 12713, 286, 22114, 3398, 8074, 284, 659, 69501, 635, 1502, 1876, 1999, 4980, 8726, 696, 286, 422, 1715, 13204, 624, 364, 3019, 6, 323, 22114, 3398, 8074, 20090, 4019, 310, 674, 7531, 2724, 323, 2724, 4886, 555, 2613, 198, 310, 2613, 284, 22114, 3398, 8074, 10048, 2245, 198, 310, 1217, 11, 1217, 9351, 284, 659, 7221, 12418, 673, 3398, 8543, 3398, 9351, 3795, 9351, 18411, 340, 310, 422, 1217, 512, 394, 8381, 446, 1502, 449, 430, 2613, 706, 2736, 9879, 498, 330, 850, 1158, 394, 471, 6559, 6659, 5595, 493, 882, 44320, 635, 3398, 25863, 310, 674, 2758, 2724, 15527, 7709, 198, 310, 1217, 20593, 7709, 284, 659, 7221, 12418, 1388, 3398, 20593, 7709, 1021, 394, 2613, 77471, 345, 394, 18719, 3795, 3398, 851, 73023, 3398, 1801, 340, 310, 659, 7221, 12418, 16105, 2892, 310, 1456, 512, 394, 674, 11244, 22114, 3398, 2613, 198, 394, 659, 10048, 12418, 5331, 96010, 3398, 9351, 8937, 3398, 11, 1217, 20593, 7709, 340, 310, 3734, 4204, 439, 384, 512, 394, 674, 3783, 502, 2724, 15527, 7709, 1665, 422, 3708, 14865, 198, 394, 659, 7221, 12418, 7592, 5427, 4374, 20593, 7709, 340, 394, 659, 7221, 12418, 16105, 746, 394, 4933, 271, 310, 674, 11244, 3288, 20593, 7709, 8450, 198, 310, 17738, 3120, 394, 662, 882, 25084, 20593, 7709, 3120, 394, 662, 6820, 8937, 8354, 1462, 456, 11327, 5427, 1535, 1217, 20593, 7709, 31264, 20593, 7709, 345, 2611, 1376, 28, 57379, 3398, 8074, 696, 310, 674, 17710, 264, 1887, 1984, 198, 310, 8381, 72267, 15527, 7709, 706, 1027, 3288, 3238, 705, 364, 5748, 4713, 310, 674, 16413, 198, 310, 6220, 11507, 2975, 284, 659, 1462, 456, 35167, 11507, 2975, 493, 3684, 518, 659, 38271, 73439, 41207, 6119, 49856, 340, 310, 471, 6559, 1161, 5763, 11507, 2975, 696, 286, 659, 22699, 20715, 8124, 30756, 746, 286, 471, 3219, 8864, 1214, 38271, 41207, 6119, 9285, 35886, 11, 1376, 28, 57379, 3398, 8074, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 80695, 3932, 311, 3708, 59769, 311, 4254, 459, 2759, 271, 14711, 6075, 512, 755, 22114, 3398, 7268, 1214, 997, 286, 4304, 46871, 3932, 311, 3708, 59769, 311, 4254, 459, 2759, 12713, 286, 22114, 3398, 8074, 284, 659, 69501, 635, 1502, 1876, 1999, 4980, 8726, 696, 286, 422, 1715, 13204, 624, 364, 3019, 6, 323, 22114, 3398, 8074, 20090, 4019, 310, 674, 7531, 2724, 323, 2724, 4886, 555, 2613, 198, 310, 2613, 284, 22114, 3398, 8074, 10048, 2245, 198, 310, 1217, 11, 1217, 9351, 284, 659, 7221, 12418, 673, 3398, 8543, 3398, 9351, 3795, 9351, 18411, 340, 310, 422, 1217, 512, 394, 8381, 446, 1502, 449, 430, 2613, 706, 2736, 9879, 498, 330, 850, 1158, 394, 471, 6559, 6659, 5595, 493, 882, 44320, 635, 3398, 25863, 310, 674, 2758, 2724, 15527, 7709, 198, 310, 1217, 20593, 7709, 284, 659, 7221, 12418, 1388, 3398, 20593, 7709, 1021, 394, 2613, 77471, 345, 394, 18719, 3795, 3398, 851, 73023, 3398, 1801, 340, 310, 659, 7221, 12418, 16105, 2892, 310, 1456, 512, 394, 674, 11244, 22114, 3398, 2613, 198, 394, 659, 10048, 12418, 5331, 96010, 3398, 9351, 8937, 3398, 11, 1217, 20593, 7709, 340, 310, 3734, 4204, 439, 384, 512, 394, 674, 3783, 502, 2724, 15527, 7709, 1665, 422, 3708, 14865, 198, 394, 659, 7221, 12418, 7592, 5427, 4374, 20593, 7709, 340, 394, 659, 7221, 12418, 16105, 746, 394, 4933, 271, 310, 674, 11244, 3288, 20593, 7709, 8450, 198, 310, 17738, 3120, 394, 662, 882, 25084, 20593, 7709, 3120, 394, 662, 6820, 8937, 8354, 1462, 456, 11327, 5427, 1535, 1217, 20593, 7709, 31264, 20593, 7709, 345, 2611, 1376, 28, 57379, 3398, 8074, 696, 310, 674, 17710, 264, 1887, 1984, 198, 310, 8381, 72267, 15527, 7709, 706, 1027, 3288, 3238, 705, 364, 5748, 4713, 310, 674, 16413, 198, 310, 6220, 11507, 2975, 284, 659, 1462, 456, 35167, 11507, 2975, 493, 3684, 518, 659, 38271, 73439, 41207, 6119, 49856, 340, 310, 471, 6559, 1161, 5763, 11507, 2975, 696, 286, 659, 22699, 20715, 8124, 30756, 746, 286, 471, 3219, 8864, 1214, 38271, 41207, 6119, 9285, 35886, 11, 1376, 28, 57379, 3398, 8074, 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 ]
wakatime/wakatime
wakatime/packages/pygments/formatters/__init__.py
load_formatter_from_file
def load_formatter_from_file(filename, formattername="CustomFormatter", **options): """Load a formatter from a file. This method expects a file located relative to the current working directory, which contains a class named CustomFormatter. By default, it expects the Formatter to be named CustomFormatter; you can specify your own class name as the second argument to this function. Users should be very careful with the input, because this method is equivalent to running eval on the input file. Raises ClassNotFound if there are any problems importing the Formatter. .. versionadded:: 2.2 """ try: # This empty dict will contain the namespace for the exec'd file custom_namespace = {} exec(open(filename, 'rb').read(), custom_namespace) # Retrieve the class `formattername` from that namespace if formattername not in custom_namespace: raise ClassNotFound('no valid %s class found in %s' % (formattername, filename)) formatter_class = custom_namespace[formattername] # And finally instantiate it with the options return formatter_class(**options) except IOError as err: raise ClassNotFound('cannot read %s' % filename) except ClassNotFound as err: raise except Exception as err: raise ClassNotFound('error when loading custom formatter: %s' % err)
python
def load_formatter_from_file(filename, formattername="CustomFormatter", **options): """Load a formatter from a file. This method expects a file located relative to the current working directory, which contains a class named CustomFormatter. By default, it expects the Formatter to be named CustomFormatter; you can specify your own class name as the second argument to this function. Users should be very careful with the input, because this method is equivalent to running eval on the input file. Raises ClassNotFound if there are any problems importing the Formatter. .. versionadded:: 2.2 """ try: # This empty dict will contain the namespace for the exec'd file custom_namespace = {} exec(open(filename, 'rb').read(), custom_namespace) # Retrieve the class `formattername` from that namespace if formattername not in custom_namespace: raise ClassNotFound('no valid %s class found in %s' % (formattername, filename)) formatter_class = custom_namespace[formattername] # And finally instantiate it with the options return formatter_class(**options) except IOError as err: raise ClassNotFound('cannot read %s' % filename) except ClassNotFound as err: raise except Exception as err: raise ClassNotFound('error when loading custom formatter: %s' % err)
[ "def", "load_formatter_from_file", "(", "filename", ",", "formattername", "=", "\"CustomFormatter\"", ",", "*", "*", "options", ")", ":", "try", ":", "# This empty dict will contain the namespace for the exec'd file", "custom_namespace", "=", "{", "}", "exec", "(", "open", "(", "filename", ",", "'rb'", ")", ".", "read", "(", ")", ",", "custom_namespace", ")", "# Retrieve the class `formattername` from that namespace", "if", "formattername", "not", "in", "custom_namespace", ":", "raise", "ClassNotFound", "(", "'no valid %s class found in %s'", "%", "(", "formattername", ",", "filename", ")", ")", "formatter_class", "=", "custom_namespace", "[", "formattername", "]", "# And finally instantiate it with the options", "return", "formatter_class", "(", "*", "*", "options", ")", "except", "IOError", "as", "err", ":", "raise", "ClassNotFound", "(", "'cannot read %s'", "%", "filename", ")", "except", "ClassNotFound", "as", "err", ":", "raise", "except", "Exception", "as", "err", ":", "raise", "ClassNotFound", "(", "'error when loading custom formatter: %s'", "%", "err", ")" ]
Load a formatter from a file. This method expects a file located relative to the current working directory, which contains a class named CustomFormatter. By default, it expects the Formatter to be named CustomFormatter; you can specify your own class name as the second argument to this function. Users should be very careful with the input, because this method is equivalent to running eval on the input file. Raises ClassNotFound if there are any problems importing the Formatter. .. versionadded:: 2.2
[ "Load", "a", "formatter", "from", "a", "file", "." ]
train
https://github.com/wakatime/wakatime/blob/74519ace04e8472f3a3993269963732b9946a01d/wakatime/packages/pygments/formatters/__init__.py#L82-L114
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Load a formatter from a file. This method expects a file located relative to the current working directory, which contains a class named CustomFormatter. By default, it expects the Formatter to be named CustomFormatter; you can specify your own class name as the second argument to this function. Users should be very careful with the input, because this method is equivalent to running eval on the input file. Raises ClassNotFound if there are any problems importing the Formatter. .. versionadded:: 2.2 ### Response: def load_formatter_from_file(filename, formattername="CustomFormatter", **options): """Load a formatter from a file. This method expects a file located relative to the current working directory, which contains a class named CustomFormatter. By default, it expects the Formatter to be named CustomFormatter; you can specify your own class name as the second argument to this function. Users should be very careful with the input, because this method is equivalent to running eval on the input file. Raises ClassNotFound if there are any problems importing the Formatter. .. versionadded:: 2.2 """ try: # This empty dict will contain the namespace for the exec'd file custom_namespace = {} exec(open(filename, 'rb').read(), custom_namespace) # Retrieve the class `formattername` from that namespace if formattername not in custom_namespace: raise ClassNotFound('no valid %s class found in %s' % (formattername, filename)) formatter_class = custom_namespace[formattername] # And finally instantiate it with the options return formatter_class(**options) except IOError as err: raise ClassNotFound('cannot read %s' % filename) except ClassNotFound as err: raise except Exception as err: raise ClassNotFound('error when loading custom formatter: %s' % 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, 6003, 264, 25851, 505, 264, 1052, 382, 262, 1115, 1749, 25283, 264, 1052, 7559, 8844, 311, 279, 1510, 3318, 198, 262, 6352, 11, 902, 5727, 264, 538, 7086, 8572, 14517, 13, 3296, 1670, 345, 262, 433, 25283, 279, 82487, 311, 387, 7086, 8572, 14517, 26, 499, 649, 14158, 198, 262, 701, 1866, 538, 836, 439, 279, 2132, 5811, 311, 420, 734, 382, 262, 14969, 1288, 387, 1633, 16994, 449, 279, 1988, 11, 1606, 420, 1749, 198, 262, 374, 13890, 311, 4401, 5720, 389, 279, 1988, 1052, 382, 262, 61411, 3308, 10588, 422, 1070, 527, 904, 5435, 50995, 279, 82487, 382, 262, 5354, 2373, 17249, 487, 220, 17, 13, 17, 271, 14711, 6075, 512, 755, 2865, 75065, 5791, 2517, 11202, 11, 25851, 609, 429, 10480, 14517, 761, 6663, 3146, 2945, 997, 262, 4304, 6003, 264, 25851, 505, 264, 1052, 382, 262, 1115, 1749, 25283, 264, 1052, 7559, 8844, 311, 279, 1510, 3318, 198, 262, 6352, 11, 902, 5727, 264, 538, 7086, 8572, 14517, 13, 3296, 1670, 345, 262, 433, 25283, 279, 82487, 311, 387, 7086, 8572, 14517, 26, 499, 649, 14158, 198, 262, 701, 1866, 538, 836, 439, 279, 2132, 5811, 311, 420, 734, 382, 262, 14969, 1288, 387, 1633, 16994, 449, 279, 1988, 11, 1606, 420, 1749, 198, 262, 374, 13890, 311, 4401, 5720, 389, 279, 1988, 1052, 382, 262, 61411, 3308, 10588, 422, 1070, 527, 904, 5435, 50995, 279, 82487, 382, 262, 5354, 2373, 17249, 487, 220, 17, 13, 17, 198, 262, 3270, 262, 1456, 512, 286, 674, 1115, 4384, 6587, 690, 6782, 279, 4573, 369, 279, 3969, 4265, 1052, 198, 286, 2587, 42671, 284, 5731, 286, 3969, 32081, 11202, 11, 364, 10910, 1861, 888, 1535, 2587, 42671, 340, 286, 674, 32662, 279, 538, 1595, 34041, 609, 63, 505, 430, 4573, 198, 286, 422, 25851, 609, 539, 304, 2587, 42671, 512, 310, 4933, 3308, 10588, 493, 2201, 2764, 1034, 82, 538, 1766, 304, 1034, 82, 6, 33648, 1408, 320, 34041, 609, 11, 3986, 1192, 286, 25851, 4895, 284, 2587, 42671, 58, 34041, 609, 933, 286, 674, 1628, 5616, 42002, 433, 449, 279, 2671, 198, 286, 471, 25851, 4895, 22551, 2945, 340, 262, 3734, 62061, 439, 1886, 512, 286, 4933, 3308, 10588, 493, 34360, 1373, 1034, 82, 6, 1034, 3986, 340, 262, 3734, 3308, 10588, 439, 1886, 512, 286, 4933, 198, 262, 3734, 4204, 439, 1886, 512, 286, 4933, 3308, 10588, 493, 850, 994, 8441, 2587, 25851, 25, 1034, 82, 6, 1034, 1886, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 6003, 264, 25851, 505, 264, 1052, 382, 262, 1115, 1749, 25283, 264, 1052, 7559, 8844, 311, 279, 1510, 3318, 198, 262, 6352, 11, 902, 5727, 264, 538, 7086, 8572, 14517, 13, 3296, 1670, 345, 262, 433, 25283, 279, 82487, 311, 387, 7086, 8572, 14517, 26, 499, 649, 14158, 198, 262, 701, 1866, 538, 836, 439, 279, 2132, 5811, 311, 420, 734, 382, 262, 14969, 1288, 387, 1633, 16994, 449, 279, 1988, 11, 1606, 420, 1749, 198, 262, 374, 13890, 311, 4401, 5720, 389, 279, 1988, 1052, 382, 262, 61411, 3308, 10588, 422, 1070, 527, 904, 5435, 50995, 279, 82487, 382, 262, 5354, 2373, 17249, 487, 220, 17, 13, 17, 271, 14711, 6075, 512, 755, 2865, 75065, 5791, 2517, 11202, 11, 25851, 609, 429, 10480, 14517, 761, 6663, 3146, 2945, 997, 262, 4304, 6003, 264, 25851, 505, 264, 1052, 382, 262, 1115, 1749, 25283, 264, 1052, 7559, 8844, 311, 279, 1510, 3318, 198, 262, 6352, 11, 902, 5727, 264, 538, 7086, 8572, 14517, 13, 3296, 1670, 345, 262, 433, 25283, 279, 82487, 311, 387, 7086, 8572, 14517, 26, 499, 649, 14158, 198, 262, 701, 1866, 538, 836, 439, 279, 2132, 5811, 311, 420, 734, 382, 262, 14969, 1288, 387, 1633, 16994, 449, 279, 1988, 11, 1606, 420, 1749, 198, 262, 374, 13890, 311, 4401, 5720, 389, 279, 1988, 1052, 382, 262, 61411, 3308, 10588, 422, 1070, 527, 904, 5435, 50995, 279, 82487, 382, 262, 5354, 2373, 17249, 487, 220, 17, 13, 17, 198, 262, 3270, 262, 1456, 512, 286, 674, 1115, 4384, 6587, 690, 6782, 279, 4573, 369, 279, 3969, 4265, 1052, 198, 286, 2587, 42671, 284, 5731, 286, 3969, 32081, 11202, 11, 364, 10910, 1861, 888, 1535, 2587, 42671, 340, 286, 674, 32662, 279, 538, 1595, 34041, 609, 63, 505, 430, 4573, 198, 286, 422, 25851, 609, 539, 304, 2587, 42671, 512, 310, 4933, 3308, 10588, 493, 2201, 2764, 1034, 82, 538, 1766, 304, 1034, 82, 6, 33648, 1408, 320, 34041, 609, 11, 3986, 1192, 286, 25851, 4895, 284, 2587, 42671, 58, 34041, 609, 933, 286, 674, 1628, 5616, 42002, 433, 449, 279, 2671, 198, 286, 471, 25851, 4895, 22551, 2945, 340, 262, 3734, 62061, 439, 1886, 512, 286, 4933, 3308, 10588, 493, 34360, 1373, 1034, 82, 6, 1034, 3986, 340, 262, 3734, 3308, 10588, 439, 1886, 512, 286, 4933, 198, 262, 3734, 4204, 439, 1886, 512, 286, 4933, 3308, 10588, 493, 850, 994, 8441, 2587, 25851, 25, 1034, 82, 6, 1034, 1886, 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 ]
markfinger/assembla
assembla/lib.py
assembla_filter
def assembla_filter(func): """ Filters :data for the objects in it which possess attributes equal in name/value to a key/value in kwargs. Each key/value combination in kwargs is compared against the object, so multiple keyword arguments can be passed in to constrain the filtering. """ @wraps(func) def wrapper(class_instance, **kwargs): # Get the result extra_params = kwargs.get('extra_params', None) if extra_params: del kwargs['extra_params'] results = func(class_instance, extra_params) # Filter the result if kwargs: results = filter( # Find the objects who have an equal number of matching attr/value # combinations as `len(kwargs)` lambda obj: len(kwargs) == len( filter( lambda boolean: boolean, [obj.get(attr_name) == value for attr_name, value in kwargs.iteritems()] ) ), results ) return results return wrapper
python
def assembla_filter(func): """ Filters :data for the objects in it which possess attributes equal in name/value to a key/value in kwargs. Each key/value combination in kwargs is compared against the object, so multiple keyword arguments can be passed in to constrain the filtering. """ @wraps(func) def wrapper(class_instance, **kwargs): # Get the result extra_params = kwargs.get('extra_params', None) if extra_params: del kwargs['extra_params'] results = func(class_instance, extra_params) # Filter the result if kwargs: results = filter( # Find the objects who have an equal number of matching attr/value # combinations as `len(kwargs)` lambda obj: len(kwargs) == len( filter( lambda boolean: boolean, [obj.get(attr_name) == value for attr_name, value in kwargs.iteritems()] ) ), results ) return results return wrapper
[ "def", "assembla_filter", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "class_instance", ",", "*", "*", "kwargs", ")", ":", "# Get the result", "extra_params", "=", "kwargs", ".", "get", "(", "'extra_params'", ",", "None", ")", "if", "extra_params", ":", "del", "kwargs", "[", "'extra_params'", "]", "results", "=", "func", "(", "class_instance", ",", "extra_params", ")", "# Filter the result", "if", "kwargs", ":", "results", "=", "filter", "(", "# Find the objects who have an equal number of matching attr/value", "# combinations as `len(kwargs)`", "lambda", "obj", ":", "len", "(", "kwargs", ")", "==", "len", "(", "filter", "(", "lambda", "boolean", ":", "boolean", ",", "[", "obj", ".", "get", "(", "attr_name", ")", "==", "value", "for", "attr_name", ",", "value", "in", "kwargs", ".", "iteritems", "(", ")", "]", ")", ")", ",", "results", ")", "return", "results", "return", "wrapper" ]
Filters :data for the objects in it which possess attributes equal in name/value to a key/value in kwargs. Each key/value combination in kwargs is compared against the object, so multiple keyword arguments can be passed in to constrain the filtering.
[ "Filters", ":", "data", "for", "the", "objects", "in", "it", "which", "possess", "attributes", "equal", "in", "name", "/", "value", "to", "a", "key", "/", "value", "in", "kwargs", "." ]
train
https://github.com/markfinger/assembla/blob/967a77a5ba718df94f60e832b6e0cf14c72426aa/assembla/lib.py#L43-L76
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Filters :data for the objects in it which possess attributes equal in name/value to a key/value in kwargs. Each key/value combination in kwargs is compared against the object, so multiple keyword arguments can be passed in to constrain the filtering. ### Response: def assembla_filter(func): """ Filters :data for the objects in it which possess attributes equal in name/value to a key/value in kwargs. Each key/value combination in kwargs is compared against the object, so multiple keyword arguments can be passed in to constrain the filtering. """ @wraps(func) def wrapper(class_instance, **kwargs): # Get the result extra_params = kwargs.get('extra_params', None) if extra_params: del kwargs['extra_params'] results = func(class_instance, extra_params) # Filter the result if kwargs: results = filter( # Find the objects who have an equal number of matching attr/value # combinations as `len(kwargs)` lambda obj: len(kwargs) == len( filter( lambda boolean: boolean, [obj.get(attr_name) == value for attr_name, value in kwargs.iteritems()] ) ), results ) return results return wrapper <|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, 29451, 551, 695, 369, 279, 6302, 304, 433, 902, 15575, 8365, 6273, 304, 198, 262, 836, 58642, 311, 264, 1401, 58642, 304, 16901, 382, 262, 9062, 1401, 58642, 10824, 304, 16901, 374, 7863, 2403, 279, 1665, 11, 779, 198, 262, 5361, 16570, 6105, 649, 387, 5946, 304, 311, 80799, 279, 30770, 382, 14711, 6075, 512, 755, 439, 28111, 64, 8901, 19062, 997, 262, 3270, 262, 46112, 551, 695, 369, 279, 6302, 304, 433, 902, 15575, 8365, 6273, 304, 198, 262, 836, 58642, 311, 264, 1401, 58642, 304, 16901, 382, 262, 9062, 1401, 58642, 10824, 304, 16901, 374, 7863, 2403, 279, 1665, 11, 779, 198, 262, 5361, 16570, 6105, 649, 387, 5946, 304, 311, 80799, 279, 30770, 627, 262, 3270, 262, 571, 19239, 2690, 19062, 340, 262, 711, 13564, 22723, 12169, 11, 3146, 9872, 7887, 286, 674, 2175, 279, 1121, 198, 286, 5066, 6887, 284, 16901, 673, 493, 15824, 6887, 518, 2290, 340, 286, 422, 5066, 6887, 512, 310, 1624, 16901, 681, 15824, 6887, 4532, 286, 3135, 284, 2988, 22723, 12169, 11, 5066, 6887, 696, 286, 674, 12619, 279, 1121, 198, 286, 422, 16901, 512, 310, 3135, 284, 4141, 1021, 394, 674, 7531, 279, 6302, 889, 617, 459, 6273, 1396, 315, 12864, 6510, 58642, 198, 394, 674, 28559, 439, 1595, 2963, 71706, 50337, 394, 12741, 2909, 25, 2479, 71706, 8, 624, 2479, 1021, 504, 4141, 1021, 667, 12741, 2777, 25, 2777, 345, 667, 510, 2347, 673, 33531, 1292, 8, 624, 907, 198, 1014, 369, 6510, 1292, 11, 907, 304, 16901, 58542, 28866, 504, 1763, 394, 2907, 394, 3135, 198, 310, 5235, 286, 471, 3135, 198, 262, 471, 13564, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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, 29451, 551, 695, 369, 279, 6302, 304, 433, 902, 15575, 8365, 6273, 304, 198, 262, 836, 58642, 311, 264, 1401, 58642, 304, 16901, 382, 262, 9062, 1401, 58642, 10824, 304, 16901, 374, 7863, 2403, 279, 1665, 11, 779, 198, 262, 5361, 16570, 6105, 649, 387, 5946, 304, 311, 80799, 279, 30770, 382, 14711, 6075, 512, 755, 439, 28111, 64, 8901, 19062, 997, 262, 3270, 262, 46112, 551, 695, 369, 279, 6302, 304, 433, 902, 15575, 8365, 6273, 304, 198, 262, 836, 58642, 311, 264, 1401, 58642, 304, 16901, 382, 262, 9062, 1401, 58642, 10824, 304, 16901, 374, 7863, 2403, 279, 1665, 11, 779, 198, 262, 5361, 16570, 6105, 649, 387, 5946, 304, 311, 80799, 279, 30770, 627, 262, 3270, 262, 571, 19239, 2690, 19062, 340, 262, 711, 13564, 22723, 12169, 11, 3146, 9872, 7887, 286, 674, 2175, 279, 1121, 198, 286, 5066, 6887, 284, 16901, 673, 493, 15824, 6887, 518, 2290, 340, 286, 422, 5066, 6887, 512, 310, 1624, 16901, 681, 15824, 6887, 4532, 286, 3135, 284, 2988, 22723, 12169, 11, 5066, 6887, 696, 286, 674, 12619, 279, 1121, 198, 286, 422, 16901, 512, 310, 3135, 284, 4141, 1021, 394, 674, 7531, 279, 6302, 889, 617, 459, 6273, 1396, 315, 12864, 6510, 58642, 198, 394, 674, 28559, 439, 1595, 2963, 71706, 50337, 394, 12741, 2909, 25, 2479, 71706, 8, 624, 2479, 1021, 504, 4141, 1021, 667, 12741, 2777, 25, 2777, 345, 667, 510, 2347, 673, 33531, 1292, 8, 624, 907, 198, 1014, 369, 6510, 1292, 11, 907, 304, 16901, 58542, 28866, 504, 1763, 394, 2907, 394, 3135, 198, 310, 5235, 286, 471, 3135, 198, 262, 471, 13564, 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 ]
bcbio/bcbio-nextgen
bcbio/variation/genotype.py
batch_for_variantcall
def batch_for_variantcall(samples): """Prepare a set of samples for parallel variant calling. CWL input target that groups samples into batches and variant callers for parallel processing. If doing joint calling, with `tools_on: [gvcf]`, split the sample into individuals instead of combining into a batch. """ sample_order = [dd.get_sample_name(utils.to_single_data(x)) for x in samples] to_process, extras = _dup_samples_by_variantcaller(samples, require_bam=False) batch_groups = collections.defaultdict(list) to_process = [utils.to_single_data(x) for x in to_process] for data in cwlutils.samples_to_records(to_process): vc = get_variantcaller(data, require_bam=False) batches = dd.get_batches(data) or dd.get_sample_name(data) if not isinstance(batches, (list, tuple)): batches = [batches] for b in batches: batch_groups[(b, vc)].append(utils.deepish_copy(data)) batches = [] for cur_group in batch_groups.values(): joint_calling = any([is_joint(d) for d in cur_group]) if joint_calling: for d in cur_group: batches.append([d]) else: batches.append(cur_group) def by_original_order(xs): return (min([sample_order.index(dd.get_sample_name(x)) for x in xs]), min([dd.get_variantcaller_order(x) for x in xs])) return sorted(batches + extras, key=by_original_order)
python
def batch_for_variantcall(samples): """Prepare a set of samples for parallel variant calling. CWL input target that groups samples into batches and variant callers for parallel processing. If doing joint calling, with `tools_on: [gvcf]`, split the sample into individuals instead of combining into a batch. """ sample_order = [dd.get_sample_name(utils.to_single_data(x)) for x in samples] to_process, extras = _dup_samples_by_variantcaller(samples, require_bam=False) batch_groups = collections.defaultdict(list) to_process = [utils.to_single_data(x) for x in to_process] for data in cwlutils.samples_to_records(to_process): vc = get_variantcaller(data, require_bam=False) batches = dd.get_batches(data) or dd.get_sample_name(data) if not isinstance(batches, (list, tuple)): batches = [batches] for b in batches: batch_groups[(b, vc)].append(utils.deepish_copy(data)) batches = [] for cur_group in batch_groups.values(): joint_calling = any([is_joint(d) for d in cur_group]) if joint_calling: for d in cur_group: batches.append([d]) else: batches.append(cur_group) def by_original_order(xs): return (min([sample_order.index(dd.get_sample_name(x)) for x in xs]), min([dd.get_variantcaller_order(x) for x in xs])) return sorted(batches + extras, key=by_original_order)
[ "def", "batch_for_variantcall", "(", "samples", ")", ":", "sample_order", "=", "[", "dd", ".", "get_sample_name", "(", "utils", ".", "to_single_data", "(", "x", ")", ")", "for", "x", "in", "samples", "]", "to_process", ",", "extras", "=", "_dup_samples_by_variantcaller", "(", "samples", ",", "require_bam", "=", "False", ")", "batch_groups", "=", "collections", ".", "defaultdict", "(", "list", ")", "to_process", "=", "[", "utils", ".", "to_single_data", "(", "x", ")", "for", "x", "in", "to_process", "]", "for", "data", "in", "cwlutils", ".", "samples_to_records", "(", "to_process", ")", ":", "vc", "=", "get_variantcaller", "(", "data", ",", "require_bam", "=", "False", ")", "batches", "=", "dd", ".", "get_batches", "(", "data", ")", "or", "dd", ".", "get_sample_name", "(", "data", ")", "if", "not", "isinstance", "(", "batches", ",", "(", "list", ",", "tuple", ")", ")", ":", "batches", "=", "[", "batches", "]", "for", "b", "in", "batches", ":", "batch_groups", "[", "(", "b", ",", "vc", ")", "]", ".", "append", "(", "utils", ".", "deepish_copy", "(", "data", ")", ")", "batches", "=", "[", "]", "for", "cur_group", "in", "batch_groups", ".", "values", "(", ")", ":", "joint_calling", "=", "any", "(", "[", "is_joint", "(", "d", ")", "for", "d", "in", "cur_group", "]", ")", "if", "joint_calling", ":", "for", "d", "in", "cur_group", ":", "batches", ".", "append", "(", "[", "d", "]", ")", "else", ":", "batches", ".", "append", "(", "cur_group", ")", "def", "by_original_order", "(", "xs", ")", ":", "return", "(", "min", "(", "[", "sample_order", ".", "index", "(", "dd", ".", "get_sample_name", "(", "x", ")", ")", "for", "x", "in", "xs", "]", ")", ",", "min", "(", "[", "dd", ".", "get_variantcaller_order", "(", "x", ")", "for", "x", "in", "xs", "]", ")", ")", "return", "sorted", "(", "batches", "+", "extras", ",", "key", "=", "by_original_order", ")" ]
Prepare a set of samples for parallel variant calling. CWL input target that groups samples into batches and variant callers for parallel processing. If doing joint calling, with `tools_on: [gvcf]`, split the sample into individuals instead of combining into a batch.
[ "Prepare", "a", "set", "of", "samples", "for", "parallel", "variant", "calling", "." ]
train
https://github.com/bcbio/bcbio-nextgen/blob/6a9348c0054ccd5baffd22f1bb7d0422f6978b20/bcbio/variation/genotype.py#L241-L272
<|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: Prepare a set of samples for parallel variant calling. CWL input target that groups samples into batches and variant callers for parallel processing. If doing joint calling, with `tools_on: [gvcf]`, split the sample into individuals instead of combining into a batch. ### Response: def batch_for_variantcall(samples): """Prepare a set of samples for parallel variant calling. CWL input target that groups samples into batches and variant callers for parallel processing. If doing joint calling, with `tools_on: [gvcf]`, split the sample into individuals instead of combining into a batch. """ sample_order = [dd.get_sample_name(utils.to_single_data(x)) for x in samples] to_process, extras = _dup_samples_by_variantcaller(samples, require_bam=False) batch_groups = collections.defaultdict(list) to_process = [utils.to_single_data(x) for x in to_process] for data in cwlutils.samples_to_records(to_process): vc = get_variantcaller(data, require_bam=False) batches = dd.get_batches(data) or dd.get_sample_name(data) if not isinstance(batches, (list, tuple)): batches = [batches] for b in batches: batch_groups[(b, vc)].append(utils.deepish_copy(data)) batches = [] for cur_group in batch_groups.values(): joint_calling = any([is_joint(d) for d in cur_group]) if joint_calling: for d in cur_group: batches.append([d]) else: batches.append(cur_group) def by_original_order(xs): return (min([sample_order.index(dd.get_sample_name(x)) for x in xs]), min([dd.get_variantcaller_order(x) for x in xs])) return sorted(batches + extras, key=by_original_order) <|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, 51690, 264, 743, 315, 10688, 369, 15638, 11678, 8260, 382, 262, 41135, 43, 1988, 2218, 430, 5315, 10688, 1139, 45892, 323, 11678, 83003, 198, 262, 369, 15638, 8863, 382, 262, 1442, 3815, 10496, 8260, 11, 449, 1595, 16297, 4570, 25, 510, 70, 7513, 69, 60, 7964, 6859, 279, 6205, 1139, 198, 262, 7931, 4619, 315, 35271, 1139, 264, 7309, 382, 14711, 6075, 512, 755, 7309, 5595, 47212, 6797, 69358, 997, 262, 4304, 51690, 264, 743, 315, 10688, 369, 15638, 11678, 8260, 382, 262, 41135, 43, 1988, 2218, 430, 5315, 10688, 1139, 45892, 323, 11678, 83003, 198, 262, 369, 15638, 8863, 382, 262, 1442, 3815, 10496, 8260, 11, 449, 1595, 16297, 4570, 25, 510, 70, 7513, 69, 60, 7964, 6859, 279, 6205, 1139, 198, 262, 7931, 4619, 315, 35271, 1139, 264, 7309, 627, 262, 3270, 262, 6205, 8028, 284, 510, 634, 673, 17949, 1292, 65266, 2446, 20052, 1807, 2120, 595, 369, 865, 304, 10688, 933, 262, 311, 11557, 11, 37375, 284, 721, 22675, 18801, 3795, 47212, 57226, 69358, 11, 1397, 890, 309, 5725, 340, 262, 7309, 21833, 284, 15661, 8939, 8644, 7455, 340, 262, 311, 11557, 284, 510, 6159, 2446, 20052, 1807, 2120, 8, 369, 865, 304, 311, 11557, 933, 262, 369, 828, 304, 272, 27515, 6159, 63307, 2401, 32379, 12464, 11557, 997, 286, 25571, 284, 636, 47212, 57226, 2657, 11, 1397, 890, 309, 5725, 340, 286, 45892, 284, 20221, 673, 58855, 2657, 8, 477, 20221, 673, 17949, 1292, 2657, 340, 286, 422, 539, 11656, 1921, 9296, 11, 320, 1638, 11, 14743, 10162, 310, 45892, 284, 510, 65, 9296, 933, 286, 369, 293, 304, 45892, 512, 310, 7309, 21833, 9896, 65, 11, 25571, 27261, 5200, 65266, 22597, 819, 16486, 2657, 1192, 262, 45892, 284, 4260, 262, 369, 2917, 6422, 304, 7309, 21833, 10883, 4019, 286, 10496, 13735, 287, 284, 904, 2625, 285, 54258, 1528, 8, 369, 294, 304, 2917, 6422, 2608, 286, 422, 10496, 13735, 287, 512, 310, 369, 294, 304, 2917, 6422, 512, 394, 45892, 2102, 2625, 67, 2608, 286, 775, 512, 310, 45892, 2102, 18053, 6422, 340, 262, 711, 555, 40656, 8028, 54422, 997, 286, 471, 320, 1083, 2625, 13925, 8028, 5265, 53959, 673, 17949, 1292, 2120, 595, 369, 865, 304, 12209, 17473, 394, 1332, 2625, 634, 673, 47212, 57226, 8028, 2120, 8, 369, 865, 304, 12209, 11147, 262, 471, 10839, 1921, 9296, 489, 37375, 11, 1401, 28, 1729, 40656, 8028, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 51690, 264, 743, 315, 10688, 369, 15638, 11678, 8260, 382, 262, 41135, 43, 1988, 2218, 430, 5315, 10688, 1139, 45892, 323, 11678, 83003, 198, 262, 369, 15638, 8863, 382, 262, 1442, 3815, 10496, 8260, 11, 449, 1595, 16297, 4570, 25, 510, 70, 7513, 69, 60, 7964, 6859, 279, 6205, 1139, 198, 262, 7931, 4619, 315, 35271, 1139, 264, 7309, 382, 14711, 6075, 512, 755, 7309, 5595, 47212, 6797, 69358, 997, 262, 4304, 51690, 264, 743, 315, 10688, 369, 15638, 11678, 8260, 382, 262, 41135, 43, 1988, 2218, 430, 5315, 10688, 1139, 45892, 323, 11678, 83003, 198, 262, 369, 15638, 8863, 382, 262, 1442, 3815, 10496, 8260, 11, 449, 1595, 16297, 4570, 25, 510, 70, 7513, 69, 60, 7964, 6859, 279, 6205, 1139, 198, 262, 7931, 4619, 315, 35271, 1139, 264, 7309, 627, 262, 3270, 262, 6205, 8028, 284, 510, 634, 673, 17949, 1292, 65266, 2446, 20052, 1807, 2120, 595, 369, 865, 304, 10688, 933, 262, 311, 11557, 11, 37375, 284, 721, 22675, 18801, 3795, 47212, 57226, 69358, 11, 1397, 890, 309, 5725, 340, 262, 7309, 21833, 284, 15661, 8939, 8644, 7455, 340, 262, 311, 11557, 284, 510, 6159, 2446, 20052, 1807, 2120, 8, 369, 865, 304, 311, 11557, 933, 262, 369, 828, 304, 272, 27515, 6159, 63307, 2401, 32379, 12464, 11557, 997, 286, 25571, 284, 636, 47212, 57226, 2657, 11, 1397, 890, 309, 5725, 340, 286, 45892, 284, 20221, 673, 58855, 2657, 8, 477, 20221, 673, 17949, 1292, 2657, 340, 286, 422, 539, 11656, 1921, 9296, 11, 320, 1638, 11, 14743, 10162, 310, 45892, 284, 510, 65, 9296, 933, 286, 369, 293, 304, 45892, 512, 310, 7309, 21833, 9896, 65, 11, 25571, 27261, 5200, 65266, 22597, 819, 16486, 2657, 1192, 262, 45892, 284, 4260, 262, 369, 2917, 6422, 304, 7309, 21833, 10883, 4019, 286, 10496, 13735, 287, 284, 904, 2625, 285, 54258, 1528, 8, 369, 294, 304, 2917, 6422, 2608, 286, 422, 10496, 13735, 287, 512, 310, 369, 294, 304, 2917, 6422, 512, 394, 45892, 2102, 2625, 67, 2608, 286, 775, 512, 310, 45892, 2102, 18053, 6422, 340, 262, 711, 555, 40656, 8028, 54422, 997, 286, 471, 320, 1083, 2625, 13925, 8028, 5265, 53959, 673, 17949, 1292, 2120, 595, 369, 865, 304, 12209, 17473, 394, 1332, 2625, 634, 673, 47212, 57226, 8028, 2120, 8, 369, 865, 304, 12209, 11147, 262, 471, 10839, 1921, 9296, 489, 37375, 11, 1401, 28, 1729, 40656, 8028, 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 ]
biocore-ntnu/epic
epic/matrixes/matrixes.py
create_matrixes
def create_matrixes(chip, input, df, args): # type: (Iterable[pd.DataFrame], Iterable[pd.DataFrame], pd.DataFrame, Namespace) -> List[pd.DataFrame] "Creates matrixes which can be written to file as is (matrix) or as bedGraph." genome = args.chromosome_sizes chip = put_dfs_in_chromosome_dict(chip) input = put_dfs_in_chromosome_dict(input) all_chromosomes = natsorted(set(list(chip.keys()) + list(input.keys()))) # print("df1\n", df, file=sys.stderr) islands = enriched_bins(df, args) # print("islands1\n", islands, file=sys.stderr) logging.info("Creating matrixes from count data.") dfms = Parallel(n_jobs=args.number_cores)(delayed(_create_matrixes)( chromosome, chip, input, islands, genome[chromosome], args.window_size) for chromosome in all_chromosomes) return dfms
python
def create_matrixes(chip, input, df, args): # type: (Iterable[pd.DataFrame], Iterable[pd.DataFrame], pd.DataFrame, Namespace) -> List[pd.DataFrame] "Creates matrixes which can be written to file as is (matrix) or as bedGraph." genome = args.chromosome_sizes chip = put_dfs_in_chromosome_dict(chip) input = put_dfs_in_chromosome_dict(input) all_chromosomes = natsorted(set(list(chip.keys()) + list(input.keys()))) # print("df1\n", df, file=sys.stderr) islands = enriched_bins(df, args) # print("islands1\n", islands, file=sys.stderr) logging.info("Creating matrixes from count data.") dfms = Parallel(n_jobs=args.number_cores)(delayed(_create_matrixes)( chromosome, chip, input, islands, genome[chromosome], args.window_size) for chromosome in all_chromosomes) return dfms
[ "def", "create_matrixes", "(", "chip", ",", "input", ",", "df", ",", "args", ")", ":", "# type: (Iterable[pd.DataFrame], Iterable[pd.DataFrame], pd.DataFrame, Namespace) -> List[pd.DataFrame]", "genome", "=", "args", ".", "chromosome_sizes", "chip", "=", "put_dfs_in_chromosome_dict", "(", "chip", ")", "input", "=", "put_dfs_in_chromosome_dict", "(", "input", ")", "all_chromosomes", "=", "natsorted", "(", "set", "(", "list", "(", "chip", ".", "keys", "(", ")", ")", "+", "list", "(", "input", ".", "keys", "(", ")", ")", ")", ")", "# print(\"df1\\n\", df, file=sys.stderr)", "islands", "=", "enriched_bins", "(", "df", ",", "args", ")", "# print(\"islands1\\n\", islands, file=sys.stderr)", "logging", ".", "info", "(", "\"Creating matrixes from count data.\"", ")", "dfms", "=", "Parallel", "(", "n_jobs", "=", "args", ".", "number_cores", ")", "(", "delayed", "(", "_create_matrixes", ")", "(", "chromosome", ",", "chip", ",", "input", ",", "islands", ",", "genome", "[", "chromosome", "]", ",", "args", ".", "window_size", ")", "for", "chromosome", "in", "all_chromosomes", ")", "return", "dfms" ]
Creates matrixes which can be written to file as is (matrix) or as bedGraph.
[ "Creates", "matrixes", "which", "can", "be", "written", "to", "file", "as", "is", "(", "matrix", ")", "or", "as", "bedGraph", "." ]
train
https://github.com/biocore-ntnu/epic/blob/ed0024939ec6182a0a39d59d845ff14a4889a6ef/epic/matrixes/matrixes.py#L148-L168
<|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: Creates matrixes which can be written to file as is (matrix) or as bedGraph. ### Response: def create_matrixes(chip, input, df, args): # type: (Iterable[pd.DataFrame], Iterable[pd.DataFrame], pd.DataFrame, Namespace) -> List[pd.DataFrame] "Creates matrixes which can be written to file as is (matrix) or as bedGraph." genome = args.chromosome_sizes chip = put_dfs_in_chromosome_dict(chip) input = put_dfs_in_chromosome_dict(input) all_chromosomes = natsorted(set(list(chip.keys()) + list(input.keys()))) # print("df1\n", df, file=sys.stderr) islands = enriched_bins(df, args) # print("islands1\n", islands, file=sys.stderr) logging.info("Creating matrixes from count data.") dfms = Parallel(n_jobs=args.number_cores)(delayed(_create_matrixes)( chromosome, chip, input, islands, genome[chromosome], args.window_size) for chromosome in all_chromosomes) return dfms <|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, 55968, 6303, 288, 902, 649, 387, 5439, 311, 1052, 439, 374, 320, 18602, 8, 477, 439, 4950, 11461, 382, 14711, 6075, 512, 755, 1893, 10403, 288, 75025, 11, 1988, 11, 6907, 11, 2897, 997, 262, 674, 955, 25, 320, 51735, 11661, 67, 21756, 1145, 39116, 11661, 67, 21756, 1145, 7900, 21756, 11, 43062, 8, 1492, 1796, 11661, 67, 21756, 933, 262, 330, 55968, 6303, 288, 902, 649, 387, 5439, 311, 1052, 439, 374, 320, 18602, 8, 477, 439, 4950, 11461, 2266, 262, 33869, 284, 2897, 5442, 76218, 33259, 271, 262, 16797, 284, 2231, 821, 3933, 1265, 4231, 76218, 5356, 75025, 340, 262, 1988, 284, 2231, 821, 3933, 1265, 4231, 76218, 5356, 5498, 340, 262, 682, 4231, 442, 58375, 284, 308, 1900, 13909, 14505, 7455, 75025, 9301, 2189, 489, 1160, 5498, 9301, 10340, 696, 262, 674, 1194, 446, 3013, 16, 1734, 498, 6907, 11, 1052, 59970, 35842, 340, 262, 30100, 284, 69671, 46012, 16446, 11, 2897, 340, 262, 674, 1194, 446, 285, 8329, 16, 1734, 498, 30100, 11, 1052, 59970, 35842, 3707, 262, 8558, 5506, 446, 26021, 6303, 288, 505, 1797, 828, 13352, 262, 6907, 1026, 284, 50372, 1471, 38347, 32358, 14678, 94541, 2432, 23059, 291, 2551, 3261, 10403, 288, 71642, 286, 51815, 11, 16797, 11, 1988, 11, 30100, 11, 33869, 58, 41484, 32554, 1282, 286, 2897, 19819, 2424, 8, 369, 51815, 304, 682, 4231, 442, 58375, 696, 262, 471, 6907, 1026, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 55968, 6303, 288, 902, 649, 387, 5439, 311, 1052, 439, 374, 320, 18602, 8, 477, 439, 4950, 11461, 382, 14711, 6075, 512, 755, 1893, 10403, 288, 75025, 11, 1988, 11, 6907, 11, 2897, 997, 262, 674, 955, 25, 320, 51735, 11661, 67, 21756, 1145, 39116, 11661, 67, 21756, 1145, 7900, 21756, 11, 43062, 8, 1492, 1796, 11661, 67, 21756, 933, 262, 330, 55968, 6303, 288, 902, 649, 387, 5439, 311, 1052, 439, 374, 320, 18602, 8, 477, 439, 4950, 11461, 2266, 262, 33869, 284, 2897, 5442, 76218, 33259, 271, 262, 16797, 284, 2231, 821, 3933, 1265, 4231, 76218, 5356, 75025, 340, 262, 1988, 284, 2231, 821, 3933, 1265, 4231, 76218, 5356, 5498, 340, 262, 682, 4231, 442, 58375, 284, 308, 1900, 13909, 14505, 7455, 75025, 9301, 2189, 489, 1160, 5498, 9301, 10340, 696, 262, 674, 1194, 446, 3013, 16, 1734, 498, 6907, 11, 1052, 59970, 35842, 340, 262, 30100, 284, 69671, 46012, 16446, 11, 2897, 340, 262, 674, 1194, 446, 285, 8329, 16, 1734, 498, 30100, 11, 1052, 59970, 35842, 3707, 262, 8558, 5506, 446, 26021, 6303, 288, 505, 1797, 828, 13352, 262, 6907, 1026, 284, 50372, 1471, 38347, 32358, 14678, 94541, 2432, 23059, 291, 2551, 3261, 10403, 288, 71642, 286, 51815, 11, 16797, 11, 1988, 11, 30100, 11, 33869, 58, 41484, 32554, 1282, 286, 2897, 19819, 2424, 8, 369, 51815, 304, 682, 4231, 442, 58375, 696, 262, 471, 6907, 1026, 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 ]
linkedin/Zopkio
zopkio/deployer.py
Deployer.hangup
def hangup(self, unique_id, configs=None): """ Issue a signal to hangup the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGHUP, configs)
python
def hangup(self, unique_id, configs=None): """ Issue a signal to hangup the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGHUP, configs)
[ "def", "hangup", "(", "self", ",", "unique_id", ",", "configs", "=", "None", ")", ":", "self", ".", "_send_signal", "(", "unique_id", ",", "signal", ".", "SIGHUP", ",", "configs", ")" ]
Issue a signal to hangup the specified process :Parameter unique_id: the name of the process
[ "Issue", "a", "signal", "to", "hangup", "the", "specified", "process" ]
train
https://github.com/linkedin/Zopkio/blob/a06e35a884cd26eedca0aac8ba6b9b40c417a01c/zopkio/deployer.py#L224-L230
<|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: Issue a signal to hangup the specified process :Parameter unique_id: the name of the process ### Response: def hangup(self, unique_id, configs=None): """ Issue a signal to hangup the specified process :Parameter unique_id: the name of the process """ self._send_signal(unique_id, signal.SIGHUP, configs) <|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, 43106, 264, 8450, 311, 15020, 455, 279, 5300, 1920, 271, 262, 551, 5078, 5016, 851, 25, 279, 836, 315, 279, 1920, 271, 14711, 6075, 512, 755, 15020, 455, 1214, 11, 5016, 851, 11, 43409, 5980, 997, 262, 3270, 262, 26292, 264, 8450, 311, 15020, 455, 279, 5300, 1920, 271, 262, 551, 5078, 5016, 851, 25, 279, 836, 315, 279, 1920, 198, 262, 3270, 262, 659, 1462, 6820, 21821, 54540, 851, 11, 8450, 815, 17186, 3202, 11, 43409, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 43106, 264, 8450, 311, 15020, 455, 279, 5300, 1920, 271, 262, 551, 5078, 5016, 851, 25, 279, 836, 315, 279, 1920, 271, 14711, 6075, 512, 755, 15020, 455, 1214, 11, 5016, 851, 11, 43409, 5980, 997, 262, 3270, 262, 26292, 264, 8450, 311, 15020, 455, 279, 5300, 1920, 271, 262, 551, 5078, 5016, 851, 25, 279, 836, 315, 279, 1920, 198, 262, 3270, 262, 659, 1462, 6820, 21821, 54540, 851, 11, 8450, 815, 17186, 3202, 11, 43409, 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 ]
pantsbuild/pants
src/python/pants/backend/python/tasks/resolve_requirements_task_base.py
ResolveRequirementsTaskBase.merged_pex
def merged_pex(cls, path, pex_info, interpreter, pexes, interpeter_constraints=None): """Yields a pex builder at path with the given pexes already merged. :rtype: :class:`pex.pex_builder.PEXBuilder` """ pex_paths = [pex.path() for pex in pexes if pex] if pex_paths: pex_info = pex_info.copy() pex_info.merge_pex_path(':'.join(pex_paths)) with safe_concurrent_creation(path) as safe_path: builder = PEXBuilder(safe_path, interpreter, pex_info=pex_info) if interpeter_constraints: for constraint in interpeter_constraints: builder.add_interpreter_constraint(constraint) yield builder
python
def merged_pex(cls, path, pex_info, interpreter, pexes, interpeter_constraints=None): """Yields a pex builder at path with the given pexes already merged. :rtype: :class:`pex.pex_builder.PEXBuilder` """ pex_paths = [pex.path() for pex in pexes if pex] if pex_paths: pex_info = pex_info.copy() pex_info.merge_pex_path(':'.join(pex_paths)) with safe_concurrent_creation(path) as safe_path: builder = PEXBuilder(safe_path, interpreter, pex_info=pex_info) if interpeter_constraints: for constraint in interpeter_constraints: builder.add_interpreter_constraint(constraint) yield builder
[ "def", "merged_pex", "(", "cls", ",", "path", ",", "pex_info", ",", "interpreter", ",", "pexes", ",", "interpeter_constraints", "=", "None", ")", ":", "pex_paths", "=", "[", "pex", ".", "path", "(", ")", "for", "pex", "in", "pexes", "if", "pex", "]", "if", "pex_paths", ":", "pex_info", "=", "pex_info", ".", "copy", "(", ")", "pex_info", ".", "merge_pex_path", "(", "':'", ".", "join", "(", "pex_paths", ")", ")", "with", "safe_concurrent_creation", "(", "path", ")", "as", "safe_path", ":", "builder", "=", "PEXBuilder", "(", "safe_path", ",", "interpreter", ",", "pex_info", "=", "pex_info", ")", "if", "interpeter_constraints", ":", "for", "constraint", "in", "interpeter_constraints", ":", "builder", ".", "add_interpreter_constraint", "(", "constraint", ")", "yield", "builder" ]
Yields a pex builder at path with the given pexes already merged. :rtype: :class:`pex.pex_builder.PEXBuilder`
[ "Yields", "a", "pex", "builder", "at", "path", "with", "the", "given", "pexes", "already", "merged", "." ]
train
https://github.com/pantsbuild/pants/blob/b72e650da0df685824ffdcc71988b8c282d0962d/src/python/pants/backend/python/tasks/resolve_requirements_task_base.py#L121-L136
<|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: Yields a pex builder at path with the given pexes already merged. :rtype: :class:`pex.pex_builder.PEXBuilder` ### Response: def merged_pex(cls, path, pex_info, interpreter, pexes, interpeter_constraints=None): """Yields a pex builder at path with the given pexes already merged. :rtype: :class:`pex.pex_builder.PEXBuilder` """ pex_paths = [pex.path() for pex in pexes if pex] if pex_paths: pex_info = pex_info.copy() pex_info.merge_pex_path(':'.join(pex_paths)) with safe_concurrent_creation(path) as safe_path: builder = PEXBuilder(safe_path, interpreter, pex_info=pex_info) if interpeter_constraints: for constraint in interpeter_constraints: builder.add_interpreter_constraint(constraint) yield builder <|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, 56, 7052, 264, 281, 327, 7514, 520, 1853, 449, 279, 2728, 281, 327, 288, 2736, 27092, 382, 262, 551, 33613, 25, 551, 1058, 19258, 79, 327, 558, 327, 29632, 1087, 3337, 3377, 19884, 14711, 6075, 512, 755, 27092, 623, 327, 21024, 11, 1853, 11, 281, 327, 3186, 11, 40399, 11, 281, 327, 288, 11, 48371, 1430, 61367, 5980, 997, 262, 4304, 56, 7052, 264, 281, 327, 7514, 520, 1853, 449, 279, 2728, 281, 327, 288, 2736, 27092, 382, 262, 551, 33613, 25, 551, 1058, 19258, 79, 327, 558, 327, 29632, 1087, 3337, 3377, 4077, 262, 3270, 262, 281, 327, 25124, 284, 510, 79, 327, 3960, 368, 369, 281, 327, 304, 281, 327, 288, 422, 281, 327, 933, 262, 422, 281, 327, 25124, 512, 415, 281, 327, 3186, 284, 281, 327, 3186, 12511, 746, 415, 281, 327, 3186, 26052, 623, 327, 2703, 16364, 4527, 6115, 1319, 327, 25124, 4489, 262, 449, 6220, 3464, 3311, 47263, 5698, 8, 439, 6220, 2703, 512, 415, 7514, 284, 393, 3337, 3377, 1161, 5763, 2703, 11, 40399, 11, 281, 327, 3186, 17841, 327, 3186, 340, 415, 422, 48371, 1430, 61367, 512, 286, 369, 22295, 304, 48371, 1430, 61367, 512, 692, 7514, 1388, 15678, 29737, 48073, 18350, 4759, 340, 415, 7692, 7514, 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 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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 56, 7052, 264, 281, 327, 7514, 520, 1853, 449, 279, 2728, 281, 327, 288, 2736, 27092, 382, 262, 551, 33613, 25, 551, 1058, 19258, 79, 327, 558, 327, 29632, 1087, 3337, 3377, 19884, 14711, 6075, 512, 755, 27092, 623, 327, 21024, 11, 1853, 11, 281, 327, 3186, 11, 40399, 11, 281, 327, 288, 11, 48371, 1430, 61367, 5980, 997, 262, 4304, 56, 7052, 264, 281, 327, 7514, 520, 1853, 449, 279, 2728, 281, 327, 288, 2736, 27092, 382, 262, 551, 33613, 25, 551, 1058, 19258, 79, 327, 558, 327, 29632, 1087, 3337, 3377, 4077, 262, 3270, 262, 281, 327, 25124, 284, 510, 79, 327, 3960, 368, 369, 281, 327, 304, 281, 327, 288, 422, 281, 327, 933, 262, 422, 281, 327, 25124, 512, 415, 281, 327, 3186, 284, 281, 327, 3186, 12511, 746, 415, 281, 327, 3186, 26052, 623, 327, 2703, 16364, 4527, 6115, 1319, 327, 25124, 4489, 262, 449, 6220, 3464, 3311, 47263, 5698, 8, 439, 6220, 2703, 512, 415, 7514, 284, 393, 3337, 3377, 1161, 5763, 2703, 11, 40399, 11, 281, 327, 3186, 17841, 327, 3186, 340, 415, 422, 48371, 1430, 61367, 512, 286, 369, 22295, 304, 48371, 1430, 61367, 512, 692, 7514, 1388, 15678, 29737, 48073, 18350, 4759, 340, 415, 7692, 7514, 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 ]
infobloxopen/infoblox-client
infoblox_client/connector.py
Connector.create_object
def create_object(self, obj_type, payload, return_fields=None): """Create an Infoblox object of type 'obj_type' Args: obj_type (str): Infoblox object type, e.g. 'network', 'range', etc. payload (dict): Payload with data to send return_fields (list): List of fields to be returned Returns: The object reference of the newly create object Raises: InfobloxException """ self._validate_obj_type_or_die(obj_type) query_params = self._build_query_params(return_fields=return_fields) url = self._construct_url(obj_type, query_params) opts = self._get_request_options(data=payload) self._log_request('post', url, opts) if(self.session.cookies): # the first 'get' or 'post' action will generate a cookie # after that, we don't need to re-authenticate self.session.auth = None r = self.session.post(url, **opts) self._validate_authorized(r) if r.status_code != requests.codes.CREATED: response = utils.safe_json_load(r.content) already_assigned = 'is assigned to another network view' if response and already_assigned in response.get('text'): exception = ib_ex.InfobloxMemberAlreadyAssigned else: exception = ib_ex.InfobloxCannotCreateObject raise exception( response=response, obj_type=obj_type, content=r.content, args=payload, code=r.status_code) return self._parse_reply(r)
python
def create_object(self, obj_type, payload, return_fields=None): """Create an Infoblox object of type 'obj_type' Args: obj_type (str): Infoblox object type, e.g. 'network', 'range', etc. payload (dict): Payload with data to send return_fields (list): List of fields to be returned Returns: The object reference of the newly create object Raises: InfobloxException """ self._validate_obj_type_or_die(obj_type) query_params = self._build_query_params(return_fields=return_fields) url = self._construct_url(obj_type, query_params) opts = self._get_request_options(data=payload) self._log_request('post', url, opts) if(self.session.cookies): # the first 'get' or 'post' action will generate a cookie # after that, we don't need to re-authenticate self.session.auth = None r = self.session.post(url, **opts) self._validate_authorized(r) if r.status_code != requests.codes.CREATED: response = utils.safe_json_load(r.content) already_assigned = 'is assigned to another network view' if response and already_assigned in response.get('text'): exception = ib_ex.InfobloxMemberAlreadyAssigned else: exception = ib_ex.InfobloxCannotCreateObject raise exception( response=response, obj_type=obj_type, content=r.content, args=payload, code=r.status_code) return self._parse_reply(r)
[ "def", "create_object", "(", "self", ",", "obj_type", ",", "payload", ",", "return_fields", "=", "None", ")", ":", "self", ".", "_validate_obj_type_or_die", "(", "obj_type", ")", "query_params", "=", "self", ".", "_build_query_params", "(", "return_fields", "=", "return_fields", ")", "url", "=", "self", ".", "_construct_url", "(", "obj_type", ",", "query_params", ")", "opts", "=", "self", ".", "_get_request_options", "(", "data", "=", "payload", ")", "self", ".", "_log_request", "(", "'post'", ",", "url", ",", "opts", ")", "if", "(", "self", ".", "session", ".", "cookies", ")", ":", "# the first 'get' or 'post' action will generate a cookie", "# after that, we don't need to re-authenticate", "self", ".", "session", ".", "auth", "=", "None", "r", "=", "self", ".", "session", ".", "post", "(", "url", ",", "*", "*", "opts", ")", "self", ".", "_validate_authorized", "(", "r", ")", "if", "r", ".", "status_code", "!=", "requests", ".", "codes", ".", "CREATED", ":", "response", "=", "utils", ".", "safe_json_load", "(", "r", ".", "content", ")", "already_assigned", "=", "'is assigned to another network view'", "if", "response", "and", "already_assigned", "in", "response", ".", "get", "(", "'text'", ")", ":", "exception", "=", "ib_ex", ".", "InfobloxMemberAlreadyAssigned", "else", ":", "exception", "=", "ib_ex", ".", "InfobloxCannotCreateObject", "raise", "exception", "(", "response", "=", "response", ",", "obj_type", "=", "obj_type", ",", "content", "=", "r", ".", "content", ",", "args", "=", "payload", ",", "code", "=", "r", ".", "status_code", ")", "return", "self", ".", "_parse_reply", "(", "r", ")" ]
Create an Infoblox object of type 'obj_type' Args: obj_type (str): Infoblox object type, e.g. 'network', 'range', etc. payload (dict): Payload with data to send return_fields (list): List of fields to be returned Returns: The object reference of the newly create object Raises: InfobloxException
[ "Create", "an", "Infoblox", "object", "of", "type", "obj_type" ]
train
https://github.com/infobloxopen/infoblox-client/blob/edeec62db1935784c728731b2ae7cf0fcc9bf84d/infoblox_client/connector.py#L345-L387
<|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 an Infoblox object of type 'obj_type' Args: obj_type (str): Infoblox object type, e.g. 'network', 'range', etc. payload (dict): Payload with data to send return_fields (list): List of fields to be returned Returns: The object reference of the newly create object Raises: InfobloxException ### Response: def create_object(self, obj_type, payload, return_fields=None): """Create an Infoblox object of type 'obj_type' Args: obj_type (str): Infoblox object type, e.g. 'network', 'range', etc. payload (dict): Payload with data to send return_fields (list): List of fields to be returned Returns: The object reference of the newly create object Raises: InfobloxException """ self._validate_obj_type_or_die(obj_type) query_params = self._build_query_params(return_fields=return_fields) url = self._construct_url(obj_type, query_params) opts = self._get_request_options(data=payload) self._log_request('post', url, opts) if(self.session.cookies): # the first 'get' or 'post' action will generate a cookie # after that, we don't need to re-authenticate self.session.auth = None r = self.session.post(url, **opts) self._validate_authorized(r) if r.status_code != requests.codes.CREATED: response = utils.safe_json_load(r.content) already_assigned = 'is assigned to another network view' if response and already_assigned in response.get('text'): exception = ib_ex.InfobloxMemberAlreadyAssigned else: exception = ib_ex.InfobloxCannotCreateObject raise exception( response=response, obj_type=obj_type, content=r.content, args=payload, code=r.status_code) return self._parse_reply(r) <|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, 459, 15268, 677, 56828, 1665, 315, 955, 364, 2347, 1857, 3961, 286, 18161, 512, 310, 2909, 1857, 286, 320, 496, 1680, 15268, 677, 56828, 1665, 955, 345, 6794, 384, 1326, 13, 364, 17969, 518, 364, 9866, 518, 5099, 627, 310, 7885, 996, 320, 8644, 1680, 54016, 449, 828, 311, 3708, 198, 310, 471, 12406, 320, 1638, 1680, 1796, 315, 5151, 311, 387, 6052, 198, 286, 5295, 512, 310, 578, 1665, 5905, 315, 279, 13945, 1893, 1665, 198, 286, 61411, 512, 310, 15268, 677, 56828, 1378, 271, 14711, 6075, 512, 755, 1893, 5427, 1214, 11, 2909, 1857, 11, 7885, 11, 471, 12406, 5980, 997, 286, 4304, 4110, 459, 15268, 677, 56828, 1665, 315, 955, 364, 2347, 1857, 3961, 286, 18161, 512, 310, 2909, 1857, 286, 320, 496, 1680, 15268, 677, 56828, 1665, 955, 345, 6794, 384, 1326, 13, 364, 17969, 518, 364, 9866, 518, 5099, 627, 310, 7885, 996, 320, 8644, 1680, 54016, 449, 828, 311, 3708, 198, 310, 471, 12406, 320, 1638, 1680, 1796, 315, 5151, 311, 387, 6052, 198, 286, 5295, 512, 310, 578, 1665, 5905, 315, 279, 13945, 1893, 1665, 198, 286, 61411, 512, 310, 15268, 677, 56828, 1378, 198, 286, 3270, 286, 659, 1462, 7212, 7478, 1857, 8908, 62688, 6922, 1857, 696, 286, 3319, 6887, 284, 659, 1462, 5957, 5857, 6887, 36206, 12406, 28, 693, 12406, 696, 286, 2576, 284, 659, 1462, 7750, 2975, 6922, 1857, 11, 3319, 6887, 340, 286, 12462, 284, 659, 1462, 456, 8052, 8917, 2657, 17841, 7134, 340, 286, 659, 1462, 848, 8052, 493, 2252, 518, 2576, 11, 12462, 340, 286, 422, 1214, 10387, 66398, 997, 310, 674, 279, 1176, 364, 456, 6, 477, 364, 2252, 6, 1957, 690, 7068, 264, 12829, 198, 310, 674, 1306, 430, 11, 584, 1541, 956, 1205, 311, 312, 34603, 23491, 198, 310, 659, 10387, 9144, 284, 2290, 198, 286, 436, 284, 659, 10387, 6679, 6659, 11, 3146, 10740, 696, 286, 659, 1462, 7212, 62, 19626, 2666, 696, 286, 422, 436, 4397, 4229, 976, 7540, 95318, 99739, 512, 310, 2077, 284, 12721, 53983, 9643, 12693, 2666, 5521, 340, 310, 2736, 86615, 284, 364, 285, 12893, 311, 2500, 4009, 1684, 1270, 310, 422, 2077, 323, 2736, 86615, 304, 2077, 673, 493, 1342, 11290, 394, 4788, 284, 19185, 2769, 34621, 677, 56828, 9550, 39470, 95125, 198, 310, 775, 512, 394, 4788, 284, 19185, 2769, 34621, 677, 385, 12398, 3483, 4110, 1211, 198, 310, 4933, 4788, 1021, 394, 2077, 80190, 345, 394, 2909, 1857, 78346, 1857, 345, 394, 2262, 32220, 5521, 345, 394, 2897, 17841, 7134, 345, 394, 2082, 32220, 4397, 4229, 696, 286, 471, 659, 1462, 6534, 15683, 2666, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 459, 15268, 677, 56828, 1665, 315, 955, 364, 2347, 1857, 3961, 286, 18161, 512, 310, 2909, 1857, 286, 320, 496, 1680, 15268, 677, 56828, 1665, 955, 345, 6794, 384, 1326, 13, 364, 17969, 518, 364, 9866, 518, 5099, 627, 310, 7885, 996, 320, 8644, 1680, 54016, 449, 828, 311, 3708, 198, 310, 471, 12406, 320, 1638, 1680, 1796, 315, 5151, 311, 387, 6052, 198, 286, 5295, 512, 310, 578, 1665, 5905, 315, 279, 13945, 1893, 1665, 198, 286, 61411, 512, 310, 15268, 677, 56828, 1378, 271, 14711, 6075, 512, 755, 1893, 5427, 1214, 11, 2909, 1857, 11, 7885, 11, 471, 12406, 5980, 997, 286, 4304, 4110, 459, 15268, 677, 56828, 1665, 315, 955, 364, 2347, 1857, 3961, 286, 18161, 512, 310, 2909, 1857, 286, 320, 496, 1680, 15268, 677, 56828, 1665, 955, 345, 6794, 384, 1326, 13, 364, 17969, 518, 364, 9866, 518, 5099, 627, 310, 7885, 996, 320, 8644, 1680, 54016, 449, 828, 311, 3708, 198, 310, 471, 12406, 320, 1638, 1680, 1796, 315, 5151, 311, 387, 6052, 198, 286, 5295, 512, 310, 578, 1665, 5905, 315, 279, 13945, 1893, 1665, 198, 286, 61411, 512, 310, 15268, 677, 56828, 1378, 198, 286, 3270, 286, 659, 1462, 7212, 7478, 1857, 8908, 62688, 6922, 1857, 696, 286, 3319, 6887, 284, 659, 1462, 5957, 5857, 6887, 36206, 12406, 28, 693, 12406, 696, 286, 2576, 284, 659, 1462, 7750, 2975, 6922, 1857, 11, 3319, 6887, 340, 286, 12462, 284, 659, 1462, 456, 8052, 8917, 2657, 17841, 7134, 340, 286, 659, 1462, 848, 8052, 493, 2252, 518, 2576, 11, 12462, 340, 286, 422, 1214, 10387, 66398, 997, 310, 674, 279, 1176, 364, 456, 6, 477, 364, 2252, 6, 1957, 690, 7068, 264, 12829, 198, 310, 674, 1306, 430, 11, 584, 1541, 956, 1205, 311, 312, 34603, 23491, 198, 310, 659, 10387, 9144, 284, 2290, 198, 286, 436, 284, 659, 10387, 6679, 6659, 11, 3146, 10740, 696, 286, 659, 1462, 7212, 62, 19626, 2666, 696, 286, 422, 436, 4397, 4229, 976, 7540, 95318, 99739, 512, 310, 2077, 284, 12721, 53983, 9643, 12693, 2666, 5521, 340, 310, 2736, 86615, 284, 364, 285, 12893, 311, 2500, 4009, 1684, 1270, 310, 422, 2077, 323, 2736, 86615, 304, 2077, 673, 493, 1342, 11290, 394, 4788, 284, 19185, 2769, 34621, 677, 56828, 9550, 39470, 95125, 198, 310, 775, 512, 394, 4788, 284, 19185, 2769, 34621, 677, 385, 12398, 3483, 4110, 1211, 198, 310, 4933, 4788, 1021, 394, 2077, 80190, 345, 394, 2909, 1857, 78346, 1857, 345, 394, 2262, 32220, 5521, 345, 394, 2897, 17841, 7134, 345, 394, 2082, 32220, 4397, 4229, 696, 286, 471, 659, 1462, 6534, 15683, 2666, 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 ]
deepmind/sonnet
sonnet/python/modules/basic.py
BatchReshape.transpose
def transpose(self, name=None): """Returns transpose batch reshape.""" if name is None: name = self.module_name + "_transpose" return BatchReshape(shape=lambda: self.input_shape, preserve_dims=self._preserve_dims, name=name)
python
def transpose(self, name=None): """Returns transpose batch reshape.""" if name is None: name = self.module_name + "_transpose" return BatchReshape(shape=lambda: self.input_shape, preserve_dims=self._preserve_dims, name=name)
[ "def", "transpose", "(", "self", ",", "name", "=", "None", ")", ":", "if", "name", "is", "None", ":", "name", "=", "self", ".", "module_name", "+", "\"_transpose\"", "return", "BatchReshape", "(", "shape", "=", "lambda", ":", "self", ".", "input_shape", ",", "preserve_dims", "=", "self", ".", "_preserve_dims", ",", "name", "=", "name", ")" ]
Returns transpose batch reshape.
[ "Returns", "transpose", "batch", "reshape", "." ]
train
https://github.com/deepmind/sonnet/blob/00612ca3178964d86b556e062694d808ff81fcca/sonnet/python/modules/basic.py#L868-L874
<|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 transpose batch reshape. ### Response: def transpose(self, name=None): """Returns transpose batch reshape.""" if name is None: name = self.module_name + "_transpose" return BatchReshape(shape=lambda: self.input_shape, preserve_dims=self._preserve_dims, name=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, 16851, 52023, 7309, 44909, 382, 14711, 6075, 512, 755, 52023, 1214, 11, 836, 5980, 997, 262, 4304, 16851, 52023, 7309, 44909, 14781, 262, 422, 836, 374, 2290, 512, 415, 836, 284, 659, 10282, 1292, 489, 9177, 55587, 702, 262, 471, 35004, 1079, 30888, 27022, 28604, 25, 659, 10252, 13911, 345, 667, 21813, 30367, 7822, 1462, 93982, 30367, 345, 667, 836, 40341, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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,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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, 52023, 7309, 44909, 382, 14711, 6075, 512, 755, 52023, 1214, 11, 836, 5980, 997, 262, 4304, 16851, 52023, 7309, 44909, 14781, 262, 422, 836, 374, 2290, 512, 415, 836, 284, 659, 10282, 1292, 489, 9177, 55587, 702, 262, 471, 35004, 1079, 30888, 27022, 28604, 25, 659, 10252, 13911, 345, 667, 21813, 30367, 7822, 1462, 93982, 30367, 345, 667, 836, 40341, 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 ]
saltstack/salt
salt/modules/git.py
stash
def stash(cwd, action='save', opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-stash(1)`_, returns the stdout from the git command cwd The path to the git checkout opts Any additional options to add to the command line, in a single string. Use this to complete the ``git stash`` command by adding the remaining arguments (i.e. ``'save <stash comment>'``, ``'apply stash@{2}'``, ``'show'``, etc.). Omitting this argument will simply run ``git stash``. git_opts Any additional options to add to git command itself (not the ``stash`` subcommand), in a single string. This is useful for passing ``-c`` to run git with temporary changes to the git configuration. .. versionadded:: 2017.7.0 .. note:: This is only supported in git 1.7.2 and newer. user User under which to run the git command. By default, the command is run by the user under which the minion is running. password Windows only. Required when specifying ``user``. This parameter will be ignored on non-Windows platforms. .. versionadded:: 2016.3.4 ignore_retcode : False If ``True``, do not log an error to the minion log if the git command returns a nonzero exit status. .. versionadded:: 2015.8.0 output_encoding Use this option to specify which encoding to use to decode the output from any git commands which are run. This should not be needed in most cases. .. note:: This should only be needed if the files in the repository were created with filenames using an encoding other than UTF-8 to handle Unicode characters. .. versionadded:: 2018.3.1 .. _`git-stash(1)`: http://git-scm.com/docs/git-stash CLI Examples: .. code-block:: bash salt myminion git.stash /path/to/repo save opts='work in progress' salt myminion git.stash /path/to/repo apply opts='stash@{1}' salt myminion git.stash /path/to/repo drop opts='stash@{1}' salt myminion git.stash /path/to/repo list ''' cwd = _expand_path(cwd, user) command = ['git'] + _format_git_opts(git_opts) command.extend(['stash', action]) command.extend(_format_opts(opts)) return _git_run(command, cwd=cwd, user=user, password=password, ignore_retcode=ignore_retcode, output_encoding=output_encoding)['stdout']
python
def stash(cwd, action='save', opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-stash(1)`_, returns the stdout from the git command cwd The path to the git checkout opts Any additional options to add to the command line, in a single string. Use this to complete the ``git stash`` command by adding the remaining arguments (i.e. ``'save <stash comment>'``, ``'apply stash@{2}'``, ``'show'``, etc.). Omitting this argument will simply run ``git stash``. git_opts Any additional options to add to git command itself (not the ``stash`` subcommand), in a single string. This is useful for passing ``-c`` to run git with temporary changes to the git configuration. .. versionadded:: 2017.7.0 .. note:: This is only supported in git 1.7.2 and newer. user User under which to run the git command. By default, the command is run by the user under which the minion is running. password Windows only. Required when specifying ``user``. This parameter will be ignored on non-Windows platforms. .. versionadded:: 2016.3.4 ignore_retcode : False If ``True``, do not log an error to the minion log if the git command returns a nonzero exit status. .. versionadded:: 2015.8.0 output_encoding Use this option to specify which encoding to use to decode the output from any git commands which are run. This should not be needed in most cases. .. note:: This should only be needed if the files in the repository were created with filenames using an encoding other than UTF-8 to handle Unicode characters. .. versionadded:: 2018.3.1 .. _`git-stash(1)`: http://git-scm.com/docs/git-stash CLI Examples: .. code-block:: bash salt myminion git.stash /path/to/repo save opts='work in progress' salt myminion git.stash /path/to/repo apply opts='stash@{1}' salt myminion git.stash /path/to/repo drop opts='stash@{1}' salt myminion git.stash /path/to/repo list ''' cwd = _expand_path(cwd, user) command = ['git'] + _format_git_opts(git_opts) command.extend(['stash', action]) command.extend(_format_opts(opts)) return _git_run(command, cwd=cwd, user=user, password=password, ignore_retcode=ignore_retcode, output_encoding=output_encoding)['stdout']
[ "def", "stash", "(", "cwd", ",", "action", "=", "'save'", ",", "opts", "=", "''", ",", "git_opts", "=", "''", ",", "user", "=", "None", ",", "password", "=", "None", ",", "ignore_retcode", "=", "False", ",", "output_encoding", "=", "None", ")", ":", "cwd", "=", "_expand_path", "(", "cwd", ",", "user", ")", "command", "=", "[", "'git'", "]", "+", "_format_git_opts", "(", "git_opts", ")", "command", ".", "extend", "(", "[", "'stash'", ",", "action", "]", ")", "command", ".", "extend", "(", "_format_opts", "(", "opts", ")", ")", "return", "_git_run", "(", "command", ",", "cwd", "=", "cwd", ",", "user", "=", "user", ",", "password", "=", "password", ",", "ignore_retcode", "=", "ignore_retcode", ",", "output_encoding", "=", "output_encoding", ")", "[", "'stdout'", "]" ]
Interface to `git-stash(1)`_, returns the stdout from the git command cwd The path to the git checkout opts Any additional options to add to the command line, in a single string. Use this to complete the ``git stash`` command by adding the remaining arguments (i.e. ``'save <stash comment>'``, ``'apply stash@{2}'``, ``'show'``, etc.). Omitting this argument will simply run ``git stash``. git_opts Any additional options to add to git command itself (not the ``stash`` subcommand), in a single string. This is useful for passing ``-c`` to run git with temporary changes to the git configuration. .. versionadded:: 2017.7.0 .. note:: This is only supported in git 1.7.2 and newer. user User under which to run the git command. By default, the command is run by the user under which the minion is running. password Windows only. Required when specifying ``user``. This parameter will be ignored on non-Windows platforms. .. versionadded:: 2016.3.4 ignore_retcode : False If ``True``, do not log an error to the minion log if the git command returns a nonzero exit status. .. versionadded:: 2015.8.0 output_encoding Use this option to specify which encoding to use to decode the output from any git commands which are run. This should not be needed in most cases. .. note:: This should only be needed if the files in the repository were created with filenames using an encoding other than UTF-8 to handle Unicode characters. .. versionadded:: 2018.3.1 .. _`git-stash(1)`: http://git-scm.com/docs/git-stash CLI Examples: .. code-block:: bash salt myminion git.stash /path/to/repo save opts='work in progress' salt myminion git.stash /path/to/repo apply opts='stash@{1}' salt myminion git.stash /path/to/repo drop opts='stash@{1}' salt myminion git.stash /path/to/repo list
[ "Interface", "to", "git", "-", "stash", "(", "1", ")", "_", "returns", "the", "stdout", "from", "the", "git", "command" ]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/git.py#L4544-L4623
<|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: Interface to `git-stash(1)`_, returns the stdout from the git command cwd The path to the git checkout opts Any additional options to add to the command line, in a single string. Use this to complete the ``git stash`` command by adding the remaining arguments (i.e. ``'save <stash comment>'``, ``'apply stash@{2}'``, ``'show'``, etc.). Omitting this argument will simply run ``git stash``. git_opts Any additional options to add to git command itself (not the ``stash`` subcommand), in a single string. This is useful for passing ``-c`` to run git with temporary changes to the git configuration. .. versionadded:: 2017.7.0 .. note:: This is only supported in git 1.7.2 and newer. user User under which to run the git command. By default, the command is run by the user under which the minion is running. password Windows only. Required when specifying ``user``. This parameter will be ignored on non-Windows platforms. .. versionadded:: 2016.3.4 ignore_retcode : False If ``True``, do not log an error to the minion log if the git command returns a nonzero exit status. .. versionadded:: 2015.8.0 output_encoding Use this option to specify which encoding to use to decode the output from any git commands which are run. This should not be needed in most cases. .. note:: This should only be needed if the files in the repository were created with filenames using an encoding other than UTF-8 to handle Unicode characters. .. versionadded:: 2018.3.1 .. _`git-stash(1)`: http://git-scm.com/docs/git-stash CLI Examples: .. code-block:: bash salt myminion git.stash /path/to/repo save opts='work in progress' salt myminion git.stash /path/to/repo apply opts='stash@{1}' salt myminion git.stash /path/to/repo drop opts='stash@{1}' salt myminion git.stash /path/to/repo list ### Response: def stash(cwd, action='save', opts='', git_opts='', user=None, password=None, ignore_retcode=False, output_encoding=None): ''' Interface to `git-stash(1)`_, returns the stdout from the git command cwd The path to the git checkout opts Any additional options to add to the command line, in a single string. Use this to complete the ``git stash`` command by adding the remaining arguments (i.e. ``'save <stash comment>'``, ``'apply stash@{2}'``, ``'show'``, etc.). Omitting this argument will simply run ``git stash``. git_opts Any additional options to add to git command itself (not the ``stash`` subcommand), in a single string. This is useful for passing ``-c`` to run git with temporary changes to the git configuration. .. versionadded:: 2017.7.0 .. note:: This is only supported in git 1.7.2 and newer. user User under which to run the git command. By default, the command is run by the user under which the minion is running. password Windows only. Required when specifying ``user``. This parameter will be ignored on non-Windows platforms. .. versionadded:: 2016.3.4 ignore_retcode : False If ``True``, do not log an error to the minion log if the git command returns a nonzero exit status. .. versionadded:: 2015.8.0 output_encoding Use this option to specify which encoding to use to decode the output from any git commands which are run. This should not be needed in most cases. .. note:: This should only be needed if the files in the repository were created with filenames using an encoding other than UTF-8 to handle Unicode characters. .. versionadded:: 2018.3.1 .. _`git-stash(1)`: http://git-scm.com/docs/git-stash CLI Examples: .. code-block:: bash salt myminion git.stash /path/to/repo save opts='work in progress' salt myminion git.stash /path/to/repo apply opts='stash@{1}' salt myminion git.stash /path/to/repo drop opts='stash@{1}' salt myminion git.stash /path/to/repo list ''' cwd = _expand_path(cwd, user) command = ['git'] + _format_git_opts(git_opts) command.extend(['stash', action]) command.extend(_format_opts(opts)) return _git_run(command, cwd=cwd, user=user, password=password, ignore_retcode=ignore_retcode, output_encoding=output_encoding)['stdout'] <|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, 5160, 311, 1595, 13178, 5594, 1003, 7, 16, 47286, 7022, 4780, 279, 20676, 505, 279, 16749, 3290, 271, 262, 48038, 198, 286, 578, 1853, 311, 279, 16749, 28363, 271, 262, 12462, 198, 286, 5884, 5217, 2671, 311, 923, 311, 279, 3290, 1584, 11, 304, 264, 3254, 925, 627, 286, 5560, 420, 311, 4686, 279, 10103, 13178, 65137, 14196, 3290, 555, 7999, 279, 9861, 198, 286, 6105, 320, 72, 1770, 13, 220, 10103, 6, 6766, 366, 50871, 4068, 5709, 91816, 10103, 6, 10492, 65137, 31, 90, 17, 11923, 63, 13188, 286, 10103, 6, 3528, 6, 91816, 5099, 36434, 220, 507, 1800, 1303, 420, 5811, 690, 5042, 1629, 10103, 13178, 198, 286, 65137, 14196, 382, 262, 16749, 33454, 198, 286, 5884, 5217, 2671, 311, 923, 311, 16749, 3290, 5196, 320, 1962, 279, 10103, 50871, 85374, 286, 1207, 5749, 705, 304, 264, 3254, 925, 13, 1115, 374, 5505, 369, 12579, 10103, 12, 66, 14196, 311, 198, 286, 1629, 16749, 449, 13643, 4442, 311, 279, 16749, 6683, 382, 286, 5354, 2373, 17249, 487, 220, 679, 22, 13, 22, 13, 15, 271, 286, 5354, 5296, 50677, 310, 1115, 374, 1193, 7396, 304, 16749, 220, 16, 13, 22, 13, 17, 323, 26627, 382, 262, 1217, 198, 286, 2724, 1234, 902, 311, 1629, 279, 16749, 3290, 13, 3296, 1670, 11, 279, 3290, 374, 1629, 198, 286, 555, 279, 1217, 1234, 902, 279, 63635, 374, 4401, 382, 262, 3636, 198, 286, 5632, 1193, 13, 12948, 994, 38938, 10103, 882, 14196, 13, 1115, 5852, 690, 387, 198, 286, 12305, 389, 2536, 13299, 1519, 15771, 382, 415, 5354, 2373, 17249, 487, 220, 679, 21, 13, 18, 13, 19, 271, 262, 10240, 22437, 1889, 551, 3641, 198, 286, 1442, 10103, 2575, 91816, 656, 539, 1515, 459, 1493, 311, 279, 63635, 1515, 422, 279, 16749, 3290, 198, 286, 4780, 264, 73332, 4974, 2704, 382, 286, 5354, 2373, 17249, 487, 220, 679, 20, 13, 23, 13, 15, 271, 262, 2612, 38713, 198, 286, 5560, 420, 3072, 311, 14158, 902, 11418, 311, 1005, 311, 17322, 279, 2612, 198, 286, 505, 904, 16749, 11545, 902, 527, 1629, 13, 1115, 1288, 539, 387, 4460, 304, 1455, 198, 286, 5157, 382, 286, 5354, 5296, 50677, 310, 1115, 1288, 1193, 387, 4460, 422, 279, 3626, 304, 279, 12827, 1051, 198, 310, 3549, 449, 41640, 1701, 459, 11418, 1023, 1109, 20677, 12, 23, 311, 3790, 198, 310, 36997, 5885, 382, 286, 5354, 2373, 17249, 487, 220, 679, 23, 13, 18, 13, 16, 271, 262, 5354, 721, 63, 13178, 5594, 1003, 7, 16, 8, 45722, 1795, 1129, 13178, 1355, 6358, 916, 27057, 61690, 5594, 1003, 271, 262, 40377, 26379, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 856, 1083, 290, 16749, 1258, 1003, 611, 2398, 33529, 10991, 5481, 3665, 12462, 1151, 1816, 304, 5208, 1270, 286, 12290, 856, 1083, 290, 16749, 1258, 1003, 611, 2398, 33529, 10991, 5481, 3881, 12462, 1151 ]
[ 1, 1, 1, 1, 1, 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, 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, 5160, 311, 1595, 13178, 5594, 1003, 7, 16, 47286, 7022, 4780, 279, 20676, 505, 279, 16749, 3290, 271, 262, 48038, 198, 286, 578, 1853, 311, 279, 16749, 28363, 271, 262, 12462, 198, 286, 5884, 5217, 2671, 311, 923, 311, 279, 3290, 1584, 11, 304, 264, 3254, 925, 627, 286, 5560, 420, 311, 4686, 279, 10103, 13178, 65137, 14196, 3290, 555, 7999, 279, 9861, 198, 286, 6105, 320, 72, 1770, 13, 220, 10103, 6, 6766, 366, 50871, 4068, 5709, 91816, 10103, 6, 10492, 65137, 31, 90, 17, 11923, 63, 13188, 286, 10103, 6, 3528, 6, 91816, 5099, 36434, 220, 507, 1800, 1303, 420, 5811, 690, 5042, 1629, 10103, 13178, 198, 286, 65137, 14196, 382, 262, 16749, 33454, 198, 286, 5884, 5217, 2671, 311, 923, 311, 16749, 3290, 5196, 320, 1962, 279, 10103, 50871, 85374, 286, 1207, 5749, 705, 304, 264, 3254, 925, 13, 1115, 374, 5505, 369, 12579, 10103, 12, 66, 14196, 311, 198, 286, 1629, 16749, 449, 13643, 4442, 311, 279, 16749, 6683, 382, 286, 5354, 2373, 17249, 487, 220, 679, 22, 13, 22, 13, 15, 271, 286, 5354, 5296, 50677, 310, 1115, 374, 1193, 7396, 304, 16749, 220, 16, 13, 22, 13, 17, 323, 26627, 382, 262, 1217, 198, 286, 2724, 1234, 902, 311, 1629, 279, 16749, 3290, 13, 3296, 1670, 11, 279, 3290, 374, 1629, 198, 286, 555, 279, 1217, 1234, 902, 279, 63635, 374, 4401, 382, 262, 3636, 198, 286, 5632, 1193, 13, 12948, 994, 38938, 10103, 882, 14196, 13, 1115, 5852, 690, 387, 198, 286, 12305, 389, 2536, 13299, 1519, 15771, 382, 415, 5354, 2373, 17249, 487, 220, 679, 21, 13, 18, 13, 19, 271, 262, 10240, 22437, 1889, 551, 3641, 198, 286, 1442, 10103, 2575, 91816, 656, 539, 1515, 459, 1493, 311, 279, 63635, 1515, 422, 279, 16749, 3290, 198, 286, 4780, 264, 73332, 4974, 2704, 382, 286, 5354, 2373, 17249, 487, 220, 679, 20, 13, 23, 13, 15, 271, 262, 2612, 38713, 198, 286, 5560, 420, 3072, 311, 14158, 902, 11418, 311, 1005, 311, 17322, 279, 2612, 198, 286, 505, 904, 16749, 11545, 902, 527, 1629, 13, 1115, 1288, 539, 387, 4460, 304, 1455, 198, 286, 5157, 382, 286, 5354, 5296, 50677, 310, 1115, 1288, 1193, 387, 4460, 422, 279, 3626, 304, 279, 12827, 1051, 198, 310, 3549, 449, 41640, 1701, 459, 11418, 1023, 1109, 20677, 12, 23, 311, 3790, 198, 310, 36997, 5885, 382, 286, 5354, 2373, 17249, 487, 220, 679, 23, 13, 18, 13, 16, 271, 262, 5354, 721, 63, 13178, 5594, 1003, 7, 16, 8, 45722, 1795, 1129, 13178, 1355, 6358, 916, 27057, 61690, 5594, 1003, 271, 262, 40377, 26379, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 286, 12290, 856, 1083, 290, 16749, 1258, 1003, 611, 2398, 33529, 10991, 5481, 3665, 12462, 1151, 1816, 304, 5208, 1270, 286, 12290, 856, 1083, 290, 16749, 1258, 1003, 611, 2398, 33529, 10991, 5481, 3881, 12462, 1151 ]
osrg/ryu
ryu/cmd/of_config_cli.py
Cmd.do_list_cap
def do_list_cap(self, line): """list_cap <peer> """ def f(p, args): for i in p.netconf.server_capabilities: print(i) self._request(line, f)
python
def do_list_cap(self, line): """list_cap <peer> """ def f(p, args): for i in p.netconf.server_capabilities: print(i) self._request(line, f)
[ "def", "do_list_cap", "(", "self", ",", "line", ")", ":", "def", "f", "(", "p", ",", "args", ")", ":", "for", "i", "in", "p", ".", "netconf", ".", "server_capabilities", ":", "print", "(", "i", ")", "self", ".", "_request", "(", "line", ",", "f", ")" ]
list_cap <peer>
[ "list_cap", "<peer", ">" ]
train
https://github.com/osrg/ryu/blob/6f906e72c92e10bd0264c9b91a2f7bb85b97780c/ryu/cmd/of_config_cli.py#L104-L112
<|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_cap <peer> ### Response: def do_list_cap(self, line): """list_cap <peer> """ def f(p, args): for i in p.netconf.server_capabilities: print(i) self._request(line, f) <|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, 1638, 16793, 366, 16944, 1363, 14711, 6075, 512, 755, 656, 2062, 16793, 1214, 11, 1584, 997, 286, 4304, 1638, 16793, 366, 16944, 397, 286, 12713, 286, 711, 282, 1319, 11, 2897, 997, 310, 369, 602, 304, 281, 5181, 6263, 12926, 93192, 512, 394, 1194, 1998, 696, 286, 659, 1462, 2079, 8973, 11, 282, 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,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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 1638, 16793, 366, 16944, 1363, 14711, 6075, 512, 755, 656, 2062, 16793, 1214, 11, 1584, 997, 286, 4304, 1638, 16793, 366, 16944, 397, 286, 12713, 286, 711, 282, 1319, 11, 2897, 997, 310, 369, 602, 304, 281, 5181, 6263, 12926, 93192, 512, 394, 1194, 1998, 696, 286, 659, 1462, 2079, 8973, 11, 282, 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 ]
acoomans/flask-autodoc
examples/factory/blog/frontend.py
post_post
def post_post(): """Create a new post. Form Data: title, content, authorid. """ authorid = request.form.get('authorid', None) Post(request.form['title'], request.form['content'], users[authorid]) return redirect("/posts")
python
def post_post(): """Create a new post. Form Data: title, content, authorid. """ authorid = request.form.get('authorid', None) Post(request.form['title'], request.form['content'], users[authorid]) return redirect("/posts")
[ "def", "post_post", "(", ")", ":", "authorid", "=", "request", ".", "form", ".", "get", "(", "'authorid'", ",", "None", ")", "Post", "(", "request", ".", "form", "[", "'title'", "]", ",", "request", ".", "form", "[", "'content'", "]", ",", "users", "[", "authorid", "]", ")", "return", "redirect", "(", "\"/posts\"", ")" ]
Create a new post. Form Data: title, content, authorid.
[ "Create", "a", "new", "post", ".", "Form", "Data", ":", "title", "content", "authorid", "." ]
train
https://github.com/acoomans/flask-autodoc/blob/6c77c8935b71fbf3243b5e589c5c255d0299d853/examples/factory/blog/frontend.py#L59-L67
<|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 post. Form Data: title, content, authorid. ### Response: def post_post(): """Create a new post. Form Data: title, content, authorid. """ authorid = request.form.get('authorid', None) Post(request.form['title'], request.form['content'], users[authorid]) return redirect("/posts") <|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, 1772, 627, 262, 3459, 2956, 25, 2316, 11, 2262, 11, 3229, 307, 382, 14711, 6075, 512, 755, 1772, 6467, 4019, 262, 4304, 4110, 264, 502, 1772, 627, 262, 3459, 2956, 25, 2316, 11, 2262, 11, 3229, 307, 627, 262, 3270, 262, 3229, 307, 284, 1715, 8726, 673, 493, 3170, 307, 518, 2290, 340, 262, 3962, 4980, 8726, 681, 2150, 4479, 260, 1715, 8726, 681, 1834, 4479, 260, 3932, 58, 3170, 307, 2608, 262, 471, 6559, 4380, 12953, 1158, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 4110, 264, 502, 1772, 627, 262, 3459, 2956, 25, 2316, 11, 2262, 11, 3229, 307, 382, 14711, 6075, 512, 755, 1772, 6467, 4019, 262, 4304, 4110, 264, 502, 1772, 627, 262, 3459, 2956, 25, 2316, 11, 2262, 11, 3229, 307, 627, 262, 3270, 262, 3229, 307, 284, 1715, 8726, 673, 493, 3170, 307, 518, 2290, 340, 262, 3962, 4980, 8726, 681, 2150, 4479, 260, 1715, 8726, 681, 1834, 4479, 260, 3932, 58, 3170, 307, 2608, 262, 471, 6559, 4380, 12953, 1158, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
dedupeio/dedupe
dedupe/api.py
GazetteerMatching.match
def match(self, messy_data, threshold=0.5, n_matches=1, generator=False): # pragma: no cover """Identifies pairs of records that refer to the same entity, returns tuples containing a set of record ids and a confidence score as a float between 0 and 1. The record_ids within each set should refer to the same entity and the confidence score is the estimated probability that the records refer to the same entity. This method should only used for small to moderately sized datasets for larger data, use matchBlocks Arguments: messy_data -- Dictionary of records from messy dataset, where the keys are record_ids and the values are dictionaries with the keys being field names threshold -- Number between 0 and 1 (default is .5). We will consider records as potential duplicates if the predicted probability of being a duplicate is above the threshold. Lowering the number will increase recall, raising it will increase precision n_matches -- Maximum number of possible matches from the canonical record set to match against each record in the messy record set """ blocked_pairs = self._blockData(messy_data) clusters = self.matchBlocks(blocked_pairs, threshold, n_matches) clusters = (cluster for cluster in clusters if len(cluster)) if generator: return clusters else: return list(clusters)
python
def match(self, messy_data, threshold=0.5, n_matches=1, generator=False): # pragma: no cover """Identifies pairs of records that refer to the same entity, returns tuples containing a set of record ids and a confidence score as a float between 0 and 1. The record_ids within each set should refer to the same entity and the confidence score is the estimated probability that the records refer to the same entity. This method should only used for small to moderately sized datasets for larger data, use matchBlocks Arguments: messy_data -- Dictionary of records from messy dataset, where the keys are record_ids and the values are dictionaries with the keys being field names threshold -- Number between 0 and 1 (default is .5). We will consider records as potential duplicates if the predicted probability of being a duplicate is above the threshold. Lowering the number will increase recall, raising it will increase precision n_matches -- Maximum number of possible matches from the canonical record set to match against each record in the messy record set """ blocked_pairs = self._blockData(messy_data) clusters = self.matchBlocks(blocked_pairs, threshold, n_matches) clusters = (cluster for cluster in clusters if len(cluster)) if generator: return clusters else: return list(clusters)
[ "def", "match", "(", "self", ",", "messy_data", ",", "threshold", "=", "0.5", ",", "n_matches", "=", "1", ",", "generator", "=", "False", ")", ":", "# pragma: no cover", "blocked_pairs", "=", "self", ".", "_blockData", "(", "messy_data", ")", "clusters", "=", "self", ".", "matchBlocks", "(", "blocked_pairs", ",", "threshold", ",", "n_matches", ")", "clusters", "=", "(", "cluster", "for", "cluster", "in", "clusters", "if", "len", "(", "cluster", ")", ")", "if", "generator", ":", "return", "clusters", "else", ":", "return", "list", "(", "clusters", ")" ]
Identifies pairs of records that refer to the same entity, returns tuples containing a set of record ids and a confidence score as a float between 0 and 1. The record_ids within each set should refer to the same entity and the confidence score is the estimated probability that the records refer to the same entity. This method should only used for small to moderately sized datasets for larger data, use matchBlocks Arguments: messy_data -- Dictionary of records from messy dataset, where the keys are record_ids and the values are dictionaries with the keys being field names threshold -- Number between 0 and 1 (default is .5). We will consider records as potential duplicates if the predicted probability of being a duplicate is above the threshold. Lowering the number will increase recall, raising it will increase precision n_matches -- Maximum number of possible matches from the canonical record set to match against each record in the messy record set
[ "Identifies", "pairs", "of", "records", "that", "refer", "to", "the", "same", "entity", "returns", "tuples", "containing", "a", "set", "of", "record", "ids", "and", "a", "confidence", "score", "as", "a", "float", "between", "0", "and", "1", ".", "The", "record_ids", "within", "each", "set", "should", "refer", "to", "the", "same", "entity", "and", "the", "confidence", "score", "is", "the", "estimated", "probability", "that", "the", "records", "refer", "to", "the", "same", "entity", "." ]
train
https://github.com/dedupeio/dedupe/blob/9f7c9f84473a4bcacf0f2b11152d8ed3eb35d48b/dedupe/api.py#L920-L955
<|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: Identifies pairs of records that refer to the same entity, returns tuples containing a set of record ids and a confidence score as a float between 0 and 1. The record_ids within each set should refer to the same entity and the confidence score is the estimated probability that the records refer to the same entity. This method should only used for small to moderately sized datasets for larger data, use matchBlocks Arguments: messy_data -- Dictionary of records from messy dataset, where the keys are record_ids and the values are dictionaries with the keys being field names threshold -- Number between 0 and 1 (default is .5). We will consider records as potential duplicates if the predicted probability of being a duplicate is above the threshold. Lowering the number will increase recall, raising it will increase precision n_matches -- Maximum number of possible matches from the canonical record set to match against each record in the messy record set ### Response: def match(self, messy_data, threshold=0.5, n_matches=1, generator=False): # pragma: no cover """Identifies pairs of records that refer to the same entity, returns tuples containing a set of record ids and a confidence score as a float between 0 and 1. The record_ids within each set should refer to the same entity and the confidence score is the estimated probability that the records refer to the same entity. This method should only used for small to moderately sized datasets for larger data, use matchBlocks Arguments: messy_data -- Dictionary of records from messy dataset, where the keys are record_ids and the values are dictionaries with the keys being field names threshold -- Number between 0 and 1 (default is .5). We will consider records as potential duplicates if the predicted probability of being a duplicate is above the threshold. Lowering the number will increase recall, raising it will increase precision n_matches -- Maximum number of possible matches from the canonical record set to match against each record in the messy record set """ blocked_pairs = self._blockData(messy_data) clusters = self.matchBlocks(blocked_pairs, threshold, n_matches) clusters = (cluster for cluster in clusters if len(cluster)) if generator: return clusters else: return list(clusters) <|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, 29401, 9803, 13840, 315, 7576, 430, 8464, 311, 279, 1890, 5502, 11, 4780, 198, 286, 46325, 8649, 264, 743, 315, 3335, 14483, 323, 264, 12410, 5573, 439, 264, 2273, 198, 286, 1990, 220, 15, 323, 220, 16, 13, 578, 3335, 8237, 2949, 1855, 743, 1288, 8464, 311, 279, 198, 286, 1890, 5502, 323, 279, 12410, 5573, 374, 279, 13240, 19463, 430, 198, 286, 279, 7576, 8464, 311, 279, 1890, 5502, 382, 286, 1115, 1749, 1288, 1193, 1511, 369, 2678, 311, 70351, 30387, 30525, 198, 286, 369, 8294, 828, 11, 1005, 2489, 30904, 271, 286, 28802, 512, 286, 46946, 1807, 1198, 10685, 315, 7576, 505, 46946, 10550, 11, 1405, 279, 198, 2611, 7039, 527, 3335, 8237, 323, 279, 2819, 527, 58614, 449, 198, 2611, 279, 7039, 1694, 2115, 5144, 271, 286, 12447, 1198, 5742, 1990, 220, 15, 323, 220, 16, 320, 2309, 374, 662, 20, 570, 1226, 690, 2980, 198, 3909, 7576, 439, 4754, 43428, 422, 279, 19698, 198, 3909, 19463, 315, 1694, 264, 23329, 374, 3485, 279, 12447, 382, 3909, 28636, 287, 279, 1396, 690, 5376, 19635, 11, 19054, 433, 198, 3909, 690, 5376, 16437, 271, 286, 308, 39444, 1198, 27697, 1396, 315, 3284, 9248, 505, 279, 43553, 198, 3909, 3335, 743, 311, 2489, 2403, 1855, 3335, 304, 279, 46946, 198, 3909, 3335, 743, 271, 14711, 6075, 512, 755, 2489, 1214, 11, 46946, 1807, 11, 12447, 28, 15, 13, 20, 11, 308, 39444, 28, 16, 11, 14143, 5725, 1680, 220, 674, 63220, 25, 912, 3504, 198, 286, 4304, 29401, 9803, 13840, 315, 7576, 430, 8464, 311, 279, 1890, 5502, 11, 4780, 198, 286, 46325, 8649, 264, 743, 315, 3335, 14483, 323, 264, 12410, 5573, 439, 264, 2273, 198, 286, 1990, 220, 15, 323, 220, 16, 13, 578, 3335, 8237, 2949, 1855, 743, 1288, 8464, 311, 279, 198, 286, 1890, 5502, 323, 279, 12410, 5573, 374, 279, 13240, 19463, 430, 198, 286, 279, 7576, 8464, 311, 279, 1890, 5502, 382, 286, 1115, 1749, 1288, 1193, 1511, 369, 2678, 311, 70351, 30387, 30525, 198, 286, 369, 8294, 828, 11, 1005, 2489, 30904, 271, 286, 28802, 512, 286, 46946, 1807, 1198, 10685, 315, 7576, 505, 46946, 10550, 11, 1405, 279, 198, 2611, 7039, 527, 3335, 8237, 323, 279, 2819, 527, 58614, 449, 198, 2611, 279, 7039, 1694, 2115, 5144, 271, 286, 12447, 1198, 5742, 1990, 220, 15, 323, 220, 16, 320, 2309, 374, 662, 20, 570, 1226, 690, 2980, 198, 3909, 7576, 439, 4754, 43428, 422, 279, 19698, 198, 3909, 19463, 315, 1694, 264, 23329, 374, 3485, 279, 12447, 382, 3909, 28636, 287, 279, 1396, 690, 5376, 19635, 11, 19054, 433, 198, 3909, 690, 5376, 16437, 271, 286, 308, 39444, 1198, 27697, 1396, 315, 3284, 9248, 505, 279, 43553, 198, 3909, 3335, 743, 311, 2489, 2403, 1855, 3335, 304, 279, 46946, 198, 3909, 3335, 743, 198, 286, 3270, 286, 19857, 37530, 284, 659, 1462, 4677, 1061 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 29401, 9803, 13840, 315, 7576, 430, 8464, 311, 279, 1890, 5502, 11, 4780, 198, 286, 46325, 8649, 264, 743, 315, 3335, 14483, 323, 264, 12410, 5573, 439, 264, 2273, 198, 286, 1990, 220, 15, 323, 220, 16, 13, 578, 3335, 8237, 2949, 1855, 743, 1288, 8464, 311, 279, 198, 286, 1890, 5502, 323, 279, 12410, 5573, 374, 279, 13240, 19463, 430, 198, 286, 279, 7576, 8464, 311, 279, 1890, 5502, 382, 286, 1115, 1749, 1288, 1193, 1511, 369, 2678, 311, 70351, 30387, 30525, 198, 286, 369, 8294, 828, 11, 1005, 2489, 30904, 271, 286, 28802, 512, 286, 46946, 1807, 1198, 10685, 315, 7576, 505, 46946, 10550, 11, 1405, 279, 198, 2611, 7039, 527, 3335, 8237, 323, 279, 2819, 527, 58614, 449, 198, 2611, 279, 7039, 1694, 2115, 5144, 271, 286, 12447, 1198, 5742, 1990, 220, 15, 323, 220, 16, 320, 2309, 374, 662, 20, 570, 1226, 690, 2980, 198, 3909, 7576, 439, 4754, 43428, 422, 279, 19698, 198, 3909, 19463, 315, 1694, 264, 23329, 374, 3485, 279, 12447, 382, 3909, 28636, 287, 279, 1396, 690, 5376, 19635, 11, 19054, 433, 198, 3909, 690, 5376, 16437, 271, 286, 308, 39444, 1198, 27697, 1396, 315, 3284, 9248, 505, 279, 43553, 198, 3909, 3335, 743, 311, 2489, 2403, 1855, 3335, 304, 279, 46946, 198, 3909, 3335, 743, 271, 14711, 6075, 512, 755, 2489, 1214, 11, 46946, 1807, 11, 12447, 28, 15, 13, 20, 11, 308, 39444, 28, 16, 11, 14143, 5725, 1680, 220, 674, 63220, 25, 912, 3504, 198, 286, 4304, 29401, 9803, 13840, 315, 7576, 430, 8464, 311, 279, 1890, 5502, 11, 4780, 198, 286, 46325, 8649, 264, 743, 315, 3335, 14483, 323, 264, 12410, 5573, 439, 264, 2273, 198, 286, 1990, 220, 15, 323, 220, 16, 13, 578, 3335, 8237, 2949, 1855, 743, 1288, 8464, 311, 279, 198, 286, 1890, 5502, 323, 279, 12410, 5573, 374, 279, 13240, 19463, 430, 198, 286, 279, 7576, 8464, 311, 279, 1890, 5502, 382, 286, 1115, 1749, 1288, 1193, 1511, 369, 2678, 311, 70351, 30387, 30525, 198, 286, 369, 8294, 828, 11, 1005, 2489, 30904, 271, 286, 28802, 512, 286, 46946, 1807, 1198, 10685, 315, 7576, 505, 46946, 10550, 11, 1405, 279, 198, 2611, 7039, 527, 3335, 8237, 323, 279, 2819, 527, 58614, 449, 198, 2611, 279, 7039, 1694, 2115, 5144, 271, 286, 12447, 1198, 5742, 1990, 220, 15, 323, 220, 16, 320, 2309, 374, 662, 20, 570, 1226, 690, 2980, 198, 3909, 7576, 439, 4754, 43428, 422, 279, 19698, 198, 3909, 19463, 315, 1694, 264, 23329, 374, 3485, 279, 12447, 382, 3909, 28636, 287, 279, 1396, 690, 5376, 19635, 11, 19054, 433, 198, 3909, 690, 5376, 16437, 271, 286, 308, 39444, 1198, 27697, 1396, 315, 3284, 9248, 505, 279, 43553, 198, 3909, 3335, 743, 311, 2489, 2403, 1855, 3335, 304, 279, 46946, 198, 3909, 3335, 743, 198, 286, 3270, 286, 19857, 37530, 284, 659, 1462, 4677, 1061 ]
apache/spark
python/pyspark/sql/functions.py
when
def when(condition, value): """Evaluates a list of conditions and returns one of multiple possible result expressions. If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions. :param condition: a boolean :class:`Column` expression. :param value: a literal value, or a :class:`Column` expression. >>> df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect() [Row(age=3), Row(age=4)] >>> df.select(when(df.age == 2, df.age + 1).alias("age")).collect() [Row(age=3), Row(age=None)] """ sc = SparkContext._active_spark_context if not isinstance(condition, Column): raise TypeError("condition should be a Column") v = value._jc if isinstance(value, Column) else value jc = sc._jvm.functions.when(condition._jc, v) return Column(jc)
python
def when(condition, value): """Evaluates a list of conditions and returns one of multiple possible result expressions. If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions. :param condition: a boolean :class:`Column` expression. :param value: a literal value, or a :class:`Column` expression. >>> df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect() [Row(age=3), Row(age=4)] >>> df.select(when(df.age == 2, df.age + 1).alias("age")).collect() [Row(age=3), Row(age=None)] """ sc = SparkContext._active_spark_context if not isinstance(condition, Column): raise TypeError("condition should be a Column") v = value._jc if isinstance(value, Column) else value jc = sc._jvm.functions.when(condition._jc, v) return Column(jc)
[ "def", "when", "(", "condition", ",", "value", ")", ":", "sc", "=", "SparkContext", ".", "_active_spark_context", "if", "not", "isinstance", "(", "condition", ",", "Column", ")", ":", "raise", "TypeError", "(", "\"condition should be a Column\"", ")", "v", "=", "value", ".", "_jc", "if", "isinstance", "(", "value", ",", "Column", ")", "else", "value", "jc", "=", "sc", ".", "_jvm", ".", "functions", ".", "when", "(", "condition", ".", "_jc", ",", "v", ")", "return", "Column", "(", "jc", ")" ]
Evaluates a list of conditions and returns one of multiple possible result expressions. If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions. :param condition: a boolean :class:`Column` expression. :param value: a literal value, or a :class:`Column` expression. >>> df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect() [Row(age=3), Row(age=4)] >>> df.select(when(df.age == 2, df.age + 1).alias("age")).collect() [Row(age=3), Row(age=None)]
[ "Evaluates", "a", "list", "of", "conditions", "and", "returns", "one", "of", "multiple", "possible", "result", "expressions", ".", "If", ":", "func", ":", "Column", ".", "otherwise", "is", "not", "invoked", "None", "is", "returned", "for", "unmatched", "conditions", "." ]
train
https://github.com/apache/spark/blob/618d6bff71073c8c93501ab7392c3cc579730f0b/python/pyspark/sql/functions.py#L756-L774
<|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: Evaluates a list of conditions and returns one of multiple possible result expressions. If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions. :param condition: a boolean :class:`Column` expression. :param value: a literal value, or a :class:`Column` expression. >>> df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect() [Row(age=3), Row(age=4)] >>> df.select(when(df.age == 2, df.age + 1).alias("age")).collect() [Row(age=3), Row(age=None)] ### Response: def when(condition, value): """Evaluates a list of conditions and returns one of multiple possible result expressions. If :func:`Column.otherwise` is not invoked, None is returned for unmatched conditions. :param condition: a boolean :class:`Column` expression. :param value: a literal value, or a :class:`Column` expression. >>> df.select(when(df['age'] == 2, 3).otherwise(4).alias("age")).collect() [Row(age=3), Row(age=4)] >>> df.select(when(df.age == 2, df.age + 1).alias("age")).collect() [Row(age=3), Row(age=None)] """ sc = SparkContext._active_spark_context if not isinstance(condition, Column): raise TypeError("condition should be a Column") v = value._jc if isinstance(value, Column) else value jc = sc._jvm.functions.when(condition._jc, v) return Column(jc) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 36, 26591, 988, 264, 1160, 315, 4787, 323, 4780, 832, 315, 5361, 3284, 1121, 24282, 627, 262, 1442, 551, 2900, 19258, 3006, 48881, 4583, 63, 374, 539, 27979, 11, 2290, 374, 6052, 369, 69477, 4787, 382, 262, 551, 913, 3044, 25, 264, 2777, 551, 1058, 19258, 3006, 63, 7645, 627, 262, 551, 913, 907, 25, 264, 24016, 907, 11, 477, 264, 551, 1058, 19258, 3006, 63, 7645, 382, 262, 12382, 6907, 9911, 7, 9493, 16446, 681, 425, 663, 624, 220, 17, 11, 220, 18, 570, 61036, 7, 19, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 28, 19, 28871, 262, 12382, 6907, 9911, 7, 9493, 16446, 31910, 624, 220, 17, 11, 6907, 31910, 489, 220, 16, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 5980, 28871, 14711, 6075, 512, 755, 994, 48589, 11, 907, 997, 262, 4304, 36, 26591, 988, 264, 1160, 315, 4787, 323, 4780, 832, 315, 5361, 3284, 1121, 24282, 627, 262, 1442, 551, 2900, 19258, 3006, 48881, 4583, 63, 374, 539, 27979, 11, 2290, 374, 6052, 369, 69477, 4787, 382, 262, 551, 913, 3044, 25, 264, 2777, 551, 1058, 19258, 3006, 63, 7645, 627, 262, 551, 913, 907, 25, 264, 24016, 907, 11, 477, 264, 551, 1058, 19258, 3006, 63, 7645, 382, 262, 12382, 6907, 9911, 7, 9493, 16446, 681, 425, 663, 624, 220, 17, 11, 220, 18, 570, 61036, 7, 19, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 28, 19, 28871, 262, 12382, 6907, 9911, 7, 9493, 16446, 31910, 624, 220, 17, 11, 6907, 31910, 489, 220, 16, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 5980, 5680, 262, 3270, 262, 1156, 284, 27565, 2014, 1462, 3104, 10331, 847, 8634, 198, 262, 422, 539, 11656, 48589, 11, 9516, 997, 286, 4933, 26082, 446, 9233, 1288, 387, 264, 9516, 1158, 262, 348, 284, 907, 1462, 64087, 422, 11656, 3764, 11, 9516, 8, 775, 907, 198, 262, 73918, 284, 1156, 1462, 73, 7488, 50374, 41700, 48589, 1462, 64087, 11, 348, 340, 262, 471, 9516, 3406, 66, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 36, 26591, 988, 264, 1160, 315, 4787, 323, 4780, 832, 315, 5361, 3284, 1121, 24282, 627, 262, 1442, 551, 2900, 19258, 3006, 48881, 4583, 63, 374, 539, 27979, 11, 2290, 374, 6052, 369, 69477, 4787, 382, 262, 551, 913, 3044, 25, 264, 2777, 551, 1058, 19258, 3006, 63, 7645, 627, 262, 551, 913, 907, 25, 264, 24016, 907, 11, 477, 264, 551, 1058, 19258, 3006, 63, 7645, 382, 262, 12382, 6907, 9911, 7, 9493, 16446, 681, 425, 663, 624, 220, 17, 11, 220, 18, 570, 61036, 7, 19, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 28, 19, 28871, 262, 12382, 6907, 9911, 7, 9493, 16446, 31910, 624, 220, 17, 11, 6907, 31910, 489, 220, 16, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 5980, 28871, 14711, 6075, 512, 755, 994, 48589, 11, 907, 997, 262, 4304, 36, 26591, 988, 264, 1160, 315, 4787, 323, 4780, 832, 315, 5361, 3284, 1121, 24282, 627, 262, 1442, 551, 2900, 19258, 3006, 48881, 4583, 63, 374, 539, 27979, 11, 2290, 374, 6052, 369, 69477, 4787, 382, 262, 551, 913, 3044, 25, 264, 2777, 551, 1058, 19258, 3006, 63, 7645, 627, 262, 551, 913, 907, 25, 264, 24016, 907, 11, 477, 264, 551, 1058, 19258, 3006, 63, 7645, 382, 262, 12382, 6907, 9911, 7, 9493, 16446, 681, 425, 663, 624, 220, 17, 11, 220, 18, 570, 61036, 7, 19, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 28, 19, 28871, 262, 12382, 6907, 9911, 7, 9493, 16446, 31910, 624, 220, 17, 11, 6907, 31910, 489, 220, 16, 570, 15305, 446, 425, 15552, 17840, 746, 262, 510, 3179, 67695, 28, 18, 705, 11035, 67695, 5980, 5680, 262, 3270, 262, 1156, 284, 27565, 2014, 1462, 3104, 10331, 847, 8634, 198, 262, 422, 539, 11656, 48589, 11, 9516, 997, 286, 4933, 26082, 446, 9233, 1288, 387, 264, 9516, 1158, 262, 348, 284, 907, 1462, 64087, 422, 11656, 3764, 11, 9516, 8, 775, 907, 198, 262, 73918, 284, 1156, 1462, 73, 7488, 50374, 41700, 48589, 1462, 64087, 11, 348, 340, 262, 471, 9516, 3406, 66, 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 ]
Pipoline/rocket-python
rocketchat/api.py
RocketChatAPI.get_user_info
def get_user_info(self, user_id, **kwargs): """ Retrieves information about a user, the result is only limited to what the callee has access to view. :param user_id: :param kwargs: :return: """ return GetUserInfo(settings=self.settings, **kwargs).call( user_id=user_id, **kwargs )
python
def get_user_info(self, user_id, **kwargs): """ Retrieves information about a user, the result is only limited to what the callee has access to view. :param user_id: :param kwargs: :return: """ return GetUserInfo(settings=self.settings, **kwargs).call( user_id=user_id, **kwargs )
[ "def", "get_user_info", "(", "self", ",", "user_id", ",", "*", "*", "kwargs", ")", ":", "return", "GetUserInfo", "(", "settings", "=", "self", ".", "settings", ",", "*", "*", "kwargs", ")", ".", "call", "(", "user_id", "=", "user_id", ",", "*", "*", "kwargs", ")" ]
Retrieves information about a user, the result is only limited to what the callee has access to view. :param user_id: :param kwargs: :return:
[ "Retrieves", "information", "about", "a", "user", "the", "result", "is", "only", "limited", "to", "what", "the", "callee", "has", "access", "to", "view", ".", ":", "param", "user_id", ":", ":", "param", "kwargs", ":", ":", "return", ":" ]
train
https://github.com/Pipoline/rocket-python/blob/643ece8a9db106922e019984a859ca04283262ff/rocketchat/api.py#L180-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: Retrieves information about a user, the result is only limited to what the callee has access to view. :param user_id: :param kwargs: :return: ### Response: def get_user_info(self, user_id, **kwargs): """ Retrieves information about a user, the result is only limited to what the callee has access to view. :param user_id: :param kwargs: :return: """ return GetUserInfo(settings=self.settings, **kwargs).call( user_id=user_id, **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, 12289, 7379, 2396, 2038, 922, 264, 1217, 345, 286, 279, 1121, 374, 1193, 7347, 311, 1148, 279, 95900, 706, 2680, 311, 1684, 627, 286, 551, 913, 1217, 851, 512, 286, 551, 913, 16901, 512, 286, 551, 693, 1473, 14711, 6075, 512, 755, 636, 3398, 3186, 1214, 11, 1217, 851, 11, 3146, 9872, 997, 286, 3270, 286, 49761, 2038, 922, 264, 1217, 345, 286, 279, 1121, 374, 1193, 7347, 311, 1148, 279, 95900, 706, 2680, 311, 1684, 627, 286, 551, 913, 1217, 851, 512, 286, 551, 913, 16901, 512, 286, 551, 693, 512, 286, 3270, 286, 471, 2175, 37258, 24258, 7822, 16728, 11, 3146, 9872, 570, 6797, 1021, 310, 1217, 851, 31264, 851, 345, 310, 3146, 9872, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 12289, 7379, 2396, 2038, 922, 264, 1217, 345, 286, 279, 1121, 374, 1193, 7347, 311, 1148, 279, 95900, 706, 2680, 311, 1684, 627, 286, 551, 913, 1217, 851, 512, 286, 551, 913, 16901, 512, 286, 551, 693, 1473, 14711, 6075, 512, 755, 636, 3398, 3186, 1214, 11, 1217, 851, 11, 3146, 9872, 997, 286, 3270, 286, 49761, 2038, 922, 264, 1217, 345, 286, 279, 1121, 374, 1193, 7347, 311, 1148, 279, 95900, 706, 2680, 311, 1684, 627, 286, 551, 913, 1217, 851, 512, 286, 551, 913, 16901, 512, 286, 551, 693, 512, 286, 3270, 286, 471, 2175, 37258, 24258, 7822, 16728, 11, 3146, 9872, 570, 6797, 1021, 310, 1217, 851, 31264, 851, 345, 310, 3146, 9872, 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, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
eqcorrscan/EQcorrscan
eqcorrscan/utils/mag_calc.py
calc_b_value
def calc_b_value(magnitudes, completeness, max_mag=None, plotvar=True): """ Calculate the b-value for a range of completeness magnitudes. Calculates a power-law fit to given magnitudes for each completeness magnitude. Plots the b-values and residuals for the fitted catalogue against the completeness values. Computes fits using numpy.polyfit, which uses a least-squares technique. :type magnitudes: list :param magnitudes: Magnitudes to compute the b-value for. :type completeness: list :param completeness: list of completeness values to compute b-values for. :type max_mag: float :param max_mag: Maximum magnitude to attempt to fit in magnitudes. :type plotvar: bool :param plotvar: Turn plotting on or off. :rtype: list :return: List of tuples of (completeness, b-value, residual,\ number of magnitudes used) .. rubric:: Example >>> from obspy.clients.fdsn import Client >>> from obspy import UTCDateTime >>> from eqcorrscan.utils.mag_calc import calc_b_value >>> client = Client('IRIS') >>> t1 = UTCDateTime('2012-03-26T00:00:00') >>> t2 = t1 + (3 * 86400) >>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3) >>> magnitudes = [event.magnitudes[0].mag for event in catalog] >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False) >>> round(b_values[4][1]) 1.0 >>> # We can set a maximum magnitude: >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False, max_mag=5) >>> round(b_values[4][1]) 1.0 """ b_values = [] # Calculate the cdf for all magnitudes counts = Counter(magnitudes) cdf = np.zeros(len(counts)) mag_steps = np.zeros(len(counts)) for i, magnitude in enumerate(sorted(counts.keys(), reverse=True)): mag_steps[i] = magnitude if i > 0: cdf[i] = cdf[i - 1] + counts[magnitude] else: cdf[i] = counts[magnitude] if not max_mag: max_mag = max(magnitudes) for m_c in completeness: if m_c >= max_mag or m_c >= max(magnitudes): warnings.warn('Not computing completeness at %s, above max_mag' % str(m_c)) break complete_mags = [] complete_freq = [] for i, mag in enumerate(mag_steps): if mag >= m_c <= max_mag: complete_mags.append(mag) complete_freq.append(np.log10(cdf[i])) if len(complete_mags) < 4: warnings.warn('Not computing completeness above ' + str(m_c) + ', fewer than 4 events') break fit = np.polyfit(complete_mags, complete_freq, 1, full=True) # Calculate the residuals according to the Wiemer & Wys 2000 definition predicted_freqs = [fit[0][1] - abs(fit[0][0] * M) for M in complete_mags] r = 100 - ((np.sum([abs(complete_freq[i] - predicted_freqs[i]) for i in range(len(complete_freq))]) * 100) / np.sum(complete_freq)) b_values.append((m_c, abs(fit[0][0]), r, str(len(complete_mags)))) if plotvar: fig, ax1 = plt.subplots() b_vals = ax1.scatter(list(zip(*b_values))[0], list(zip(*b_values))[1], c='k') resid = ax1.scatter(list(zip(*b_values))[0], [100 - b for b in list(zip(*b_values))[2]], c='r') ax1.set_ylabel('b-value and residual') plt.xlabel('Completeness magnitude') ax2 = ax1.twinx() ax2.set_ylabel('Number of events used in fit') n_ev = ax2.scatter(list(zip(*b_values))[0], list(zip(*b_values))[3], c='g') fig.legend((b_vals, resid, n_ev), ('b-values', 'residuals', 'number of events'), 'lower right') ax1.set_title('Possible completeness values') plt.show() return b_values
python
def calc_b_value(magnitudes, completeness, max_mag=None, plotvar=True): """ Calculate the b-value for a range of completeness magnitudes. Calculates a power-law fit to given magnitudes for each completeness magnitude. Plots the b-values and residuals for the fitted catalogue against the completeness values. Computes fits using numpy.polyfit, which uses a least-squares technique. :type magnitudes: list :param magnitudes: Magnitudes to compute the b-value for. :type completeness: list :param completeness: list of completeness values to compute b-values for. :type max_mag: float :param max_mag: Maximum magnitude to attempt to fit in magnitudes. :type plotvar: bool :param plotvar: Turn plotting on or off. :rtype: list :return: List of tuples of (completeness, b-value, residual,\ number of magnitudes used) .. rubric:: Example >>> from obspy.clients.fdsn import Client >>> from obspy import UTCDateTime >>> from eqcorrscan.utils.mag_calc import calc_b_value >>> client = Client('IRIS') >>> t1 = UTCDateTime('2012-03-26T00:00:00') >>> t2 = t1 + (3 * 86400) >>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3) >>> magnitudes = [event.magnitudes[0].mag for event in catalog] >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False) >>> round(b_values[4][1]) 1.0 >>> # We can set a maximum magnitude: >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False, max_mag=5) >>> round(b_values[4][1]) 1.0 """ b_values = [] # Calculate the cdf for all magnitudes counts = Counter(magnitudes) cdf = np.zeros(len(counts)) mag_steps = np.zeros(len(counts)) for i, magnitude in enumerate(sorted(counts.keys(), reverse=True)): mag_steps[i] = magnitude if i > 0: cdf[i] = cdf[i - 1] + counts[magnitude] else: cdf[i] = counts[magnitude] if not max_mag: max_mag = max(magnitudes) for m_c in completeness: if m_c >= max_mag or m_c >= max(magnitudes): warnings.warn('Not computing completeness at %s, above max_mag' % str(m_c)) break complete_mags = [] complete_freq = [] for i, mag in enumerate(mag_steps): if mag >= m_c <= max_mag: complete_mags.append(mag) complete_freq.append(np.log10(cdf[i])) if len(complete_mags) < 4: warnings.warn('Not computing completeness above ' + str(m_c) + ', fewer than 4 events') break fit = np.polyfit(complete_mags, complete_freq, 1, full=True) # Calculate the residuals according to the Wiemer & Wys 2000 definition predicted_freqs = [fit[0][1] - abs(fit[0][0] * M) for M in complete_mags] r = 100 - ((np.sum([abs(complete_freq[i] - predicted_freqs[i]) for i in range(len(complete_freq))]) * 100) / np.sum(complete_freq)) b_values.append((m_c, abs(fit[0][0]), r, str(len(complete_mags)))) if plotvar: fig, ax1 = plt.subplots() b_vals = ax1.scatter(list(zip(*b_values))[0], list(zip(*b_values))[1], c='k') resid = ax1.scatter(list(zip(*b_values))[0], [100 - b for b in list(zip(*b_values))[2]], c='r') ax1.set_ylabel('b-value and residual') plt.xlabel('Completeness magnitude') ax2 = ax1.twinx() ax2.set_ylabel('Number of events used in fit') n_ev = ax2.scatter(list(zip(*b_values))[0], list(zip(*b_values))[3], c='g') fig.legend((b_vals, resid, n_ev), ('b-values', 'residuals', 'number of events'), 'lower right') ax1.set_title('Possible completeness values') plt.show() return b_values
[ "def", "calc_b_value", "(", "magnitudes", ",", "completeness", ",", "max_mag", "=", "None", ",", "plotvar", "=", "True", ")", ":", "b_values", "=", "[", "]", "# Calculate the cdf for all magnitudes", "counts", "=", "Counter", "(", "magnitudes", ")", "cdf", "=", "np", ".", "zeros", "(", "len", "(", "counts", ")", ")", "mag_steps", "=", "np", ".", "zeros", "(", "len", "(", "counts", ")", ")", "for", "i", ",", "magnitude", "in", "enumerate", "(", "sorted", "(", "counts", ".", "keys", "(", ")", ",", "reverse", "=", "True", ")", ")", ":", "mag_steps", "[", "i", "]", "=", "magnitude", "if", "i", ">", "0", ":", "cdf", "[", "i", "]", "=", "cdf", "[", "i", "-", "1", "]", "+", "counts", "[", "magnitude", "]", "else", ":", "cdf", "[", "i", "]", "=", "counts", "[", "magnitude", "]", "if", "not", "max_mag", ":", "max_mag", "=", "max", "(", "magnitudes", ")", "for", "m_c", "in", "completeness", ":", "if", "m_c", ">=", "max_mag", "or", "m_c", ">=", "max", "(", "magnitudes", ")", ":", "warnings", ".", "warn", "(", "'Not computing completeness at %s, above max_mag'", "%", "str", "(", "m_c", ")", ")", "break", "complete_mags", "=", "[", "]", "complete_freq", "=", "[", "]", "for", "i", ",", "mag", "in", "enumerate", "(", "mag_steps", ")", ":", "if", "mag", ">=", "m_c", "<=", "max_mag", ":", "complete_mags", ".", "append", "(", "mag", ")", "complete_freq", ".", "append", "(", "np", ".", "log10", "(", "cdf", "[", "i", "]", ")", ")", "if", "len", "(", "complete_mags", ")", "<", "4", ":", "warnings", ".", "warn", "(", "'Not computing completeness above '", "+", "str", "(", "m_c", ")", "+", "', fewer than 4 events'", ")", "break", "fit", "=", "np", ".", "polyfit", "(", "complete_mags", ",", "complete_freq", ",", "1", ",", "full", "=", "True", ")", "# Calculate the residuals according to the Wiemer & Wys 2000 definition", "predicted_freqs", "=", "[", "fit", "[", "0", "]", "[", "1", "]", "-", "abs", "(", "fit", "[", "0", "]", "[", "0", "]", "*", "M", ")", "for", "M", "in", "complete_mags", "]", "r", "=", "100", "-", "(", "(", "np", ".", "sum", "(", "[", "abs", "(", "complete_freq", "[", "i", "]", "-", "predicted_freqs", "[", "i", "]", ")", "for", "i", "in", "range", "(", "len", "(", "complete_freq", ")", ")", "]", ")", "*", "100", ")", "/", "np", ".", "sum", "(", "complete_freq", ")", ")", "b_values", ".", "append", "(", "(", "m_c", ",", "abs", "(", "fit", "[", "0", "]", "[", "0", "]", ")", ",", "r", ",", "str", "(", "len", "(", "complete_mags", ")", ")", ")", ")", "if", "plotvar", ":", "fig", ",", "ax1", "=", "plt", ".", "subplots", "(", ")", "b_vals", "=", "ax1", ".", "scatter", "(", "list", "(", "zip", "(", "*", "b_values", ")", ")", "[", "0", "]", ",", "list", "(", "zip", "(", "*", "b_values", ")", ")", "[", "1", "]", ",", "c", "=", "'k'", ")", "resid", "=", "ax1", ".", "scatter", "(", "list", "(", "zip", "(", "*", "b_values", ")", ")", "[", "0", "]", ",", "[", "100", "-", "b", "for", "b", "in", "list", "(", "zip", "(", "*", "b_values", ")", ")", "[", "2", "]", "]", ",", "c", "=", "'r'", ")", "ax1", ".", "set_ylabel", "(", "'b-value and residual'", ")", "plt", ".", "xlabel", "(", "'Completeness magnitude'", ")", "ax2", "=", "ax1", ".", "twinx", "(", ")", "ax2", ".", "set_ylabel", "(", "'Number of events used in fit'", ")", "n_ev", "=", "ax2", ".", "scatter", "(", "list", "(", "zip", "(", "*", "b_values", ")", ")", "[", "0", "]", ",", "list", "(", "zip", "(", "*", "b_values", ")", ")", "[", "3", "]", ",", "c", "=", "'g'", ")", "fig", ".", "legend", "(", "(", "b_vals", ",", "resid", ",", "n_ev", ")", ",", "(", "'b-values'", ",", "'residuals'", ",", "'number of events'", ")", ",", "'lower right'", ")", "ax1", ".", "set_title", "(", "'Possible completeness values'", ")", "plt", ".", "show", "(", ")", "return", "b_values" ]
Calculate the b-value for a range of completeness magnitudes. Calculates a power-law fit to given magnitudes for each completeness magnitude. Plots the b-values and residuals for the fitted catalogue against the completeness values. Computes fits using numpy.polyfit, which uses a least-squares technique. :type magnitudes: list :param magnitudes: Magnitudes to compute the b-value for. :type completeness: list :param completeness: list of completeness values to compute b-values for. :type max_mag: float :param max_mag: Maximum magnitude to attempt to fit in magnitudes. :type plotvar: bool :param plotvar: Turn plotting on or off. :rtype: list :return: List of tuples of (completeness, b-value, residual,\ number of magnitudes used) .. rubric:: Example >>> from obspy.clients.fdsn import Client >>> from obspy import UTCDateTime >>> from eqcorrscan.utils.mag_calc import calc_b_value >>> client = Client('IRIS') >>> t1 = UTCDateTime('2012-03-26T00:00:00') >>> t2 = t1 + (3 * 86400) >>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3) >>> magnitudes = [event.magnitudes[0].mag for event in catalog] >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False) >>> round(b_values[4][1]) 1.0 >>> # We can set a maximum magnitude: >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False, max_mag=5) >>> round(b_values[4][1]) 1.0
[ "Calculate", "the", "b", "-", "value", "for", "a", "range", "of", "completeness", "magnitudes", "." ]
train
https://github.com/eqcorrscan/EQcorrscan/blob/3121b4aca801ee5d38f56ca297ce1c0f9515d9ff/eqcorrscan/utils/mag_calc.py#L132-L228
<|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: Calculate the b-value for a range of completeness magnitudes. Calculates a power-law fit to given magnitudes for each completeness magnitude. Plots the b-values and residuals for the fitted catalogue against the completeness values. Computes fits using numpy.polyfit, which uses a least-squares technique. :type magnitudes: list :param magnitudes: Magnitudes to compute the b-value for. :type completeness: list :param completeness: list of completeness values to compute b-values for. :type max_mag: float :param max_mag: Maximum magnitude to attempt to fit in magnitudes. :type plotvar: bool :param plotvar: Turn plotting on or off. :rtype: list :return: List of tuples of (completeness, b-value, residual,\ number of magnitudes used) .. rubric:: Example >>> from obspy.clients.fdsn import Client >>> from obspy import UTCDateTime >>> from eqcorrscan.utils.mag_calc import calc_b_value >>> client = Client('IRIS') >>> t1 = UTCDateTime('2012-03-26T00:00:00') >>> t2 = t1 + (3 * 86400) >>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3) >>> magnitudes = [event.magnitudes[0].mag for event in catalog] >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False) >>> round(b_values[4][1]) 1.0 >>> # We can set a maximum magnitude: >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False, max_mag=5) >>> round(b_values[4][1]) 1.0 ### Response: def calc_b_value(magnitudes, completeness, max_mag=None, plotvar=True): """ Calculate the b-value for a range of completeness magnitudes. Calculates a power-law fit to given magnitudes for each completeness magnitude. Plots the b-values and residuals for the fitted catalogue against the completeness values. Computes fits using numpy.polyfit, which uses a least-squares technique. :type magnitudes: list :param magnitudes: Magnitudes to compute the b-value for. :type completeness: list :param completeness: list of completeness values to compute b-values for. :type max_mag: float :param max_mag: Maximum magnitude to attempt to fit in magnitudes. :type plotvar: bool :param plotvar: Turn plotting on or off. :rtype: list :return: List of tuples of (completeness, b-value, residual,\ number of magnitudes used) .. rubric:: Example >>> from obspy.clients.fdsn import Client >>> from obspy import UTCDateTime >>> from eqcorrscan.utils.mag_calc import calc_b_value >>> client = Client('IRIS') >>> t1 = UTCDateTime('2012-03-26T00:00:00') >>> t2 = t1 + (3 * 86400) >>> catalog = client.get_events(starttime=t1, endtime=t2, minmagnitude=3) >>> magnitudes = [event.magnitudes[0].mag for event in catalog] >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False) >>> round(b_values[4][1]) 1.0 >>> # We can set a maximum magnitude: >>> b_values = calc_b_value(magnitudes, completeness=np.arange(3, 7, 0.2), ... plotvar=False, max_mag=5) >>> round(b_values[4][1]) 1.0 """ b_values = [] # Calculate the cdf for all magnitudes counts = Counter(magnitudes) cdf = np.zeros(len(counts)) mag_steps = np.zeros(len(counts)) for i, magnitude in enumerate(sorted(counts.keys(), reverse=True)): mag_steps[i] = magnitude if i > 0: cdf[i] = cdf[i - 1] + counts[magnitude] else: cdf[i] = counts[magnitude] if not max_mag: max_mag = max(magnitudes) for m_c in completeness: if m_c >= max_mag or m_c >= max(magnitudes): warnings.warn('Not computing completeness at %s, above max_mag' % str(m_c)) break complete_mags = [] complete_freq = [] for i, mag in enumerate(mag_steps): if mag >= m_c <= max_mag: complete_mags.append(mag) complete_freq.append(np.log10(cdf[i])) if len(complete_mags) < 4: warnings.warn('Not computing completeness above ' + str(m_c) + ', fewer than 4 events') break fit = np.polyfit(complete_mags, complete_freq, 1, full=True) # Calculate the residuals according to the Wiemer & Wys 2000 definition predicted_freqs = [fit[0][1] - abs(fit[0][0] * M) for M in complete_mags] r = 100 - ((np.sum([abs(complete_freq[i] - predicted_freqs[i]) for i in range(len(complete_freq))]) * 100) / np.sum(complete_freq)) b_values.append((m_c, abs(fit[0][0]), r, str(len(complete_mags)))) if plotvar: fig, ax1 = plt.subplots() b_vals = ax1.scatter(list(zip(*b_values))[0], list(zip(*b_values))[1], c='k') resid = ax1.scatter(list(zip(*b_values))[0], [100 - b for b in list(zip(*b_values))[2]], c='r') ax1.set_ylabel('b-value and residual') plt.xlabel('Completeness magnitude') ax2 = ax1.twinx() ax2.set_ylabel('Number of events used in fit') n_ev = ax2.scatter(list(zip(*b_values))[0], list(zip(*b_values))[3], c='g') fig.legend((b_vals, resid, n_ev), ('b-values', 'residuals', 'number of events'), 'lower right') ax1.set_title('Possible completeness values') plt.show() return b_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, 48966, 279, 293, 19625, 369, 264, 2134, 315, 80414, 8622, 21237, 382, 262, 60953, 264, 2410, 31412, 5052, 311, 2728, 8622, 21237, 369, 1855, 80414, 198, 262, 26703, 13, 220, 1856, 2469, 279, 293, 70150, 323, 98640, 369, 279, 29441, 49639, 198, 262, 2403, 279, 80414, 2819, 13, 66075, 18809, 1701, 8760, 65681, 6410, 345, 262, 902, 5829, 264, 3325, 1355, 41956, 15105, 382, 262, 551, 1337, 8622, 21237, 25, 1160, 198, 262, 551, 913, 8622, 21237, 25, 20918, 21237, 311, 12849, 279, 293, 19625, 369, 627, 262, 551, 1337, 80414, 25, 1160, 198, 262, 551, 913, 80414, 25, 1160, 315, 80414, 2819, 311, 12849, 293, 70150, 369, 627, 262, 551, 1337, 1973, 49410, 25, 2273, 198, 262, 551, 913, 1973, 49410, 25, 27697, 26703, 311, 4879, 311, 5052, 304, 8622, 21237, 627, 262, 551, 1337, 7234, 959, 25, 1845, 198, 262, 551, 913, 7234, 959, 25, 12268, 45002, 389, 477, 1022, 382, 262, 551, 33613, 25, 1160, 198, 262, 551, 693, 25, 1796, 315, 46325, 315, 320, 884, 698, 64197, 11, 293, 19625, 11, 33247, 43971, 286, 1396, 315, 8622, 21237, 1511, 696, 262, 5354, 10485, 2265, 487, 13688, 271, 262, 12382, 505, 7600, 3368, 50833, 840, 76236, 1179, 8589, 198, 262, 12382, 505, 7600, 3368, 1179, 28503, 7844, 198, 262, 12382, 505, 9116, 60377, 16810, 8576, 91776, 39341, 1179, 10241, 890, 3220, 198, 262, 12382, 3016, 284, 8589, 493, 2871, 1669, 1329, 262, 12382, 259, 16, 284, 28503, 7844, 493, 679, 17, 12, 2839, 12, 1627, 51, 410, 25, 410, 25, 410, 1329, 262, 12382, 259, 17, 284, 259, 16, 489, 320, 18, 353, 220, 19355, 410, 340, 262, 12382, 16808, 284, 3016, 673, 20269, 10865, 1712, 24957, 16, 11, 842, 1712, 24957, 17, 11, 1332, 97364, 28, 18, 340, 262, 12382, 8622, 21237, 284, 510, 3163, 749, 3326, 21237, 58, 15, 948, 31606, 369, 1567, 304, 16808, 933, 262, 12382, 293, 9324, 284, 10241, 890, 3220, 1278, 3326, 21237, 11, 80414, 17874, 25306, 7, 18, 11, 220, 22, 11, 220, 15, 13, 17, 1350, 262, 2564, 5218, 7234, 959, 5725, 340, 262, 12382, 4883, 1921, 9324, 58, 19, 1483, 16, 2608, 262, 220, 16, 13, 15, 198, 262, 12382, 674, 1226, 649, 743, 264, 7340, 26703, 512, 262, 12382, 293, 9324, 284, 10241, 890, 3220, 1278, 3326, 21237, 11, 80414, 17874, 25306, 7, 18, 11, 220, 22, 11, 220, 15, 13, 17, 1350, 262, 2564, 5218, 7234, 959, 5725, 11, 1973, 49410, 28, 20, 340, 262, 12382, 4883, 1921, 9324, 58, 19, 1483, 16, 2608, 262, 220, 16, 13, 15, 271, 14711, 6075, 512, 755, 10241, 890, 3220, 1278, 3326, 21237, 11, 80414, 11, 1973, 49410, 5980, 11, 7234, 959, 3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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 48966, 279, 293, 19625, 369, 264, 2134, 315, 80414, 8622, 21237, 382, 262, 60953, 264, 2410, 31412, 5052, 311, 2728, 8622, 21237, 369, 1855, 80414, 198, 262, 26703, 13, 220, 1856, 2469, 279, 293, 70150, 323, 98640, 369, 279, 29441, 49639, 198, 262, 2403, 279, 80414, 2819, 13, 66075, 18809, 1701, 8760, 65681, 6410, 345, 262, 902, 5829, 264, 3325, 1355, 41956, 15105, 382, 262, 551, 1337, 8622, 21237, 25, 1160, 198, 262, 551, 913, 8622, 21237, 25, 20918, 21237, 311, 12849, 279, 293, 19625, 369, 627, 262, 551, 1337, 80414, 25, 1160, 198, 262, 551, 913, 80414, 25, 1160, 315, 80414, 2819, 311, 12849, 293, 70150, 369, 627, 262, 551, 1337, 1973, 49410, 25, 2273, 198, 262, 551, 913, 1973, 49410, 25, 27697, 26703, 311, 4879, 311, 5052, 304, 8622, 21237, 627, 262, 551, 1337, 7234, 959, 25, 1845, 198, 262, 551, 913, 7234, 959, 25, 12268, 45002, 389, 477, 1022, 382, 262, 551, 33613, 25, 1160, 198, 262, 551, 693, 25, 1796, 315, 46325, 315, 320, 884, 698, 64197, 11, 293, 19625, 11, 33247, 43971, 286, 1396, 315, 8622, 21237, 1511, 696, 262, 5354, 10485, 2265, 487, 13688, 271, 262, 12382, 505, 7600, 3368, 50833, 840, 76236, 1179, 8589, 198, 262, 12382, 505, 7600, 3368, 1179, 28503, 7844, 198, 262, 12382, 505, 9116, 60377, 16810, 8576, 91776, 39341, 1179, 10241, 890, 3220, 198, 262, 12382, 3016, 284, 8589, 493, 2871, 1669, 1329, 262, 12382, 259, 16, 284, 28503, 7844, 493, 679, 17, 12, 2839, 12, 1627, 51, 410, 25, 410, 25, 410, 1329, 262, 12382, 259, 17, 284, 259, 16, 489, 320, 18, 353, 220, 19355, 410, 340, 262, 12382, 16808, 284, 3016, 673, 20269, 10865, 1712, 24957, 16, 11, 842, 1712, 24957, 17, 11, 1332, 97364, 28, 18, 340, 262, 12382, 8622, 21237, 284, 510, 3163, 749, 3326, 21237, 58, 15, 948, 31606, 369, 1567, 304, 16808, 933, 262, 12382, 293, 9324, 284, 10241, 890, 3220, 1278, 3326, 21237, 11, 80414, 17874, 25306, 7, 18, 11, 220, 22, 11, 220, 15, 13, 17, 1350, 262, 2564, 5218, 7234, 959, 5725, 340, 262, 12382, 4883, 1921, 9324, 58, 19, 1483, 16, 2608, 262, 220, 16, 13, 15, 198, 262, 12382, 674, 1226, 649, 743, 264, 7340, 26703, 512, 262, 12382, 293, 9324, 284, 10241, 890, 3220, 1278, 3326, 21237, 11, 80414, 17874, 25306, 7, 18, 11, 220, 22, 11, 220, 15, 13, 17, 1350, 262, 2564, 5218, 7234, 959, 5725, 11, 1973, 49410, 28, 20, 340, 262, 12382, 4883, 1921, 9324, 58, 19, 1483, 16, 2608, 262, 220, 16, 13, 15, 271, 14711, 6075, 512, 755, 10241, 890, 3220, 1278, 3326, 21237, 11, 80414, 11, 1973, 49410, 5980, 11, 7234, 959, 3702, 997, 262, 3270, 262, 21157, 279, 293, 19625, 369, 264, 2134, 315, 80414, 8622, 21237, 382, 262, 60953, 264, 2410, 31412, 5052, 311, 2728, 8622, 21237, 369, 1855, 80414 ]
carpedm20/fbchat
fbchat/_client.py
Client.setDefaultThread
def setDefaultThread(self, thread_id, thread_type): """ Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType """ self._default_thread_id = thread_id self._default_thread_type = thread_type
python
def setDefaultThread(self, thread_id, thread_type): """ Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType """ self._default_thread_id = thread_id self._default_thread_type = thread_type
[ "def", "setDefaultThread", "(", "self", ",", "thread_id", ",", "thread_type", ")", ":", "self", ".", "_default_thread_id", "=", "thread_id", "self", ".", "_default_thread_type", "=", "thread_type" ]
Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType
[ "Sets", "default", "thread", "to", "send", "messages", "to" ]
train
https://github.com/carpedm20/fbchat/blob/f480d68b5773473e6daba7f66075ee30e8d737a8/fbchat/_client.py#L550-L559
<|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 default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType ### Response: def setDefaultThread(self, thread_id, thread_type): """ Sets default thread to send messages to :param thread_id: User/Group ID to default to. See :ref:`intro_threads` :param thread_type: See :ref:`intro_threads` :type thread_type: models.ThreadType """ self._default_thread_id = thread_id self._default_thread_type = thread_type <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 31275, 1670, 4617, 311, 3708, 6743, 311, 271, 286, 551, 913, 4617, 851, 25, 2724, 14, 2878, 3110, 311, 1670, 311, 13, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 913, 4617, 1857, 25, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 1337, 4617, 1857, 25, 4211, 33132, 941, 271, 14711, 6075, 512, 755, 743, 3760, 6998, 1214, 11, 4617, 851, 11, 4617, 1857, 997, 286, 3270, 286, 12808, 1670, 4617, 311, 3708, 6743, 311, 271, 286, 551, 913, 4617, 851, 25, 2724, 14, 2878, 3110, 311, 1670, 311, 13, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 913, 4617, 1857, 25, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 1337, 4617, 1857, 25, 4211, 33132, 941, 198, 286, 3270, 286, 659, 1462, 2309, 11048, 851, 284, 4617, 851, 198, 286, 659, 1462, 2309, 11048, 1857, 284, 4617, 1857, 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, 128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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 31275, 1670, 4617, 311, 3708, 6743, 311, 271, 286, 551, 913, 4617, 851, 25, 2724, 14, 2878, 3110, 311, 1670, 311, 13, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 913, 4617, 1857, 25, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 1337, 4617, 1857, 25, 4211, 33132, 941, 271, 14711, 6075, 512, 755, 743, 3760, 6998, 1214, 11, 4617, 851, 11, 4617, 1857, 997, 286, 3270, 286, 12808, 1670, 4617, 311, 3708, 6743, 311, 271, 286, 551, 913, 4617, 851, 25, 2724, 14, 2878, 3110, 311, 1670, 311, 13, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 913, 4617, 1857, 25, 3580, 551, 1116, 19258, 37542, 30825, 4077, 286, 551, 1337, 4617, 1857, 25, 4211, 33132, 941, 198, 286, 3270, 286, 659, 1462, 2309, 11048, 851, 284, 4617, 851, 198, 286, 659, 1462, 2309, 11048, 1857, 284, 4617, 1857, 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 ]
SKA-ScienceDataProcessor/integration-prototype
sip/execution_control/configuration_db/sip_config_db/scheduling/workflow_definitions.py
get_workflow
def get_workflow(workflow_id: str, workflow_version: str) -> dict: """Get a workflow definition from the Configuration Database. Args: workflow_id (str): Workflow identifier workflow_version (str): Workflow version Returns: dict, Workflow definition dictionary """ name = "workflow_definitions:{}:{}".format(workflow_id, workflow_version) workflow = DB.get_hash_dict(name) workflow['stages'] = ast.literal_eval(workflow['stages']) return workflow
python
def get_workflow(workflow_id: str, workflow_version: str) -> dict: """Get a workflow definition from the Configuration Database. Args: workflow_id (str): Workflow identifier workflow_version (str): Workflow version Returns: dict, Workflow definition dictionary """ name = "workflow_definitions:{}:{}".format(workflow_id, workflow_version) workflow = DB.get_hash_dict(name) workflow['stages'] = ast.literal_eval(workflow['stages']) return workflow
[ "def", "get_workflow", "(", "workflow_id", ":", "str", ",", "workflow_version", ":", "str", ")", "->", "dict", ":", "name", "=", "\"workflow_definitions:{}:{}\"", ".", "format", "(", "workflow_id", ",", "workflow_version", ")", "workflow", "=", "DB", ".", "get_hash_dict", "(", "name", ")", "workflow", "[", "'stages'", "]", "=", "ast", ".", "literal_eval", "(", "workflow", "[", "'stages'", "]", ")", "return", "workflow" ]
Get a workflow definition from the Configuration Database. Args: workflow_id (str): Workflow identifier workflow_version (str): Workflow version Returns: dict, Workflow definition dictionary
[ "Get", "a", "workflow", "definition", "from", "the", "Configuration", "Database", "." ]
train
https://github.com/SKA-ScienceDataProcessor/integration-prototype/blob/8c8006de6ad71dcd44114b0338780738079c87d4/sip/execution_control/configuration_db/sip_config_db/scheduling/workflow_definitions.py#L91-L105
<|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 workflow definition from the Configuration Database. Args: workflow_id (str): Workflow identifier workflow_version (str): Workflow version Returns: dict, Workflow definition dictionary ### Response: def get_workflow(workflow_id: str, workflow_version: str) -> dict: """Get a workflow definition from the Configuration Database. Args: workflow_id (str): Workflow identifier workflow_version (str): Workflow version Returns: dict, Workflow definition dictionary """ name = "workflow_definitions:{}:{}".format(workflow_id, workflow_version) workflow = DB.get_hash_dict(name) workflow['stages'] = ast.literal_eval(workflow['stages']) return workflow <|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, 29388, 7419, 505, 279, 12499, 10199, 382, 262, 18161, 512, 286, 29388, 851, 320, 496, 1680, 61273, 13110, 198, 286, 29388, 9625, 320, 496, 1680, 61273, 2373, 271, 262, 5295, 512, 286, 6587, 11, 61273, 7419, 11240, 271, 14711, 6075, 512, 755, 636, 87518, 32570, 5072, 851, 25, 610, 11, 29388, 9625, 25, 610, 8, 1492, 6587, 512, 262, 4304, 1991, 264, 29388, 7419, 505, 279, 12499, 10199, 382, 262, 18161, 512, 286, 29388, 851, 320, 496, 1680, 61273, 13110, 198, 286, 29388, 9625, 320, 496, 1680, 61273, 2373, 271, 262, 5295, 512, 286, 6587, 11, 61273, 7419, 11240, 271, 262, 3270, 262, 836, 284, 330, 57349, 85981, 80511, 25, 43125, 2293, 32570, 5072, 851, 11, 29388, 9625, 340, 262, 29388, 284, 6078, 673, 9127, 5356, 3232, 340, 262, 29388, 681, 267, 1154, 663, 284, 12025, 53908, 22001, 32570, 5072, 681, 267, 1154, 7519, 262, 471, 29388, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1991, 264, 29388, 7419, 505, 279, 12499, 10199, 382, 262, 18161, 512, 286, 29388, 851, 320, 496, 1680, 61273, 13110, 198, 286, 29388, 9625, 320, 496, 1680, 61273, 2373, 271, 262, 5295, 512, 286, 6587, 11, 61273, 7419, 11240, 271, 14711, 6075, 512, 755, 636, 87518, 32570, 5072, 851, 25, 610, 11, 29388, 9625, 25, 610, 8, 1492, 6587, 512, 262, 4304, 1991, 264, 29388, 7419, 505, 279, 12499, 10199, 382, 262, 18161, 512, 286, 29388, 851, 320, 496, 1680, 61273, 13110, 198, 286, 29388, 9625, 320, 496, 1680, 61273, 2373, 271, 262, 5295, 512, 286, 6587, 11, 61273, 7419, 11240, 271, 262, 3270, 262, 836, 284, 330, 57349, 85981, 80511, 25, 43125, 2293, 32570, 5072, 851, 11, 29388, 9625, 340, 262, 29388, 284, 6078, 673, 9127, 5356, 3232, 340, 262, 29388, 681, 267, 1154, 663, 284, 12025, 53908, 22001, 32570, 5072, 681, 267, 1154, 7519, 262, 471, 29388, 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 ]
brocade/pynos
pynos/versions/ver_6/ver_6_0_1/yang/brocade_common_def.py
brocade_common_def.router_fabric_virtual_gateway_address_family_ipv6_enable_global
def router_fabric_virtual_gateway_address_family_ipv6_enable_global(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") router = ET.SubElement(config, "router", xmlns="urn:brocade.com:mgmt:brocade-common-def") fabric_virtual_gateway = ET.SubElement(router, "fabric-virtual-gateway", xmlns="urn:brocade.com:mgmt:brocade-anycast-gateway") address_family = ET.SubElement(fabric_virtual_gateway, "address-family") ipv6 = ET.SubElement(address_family, "ipv6") enable_global = ET.SubElement(ipv6, "enable_global") callback = kwargs.pop('callback', self._callback) return callback(config)
python
def router_fabric_virtual_gateway_address_family_ipv6_enable_global(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") router = ET.SubElement(config, "router", xmlns="urn:brocade.com:mgmt:brocade-common-def") fabric_virtual_gateway = ET.SubElement(router, "fabric-virtual-gateway", xmlns="urn:brocade.com:mgmt:brocade-anycast-gateway") address_family = ET.SubElement(fabric_virtual_gateway, "address-family") ipv6 = ET.SubElement(address_family, "ipv6") enable_global = ET.SubElement(ipv6, "enable_global") callback = kwargs.pop('callback', self._callback) return callback(config)
[ "def", "router_fabric_virtual_gateway_address_family_ipv6_enable_global", "(", "self", ",", "*", "*", "kwargs", ")", ":", "config", "=", "ET", ".", "Element", "(", "\"config\"", ")", "router", "=", "ET", ".", "SubElement", "(", "config", ",", "\"router\"", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:brocade-common-def\"", ")", "fabric_virtual_gateway", "=", "ET", ".", "SubElement", "(", "router", ",", "\"fabric-virtual-gateway\"", ",", "xmlns", "=", "\"urn:brocade.com:mgmt:brocade-anycast-gateway\"", ")", "address_family", "=", "ET", ".", "SubElement", "(", "fabric_virtual_gateway", ",", "\"address-family\"", ")", "ipv6", "=", "ET", ".", "SubElement", "(", "address_family", ",", "\"ipv6\"", ")", "enable_global", "=", "ET", ".", "SubElement", "(", "ipv6", ",", "\"enable_global\"", ")", "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_6/ver_6_0_1/yang/brocade_common_def.py#L1164-L1175
<|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 router_fabric_virtual_gateway_address_family_ipv6_enable_global(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") router = ET.SubElement(config, "router", xmlns="urn:brocade.com:mgmt:brocade-common-def") fabric_virtual_gateway = ET.SubElement(router, "fabric-virtual-gateway", xmlns="urn:brocade.com:mgmt:brocade-anycast-gateway") address_family = ET.SubElement(fabric_virtual_gateway, "address-family") ipv6 = ET.SubElement(address_family, "ipv6") enable_global = ET.SubElement(ipv6, "enable_global") 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, 9457, 766, 29997, 59830, 65149, 6886, 27921, 50478, 21, 19525, 19854, 1214, 11, 3146, 9872, 997, 286, 4304, 13556, 31588, 6247, 198, 286, 3270, 286, 2242, 284, 18241, 20743, 446, 1710, 1158, 286, 9457, 284, 18241, 93442, 8928, 11, 330, 10140, 498, 26015, 429, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 46145, 29899, 1158, 286, 13354, 59830, 65149, 284, 18241, 93442, 62310, 11, 330, 86254, 8437, 2973, 2427, 12312, 498, 26015, 429, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 19415, 3418, 561, 2427, 12312, 1158, 286, 2686, 27921, 284, 18241, 93442, 968, 29997, 59830, 65149, 11, 330, 5102, 17633, 1158, 286, 46575, 21, 284, 18241, 93442, 15797, 27921, 11, 330, 43776, 21, 1158, 286, 7431, 19854, 284, 18241, 93442, 24338, 85, 21, 11, 330, 12837, 19854, 5240, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 13556, 31588, 6247, 271, 14711, 6075, 512, 755, 9457, 766, 29997, 59830, 65149, 6886, 27921, 50478, 21, 19525, 19854, 1214, 11, 3146, 9872, 997, 286, 4304, 13556, 31588, 6247, 198, 286, 3270, 286, 2242, 284, 18241, 20743, 446, 1710, 1158, 286, 9457, 284, 18241, 93442, 8928, 11, 330, 10140, 498, 26015, 429, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 46145, 29899, 1158, 286, 13354, 59830, 65149, 284, 18241, 93442, 62310, 11, 330, 86254, 8437, 2973, 2427, 12312, 498, 26015, 429, 399, 25, 15222, 33896, 916, 25, 12591, 2562, 25, 15222, 33896, 19415, 3418, 561, 2427, 12312, 1158, 286, 2686, 27921, 284, 18241, 93442, 968, 29997, 59830, 65149, 11, 330, 5102, 17633, 1158, 286, 46575, 21, 284, 18241, 93442, 15797, 27921, 11, 330, 43776, 21, 1158, 286, 7431, 19854, 284, 18241, 93442, 24338, 85, 21, 11, 330, 12837, 19854, 5240, 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 ]
stevearc/dynamo3
dynamo3/connection.py
DynamoDBConnection.put_item
def put_item(self, tablename, item, expected=None, returns=NONE, return_capacity=None, expect_or=False, **kwargs): """ Store an item, overwriting existing data This uses the older version of the DynamoDB API. See also: :meth:`~.put_item2`. Parameters ---------- tablename : str Name of the table to write item : dict Item data expected : dict, optional DEPRECATED (use **kwargs instead). If present, will check the values in Dynamo before performing the write. If values do not match, will raise an exception. (Using None as a value checks that the field does not exist). returns : {NONE, ALL_OLD}, optional If ALL_OLD, will return any data that was overwritten (default NONE) return_capacity : {NONE, INDEXES, TOTAL}, optional INDEXES will return the consumed capacity for indexes, TOTAL will return the consumed capacity for the table and the indexes. (default NONE) expect_or : bool, optional If True, the **kwargs conditionals will be OR'd together. If False, they will be AND'd. (default False). **kwargs : dict, optional Conditional filter on the PUT. Same format as the kwargs for :meth:`~.scan`. """ keywords = {} if kwargs: keywords['Expected'] = encode_query_kwargs(self.dynamizer, kwargs) if len(keywords['Expected']) > 1: keywords['ConditionalOperator'] = 'OR' if expect_or else 'AND' elif expected is not None: keywords['Expected'] = build_expected(self.dynamizer, expected) keywords['ReturnConsumedCapacity'] = \ self._default_capacity(return_capacity) item = self.dynamizer.encode_keys(item) ret = self.call('put_item', TableName=tablename, Item=item, ReturnValues=returns, **keywords) if ret: return Result(self.dynamizer, ret, 'Attributes')
python
def put_item(self, tablename, item, expected=None, returns=NONE, return_capacity=None, expect_or=False, **kwargs): """ Store an item, overwriting existing data This uses the older version of the DynamoDB API. See also: :meth:`~.put_item2`. Parameters ---------- tablename : str Name of the table to write item : dict Item data expected : dict, optional DEPRECATED (use **kwargs instead). If present, will check the values in Dynamo before performing the write. If values do not match, will raise an exception. (Using None as a value checks that the field does not exist). returns : {NONE, ALL_OLD}, optional If ALL_OLD, will return any data that was overwritten (default NONE) return_capacity : {NONE, INDEXES, TOTAL}, optional INDEXES will return the consumed capacity for indexes, TOTAL will return the consumed capacity for the table and the indexes. (default NONE) expect_or : bool, optional If True, the **kwargs conditionals will be OR'd together. If False, they will be AND'd. (default False). **kwargs : dict, optional Conditional filter on the PUT. Same format as the kwargs for :meth:`~.scan`. """ keywords = {} if kwargs: keywords['Expected'] = encode_query_kwargs(self.dynamizer, kwargs) if len(keywords['Expected']) > 1: keywords['ConditionalOperator'] = 'OR' if expect_or else 'AND' elif expected is not None: keywords['Expected'] = build_expected(self.dynamizer, expected) keywords['ReturnConsumedCapacity'] = \ self._default_capacity(return_capacity) item = self.dynamizer.encode_keys(item) ret = self.call('put_item', TableName=tablename, Item=item, ReturnValues=returns, **keywords) if ret: return Result(self.dynamizer, ret, 'Attributes')
[ "def", "put_item", "(", "self", ",", "tablename", ",", "item", ",", "expected", "=", "None", ",", "returns", "=", "NONE", ",", "return_capacity", "=", "None", ",", "expect_or", "=", "False", ",", "*", "*", "kwargs", ")", ":", "keywords", "=", "{", "}", "if", "kwargs", ":", "keywords", "[", "'Expected'", "]", "=", "encode_query_kwargs", "(", "self", ".", "dynamizer", ",", "kwargs", ")", "if", "len", "(", "keywords", "[", "'Expected'", "]", ")", ">", "1", ":", "keywords", "[", "'ConditionalOperator'", "]", "=", "'OR'", "if", "expect_or", "else", "'AND'", "elif", "expected", "is", "not", "None", ":", "keywords", "[", "'Expected'", "]", "=", "build_expected", "(", "self", ".", "dynamizer", ",", "expected", ")", "keywords", "[", "'ReturnConsumedCapacity'", "]", "=", "self", ".", "_default_capacity", "(", "return_capacity", ")", "item", "=", "self", ".", "dynamizer", ".", "encode_keys", "(", "item", ")", "ret", "=", "self", ".", "call", "(", "'put_item'", ",", "TableName", "=", "tablename", ",", "Item", "=", "item", ",", "ReturnValues", "=", "returns", ",", "*", "*", "keywords", ")", "if", "ret", ":", "return", "Result", "(", "self", ".", "dynamizer", ",", "ret", ",", "'Attributes'", ")" ]
Store an item, overwriting existing data This uses the older version of the DynamoDB API. See also: :meth:`~.put_item2`. Parameters ---------- tablename : str Name of the table to write item : dict Item data expected : dict, optional DEPRECATED (use **kwargs instead). If present, will check the values in Dynamo before performing the write. If values do not match, will raise an exception. (Using None as a value checks that the field does not exist). returns : {NONE, ALL_OLD}, optional If ALL_OLD, will return any data that was overwritten (default NONE) return_capacity : {NONE, INDEXES, TOTAL}, optional INDEXES will return the consumed capacity for indexes, TOTAL will return the consumed capacity for the table and the indexes. (default NONE) expect_or : bool, optional If True, the **kwargs conditionals will be OR'd together. If False, they will be AND'd. (default False). **kwargs : dict, optional Conditional filter on the PUT. Same format as the kwargs for :meth:`~.scan`.
[ "Store", "an", "item", "overwriting", "existing", "data" ]
train
https://github.com/stevearc/dynamo3/blob/f897c40ece28586272dbcab8f0d99a14a1831dda/dynamo3/connection.py#L466-L513
<|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: Store an item, overwriting existing data This uses the older version of the DynamoDB API. See also: :meth:`~.put_item2`. Parameters ---------- tablename : str Name of the table to write item : dict Item data expected : dict, optional DEPRECATED (use **kwargs instead). If present, will check the values in Dynamo before performing the write. If values do not match, will raise an exception. (Using None as a value checks that the field does not exist). returns : {NONE, ALL_OLD}, optional If ALL_OLD, will return any data that was overwritten (default NONE) return_capacity : {NONE, INDEXES, TOTAL}, optional INDEXES will return the consumed capacity for indexes, TOTAL will return the consumed capacity for the table and the indexes. (default NONE) expect_or : bool, optional If True, the **kwargs conditionals will be OR'd together. If False, they will be AND'd. (default False). **kwargs : dict, optional Conditional filter on the PUT. Same format as the kwargs for :meth:`~.scan`. ### Response: def put_item(self, tablename, item, expected=None, returns=NONE, return_capacity=None, expect_or=False, **kwargs): """ Store an item, overwriting existing data This uses the older version of the DynamoDB API. See also: :meth:`~.put_item2`. Parameters ---------- tablename : str Name of the table to write item : dict Item data expected : dict, optional DEPRECATED (use **kwargs instead). If present, will check the values in Dynamo before performing the write. If values do not match, will raise an exception. (Using None as a value checks that the field does not exist). returns : {NONE, ALL_OLD}, optional If ALL_OLD, will return any data that was overwritten (default NONE) return_capacity : {NONE, INDEXES, TOTAL}, optional INDEXES will return the consumed capacity for indexes, TOTAL will return the consumed capacity for the table and the indexes. (default NONE) expect_or : bool, optional If True, the **kwargs conditionals will be OR'd together. If False, they will be AND'd. (default False). **kwargs : dict, optional Conditional filter on the PUT. Same format as the kwargs for :meth:`~.scan`. """ keywords = {} if kwargs: keywords['Expected'] = encode_query_kwargs(self.dynamizer, kwargs) if len(keywords['Expected']) > 1: keywords['ConditionalOperator'] = 'OR' if expect_or else 'AND' elif expected is not None: keywords['Expected'] = build_expected(self.dynamizer, expected) keywords['ReturnConsumedCapacity'] = \ self._default_capacity(return_capacity) item = self.dynamizer.encode_keys(item) ret = self.call('put_item', TableName=tablename, Item=item, ReturnValues=returns, **keywords) if ret: return Result(self.dynamizer, ret, 'Attributes') <|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, 6221, 459, 1537, 11, 927, 26372, 6484, 828, 271, 286, 1115, 5829, 279, 9191, 2373, 315, 279, 72913, 3590, 5446, 627, 286, 3580, 1101, 25, 551, 69991, 78902, 13, 631, 5752, 17, 63438, 286, 13831, 198, 286, 31423, 286, 87465, 551, 610, 198, 310, 4076, 315, 279, 2007, 311, 3350, 198, 286, 1537, 551, 6587, 198, 310, 5858, 828, 198, 286, 3685, 551, 6587, 11, 10309, 198, 310, 3467, 58813, 320, 817, 3146, 9872, 4619, 4390, 310, 1442, 3118, 11, 690, 1817, 279, 2819, 304, 72913, 1603, 16785, 279, 198, 310, 3350, 13, 1442, 2819, 656, 539, 2489, 11, 690, 4933, 459, 4788, 13, 320, 16834, 2290, 198, 310, 439, 264, 907, 12621, 430, 279, 2115, 1587, 539, 3073, 4390, 286, 4780, 551, 314, 46525, 11, 13398, 83969, 2186, 10309, 198, 310, 1442, 13398, 83969, 11, 690, 471, 904, 828, 430, 574, 60273, 320, 2309, 198, 310, 43969, 340, 286, 471, 36703, 551, 314, 46525, 11, 40400, 1600, 11, 48062, 2186, 10309, 198, 310, 40400, 1600, 690, 471, 279, 27073, 8824, 369, 25998, 11, 48062, 690, 198, 310, 471, 279, 27073, 8824, 369, 279, 2007, 323, 279, 25998, 627, 310, 320, 2309, 43969, 340, 286, 1755, 8908, 551, 1845, 11, 10309, 198, 310, 1442, 3082, 11, 279, 3146, 9872, 3044, 1147, 690, 387, 2794, 4265, 3871, 13, 1442, 3641, 345, 310, 814, 690, 387, 3651, 4265, 13, 320, 2309, 3641, 4390, 286, 3146, 9872, 551, 6587, 11, 10309, 198, 310, 93073, 4141, 389, 279, 35480, 13, 26823, 3645, 439, 279, 16901, 369, 198, 310, 551, 69991, 78902, 13, 16810, 63438, 14711, 6075, 512, 755, 2231, 5752, 1214, 11, 87465, 11, 1537, 11, 3685, 5980, 11, 4780, 28, 46525, 345, 338, 471, 36703, 5980, 11, 1755, 8908, 5725, 11, 3146, 9872, 997, 286, 3270, 286, 9307, 459, 1537, 11, 927, 26372, 6484, 828, 271, 286, 1115, 5829, 279, 9191, 2373, 315, 279, 72913, 3590, 5446, 627, 286, 3580, 1101, 25, 551, 69991, 78902, 13, 631, 5752, 17, 63438, 286, 13831, 198, 286, 31423, 286, 87465, 551, 610, 198, 310, 4076, 315, 279, 2007, 311, 3350, 198, 286, 1537, 551, 6587, 198, 310, 5858, 828, 198, 286, 3685, 551, 6587, 11, 10309, 198, 310, 3467, 58813, 320, 817, 3146, 9872, 4619, 4390, 310, 1442, 3118, 11, 690, 1817, 279, 2819, 304, 72913, 1603, 16785, 279, 198, 310, 3350, 13, 1442, 2819, 656, 539, 2489, 11, 690, 4933, 459, 4788, 13, 320, 16834, 2290, 198, 310, 439, 264, 907, 12621, 430, 279, 2115, 1587, 539, 3073, 4390, 286, 4780, 551, 314, 46525, 11, 13398, 83969, 2186, 10309, 198, 310, 1442, 13398, 83969, 11, 690, 471, 904, 828, 430, 574, 60273, 320, 2309, 198, 310, 43969, 340, 286, 471, 36703, 551, 314, 46525, 11, 40400, 1600, 11, 48062, 2186, 10309, 198, 310, 40400, 1600, 690, 471, 279, 27073, 8824, 369, 25998, 11, 48062, 690, 198, 310, 471 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 6221, 459, 1537, 11, 927, 26372, 6484, 828, 271, 286, 1115, 5829, 279, 9191, 2373, 315, 279, 72913, 3590, 5446, 627, 286, 3580, 1101, 25, 551, 69991, 78902, 13, 631, 5752, 17, 63438, 286, 13831, 198, 286, 31423, 286, 87465, 551, 610, 198, 310, 4076, 315, 279, 2007, 311, 3350, 198, 286, 1537, 551, 6587, 198, 310, 5858, 828, 198, 286, 3685, 551, 6587, 11, 10309, 198, 310, 3467, 58813, 320, 817, 3146, 9872, 4619, 4390, 310, 1442, 3118, 11, 690, 1817, 279, 2819, 304, 72913, 1603, 16785, 279, 198, 310, 3350, 13, 1442, 2819, 656, 539, 2489, 11, 690, 4933, 459, 4788, 13, 320, 16834, 2290, 198, 310, 439, 264, 907, 12621, 430, 279, 2115, 1587, 539, 3073, 4390, 286, 4780, 551, 314, 46525, 11, 13398, 83969, 2186, 10309, 198, 310, 1442, 13398, 83969, 11, 690, 471, 904, 828, 430, 574, 60273, 320, 2309, 198, 310, 43969, 340, 286, 471, 36703, 551, 314, 46525, 11, 40400, 1600, 11, 48062, 2186, 10309, 198, 310, 40400, 1600, 690, 471, 279, 27073, 8824, 369, 25998, 11, 48062, 690, 198, 310, 471, 279, 27073, 8824, 369, 279, 2007, 323, 279, 25998, 627, 310, 320, 2309, 43969, 340, 286, 1755, 8908, 551, 1845, 11, 10309, 198, 310, 1442, 3082, 11, 279, 3146, 9872, 3044, 1147, 690, 387, 2794, 4265, 3871, 13, 1442, 3641, 345, 310, 814, 690, 387, 3651, 4265, 13, 320, 2309, 3641, 4390, 286, 3146, 9872, 551, 6587, 11, 10309, 198, 310, 93073, 4141, 389, 279, 35480, 13, 26823, 3645, 439, 279, 16901, 369, 198, 310, 551, 69991, 78902, 13, 16810, 63438, 14711, 6075, 512, 755, 2231, 5752, 1214, 11, 87465, 11, 1537, 11, 3685, 5980, 11, 4780, 28, 46525, 345, 338, 471, 36703, 5980, 11, 1755, 8908, 5725, 11, 3146, 9872, 997, 286, 3270, 286, 9307, 459, 1537, 11, 927, 26372, 6484, 828, 271, 286, 1115, 5829, 279, 9191, 2373, 315, 279, 72913, 3590, 5446, 627, 286, 3580, 1101, 25, 551, 69991, 78902, 13, 631, 5752, 17, 63438, 286, 13831, 198, 286, 31423, 286, 87465, 551, 610, 198, 310, 4076, 315, 279, 2007, 311, 3350, 198, 286, 1537, 551, 6587, 198, 310, 5858, 828, 198, 286, 3685, 551, 6587, 11, 10309, 198, 310, 3467, 58813, 320, 817, 3146, 9872, 4619, 4390, 310, 1442, 3118, 11, 690, 1817, 279, 2819, 304, 72913, 1603, 16785, 279, 198, 310, 3350, 13, 1442, 2819, 656, 539, 2489, 11, 690, 4933, 459, 4788, 13, 320, 16834, 2290, 198, 310, 439, 264, 907, 12621, 430, 279, 2115, 1587, 539, 3073, 4390, 286, 4780, 551, 314, 46525, 11, 13398, 83969, 2186, 10309, 198, 310, 1442, 13398, 83969, 11, 690, 471, 904, 828, 430, 574, 60273, 320, 2309, 198, 310, 43969, 340, 286, 471, 36703, 551, 314, 46525, 11, 40400, 1600, 11, 48062, 2186, 10309, 198, 310, 40400, 1600, 690, 471, 279, 27073, 8824, 369, 25998, 11, 48062, 690, 198, 310, 471 ]
atl/py-smartdc
smartdc/datacenter.py
DataCenter.delete_key
def delete_key(self, key_id): """ :: DELETE /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`. """ j, r = self.request('DELETE', '/keys/' + str(key_id)) r.raise_for_status() return j
python
def delete_key(self, key_id): """ :: DELETE /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`. """ j, r = self.request('DELETE', '/keys/' + str(key_id)) r.raise_for_status() return j
[ "def", "delete_key", "(", "self", ",", "key_id", ")", ":", "j", ",", "r", "=", "self", ".", "request", "(", "'DELETE'", ",", "'/keys/'", "+", "str", "(", "key_id", ")", ")", "r", ".", "raise_for_status", "(", ")", "return", "j" ]
:: DELETE /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`.
[ "::", "DELETE", "/", ":", "login", "/", "keys", "/", ":", "key", ":", "param", "key_id", ":", "identifier", "for", "an", "individual", "key", "record", "for", "the", "account", ":", "type", "key_id", ":", ":", "py", ":", "class", ":", "basestring", "Deletes", "an", "SSH", "key", "from", "the", "server", "identified", "by", "key_id", "." ]
train
https://github.com/atl/py-smartdc/blob/cc5cd5910e19004cc46e376ce035affe28fc798e/smartdc/datacenter.py#L430-L443
<|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 /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`. ### Response: def delete_key(self, key_id): """ :: DELETE /:login/keys/:key :param key_id: identifier for an individual key record for the account :type key_id: :py:class:`basestring` Deletes an SSH key from the server identified by `key_id`. """ j, r = self.request('DELETE', '/keys/' + str(key_id)) r.raise_for_status() return j <|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, 50677, 1827, 310, 17640, 105064, 3758, 14, 10786, 11567, 798, 9122, 286, 551, 913, 1401, 851, 25, 13110, 369, 459, 3927, 1401, 3335, 369, 279, 2759, 198, 286, 551, 1337, 1401, 851, 25, 551, 3368, 93064, 19258, 18275, 66140, 4077, 1827, 286, 56624, 459, 41563, 1401, 505, 279, 3622, 11054, 555, 1595, 798, 851, 63438, 14711, 6075, 512, 755, 3783, 3173, 1214, 11, 1401, 851, 997, 286, 3270, 286, 81787, 1827, 310, 17640, 105064, 3758, 14, 10786, 11567, 798, 9122, 286, 551, 913, 1401, 851, 25, 13110, 369, 459, 3927, 1401, 3335, 369, 279, 2759, 198, 286, 551, 1337, 1401, 851, 25, 551, 3368, 93064, 19258, 18275, 66140, 4077, 1827, 286, 56624, 459, 41563, 1401, 505, 279, 3622, 11054, 555, 1595, 798, 851, 19154, 286, 3270, 286, 503, 11, 436, 284, 659, 8387, 493, 14762, 518, 3434, 10786, 11576, 489, 610, 4962, 851, 1192, 286, 436, 68934, 5595, 4878, 746, 286, 471, 503, 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,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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 50677, 1827, 310, 17640, 105064, 3758, 14, 10786, 11567, 798, 9122, 286, 551, 913, 1401, 851, 25, 13110, 369, 459, 3927, 1401, 3335, 369, 279, 2759, 198, 286, 551, 1337, 1401, 851, 25, 551, 3368, 93064, 19258, 18275, 66140, 4077, 1827, 286, 56624, 459, 41563, 1401, 505, 279, 3622, 11054, 555, 1595, 798, 851, 63438, 14711, 6075, 512, 755, 3783, 3173, 1214, 11, 1401, 851, 997, 286, 3270, 286, 81787, 1827, 310, 17640, 105064, 3758, 14, 10786, 11567, 798, 9122, 286, 551, 913, 1401, 851, 25, 13110, 369, 459, 3927, 1401, 3335, 369, 279, 2759, 198, 286, 551, 1337, 1401, 851, 25, 551, 3368, 93064, 19258, 18275, 66140, 4077, 1827, 286, 56624, 459, 41563, 1401, 505, 279, 3622, 11054, 555, 1595, 798, 851, 19154, 286, 3270, 286, 503, 11, 436, 284, 659, 8387, 493, 14762, 518, 3434, 10786, 11576, 489, 610, 4962, 851, 1192, 286, 436, 68934, 5595, 4878, 746, 286, 471, 503, 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 ]
saltstack/salt
salt/modules/file.py
restorecon
def restorecon(path, recursive=False): ''' Reset the SELinux context on a given path CLI Example: .. code-block:: bash salt '*' file.restorecon /home/user/.ssh/authorized_keys ''' if recursive: cmd = ['restorecon', '-FR', path] else: cmd = ['restorecon', '-F', path] return not __salt__['cmd.retcode'](cmd, python_shell=False)
python
def restorecon(path, recursive=False): ''' Reset the SELinux context on a given path CLI Example: .. code-block:: bash salt '*' file.restorecon /home/user/.ssh/authorized_keys ''' if recursive: cmd = ['restorecon', '-FR', path] else: cmd = ['restorecon', '-F', path] return not __salt__['cmd.retcode'](cmd, python_shell=False)
[ "def", "restorecon", "(", "path", ",", "recursive", "=", "False", ")", ":", "if", "recursive", ":", "cmd", "=", "[", "'restorecon'", ",", "'-FR'", ",", "path", "]", "else", ":", "cmd", "=", "[", "'restorecon'", ",", "'-F'", ",", "path", "]", "return", "not", "__salt__", "[", "'cmd.retcode'", "]", "(", "cmd", ",", "python_shell", "=", "False", ")" ]
Reset the SELinux context on a given path CLI Example: .. code-block:: bash salt '*' file.restorecon /home/user/.ssh/authorized_keys
[ "Reset", "the", "SELinux", "context", "on", "a", "given", "path" ]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L3866-L3880
<|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: Reset the SELinux context on a given path CLI Example: .. code-block:: bash salt '*' file.restorecon /home/user/.ssh/authorized_keys ### Response: def restorecon(path, recursive=False): ''' Reset the SELinux context on a given path CLI Example: .. code-block:: bash salt '*' file.restorecon /home/user/.ssh/authorized_keys ''' if recursive: cmd = ['restorecon', '-FR', path] else: cmd = ['restorecon', '-F', path] return not __salt__['cmd.retcode'](cmd, python_shell=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, 15172, 279, 41938, 20130, 2317, 389, 264, 2728, 1853, 271, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 260, 12290, 31801, 1052, 43527, 444, 611, 5227, 12001, 12196, 26618, 14, 19626, 12919, 271, 14711, 6075, 512, 755, 15301, 444, 5698, 11, 31919, 5725, 997, 262, 11414, 262, 17362, 279, 41938, 20130, 2317, 389, 264, 2728, 1853, 271, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 260, 12290, 31801, 1052, 43527, 444, 611, 5227, 12001, 12196, 26618, 14, 19626, 12919, 198, 262, 11414, 262, 422, 31919, 512, 286, 5556, 284, 2570, 31904, 444, 518, 7944, 10725, 518, 1853, 933, 262, 775, 512, 286, 5556, 284, 2570, 31904, 444, 518, 7944, 37, 518, 1853, 933, 262, 471, 539, 1328, 43326, 565, 681, 8883, 63038, 1889, 85433, 8883, 11, 10344, 50045, 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, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 15172, 279, 41938, 20130, 2317, 389, 264, 2728, 1853, 271, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 260, 12290, 31801, 1052, 43527, 444, 611, 5227, 12001, 12196, 26618, 14, 19626, 12919, 271, 14711, 6075, 512, 755, 15301, 444, 5698, 11, 31919, 5725, 997, 262, 11414, 262, 17362, 279, 41938, 20130, 2317, 389, 264, 2728, 1853, 271, 262, 40377, 13688, 1473, 262, 5354, 2082, 9612, 487, 28121, 271, 260, 12290, 31801, 1052, 43527, 444, 611, 5227, 12001, 12196, 26618, 14, 19626, 12919, 198, 262, 11414, 262, 422, 31919, 512, 286, 5556, 284, 2570, 31904, 444, 518, 7944, 10725, 518, 1853, 933, 262, 775, 512, 286, 5556, 284, 2570, 31904, 444, 518, 7944, 37, 518, 1853, 933, 262, 471, 539, 1328, 43326, 565, 681, 8883, 63038, 1889, 85433, 8883, 11, 10344, 50045, 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 ]
pyviz/holoviews
holoviews/core/spaces.py
DynamicMap.relabel
def relabel(self, label=None, group=None, depth=1): """Clone object and apply new group and/or label. Applies relabeling to children up to the supplied depth. Args: label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied If applied to container allows applying relabeling to contained objects up to the specified depth Returns: Returns relabelled object """ relabelled = super(DynamicMap, self).relabel(label, group, depth) if depth > 0: from ..util import Dynamic def dynamic_relabel(obj, **dynkwargs): return obj.relabel(group=group, label=label, depth=depth-1) dmap = Dynamic(self, streams=self.streams, operation=dynamic_relabel) dmap.data = relabelled.data with util.disable_constant(dmap): dmap.group = relabelled.group dmap.label = relabelled.label return dmap return relabelled
python
def relabel(self, label=None, group=None, depth=1): """Clone object and apply new group and/or label. Applies relabeling to children up to the supplied depth. Args: label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied If applied to container allows applying relabeling to contained objects up to the specified depth Returns: Returns relabelled object """ relabelled = super(DynamicMap, self).relabel(label, group, depth) if depth > 0: from ..util import Dynamic def dynamic_relabel(obj, **dynkwargs): return obj.relabel(group=group, label=label, depth=depth-1) dmap = Dynamic(self, streams=self.streams, operation=dynamic_relabel) dmap.data = relabelled.data with util.disable_constant(dmap): dmap.group = relabelled.group dmap.label = relabelled.label return dmap return relabelled
[ "def", "relabel", "(", "self", ",", "label", "=", "None", ",", "group", "=", "None", ",", "depth", "=", "1", ")", ":", "relabelled", "=", "super", "(", "DynamicMap", ",", "self", ")", ".", "relabel", "(", "label", ",", "group", ",", "depth", ")", "if", "depth", ">", "0", ":", "from", ".", ".", "util", "import", "Dynamic", "def", "dynamic_relabel", "(", "obj", ",", "*", "*", "dynkwargs", ")", ":", "return", "obj", ".", "relabel", "(", "group", "=", "group", ",", "label", "=", "label", ",", "depth", "=", "depth", "-", "1", ")", "dmap", "=", "Dynamic", "(", "self", ",", "streams", "=", "self", ".", "streams", ",", "operation", "=", "dynamic_relabel", ")", "dmap", ".", "data", "=", "relabelled", ".", "data", "with", "util", ".", "disable_constant", "(", "dmap", ")", ":", "dmap", ".", "group", "=", "relabelled", ".", "group", "dmap", ".", "label", "=", "relabelled", ".", "label", "return", "dmap", "return", "relabelled" ]
Clone object and apply new group and/or label. Applies relabeling to children up to the supplied depth. Args: label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied If applied to container allows applying relabeling to contained objects up to the specified depth Returns: Returns relabelled object
[ "Clone", "object", "and", "apply", "new", "group", "and", "/", "or", "label", "." ]
train
https://github.com/pyviz/holoviews/blob/ae0dd2f3de448b0ca5e9065aabd6ef8d84c7e655/holoviews/core/spaces.py#L1435-L1461
<|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: Clone object and apply new group and/or label. Applies relabeling to children up to the supplied depth. Args: label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied If applied to container allows applying relabeling to contained objects up to the specified depth Returns: Returns relabelled object ### Response: def relabel(self, label=None, group=None, depth=1): """Clone object and apply new group and/or label. Applies relabeling to children up to the supplied depth. Args: label (str, optional): New label to apply to returned object group (str, optional): New group to apply to returned object depth (int, optional): Depth to which relabel will be applied If applied to container allows applying relabeling to contained objects up to the specified depth Returns: Returns relabelled object """ relabelled = super(DynamicMap, self).relabel(label, group, depth) if depth > 0: from ..util import Dynamic def dynamic_relabel(obj, **dynkwargs): return obj.relabel(group=group, label=label, depth=depth-1) dmap = Dynamic(self, streams=self.streams, operation=dynamic_relabel) dmap.data = relabelled.data with util.disable_constant(dmap): dmap.group = relabelled.group dmap.label = relabelled.label return dmap return relabelled <|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, 38777, 1665, 323, 3881, 502, 1912, 323, 5255, 2440, 382, 286, 83265, 1375, 786, 287, 311, 2911, 709, 311, 279, 17665, 8149, 382, 286, 18161, 512, 310, 2440, 320, 496, 11, 10309, 1680, 1561, 2440, 311, 3881, 311, 6052, 1665, 198, 310, 1912, 320, 496, 11, 10309, 1680, 1561, 1912, 311, 3881, 311, 6052, 1665, 198, 310, 8149, 320, 396, 11, 10309, 1680, 45020, 311, 902, 1375, 786, 690, 387, 9435, 198, 394, 1442, 9435, 311, 5593, 6276, 19486, 1375, 786, 287, 311, 198, 394, 13282, 6302, 709, 311, 279, 5300, 8149, 271, 286, 5295, 512, 310, 5295, 1375, 786, 839, 1665, 271, 14711, 6075, 512, 755, 1375, 786, 1214, 11, 2440, 5980, 11, 1912, 5980, 11, 8149, 28, 16, 997, 286, 4304, 38777, 1665, 323, 3881, 502, 1912, 323, 5255, 2440, 382, 286, 83265, 1375, 786, 287, 311, 2911, 709, 311, 279, 17665, 8149, 382, 286, 18161, 512, 310, 2440, 320, 496, 11, 10309, 1680, 1561, 2440, 311, 3881, 311, 6052, 1665, 198, 310, 1912, 320, 496, 11, 10309, 1680, 1561, 1912, 311, 3881, 311, 6052, 1665, 198, 310, 8149, 320, 396, 11, 10309, 1680, 45020, 311, 902, 1375, 786, 690, 387, 9435, 198, 394, 1442, 9435, 311, 5593, 6276, 19486, 1375, 786, 287, 311, 198, 394, 13282, 6302, 709, 311, 279, 5300, 8149, 271, 286, 5295, 512, 310, 5295, 1375, 786, 839, 1665, 198, 286, 3270, 286, 1375, 786, 839, 284, 2307, 5549, 5148, 2276, 11, 659, 570, 265, 1530, 13648, 11, 1912, 11, 8149, 340, 286, 422, 8149, 871, 220, 15, 512, 310, 505, 5354, 1338, 1179, 22648, 198, 310, 711, 8915, 1311, 1530, 6922, 11, 3146, 44185, 9872, 997, 394, 471, 2909, 1351, 1530, 18158, 28, 4166, 11, 2440, 99789, 11, 8149, 28, 18021, 12, 16, 340, 310, 294, 2235, 284, 22648, 1214, 11, 23914, 7822, 15307, 82, 11, 5784, 28, 22269, 1311, 1530, 340, 310, 294, 2235, 2245, 284, 1375, 786, 839, 2245, 198, 310, 449, 4186, 43728, 36067, 1528, 2235, 997, 394, 294, 2235, 6306, 284, 1375, 786, 839, 6306, 198, 394, 294, 2235, 2981, 284, 1375, 786, 839, 2981, 198, 310, 471, 294, 2235, 198, 286, 471, 1375, 786, 839, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 38777, 1665, 323, 3881, 502, 1912, 323, 5255, 2440, 382, 286, 83265, 1375, 786, 287, 311, 2911, 709, 311, 279, 17665, 8149, 382, 286, 18161, 512, 310, 2440, 320, 496, 11, 10309, 1680, 1561, 2440, 311, 3881, 311, 6052, 1665, 198, 310, 1912, 320, 496, 11, 10309, 1680, 1561, 1912, 311, 3881, 311, 6052, 1665, 198, 310, 8149, 320, 396, 11, 10309, 1680, 45020, 311, 902, 1375, 786, 690, 387, 9435, 198, 394, 1442, 9435, 311, 5593, 6276, 19486, 1375, 786, 287, 311, 198, 394, 13282, 6302, 709, 311, 279, 5300, 8149, 271, 286, 5295, 512, 310, 5295, 1375, 786, 839, 1665, 271, 14711, 6075, 512, 755, 1375, 786, 1214, 11, 2440, 5980, 11, 1912, 5980, 11, 8149, 28, 16, 997, 286, 4304, 38777, 1665, 323, 3881, 502, 1912, 323, 5255, 2440, 382, 286, 83265, 1375, 786, 287, 311, 2911, 709, 311, 279, 17665, 8149, 382, 286, 18161, 512, 310, 2440, 320, 496, 11, 10309, 1680, 1561, 2440, 311, 3881, 311, 6052, 1665, 198, 310, 1912, 320, 496, 11, 10309, 1680, 1561, 1912, 311, 3881, 311, 6052, 1665, 198, 310, 8149, 320, 396, 11, 10309, 1680, 45020, 311, 902, 1375, 786, 690, 387, 9435, 198, 394, 1442, 9435, 311, 5593, 6276, 19486, 1375, 786, 287, 311, 198, 394, 13282, 6302, 709, 311, 279, 5300, 8149, 271, 286, 5295, 512, 310, 5295, 1375, 786, 839, 1665, 198, 286, 3270, 286, 1375, 786, 839, 284, 2307, 5549, 5148, 2276, 11, 659, 570, 265, 1530, 13648, 11, 1912, 11, 8149, 340, 286, 422, 8149, 871, 220, 15, 512, 310, 505, 5354, 1338, 1179, 22648, 198, 310, 711, 8915, 1311, 1530, 6922, 11, 3146, 44185, 9872, 997, 394, 471, 2909, 1351, 1530, 18158, 28, 4166, 11, 2440, 99789, 11, 8149, 28, 18021, 12, 16, 340, 310, 294, 2235, 284, 22648, 1214, 11, 23914, 7822, 15307, 82, 11, 5784, 28, 22269, 1311, 1530, 340, 310, 294, 2235, 2245, 284, 1375, 786, 839, 2245, 198, 310, 449, 4186, 43728, 36067, 1528, 2235, 997, 394, 294, 2235, 6306, 284, 1375, 786, 839, 6306, 198, 394, 294, 2235, 2981, 284, 1375, 786, 839, 2981, 198, 310, 471, 294, 2235, 198, 286, 471, 1375, 786, 839, 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 ]
openstack/hacking
hacking/core.py
is_import_exception
def is_import_exception(mod): """Check module name to see if import has been whitelisted. Import based rules should not run on any whitelisted module """ return (mod in IMPORT_EXCEPTIONS or any(mod.startswith(m + '.') for m in IMPORT_EXCEPTIONS))
python
def is_import_exception(mod): """Check module name to see if import has been whitelisted. Import based rules should not run on any whitelisted module """ return (mod in IMPORT_EXCEPTIONS or any(mod.startswith(m + '.') for m in IMPORT_EXCEPTIONS))
[ "def", "is_import_exception", "(", "mod", ")", ":", "return", "(", "mod", "in", "IMPORT_EXCEPTIONS", "or", "any", "(", "mod", ".", "startswith", "(", "m", "+", "'.'", ")", "for", "m", "in", "IMPORT_EXCEPTIONS", ")", ")" ]
Check module name to see if import has been whitelisted. Import based rules should not run on any whitelisted module
[ "Check", "module", "name", "to", "see", "if", "import", "has", "been", "whitelisted", "." ]
train
https://github.com/openstack/hacking/blob/10e58f907181cac91d3b2af422c2458b04a1ec79/hacking/core.py#L91-L97
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Check module name to see if import has been whitelisted. Import based rules should not run on any whitelisted module ### Response: def is_import_exception(mod): """Check module name to see if import has been whitelisted. Import based rules should not run on any whitelisted module """ return (mod in IMPORT_EXCEPTIONS or any(mod.startswith(m + '.') for m in IMPORT_EXCEPTIONS)) <|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, 4793, 836, 311, 1518, 422, 1179, 706, 1027, 34799, 301, 13539, 382, 996, 13516, 3196, 5718, 1288, 539, 1629, 389, 904, 34799, 301, 13539, 4793, 271, 14711, 6075, 512, 755, 374, 18941, 17957, 24236, 997, 262, 4304, 4061, 4793, 836, 311, 1518, 422, 1179, 706, 1027, 34799, 301, 13539, 382, 996, 13516, 3196, 5718, 1288, 539, 1629, 389, 904, 34799, 301, 13539, 4793, 198, 996, 3270, 262, 471, 320, 2658, 304, 44703, 28385, 50, 477, 198, 310, 904, 24236, 27249, 1278, 489, 71335, 369, 296, 304, 44703, 28385, 50, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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,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179, 706, 1027, 34799, 301, 13539, 382, 996, 13516, 3196, 5718, 1288, 539, 1629, 389, 904, 34799, 301, 13539, 4793, 271, 14711, 6075, 512, 755, 374, 18941, 17957, 24236, 997, 262, 4304, 4061, 4793, 836, 311, 1518, 422, 1179, 706, 1027, 34799, 301, 13539, 382, 996, 13516, 3196, 5718, 1288, 539, 1629, 389, 904, 34799, 301, 13539, 4793, 198, 996, 3270, 262, 471, 320, 2658, 304, 44703, 28385, 50, 477, 198, 310, 904, 24236, 27249, 1278, 489, 71335, 369, 296, 304, 44703, 28385, 50, 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 ]
mkoura/dump2polarion
dump2polarion/csv2sqlite_cli.py
dump2sqlite
def dump2sqlite(records, output_file): """Dumps tests results to database.""" results_keys = list(records.results[0].keys()) pad_data = [] for key in REQUIRED_KEYS: if key not in results_keys: results_keys.append(key) pad_data.append("") conn = sqlite3.connect(os.path.expanduser(output_file), detect_types=sqlite3.PARSE_DECLTYPES) # in each row there needs to be data for every column # last column is current time pad_data.append(datetime.datetime.utcnow()) to_db = [list(row.values()) + pad_data for row in records.results] cur = conn.cursor() cur.execute( "CREATE TABLE testcases ({},sqltime TIMESTAMP)".format( ",".join("{} TEXT".format(key) for key in results_keys) ) ) cur.executemany( "INSERT INTO testcases VALUES ({},?)".format(",".join(["?"] * len(results_keys))), to_db ) if records.testrun: cur.execute("CREATE TABLE testrun (testrun TEXT)") cur.execute("INSERT INTO testrun VALUES (?)", (records.testrun,)) conn.commit() conn.close() logger.info("Data written to '%s'", output_file)
python
def dump2sqlite(records, output_file): """Dumps tests results to database.""" results_keys = list(records.results[0].keys()) pad_data = [] for key in REQUIRED_KEYS: if key not in results_keys: results_keys.append(key) pad_data.append("") conn = sqlite3.connect(os.path.expanduser(output_file), detect_types=sqlite3.PARSE_DECLTYPES) # in each row there needs to be data for every column # last column is current time pad_data.append(datetime.datetime.utcnow()) to_db = [list(row.values()) + pad_data for row in records.results] cur = conn.cursor() cur.execute( "CREATE TABLE testcases ({},sqltime TIMESTAMP)".format( ",".join("{} TEXT".format(key) for key in results_keys) ) ) cur.executemany( "INSERT INTO testcases VALUES ({},?)".format(",".join(["?"] * len(results_keys))), to_db ) if records.testrun: cur.execute("CREATE TABLE testrun (testrun TEXT)") cur.execute("INSERT INTO testrun VALUES (?)", (records.testrun,)) conn.commit() conn.close() logger.info("Data written to '%s'", output_file)
[ "def", "dump2sqlite", "(", "records", ",", "output_file", ")", ":", "results_keys", "=", "list", "(", "records", ".", "results", "[", "0", "]", ".", "keys", "(", ")", ")", "pad_data", "=", "[", "]", "for", "key", "in", "REQUIRED_KEYS", ":", "if", "key", "not", "in", "results_keys", ":", "results_keys", ".", "append", "(", "key", ")", "pad_data", ".", "append", "(", "\"\"", ")", "conn", "=", "sqlite3", ".", "connect", "(", "os", ".", "path", ".", "expanduser", "(", "output_file", ")", ",", "detect_types", "=", "sqlite3", ".", "PARSE_DECLTYPES", ")", "# in each row there needs to be data for every column", "# last column is current time", "pad_data", ".", "append", "(", "datetime", ".", "datetime", ".", "utcnow", "(", ")", ")", "to_db", "=", "[", "list", "(", "row", ".", "values", "(", ")", ")", "+", "pad_data", "for", "row", "in", "records", ".", "results", "]", "cur", "=", "conn", ".", "cursor", "(", ")", "cur", ".", "execute", "(", "\"CREATE TABLE testcases ({},sqltime TIMESTAMP)\"", ".", "format", "(", "\",\"", ".", "join", "(", "\"{} TEXT\"", ".", "format", "(", "key", ")", "for", "key", "in", "results_keys", ")", ")", ")", "cur", ".", "executemany", "(", "\"INSERT INTO testcases VALUES ({},?)\"", ".", "format", "(", "\",\"", ".", "join", "(", "[", "\"?\"", "]", "*", "len", "(", "results_keys", ")", ")", ")", ",", "to_db", ")", "if", "records", ".", "testrun", ":", "cur", ".", "execute", "(", "\"CREATE TABLE testrun (testrun TEXT)\"", ")", "cur", ".", "execute", "(", "\"INSERT INTO testrun VALUES (?)\"", ",", "(", "records", ".", "testrun", ",", ")", ")", "conn", ".", "commit", "(", ")", "conn", ".", "close", "(", ")", "logger", ".", "info", "(", "\"Data written to '%s'\"", ",", "output_file", ")" ]
Dumps tests results to database.
[ "Dumps", "tests", "results", "to", "database", "." ]
train
https://github.com/mkoura/dump2polarion/blob/f4bd24e9d5070e282aad15f1e8bb514c0525cd37/dump2polarion/csv2sqlite_cli.py#L42-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: Dumps tests results to database. ### Response: def dump2sqlite(records, output_file): """Dumps tests results to database.""" results_keys = list(records.results[0].keys()) pad_data = [] for key in REQUIRED_KEYS: if key not in results_keys: results_keys.append(key) pad_data.append("") conn = sqlite3.connect(os.path.expanduser(output_file), detect_types=sqlite3.PARSE_DECLTYPES) # in each row there needs to be data for every column # last column is current time pad_data.append(datetime.datetime.utcnow()) to_db = [list(row.values()) + pad_data for row in records.results] cur = conn.cursor() cur.execute( "CREATE TABLE testcases ({},sqltime TIMESTAMP)".format( ",".join("{} TEXT".format(key) for key in results_keys) ) ) cur.executemany( "INSERT INTO testcases VALUES ({},?)".format(",".join(["?"] * len(results_keys))), to_db ) if records.testrun: cur.execute("CREATE TABLE testrun (testrun TEXT)") cur.execute("INSERT INTO testrun VALUES (?)", (records.testrun,)) conn.commit() conn.close() logger.info("Data written to '%s'", output_file) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 35, 12055, 7177, 3135, 311, 4729, 382, 14711, 6075, 512, 755, 10488, 17, 38142, 78579, 11, 2612, 2517, 997, 262, 4304, 35, 12055, 7177, 3135, 311, 4729, 14781, 262, 3135, 12919, 284, 1160, 78579, 27526, 58, 15, 948, 10786, 2455, 262, 11262, 1807, 284, 14941, 262, 369, 1401, 304, 67677, 52351, 512, 286, 422, 1401, 539, 304, 3135, 12919, 512, 310, 3135, 12919, 2102, 4962, 340, 310, 11262, 1807, 2102, 446, 5240, 262, 4635, 284, 22775, 18, 11034, 9835, 3960, 28837, 882, 11304, 2517, 705, 11388, 9962, 28, 38142, 18, 1087, 80197, 23567, 99146, 696, 262, 674, 304, 1855, 2872, 1070, 3966, 311, 387, 828, 369, 1475, 3330, 198, 262, 674, 1566, 3330, 374, 1510, 892, 198, 262, 11262, 1807, 2102, 46344, 20296, 73435, 12647, 262, 311, 8856, 284, 510, 1638, 7991, 10883, 2189, 489, 11262, 1807, 369, 2872, 304, 7576, 27526, 2595, 262, 2917, 284, 4635, 21361, 746, 262, 2917, 7925, 1021, 286, 330, 23421, 14700, 1296, 24857, 9657, 2186, 3628, 1712, 93692, 95110, 2293, 1021, 310, 15923, 13, 6115, 54530, 16139, 3343, 2293, 4962, 8, 369, 1401, 304, 3135, 12919, 340, 286, 1763, 262, 1763, 262, 2917, 16153, 332, 336, 3852, 1021, 286, 330, 12987, 12779, 1296, 24857, 15052, 9657, 2186, 10380, 3343, 2293, 48603, 13, 6115, 19605, 30, 1365, 353, 2479, 21118, 12919, 37463, 311, 8856, 198, 262, 5235, 262, 422, 7576, 6085, 6236, 512, 286, 2917, 7925, 446, 23421, 14700, 1296, 6236, 320, 1985, 6236, 16139, 19652, 286, 2917, 7925, 446, 12987, 12779, 1296, 6236, 15052, 77640, 498, 320, 27295, 6085, 6236, 11, 4489, 262, 4635, 16105, 746, 262, 4635, 4757, 2892, 262, 6050, 5506, 446, 1061, 5439, 311, 7832, 82, 23612, 2612, 2517, 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, 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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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 12055, 7177, 3135, 311, 4729, 382, 14711, 6075, 512, 755, 10488, 17, 38142, 78579, 11, 2612, 2517, 997, 262, 4304, 35, 12055, 7177, 3135, 311, 4729, 14781, 262, 3135, 12919, 284, 1160, 78579, 27526, 58, 15, 948, 10786, 2455, 262, 11262, 1807, 284, 14941, 262, 369, 1401, 304, 67677, 52351, 512, 286, 422, 1401, 539, 304, 3135, 12919, 512, 310, 3135, 12919, 2102, 4962, 340, 310, 11262, 1807, 2102, 446, 5240, 262, 4635, 284, 22775, 18, 11034, 9835, 3960, 28837, 882, 11304, 2517, 705, 11388, 9962, 28, 38142, 18, 1087, 80197, 23567, 99146, 696, 262, 674, 304, 1855, 2872, 1070, 3966, 311, 387, 828, 369, 1475, 3330, 198, 262, 674, 1566, 3330, 374, 1510, 892, 198, 262, 11262, 1807, 2102, 46344, 20296, 73435, 12647, 262, 311, 8856, 284, 510, 1638, 7991, 10883, 2189, 489, 11262, 1807, 369, 2872, 304, 7576, 27526, 2595, 262, 2917, 284, 4635, 21361, 746, 262, 2917, 7925, 1021, 286, 330, 23421, 14700, 1296, 24857, 9657, 2186, 3628, 1712, 93692, 95110, 2293, 1021, 310, 15923, 13, 6115, 54530, 16139, 3343, 2293, 4962, 8, 369, 1401, 304, 3135, 12919, 340, 286, 1763, 262, 1763, 262, 2917, 16153, 332, 336, 3852, 1021, 286, 330, 12987, 12779, 1296, 24857, 15052, 9657, 2186, 10380, 3343, 2293, 48603, 13, 6115, 19605, 30, 1365, 353, 2479, 21118, 12919, 37463, 311, 8856, 198, 262, 5235, 262, 422, 7576, 6085, 6236, 512, 286, 2917, 7925, 446, 23421, 14700, 1296, 6236, 320, 1985, 6236, 16139, 19652, 286, 2917, 7925, 446, 12987, 12779, 1296, 6236, 15052, 77640, 498, 320, 27295, 6085, 6236, 11, 4489, 262, 4635, 16105, 746, 262, 4635, 4757, 2892, 262, 6050, 5506, 446, 1061, 5439, 311, 7832, 82, 23612, 2612, 2517, 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 ]
nicolargo/glances
glances/plugins/glances_fs.py
Plugin.update
def update(self): """Update the FS stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib # Grab the stats using the psutil disk_partitions # If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys) # and ignore all others (e.g. memory partitions such as /dev/shm) try: fs_stat = psutil.disk_partitions(all=False) except UnicodeDecodeError: return self.stats # Optionnal hack to allow logicals mounts points (issue #448) # Ex: Had to put 'allow=zfs' in the [fs] section of the conf file # to allow zfs monitoring for fstype in self.get_conf_value('allow'): try: fs_stat += [f for f in psutil.disk_partitions(all=True) if f.fstype.find(fstype) >= 0] except UnicodeDecodeError: return self.stats # Loop over fs for fs in fs_stat: # Do not take hidden file system into account if self.is_hide(fs.mountpoint): continue # Grab the disk usage try: fs_usage = psutil.disk_usage(fs.mountpoint) except OSError: # Correct issue #346 # Disk is ejected during the command continue fs_current = { 'device_name': fs.device, 'fs_type': fs.fstype, # Manage non breaking space (see issue #1065) 'mnt_point': u(fs.mountpoint).replace(u'\u00A0', ' '), 'size': fs_usage.total, 'used': fs_usage.used, 'free': fs_usage.free, 'percent': fs_usage.percent, 'key': self.get_key()} stats.append(fs_current) elif self.input_method == 'snmp': # Update stats using SNMP # SNMP bulk command to get all file system in one shot try: fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid[self.short_system_name], bulk=True) except KeyError: fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid['default'], bulk=True) # Loop over fs if self.short_system_name in ('windows', 'esxi'): # Windows or ESXi tips for fs in fs_stat: # Memory stats are grabbed in the same OID table (ignore it) if fs == 'Virtual Memory' or fs == 'Physical Memory' or fs == 'Real Memory': continue size = int(fs_stat[fs]['size']) * int(fs_stat[fs]['alloc_unit']) used = int(fs_stat[fs]['used']) * int(fs_stat[fs]['alloc_unit']) percent = float(used * 100 / size) fs_current = { 'device_name': '', 'mnt_point': fs.partition(' ')[0], 'size': size, 'used': used, 'percent': percent, 'key': self.get_key()} stats.append(fs_current) else: # Default behavior for fs in fs_stat: fs_current = { 'device_name': fs_stat[fs]['device_name'], 'mnt_point': fs, 'size': int(fs_stat[fs]['size']) * 1024, 'used': int(fs_stat[fs]['used']) * 1024, 'percent': float(fs_stat[fs]['percent']), 'key': self.get_key()} stats.append(fs_current) # Update the stats self.stats = stats return self.stats
python
def update(self): """Update the FS stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib # Grab the stats using the psutil disk_partitions # If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys) # and ignore all others (e.g. memory partitions such as /dev/shm) try: fs_stat = psutil.disk_partitions(all=False) except UnicodeDecodeError: return self.stats # Optionnal hack to allow logicals mounts points (issue #448) # Ex: Had to put 'allow=zfs' in the [fs] section of the conf file # to allow zfs monitoring for fstype in self.get_conf_value('allow'): try: fs_stat += [f for f in psutil.disk_partitions(all=True) if f.fstype.find(fstype) >= 0] except UnicodeDecodeError: return self.stats # Loop over fs for fs in fs_stat: # Do not take hidden file system into account if self.is_hide(fs.mountpoint): continue # Grab the disk usage try: fs_usage = psutil.disk_usage(fs.mountpoint) except OSError: # Correct issue #346 # Disk is ejected during the command continue fs_current = { 'device_name': fs.device, 'fs_type': fs.fstype, # Manage non breaking space (see issue #1065) 'mnt_point': u(fs.mountpoint).replace(u'\u00A0', ' '), 'size': fs_usage.total, 'used': fs_usage.used, 'free': fs_usage.free, 'percent': fs_usage.percent, 'key': self.get_key()} stats.append(fs_current) elif self.input_method == 'snmp': # Update stats using SNMP # SNMP bulk command to get all file system in one shot try: fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid[self.short_system_name], bulk=True) except KeyError: fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid['default'], bulk=True) # Loop over fs if self.short_system_name in ('windows', 'esxi'): # Windows or ESXi tips for fs in fs_stat: # Memory stats are grabbed in the same OID table (ignore it) if fs == 'Virtual Memory' or fs == 'Physical Memory' or fs == 'Real Memory': continue size = int(fs_stat[fs]['size']) * int(fs_stat[fs]['alloc_unit']) used = int(fs_stat[fs]['used']) * int(fs_stat[fs]['alloc_unit']) percent = float(used * 100 / size) fs_current = { 'device_name': '', 'mnt_point': fs.partition(' ')[0], 'size': size, 'used': used, 'percent': percent, 'key': self.get_key()} stats.append(fs_current) else: # Default behavior for fs in fs_stat: fs_current = { 'device_name': fs_stat[fs]['device_name'], 'mnt_point': fs, 'size': int(fs_stat[fs]['size']) * 1024, 'used': int(fs_stat[fs]['used']) * 1024, 'percent': float(fs_stat[fs]['percent']), 'key': self.get_key()} stats.append(fs_current) # Update the stats self.stats = stats return self.stats
[ "def", "update", "(", "self", ")", ":", "# Init new stats", "stats", "=", "self", ".", "get_init_value", "(", ")", "if", "self", ".", "input_method", "==", "'local'", ":", "# Update stats using the standard system lib", "# Grab the stats using the psutil disk_partitions", "# If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys)", "# and ignore all others (e.g. memory partitions such as /dev/shm)", "try", ":", "fs_stat", "=", "psutil", ".", "disk_partitions", "(", "all", "=", "False", ")", "except", "UnicodeDecodeError", ":", "return", "self", ".", "stats", "# Optionnal hack to allow logicals mounts points (issue #448)", "# Ex: Had to put 'allow=zfs' in the [fs] section of the conf file", "# to allow zfs monitoring", "for", "fstype", "in", "self", ".", "get_conf_value", "(", "'allow'", ")", ":", "try", ":", "fs_stat", "+=", "[", "f", "for", "f", "in", "psutil", ".", "disk_partitions", "(", "all", "=", "True", ")", "if", "f", ".", "fstype", ".", "find", "(", "fstype", ")", ">=", "0", "]", "except", "UnicodeDecodeError", ":", "return", "self", ".", "stats", "# Loop over fs", "for", "fs", "in", "fs_stat", ":", "# Do not take hidden file system into account", "if", "self", ".", "is_hide", "(", "fs", ".", "mountpoint", ")", ":", "continue", "# Grab the disk usage", "try", ":", "fs_usage", "=", "psutil", ".", "disk_usage", "(", "fs", ".", "mountpoint", ")", "except", "OSError", ":", "# Correct issue #346", "# Disk is ejected during the command", "continue", "fs_current", "=", "{", "'device_name'", ":", "fs", ".", "device", ",", "'fs_type'", ":", "fs", ".", "fstype", ",", "# Manage non breaking space (see issue #1065)", "'mnt_point'", ":", "u", "(", "fs", ".", "mountpoint", ")", ".", "replace", "(", "u'\\u00A0'", ",", "' '", ")", ",", "'size'", ":", "fs_usage", ".", "total", ",", "'used'", ":", "fs_usage", ".", "used", ",", "'free'", ":", "fs_usage", ".", "free", ",", "'percent'", ":", "fs_usage", ".", "percent", ",", "'key'", ":", "self", ".", "get_key", "(", ")", "}", "stats", ".", "append", "(", "fs_current", ")", "elif", "self", ".", "input_method", "==", "'snmp'", ":", "# Update stats using SNMP", "# SNMP bulk command to get all file system in one shot", "try", ":", "fs_stat", "=", "self", ".", "get_stats_snmp", "(", "snmp_oid", "=", "snmp_oid", "[", "self", ".", "short_system_name", "]", ",", "bulk", "=", "True", ")", "except", "KeyError", ":", "fs_stat", "=", "self", ".", "get_stats_snmp", "(", "snmp_oid", "=", "snmp_oid", "[", "'default'", "]", ",", "bulk", "=", "True", ")", "# Loop over fs", "if", "self", ".", "short_system_name", "in", "(", "'windows'", ",", "'esxi'", ")", ":", "# Windows or ESXi tips", "for", "fs", "in", "fs_stat", ":", "# Memory stats are grabbed in the same OID table (ignore it)", "if", "fs", "==", "'Virtual Memory'", "or", "fs", "==", "'Physical Memory'", "or", "fs", "==", "'Real Memory'", ":", "continue", "size", "=", "int", "(", "fs_stat", "[", "fs", "]", "[", "'size'", "]", ")", "*", "int", "(", "fs_stat", "[", "fs", "]", "[", "'alloc_unit'", "]", ")", "used", "=", "int", "(", "fs_stat", "[", "fs", "]", "[", "'used'", "]", ")", "*", "int", "(", "fs_stat", "[", "fs", "]", "[", "'alloc_unit'", "]", ")", "percent", "=", "float", "(", "used", "*", "100", "/", "size", ")", "fs_current", "=", "{", "'device_name'", ":", "''", ",", "'mnt_point'", ":", "fs", ".", "partition", "(", "' '", ")", "[", "0", "]", ",", "'size'", ":", "size", ",", "'used'", ":", "used", ",", "'percent'", ":", "percent", ",", "'key'", ":", "self", ".", "get_key", "(", ")", "}", "stats", ".", "append", "(", "fs_current", ")", "else", ":", "# Default behavior", "for", "fs", "in", "fs_stat", ":", "fs_current", "=", "{", "'device_name'", ":", "fs_stat", "[", "fs", "]", "[", "'device_name'", "]", ",", "'mnt_point'", ":", "fs", ",", "'size'", ":", "int", "(", "fs_stat", "[", "fs", "]", "[", "'size'", "]", ")", "*", "1024", ",", "'used'", ":", "int", "(", "fs_stat", "[", "fs", "]", "[", "'used'", "]", ")", "*", "1024", ",", "'percent'", ":", "float", "(", "fs_stat", "[", "fs", "]", "[", "'percent'", "]", ")", ",", "'key'", ":", "self", ".", "get_key", "(", ")", "}", "stats", ".", "append", "(", "fs_current", ")", "# Update the stats", "self", ".", "stats", "=", "stats", "return", "self", ".", "stats" ]
Update the FS stats using the input method.
[ "Update", "the", "FS", "stats", "using", "the", "input", "method", "." ]
train
https://github.com/nicolargo/glances/blob/5bd4d587a736e0d2b03170b56926841d2a3eb7ee/glances/plugins/glances_fs.py#L88-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: Update the FS stats using the input method. ### Response: def update(self): """Update the FS stats using the input method.""" # Init new stats stats = self.get_init_value() if self.input_method == 'local': # Update stats using the standard system lib # Grab the stats using the psutil disk_partitions # If 'all'=False return physical devices only (e.g. hard disks, cd-rom drives, USB keys) # and ignore all others (e.g. memory partitions such as /dev/shm) try: fs_stat = psutil.disk_partitions(all=False) except UnicodeDecodeError: return self.stats # Optionnal hack to allow logicals mounts points (issue #448) # Ex: Had to put 'allow=zfs' in the [fs] section of the conf file # to allow zfs monitoring for fstype in self.get_conf_value('allow'): try: fs_stat += [f for f in psutil.disk_partitions(all=True) if f.fstype.find(fstype) >= 0] except UnicodeDecodeError: return self.stats # Loop over fs for fs in fs_stat: # Do not take hidden file system into account if self.is_hide(fs.mountpoint): continue # Grab the disk usage try: fs_usage = psutil.disk_usage(fs.mountpoint) except OSError: # Correct issue #346 # Disk is ejected during the command continue fs_current = { 'device_name': fs.device, 'fs_type': fs.fstype, # Manage non breaking space (see issue #1065) 'mnt_point': u(fs.mountpoint).replace(u'\u00A0', ' '), 'size': fs_usage.total, 'used': fs_usage.used, 'free': fs_usage.free, 'percent': fs_usage.percent, 'key': self.get_key()} stats.append(fs_current) elif self.input_method == 'snmp': # Update stats using SNMP # SNMP bulk command to get all file system in one shot try: fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid[self.short_system_name], bulk=True) except KeyError: fs_stat = self.get_stats_snmp(snmp_oid=snmp_oid['default'], bulk=True) # Loop over fs if self.short_system_name in ('windows', 'esxi'): # Windows or ESXi tips for fs in fs_stat: # Memory stats are grabbed in the same OID table (ignore it) if fs == 'Virtual Memory' or fs == 'Physical Memory' or fs == 'Real Memory': continue size = int(fs_stat[fs]['size']) * int(fs_stat[fs]['alloc_unit']) used = int(fs_stat[fs]['used']) * int(fs_stat[fs]['alloc_unit']) percent = float(used * 100 / size) fs_current = { 'device_name': '', 'mnt_point': fs.partition(' ')[0], 'size': size, 'used': used, 'percent': percent, 'key': self.get_key()} stats.append(fs_current) else: # Default behavior for fs in fs_stat: fs_current = { 'device_name': fs_stat[fs]['device_name'], 'mnt_point': fs, 'size': int(fs_stat[fs]['size']) * 1024, 'used': int(fs_stat[fs]['used']) * 1024, 'percent': float(fs_stat[fs]['percent']), 'key': self.get_key()} stats.append(fs_current) # Update the stats self.stats = stats return self.stats <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 4387, 279, 25275, 10691, 1701, 279, 1988, 1749, 382, 14711, 6075, 512, 755, 2713, 1214, 997, 286, 4304, 4387, 279, 25275, 10691, 1701, 279, 1988, 1749, 14781, 286, 674, 16065, 502, 10691, 198, 286, 10691, 284, 659, 673, 6265, 3220, 2892, 286, 422, 659, 10252, 9209, 624, 364, 2497, 3730, 310, 674, 5666, 10691, 1701, 279, 5410, 1887, 3127, 271, 310, 674, 37294, 279, 10691, 1701, 279, 4831, 1338, 13668, 100197, 198, 310, 674, 1442, 364, 543, 61385, 4139, 471, 7106, 7766, 1193, 320, 68, 1326, 13, 2653, 54858, 11, 15667, 12, 442, 20722, 11, 11602, 7039, 340, 310, 674, 323, 10240, 682, 3885, 320, 68, 1326, 13, 5044, 47788, 1778, 439, 611, 3667, 15030, 76, 340, 310, 1456, 512, 394, 8789, 16670, 284, 4831, 1338, 87311, 100197, 21013, 5725, 340, 310, 3734, 36997, 33664, 1480, 512, 394, 471, 659, 30956, 271, 310, 674, 7104, 43078, 17524, 311, 2187, 20406, 82, 57322, 3585, 320, 11407, 674, 19956, 340, 310, 674, 1398, 25, 24805, 311, 2231, 364, 7331, 83670, 3933, 6, 304, 279, 510, 3933, 60, 3857, 315, 279, 2389, 1052, 198, 310, 674, 257, 311, 2187, 1167, 3933, 16967, 198, 310, 369, 49534, 500, 304, 659, 673, 16445, 3220, 493, 7331, 11290, 394, 1456, 512, 504, 8789, 16670, 1447, 510, 69, 369, 282, 304, 4831, 1338, 87311, 100197, 21013, 3702, 8, 422, 282, 840, 74620, 2725, 968, 74620, 8, 2669, 220, 15, 933, 394, 3734, 36997, 33664, 1480, 512, 504, 471, 659, 30956, 271, 310, 674, 22070, 927, 8789, 198, 310, 369, 8789, 304, 8789, 16670, 512, 394, 674, 3234, 539, 1935, 8340, 1052, 1887, 1139, 2759, 198, 394, 422, 659, 2124, 50835, 32956, 81034, 2837, 997, 504, 3136, 198, 394, 674, 37294, 279, 13668, 10648, 198, 394, 1456, 512, 504, 8789, 32607, 284, 4831, 1338, 87311, 32607, 32956, 81034, 2837, 340, 394, 3734, 75342, 512, 504, 674, 41070, 4360, 674, 18061, 198, 504, 674, 39968, 374, 95503, 2391, 279, 3290, 198, 504, 3136, 198, 394, 8789, 11327, 284, 341, 504, 364, 6239, 1292, 1232, 8789, 18861, 345, 504, 364, 3933, 1857, 1232, 8789, 840, 74620, 345, 504, 674, 43750, 2536, 15061, 3634, 320, 4151, 4360, 674, 7461, 20, 340, 504, 364, 41982, 6213, 1232, 577, 32956, 81034, 2837, 570, 8319, 8317, 16154, 84, 410, 32, 15, 518, 364, 364, 1350, 504, 364, 2190, 1232, 8789, 32607, 14032, 345, 504, 364, 2656, 1232, 8789, 32607, 84302, 345, 504, 364, 10816, 1232, 8789, 32607, 46695, 345, 504, 364, 25426, 1232, 8789, 32607, 63377, 345, 504, 364, 798, 1232, 659, 673, 3173, 24413, 394, 10691, 2102, 32956, 11327, 696, 286, 4508, 659, 10252, 9209, 624, 364, 9810, 1331, 3730, 310, 674, 5666, 10691, 1701, 89233, 271, 310, 674, 89233, 20155, 3290, 311, 636, 682, 1052, 1887, 304, 832, 6689, 198, 310, 1456, 512, 394, 8789, 16670, 284, 659, 673, 15743, 29122, 1331, 60965, 1331, 60733 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 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, 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, 4387, 279, 25275, 10691, 1701, 279, 1988, 1749, 382, 14711, 6075, 512, 755, 2713, 1214, 997, 286, 4304, 4387, 279, 25275, 10691, 1701, 279, 1988, 1749, 14781, 286, 674, 16065, 502, 10691, 198, 286, 10691, 284, 659, 673, 6265, 3220, 2892, 286, 422, 659, 10252, 9209, 624, 364, 2497, 3730, 310, 674, 5666, 10691, 1701, 279, 5410, 1887, 3127, 271, 310, 674, 37294, 279, 10691, 1701, 279, 4831, 1338, 13668, 100197, 198, 310, 674, 1442, 364, 543, 61385, 4139, 471, 7106, 7766, 1193, 320, 68, 1326, 13, 2653, 54858, 11, 15667, 12, 442, 20722, 11, 11602, 7039, 340, 310, 674, 323, 10240, 682, 3885, 320, 68, 1326, 13, 5044, 47788, 1778, 439, 611, 3667, 15030, 76, 340, 310, 1456, 512, 394, 8789, 16670, 284, 4831, 1338, 87311, 100197, 21013, 5725, 340, 310, 3734, 36997, 33664, 1480, 512, 394, 471, 659, 30956, 271, 310, 674, 7104, 43078, 17524, 311, 2187, 20406, 82, 57322, 3585, 320, 11407, 674, 19956, 340, 310, 674, 1398, 25, 24805, 311, 2231, 364, 7331, 83670, 3933, 6, 304, 279, 510, 3933, 60, 3857, 315, 279, 2389, 1052, 198, 310, 674, 257, 311, 2187, 1167, 3933, 16967, 198, 310, 369, 49534, 500, 304, 659, 673, 16445, 3220, 493, 7331, 11290, 394, 1456, 512, 504, 8789, 16670, 1447, 510, 69, 369, 282, 304, 4831, 1338, 87311, 100197, 21013, 3702, 8, 422, 282, 840, 74620, 2725, 968, 74620, 8, 2669, 220, 15, 933, 394, 3734, 36997, 33664, 1480, 512, 504, 471, 659, 30956, 271, 310, 674, 22070, 927, 8789, 198, 310, 369, 8789, 304, 8789, 16670, 512, 394, 674, 3234, 539, 1935, 8340, 1052, 1887, 1139, 2759, 198, 394, 422, 659, 2124, 50835, 32956, 81034, 2837, 997, 504, 3136, 198, 394, 674, 37294, 279, 13668, 10648, 198, 394, 1456, 512, 504, 8789, 32607, 284, 4831, 1338, 87311, 32607, 32956, 81034, 2837, 340, 394, 3734, 75342, 512, 504, 674, 41070, 4360, 674, 18061, 198, 504, 674, 39968, 374, 95503, 2391, 279, 3290, 198, 504, 3136, 198, 394, 8789, 11327, 284, 341, 504, 364, 6239, 1292, 1232, 8789, 18861, 345, 504, 364, 3933, 1857, 1232, 8789, 840, 74620, 345, 504, 674, 43750, 2536, 15061, 3634, 320, 4151, 4360, 674, 7461, 20, 340, 504, 364, 41982, 6213, 1232, 577, 32956, 81034, 2837, 570, 8319, 8317, 16154, 84, 410, 32, 15, 518, 364, 364, 1350, 504, 364, 2190, 1232, 8789, 32607, 14032, 345, 504, 364, 2656, 1232, 8789, 32607, 84302, 345, 504, 364, 10816, 1232, 8789, 32607, 46695, 345, 504, 364, 25426, 1232, 8789, 32607, 63377, 345, 504, 364, 798, 1232, 659, 673, 3173, 24413, 394, 10691, 2102, 32956, 11327, 696, 286, 4508, 659, 10252, 9209, 624, 364, 9810, 1331, 3730, 310, 674, 5666, 10691, 1701, 89233, 271, 310, 674, 89233, 20155, 3290, 311, 636, 682, 1052, 1887, 304, 832, 6689, 198, 310, 1456, 512, 394, 8789, 16670, 284, 659, 673, 15743, 29122, 1331, 60965, 1331, 60733 ]
bram85/topydo
topydo/ui/CLIApplicationBase.py
_retrieve_archive
def _retrieve_archive(): """ Returns a tuple with archive content: the first element is a TodoListBase and the second element is a TodoFile. """ archive_file = TodoFile.TodoFile(config().archive()) archive = TodoListBase.TodoListBase(archive_file.read()) return (archive, archive_file)
python
def _retrieve_archive(): """ Returns a tuple with archive content: the first element is a TodoListBase and the second element is a TodoFile. """ archive_file = TodoFile.TodoFile(config().archive()) archive = TodoListBase.TodoListBase(archive_file.read()) return (archive, archive_file)
[ "def", "_retrieve_archive", "(", ")", ":", "archive_file", "=", "TodoFile", ".", "TodoFile", "(", "config", "(", ")", ".", "archive", "(", ")", ")", "archive", "=", "TodoListBase", ".", "TodoListBase", "(", "archive_file", ".", "read", "(", ")", ")", "return", "(", "archive", ",", "archive_file", ")" ]
Returns a tuple with archive content: the first element is a TodoListBase and the second element is a TodoFile.
[ "Returns", "a", "tuple", "with", "archive", "content", ":", "the", "first", "element", "is", "a", "TodoListBase", "and", "the", "second", "element", "is", "a", "TodoFile", "." ]
train
https://github.com/bram85/topydo/blob/b59fcfca5361869a6b78d4c9808c7c6cd0a18b58/topydo/ui/CLIApplicationBase.py#L154-L162
<|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 tuple with archive content: the first element is a TodoListBase and the second element is a TodoFile. ### Response: def _retrieve_archive(): """ Returns a tuple with archive content: the first element is a TodoListBase and the second element is a TodoFile. """ archive_file = TodoFile.TodoFile(config().archive()) archive = TodoListBase.TodoListBase(archive_file.read()) return (archive, archive_file) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 16851, 264, 14743, 449, 18624, 2262, 25, 279, 1176, 2449, 374, 264, 26476, 861, 4066, 198, 262, 323, 279, 2132, 2449, 374, 264, 26476, 1738, 382, 14711, 6075, 512, 755, 721, 56627, 43973, 4019, 262, 3270, 262, 5295, 264, 14743, 449, 18624, 2262, 25, 279, 1176, 2449, 374, 264, 26476, 861, 4066, 198, 262, 323, 279, 2132, 2449, 374, 264, 26476, 1738, 627, 262, 3270, 262, 18624, 2517, 284, 26476, 1738, 844, 6132, 1738, 8928, 1020, 16402, 2455, 262, 18624, 284, 26476, 861, 4066, 844, 6132, 861, 4066, 7, 16402, 2517, 4217, 12647, 262, 471, 320, 16402, 11, 18624, 2517, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 14743, 449, 18624, 2262, 25, 279, 1176, 2449, 374, 264, 26476, 861, 4066, 198, 262, 323, 279, 2132, 2449, 374, 264, 26476, 1738, 382, 14711, 6075, 512, 755, 721, 56627, 43973, 4019, 262, 3270, 262, 5295, 264, 14743, 449, 18624, 2262, 25, 279, 1176, 2449, 374, 264, 26476, 861, 4066, 198, 262, 323, 279, 2132, 2449, 374, 264, 26476, 1738, 627, 262, 3270, 262, 18624, 2517, 284, 26476, 1738, 844, 6132, 1738, 8928, 1020, 16402, 2455, 262, 18624, 284, 26476, 861, 4066, 844, 6132, 861, 4066, 7, 16402, 2517, 4217, 12647, 262, 471, 320, 16402, 11, 18624, 2517, 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 ]
mikedh/trimesh
trimesh/proximity.py
closest_point
def closest_point(mesh, points): """ Given a mesh and a list of points, find the closest point on any triangle. Parameters ---------- mesh : Trimesh object points : (m,3) float, points in space Returns ---------- closest : (m,3) float, closest point on triangles for each point distance : (m,) float, distance triangle_id : (m,) int, index of triangle containing closest point """ points = np.asanyarray(points, dtype=np.float64) if not util.is_shape(points, (-1, 3)): raise ValueError('points must be (n,3)!') # do a tree- based query for faces near each point candidates = nearby_faces(mesh, points) # view triangles as an ndarray so we don't have to recompute # the MD5 during all of the subsequent advanced indexing triangles = mesh.triangles.view(np.ndarray) # create the corresponding list of triangles # and query points to send to the closest_point function query_point = deque() query_tri = deque() for triangle_ids, point in zip(candidates, points): query_point.append(np.tile(point, (len(triangle_ids), 1))) query_tri.append(triangles[triangle_ids]) # stack points into an (n,3) array query_point = np.vstack(query_point) # stack triangles into an (n,3,3) array query_tri = np.vstack(query_tri) # do the computation for closest point query_close = closest_point_corresponding(query_tri, query_point) query_group = np.cumsum(np.array([len(i) for i in candidates]))[:-1] distance_2 = ((query_close - query_point) ** 2).sum(axis=1) # find the single closest point for each group of candidates result_close = np.zeros((len(points), 3), dtype=np.float64) result_tid = np.zeros(len(points), dtype=np.int64) result_distance = np.zeros(len(points), dtype=np.float64) # go through results to get minimum distance result for i, close_points, distance, candidate in zip( np.arange(len(points)), np.array_split(query_close, query_group), np.array_split(distance_2, query_group), candidates): # unless some other check is true use the smallest distance idx = distance.argmin() # if we have multiple candidates check them if len(candidate) > 1: # (2, ) int, list of 2 closest candidate indices idxs = distance.argsort()[:2] # make sure the two distances are identical check_distance = distance[idxs].ptp() < tol.merge # make sure the magnitude of both distances are nonzero check_magnitude = (np.abs(distance[idxs]) > tol.merge).all() # check if query-points are actually off-surface if check_distance and check_magnitude: # get face normals for two points normals = mesh.face_normals[np.array(candidate)[idxs]] # compute normalized surface-point to query-point vectors vectors = ((points[i] - close_points[idxs]) / distance[idxs, np.newaxis] ** 0.5) # compare enclosed angle for both face normals dots = util.diagonal_dot(normals, vectors) # take the idx with the most positive angle idx = idxs[dots.argmax()] # take the single closest value from the group of values result_close[i] = close_points[idx] result_tid[i] = candidate[idx] result_distance[i] = distance[idx] # we were comparing the distance squared so # now take the square root in one vectorized operation result_distance **= .5 return result_close, result_distance, result_tid
python
def closest_point(mesh, points): """ Given a mesh and a list of points, find the closest point on any triangle. Parameters ---------- mesh : Trimesh object points : (m,3) float, points in space Returns ---------- closest : (m,3) float, closest point on triangles for each point distance : (m,) float, distance triangle_id : (m,) int, index of triangle containing closest point """ points = np.asanyarray(points, dtype=np.float64) if not util.is_shape(points, (-1, 3)): raise ValueError('points must be (n,3)!') # do a tree- based query for faces near each point candidates = nearby_faces(mesh, points) # view triangles as an ndarray so we don't have to recompute # the MD5 during all of the subsequent advanced indexing triangles = mesh.triangles.view(np.ndarray) # create the corresponding list of triangles # and query points to send to the closest_point function query_point = deque() query_tri = deque() for triangle_ids, point in zip(candidates, points): query_point.append(np.tile(point, (len(triangle_ids), 1))) query_tri.append(triangles[triangle_ids]) # stack points into an (n,3) array query_point = np.vstack(query_point) # stack triangles into an (n,3,3) array query_tri = np.vstack(query_tri) # do the computation for closest point query_close = closest_point_corresponding(query_tri, query_point) query_group = np.cumsum(np.array([len(i) for i in candidates]))[:-1] distance_2 = ((query_close - query_point) ** 2).sum(axis=1) # find the single closest point for each group of candidates result_close = np.zeros((len(points), 3), dtype=np.float64) result_tid = np.zeros(len(points), dtype=np.int64) result_distance = np.zeros(len(points), dtype=np.float64) # go through results to get minimum distance result for i, close_points, distance, candidate in zip( np.arange(len(points)), np.array_split(query_close, query_group), np.array_split(distance_2, query_group), candidates): # unless some other check is true use the smallest distance idx = distance.argmin() # if we have multiple candidates check them if len(candidate) > 1: # (2, ) int, list of 2 closest candidate indices idxs = distance.argsort()[:2] # make sure the two distances are identical check_distance = distance[idxs].ptp() < tol.merge # make sure the magnitude of both distances are nonzero check_magnitude = (np.abs(distance[idxs]) > tol.merge).all() # check if query-points are actually off-surface if check_distance and check_magnitude: # get face normals for two points normals = mesh.face_normals[np.array(candidate)[idxs]] # compute normalized surface-point to query-point vectors vectors = ((points[i] - close_points[idxs]) / distance[idxs, np.newaxis] ** 0.5) # compare enclosed angle for both face normals dots = util.diagonal_dot(normals, vectors) # take the idx with the most positive angle idx = idxs[dots.argmax()] # take the single closest value from the group of values result_close[i] = close_points[idx] result_tid[i] = candidate[idx] result_distance[i] = distance[idx] # we were comparing the distance squared so # now take the square root in one vectorized operation result_distance **= .5 return result_close, result_distance, result_tid
[ "def", "closest_point", "(", "mesh", ",", "points", ")", ":", "points", "=", "np", ".", "asanyarray", "(", "points", ",", "dtype", "=", "np", ".", "float64", ")", "if", "not", "util", ".", "is_shape", "(", "points", ",", "(", "-", "1", ",", "3", ")", ")", ":", "raise", "ValueError", "(", "'points must be (n,3)!'", ")", "# do a tree- based query for faces near each point", "candidates", "=", "nearby_faces", "(", "mesh", ",", "points", ")", "# view triangles as an ndarray so we don't have to recompute", "# the MD5 during all of the subsequent advanced indexing", "triangles", "=", "mesh", ".", "triangles", ".", "view", "(", "np", ".", "ndarray", ")", "# create the corresponding list of triangles", "# and query points to send to the closest_point function", "query_point", "=", "deque", "(", ")", "query_tri", "=", "deque", "(", ")", "for", "triangle_ids", ",", "point", "in", "zip", "(", "candidates", ",", "points", ")", ":", "query_point", ".", "append", "(", "np", ".", "tile", "(", "point", ",", "(", "len", "(", "triangle_ids", ")", ",", "1", ")", ")", ")", "query_tri", ".", "append", "(", "triangles", "[", "triangle_ids", "]", ")", "# stack points into an (n,3) array", "query_point", "=", "np", ".", "vstack", "(", "query_point", ")", "# stack triangles into an (n,3,3) array", "query_tri", "=", "np", ".", "vstack", "(", "query_tri", ")", "# do the computation for closest point", "query_close", "=", "closest_point_corresponding", "(", "query_tri", ",", "query_point", ")", "query_group", "=", "np", ".", "cumsum", "(", "np", ".", "array", "(", "[", "len", "(", "i", ")", "for", "i", "in", "candidates", "]", ")", ")", "[", ":", "-", "1", "]", "distance_2", "=", "(", "(", "query_close", "-", "query_point", ")", "**", "2", ")", ".", "sum", "(", "axis", "=", "1", ")", "# find the single closest point for each group of candidates", "result_close", "=", "np", ".", "zeros", "(", "(", "len", "(", "points", ")", ",", "3", ")", ",", "dtype", "=", "np", ".", "float64", ")", "result_tid", "=", "np", ".", "zeros", "(", "len", "(", "points", ")", ",", "dtype", "=", "np", ".", "int64", ")", "result_distance", "=", "np", ".", "zeros", "(", "len", "(", "points", ")", ",", "dtype", "=", "np", ".", "float64", ")", "# go through results to get minimum distance result", "for", "i", ",", "close_points", ",", "distance", ",", "candidate", "in", "zip", "(", "np", ".", "arange", "(", "len", "(", "points", ")", ")", ",", "np", ".", "array_split", "(", "query_close", ",", "query_group", ")", ",", "np", ".", "array_split", "(", "distance_2", ",", "query_group", ")", ",", "candidates", ")", ":", "# unless some other check is true use the smallest distance", "idx", "=", "distance", ".", "argmin", "(", ")", "# if we have multiple candidates check them", "if", "len", "(", "candidate", ")", ">", "1", ":", "# (2, ) int, list of 2 closest candidate indices", "idxs", "=", "distance", ".", "argsort", "(", ")", "[", ":", "2", "]", "# make sure the two distances are identical", "check_distance", "=", "distance", "[", "idxs", "]", ".", "ptp", "(", ")", "<", "tol", ".", "merge", "# make sure the magnitude of both distances are nonzero", "check_magnitude", "=", "(", "np", ".", "abs", "(", "distance", "[", "idxs", "]", ")", ">", "tol", ".", "merge", ")", ".", "all", "(", ")", "# check if query-points are actually off-surface", "if", "check_distance", "and", "check_magnitude", ":", "# get face normals for two points", "normals", "=", "mesh", ".", "face_normals", "[", "np", ".", "array", "(", "candidate", ")", "[", "idxs", "]", "]", "# compute normalized surface-point to query-point vectors", "vectors", "=", "(", "(", "points", "[", "i", "]", "-", "close_points", "[", "idxs", "]", ")", "/", "distance", "[", "idxs", ",", "np", ".", "newaxis", "]", "**", "0.5", ")", "# compare enclosed angle for both face normals", "dots", "=", "util", ".", "diagonal_dot", "(", "normals", ",", "vectors", ")", "# take the idx with the most positive angle", "idx", "=", "idxs", "[", "dots", ".", "argmax", "(", ")", "]", "# take the single closest value from the group of values", "result_close", "[", "i", "]", "=", "close_points", "[", "idx", "]", "result_tid", "[", "i", "]", "=", "candidate", "[", "idx", "]", "result_distance", "[", "i", "]", "=", "distance", "[", "idx", "]", "# we were comparing the distance squared so", "# now take the square root in one vectorized operation", "result_distance", "**=", ".5", "return", "result_close", ",", "result_distance", ",", "result_tid" ]
Given a mesh and a list of points, find the closest point on any triangle. Parameters ---------- mesh : Trimesh object points : (m,3) float, points in space Returns ---------- closest : (m,3) float, closest point on triangles for each point distance : (m,) float, distance triangle_id : (m,) int, index of triangle containing closest point
[ "Given", "a", "mesh", "and", "a", "list", "of", "points", "find", "the", "closest", "point", "on", "any", "triangle", "." ]
train
https://github.com/mikedh/trimesh/blob/25e059bf6d4caa74f62ffd58ce4f61a90ee4e518/trimesh/proximity.py#L112-L202
<|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 mesh and a list of points, find the closest point on any triangle. Parameters ---------- mesh : Trimesh object points : (m,3) float, points in space Returns ---------- closest : (m,3) float, closest point on triangles for each point distance : (m,) float, distance triangle_id : (m,) int, index of triangle containing closest point ### Response: def closest_point(mesh, points): """ Given a mesh and a list of points, find the closest point on any triangle. Parameters ---------- mesh : Trimesh object points : (m,3) float, points in space Returns ---------- closest : (m,3) float, closest point on triangles for each point distance : (m,) float, distance triangle_id : (m,) int, index of triangle containing closest point """ points = np.asanyarray(points, dtype=np.float64) if not util.is_shape(points, (-1, 3)): raise ValueError('points must be (n,3)!') # do a tree- based query for faces near each point candidates = nearby_faces(mesh, points) # view triangles as an ndarray so we don't have to recompute # the MD5 during all of the subsequent advanced indexing triangles = mesh.triangles.view(np.ndarray) # create the corresponding list of triangles # and query points to send to the closest_point function query_point = deque() query_tri = deque() for triangle_ids, point in zip(candidates, points): query_point.append(np.tile(point, (len(triangle_ids), 1))) query_tri.append(triangles[triangle_ids]) # stack points into an (n,3) array query_point = np.vstack(query_point) # stack triangles into an (n,3,3) array query_tri = np.vstack(query_tri) # do the computation for closest point query_close = closest_point_corresponding(query_tri, query_point) query_group = np.cumsum(np.array([len(i) for i in candidates]))[:-1] distance_2 = ((query_close - query_point) ** 2).sum(axis=1) # find the single closest point for each group of candidates result_close = np.zeros((len(points), 3), dtype=np.float64) result_tid = np.zeros(len(points), dtype=np.int64) result_distance = np.zeros(len(points), dtype=np.float64) # go through results to get minimum distance result for i, close_points, distance, candidate in zip( np.arange(len(points)), np.array_split(query_close, query_group), np.array_split(distance_2, query_group), candidates): # unless some other check is true use the smallest distance idx = distance.argmin() # if we have multiple candidates check them if len(candidate) > 1: # (2, ) int, list of 2 closest candidate indices idxs = distance.argsort()[:2] # make sure the two distances are identical check_distance = distance[idxs].ptp() < tol.merge # make sure the magnitude of both distances are nonzero check_magnitude = (np.abs(distance[idxs]) > tol.merge).all() # check if query-points are actually off-surface if check_distance and check_magnitude: # get face normals for two points normals = mesh.face_normals[np.array(candidate)[idxs]] # compute normalized surface-point to query-point vectors vectors = ((points[i] - close_points[idxs]) / distance[idxs, np.newaxis] ** 0.5) # compare enclosed angle for both face normals dots = util.diagonal_dot(normals, vectors) # take the idx with the most positive angle idx = idxs[dots.argmax()] # take the single closest value from the group of values result_close[i] = close_points[idx] result_tid[i] = candidate[idx] result_distance[i] = distance[idx] # we were comparing the distance squared so # now take the square root in one vectorized operation result_distance **= .5 return result_close, result_distance, result_tid <|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, 11546, 323, 264, 1160, 315, 3585, 11, 1505, 279, 18585, 1486, 389, 904, 22217, 382, 262, 13831, 198, 262, 31423, 262, 11546, 256, 551, 1183, 1769, 71, 1665, 198, 262, 3585, 551, 320, 76, 11, 18, 8, 256, 2273, 11, 3585, 304, 3634, 271, 262, 5295, 198, 262, 31423, 262, 18585, 257, 551, 320, 76, 11, 18, 8, 2273, 11, 18585, 1486, 389, 43546, 369, 1855, 1486, 198, 262, 6138, 262, 551, 320, 76, 47121, 220, 2273, 11, 6138, 198, 262, 22217, 851, 551, 320, 76, 47121, 220, 528, 11, 1963, 315, 22217, 8649, 18585, 1486, 271, 14711, 6075, 512, 755, 18585, 6213, 47441, 11, 3585, 997, 262, 3270, 262, 16644, 264, 11546, 323, 264, 1160, 315, 3585, 11, 1505, 279, 18585, 1486, 389, 904, 22217, 382, 262, 13831, 198, 262, 31423, 262, 11546, 256, 551, 1183, 1769, 71, 1665, 198, 262, 3585, 551, 320, 76, 11, 18, 8, 256, 2273, 11, 3585, 304, 3634, 271, 262, 5295, 198, 262, 31423, 262, 18585, 257, 551, 320, 76, 11, 18, 8, 2273, 11, 18585, 1486, 389, 43546, 369, 1855, 1486, 198, 262, 6138, 262, 551, 320, 76, 47121, 220, 2273, 11, 6138, 198, 262, 22217, 851, 551, 320, 76, 47121, 220, 528, 11, 1963, 315, 22217, 8649, 18585, 1486, 198, 262, 12713, 262, 3585, 284, 2660, 5470, 3852, 1686, 33550, 11, 13534, 17874, 16304, 1227, 340, 262, 422, 539, 4186, 2124, 13911, 33550, 11, 10505, 16, 11, 220, 18, 10162, 286, 4933, 15764, 493, 7862, 2011, 387, 320, 77, 11, 18, 42395, 4713, 262, 674, 656, 264, 5021, 12, 3196, 3319, 369, 12580, 3221, 1855, 1486, 198, 262, 11426, 284, 14373, 60948, 47441, 11, 3585, 340, 262, 674, 1684, 43546, 439, 459, 67983, 779, 584, 1541, 956, 617, 311, 312, 28806, 198, 262, 674, 279, 14306, 20, 2391, 682, 315, 279, 17876, 11084, 53080, 198, 262, 43546, 284, 11546, 5543, 72, 17694, 3877, 10101, 36649, 696, 262, 674, 1893, 279, 12435, 1160, 315, 43546, 198, 262, 674, 323, 3319, 3585, 311, 3708, 311, 279, 18585, 6213, 734, 198, 262, 3319, 6213, 284, 43050, 746, 262, 3319, 43220, 284, 43050, 746, 262, 369, 22217, 8237, 11, 1486, 304, 10521, 1361, 27316, 11, 3585, 997, 286, 3319, 6213, 2102, 10101, 31034, 20848, 11, 320, 2963, 7779, 64950, 8237, 705, 220, 16, 6054, 286, 3319, 43220, 2102, 7779, 72, 17694, 58, 56214, 8237, 9801, 262, 674, 5729, 3585, 1139, 459, 320, 77, 11, 18, 8, 1358, 198, 262, 3319, 6213, 284, 2660, 70992, 10974, 6213, 340, 262, 674, 5729, 43546, 1139, 459, 320, 77, 11, 18, 11, 18, 8, 1358, 198, 262, 3319, 43220, 284, 2660, 70992, 10974, 43220, 696, 262, 674, 656, 279, 35547, 369, 18585, 1486, 198, 262, 3319, 12993, 284, 18585, 6213, 15076, 6961, 287, 10974, 43220, 11, 3319, 6213, 340, 262, 3319, 6422, 284, 2660, 97659, 1264, 10101, 7382, 2625, 2963 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 22818, 264, 11546, 323, 264, 1160, 315, 3585, 11, 1505, 279, 18585, 1486, 389, 904, 22217, 382, 262, 13831, 198, 262, 31423, 262, 11546, 256, 551, 1183, 1769, 71, 1665, 198, 262, 3585, 551, 320, 76, 11, 18, 8, 256, 2273, 11, 3585, 304, 3634, 271, 262, 5295, 198, 262, 31423, 262, 18585, 257, 551, 320, 76, 11, 18, 8, 2273, 11, 18585, 1486, 389, 43546, 369, 1855, 1486, 198, 262, 6138, 262, 551, 320, 76, 47121, 220, 2273, 11, 6138, 198, 262, 22217, 851, 551, 320, 76, 47121, 220, 528, 11, 1963, 315, 22217, 8649, 18585, 1486, 271, 14711, 6075, 512, 755, 18585, 6213, 47441, 11, 3585, 997, 262, 3270, 262, 16644, 264, 11546, 323, 264, 1160, 315, 3585, 11, 1505, 279, 18585, 1486, 389, 904, 22217, 382, 262, 13831, 198, 262, 31423, 262, 11546, 256, 551, 1183, 1769, 71, 1665, 198, 262, 3585, 551, 320, 76, 11, 18, 8, 256, 2273, 11, 3585, 304, 3634, 271, 262, 5295, 198, 262, 31423, 262, 18585, 257, 551, 320, 76, 11, 18, 8, 2273, 11, 18585, 1486, 389, 43546, 369, 1855, 1486, 198, 262, 6138, 262, 551, 320, 76, 47121, 220, 2273, 11, 6138, 198, 262, 22217, 851, 551, 320, 76, 47121, 220, 528, 11, 1963, 315, 22217, 8649, 18585, 1486, 198, 262, 12713, 262, 3585, 284, 2660, 5470, 3852, 1686, 33550, 11, 13534, 17874, 16304, 1227, 340, 262, 422, 539, 4186, 2124, 13911, 33550, 11, 10505, 16, 11, 220, 18, 10162, 286, 4933, 15764, 493, 7862, 2011, 387, 320, 77, 11, 18, 42395, 4713, 262, 674, 656, 264, 5021, 12, 3196, 3319, 369, 12580, 3221, 1855, 1486, 198, 262, 11426, 284, 14373, 60948, 47441, 11, 3585, 340, 262, 674, 1684, 43546, 439, 459, 67983, 779, 584, 1541, 956, 617, 311, 312, 28806, 198, 262, 674, 279, 14306, 20, 2391, 682, 315, 279, 17876, 11084, 53080, 198, 262, 43546, 284, 11546, 5543, 72, 17694, 3877, 10101, 36649, 696, 262, 674, 1893, 279, 12435, 1160, 315, 43546, 198, 262, 674, 323, 3319, 3585, 311, 3708, 311, 279, 18585, 6213, 734, 198, 262, 3319, 6213, 284, 43050, 746, 262, 3319, 43220, 284, 43050, 746, 262, 369, 22217, 8237, 11, 1486, 304, 10521, 1361, 27316, 11, 3585, 997, 286, 3319, 6213, 2102, 10101, 31034, 20848, 11, 320, 2963, 7779, 64950, 8237, 705, 220, 16, 6054, 286, 3319, 43220, 2102, 7779, 72, 17694, 58, 56214, 8237, 9801, 262, 674, 5729, 3585, 1139, 459, 320, 77, 11, 18, 8, 1358, 198, 262, 3319, 6213, 284, 2660, 70992, 10974, 6213, 340, 262, 674, 5729, 43546, 1139, 459, 320, 77, 11, 18, 11, 18, 8, 1358, 198, 262, 3319, 43220, 284, 2660, 70992, 10974, 43220, 696, 262, 674, 656, 279, 35547, 369, 18585, 1486, 198, 262, 3319, 12993, 284, 18585, 6213, 15076, 6961, 287, 10974, 43220, 11, 3319, 6213, 340, 262, 3319, 6422, 284, 2660, 97659, 1264, 10101, 7382, 2625, 2963 ]
FNNDSC/pftree
pftree/pftree.py
pftree.tree_construct
def tree_construct(self, *args, **kwargs): """ Processes the <l_files> list of files from the tree_probe() and builds the input/output dictionary structures. Optionally execute a constructCallback function, and return results """ l_files = [] d_constructCallback = {} fn_constructCallback = None for k, v in kwargs.items(): if k == 'l_files': l_files = v if k == 'constructCallback': fn_constructCallback = v index = 1 total = len(l_files) for l_series in l_files: str_path = os.path.dirname(l_series[0]) l_series = [ os.path.basename(i) for i in l_series] self.simpleProgress_show(index, total) self.d_inputTree[str_path] = l_series if fn_constructCallback: kwargs['path'] = str_path d_constructCallback = fn_constructCallback(l_series, **kwargs) self.d_inputTreeCallback[str_path] = d_constructCallback self.d_outputTree[str_path] = "" index += 1 return { 'status': True, 'd_constructCalback': d_constructCallback, 'totalNumberOfAllSeries': index }
python
def tree_construct(self, *args, **kwargs): """ Processes the <l_files> list of files from the tree_probe() and builds the input/output dictionary structures. Optionally execute a constructCallback function, and return results """ l_files = [] d_constructCallback = {} fn_constructCallback = None for k, v in kwargs.items(): if k == 'l_files': l_files = v if k == 'constructCallback': fn_constructCallback = v index = 1 total = len(l_files) for l_series in l_files: str_path = os.path.dirname(l_series[0]) l_series = [ os.path.basename(i) for i in l_series] self.simpleProgress_show(index, total) self.d_inputTree[str_path] = l_series if fn_constructCallback: kwargs['path'] = str_path d_constructCallback = fn_constructCallback(l_series, **kwargs) self.d_inputTreeCallback[str_path] = d_constructCallback self.d_outputTree[str_path] = "" index += 1 return { 'status': True, 'd_constructCalback': d_constructCallback, 'totalNumberOfAllSeries': index }
[ "def", "tree_construct", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "l_files", "=", "[", "]", "d_constructCallback", "=", "{", "}", "fn_constructCallback", "=", "None", "for", "k", ",", "v", "in", "kwargs", ".", "items", "(", ")", ":", "if", "k", "==", "'l_files'", ":", "l_files", "=", "v", "if", "k", "==", "'constructCallback'", ":", "fn_constructCallback", "=", "v", "index", "=", "1", "total", "=", "len", "(", "l_files", ")", "for", "l_series", "in", "l_files", ":", "str_path", "=", "os", ".", "path", ".", "dirname", "(", "l_series", "[", "0", "]", ")", "l_series", "=", "[", "os", ".", "path", ".", "basename", "(", "i", ")", "for", "i", "in", "l_series", "]", "self", ".", "simpleProgress_show", "(", "index", ",", "total", ")", "self", ".", "d_inputTree", "[", "str_path", "]", "=", "l_series", "if", "fn_constructCallback", ":", "kwargs", "[", "'path'", "]", "=", "str_path", "d_constructCallback", "=", "fn_constructCallback", "(", "l_series", ",", "*", "*", "kwargs", ")", "self", ".", "d_inputTreeCallback", "[", "str_path", "]", "=", "d_constructCallback", "self", ".", "d_outputTree", "[", "str_path", "]", "=", "\"\"", "index", "+=", "1", "return", "{", "'status'", ":", "True", ",", "'d_constructCalback'", ":", "d_constructCallback", ",", "'totalNumberOfAllSeries'", ":", "index", "}" ]
Processes the <l_files> list of files from the tree_probe() and builds the input/output dictionary structures. Optionally execute a constructCallback function, and return results
[ "Processes", "the", "<l_files", ">", "list", "of", "files", "from", "the", "tree_probe", "()", "and", "builds", "the", "input", "/", "output", "dictionary", "structures", "." ]
train
https://github.com/FNNDSC/pftree/blob/b841e337c976bce151735f9d5dd95eded62aa094/pftree/pftree.py#L241-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: Processes the <l_files> list of files from the tree_probe() and builds the input/output dictionary structures. Optionally execute a constructCallback function, and return results ### Response: def tree_construct(self, *args, **kwargs): """ Processes the <l_files> list of files from the tree_probe() and builds the input/output dictionary structures. Optionally execute a constructCallback function, and return results """ l_files = [] d_constructCallback = {} fn_constructCallback = None for k, v in kwargs.items(): if k == 'l_files': l_files = v if k == 'constructCallback': fn_constructCallback = v index = 1 total = len(l_files) for l_series in l_files: str_path = os.path.dirname(l_series[0]) l_series = [ os.path.basename(i) for i in l_series] self.simpleProgress_show(index, total) self.d_inputTree[str_path] = l_series if fn_constructCallback: kwargs['path'] = str_path d_constructCallback = fn_constructCallback(l_series, **kwargs) self.d_inputTreeCallback[str_path] = d_constructCallback self.d_outputTree[str_path] = "" index += 1 return { 'status': True, 'd_constructCalback': d_constructCallback, 'totalNumberOfAllSeries': index } <|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, 93827, 279, 366, 75, 11171, 29, 1160, 315, 3626, 505, 279, 5021, 50208, 746, 286, 323, 22890, 279, 1988, 48116, 11240, 14726, 382, 286, 97295, 9203, 264, 9429, 7646, 734, 11, 323, 471, 198, 286, 3135, 271, 14711, 6075, 512, 755, 5021, 65903, 1214, 11, 353, 2164, 11, 3146, 9872, 997, 286, 3270, 286, 63403, 279, 366, 75, 11171, 29, 1160, 315, 3626, 505, 279, 5021, 50208, 746, 286, 323, 22890, 279, 1988, 48116, 11240, 14726, 382, 286, 97295, 9203, 264, 9429, 7646, 734, 11, 323, 471, 198, 286, 3135, 198, 286, 3270, 286, 326, 11171, 338, 284, 4260, 286, 294, 65903, 7646, 257, 284, 5731, 286, 5279, 65903, 7646, 262, 284, 2290, 198, 286, 369, 597, 11, 348, 304, 16901, 9812, 4019, 310, 422, 597, 624, 364, 75, 11171, 1232, 1881, 326, 11171, 338, 284, 348, 198, 310, 422, 597, 624, 364, 7750, 7646, 1232, 5279, 65903, 7646, 262, 284, 348, 271, 286, 1963, 256, 284, 220, 16, 198, 286, 2860, 256, 284, 2479, 2387, 11171, 340, 286, 369, 326, 36115, 304, 326, 11171, 512, 310, 610, 2703, 262, 284, 2709, 3960, 21803, 2387, 36115, 58, 15, 2608, 310, 326, 36115, 262, 284, 510, 2709, 3960, 38092, 1998, 8, 369, 602, 304, 326, 36115, 933, 310, 659, 25456, 9685, 15625, 7343, 11, 2860, 340, 310, 659, 962, 6022, 6670, 17752, 2703, 60, 220, 284, 326, 36115, 198, 310, 422, 5279, 65903, 7646, 512, 394, 16901, 681, 2398, 663, 692, 284, 610, 2703, 198, 394, 294, 65903, 7646, 257, 284, 5279, 65903, 7646, 2387, 36115, 11, 3146, 9872, 340, 394, 659, 962, 6022, 6670, 7646, 17752, 2703, 60, 220, 284, 294, 65903, 7646, 198, 310, 659, 962, 7800, 6670, 17752, 2703, 60, 284, 8555, 310, 1963, 1447, 220, 16, 198, 286, 471, 341, 310, 364, 2899, 1232, 4391, 3082, 345, 310, 364, 67, 65903, 9027, 1445, 1232, 996, 294, 65903, 7646, 11, 5996, 310, 364, 5143, 41719, 2460, 26625, 1232, 256, 1963, 198, 286, 457, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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,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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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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, 93827, 279, 366, 75, 11171, 29, 1160, 315, 3626, 505, 279, 5021, 50208, 746, 286, 323, 22890, 279, 1988, 48116, 11240, 14726, 382, 286, 97295, 9203, 264, 9429, 7646, 734, 11, 323, 471, 198, 286, 3135, 271, 14711, 6075, 512, 755, 5021, 65903, 1214, 11, 353, 2164, 11, 3146, 9872, 997, 286, 3270, 286, 63403, 279, 366, 75, 11171, 29, 1160, 315, 3626, 505, 279, 5021, 50208, 746, 286, 323, 22890, 279, 1988, 48116, 11240, 14726, 382, 286, 97295, 9203, 264, 9429, 7646, 734, 11, 323, 471, 198, 286, 3135, 198, 286, 3270, 286, 326, 11171, 338, 284, 4260, 286, 294, 65903, 7646, 257, 284, 5731, 286, 5279, 65903, 7646, 262, 284, 2290, 198, 286, 369, 597, 11, 348, 304, 16901, 9812, 4019, 310, 422, 597, 624, 364, 75, 11171, 1232, 1881, 326, 11171, 338, 284, 348, 198, 310, 422, 597, 624, 364, 7750, 7646, 1232, 5279, 65903, 7646, 262, 284, 348, 271, 286, 1963, 256, 284, 220, 16, 198, 286, 2860, 256, 284, 2479, 2387, 11171, 340, 286, 369, 326, 36115, 304, 326, 11171, 512, 310, 610, 2703, 262, 284, 2709, 3960, 21803, 2387, 36115, 58, 15, 2608, 310, 326, 36115, 262, 284, 510, 2709, 3960, 38092, 1998, 8, 369, 602, 304, 326, 36115, 933, 310, 659, 25456, 9685, 15625, 7343, 11, 2860, 340, 310, 659, 962, 6022, 6670, 17752, 2703, 60, 220, 284, 326, 36115, 198, 310, 422, 5279, 65903, 7646, 512, 394, 16901, 681, 2398, 663, 692, 284, 610, 2703, 198, 394, 294, 65903, 7646, 257, 284, 5279, 65903, 7646, 2387, 36115, 11, 3146, 9872, 340, 394, 659, 962, 6022, 6670, 7646, 17752, 2703, 60, 220, 284, 294, 65903, 7646, 198, 310, 659, 962, 7800, 6670, 17752, 2703, 60, 284, 8555, 310, 1963, 1447, 220, 16, 198, 286, 471, 341, 310, 364, 2899, 1232, 4391, 3082, 345, 310, 364, 67, 65903, 9027, 1445, 1232, 996, 294, 65903, 7646, 11, 5996, 310, 364, 5143, 41719, 2460, 26625, 1232, 256, 1963, 198, 286, 457, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
etal/biofrills
biofrills/pairutils.py
identity_abs
def identity_abs(aseq, bseq): """Compute absolute identity (# matching sites) between sequence strings.""" assert len(aseq) == len(bseq) return sum(a == b for a, b in zip(aseq, bseq) if not (a in '-.' and b in '-.'))
python
def identity_abs(aseq, bseq): """Compute absolute identity (# matching sites) between sequence strings.""" assert len(aseq) == len(bseq) return sum(a == b for a, b in zip(aseq, bseq) if not (a in '-.' and b in '-.'))
[ "def", "identity_abs", "(", "aseq", ",", "bseq", ")", ":", "assert", "len", "(", "aseq", ")", "==", "len", "(", "bseq", ")", "return", "sum", "(", "a", "==", "b", "for", "a", ",", "b", "in", "zip", "(", "aseq", ",", "bseq", ")", "if", "not", "(", "a", "in", "'-.'", "and", "b", "in", "'-.'", ")", ")" ]
Compute absolute identity (# matching sites) between sequence strings.
[ "Compute", "absolute", "identity", "(", "#", "matching", "sites", ")", "between", "sequence", "strings", "." ]
train
https://github.com/etal/biofrills/blob/36684bb6c7632f96215e8b2b4ebc86640f331bcd/biofrills/pairutils.py#L119-L124
<|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 absolute identity (# matching sites) between sequence strings. ### Response: def identity_abs(aseq, bseq): """Compute absolute identity (# matching sites) between sequence strings.""" assert len(aseq) == len(bseq) return sum(a == b for a, b in zip(aseq, bseq) if not (a in '-.' and b in '-.')) <|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, 10973, 9764, 30183, 12864, 6732, 8, 1990, 8668, 9246, 382, 14711, 6075, 512, 755, 9764, 32270, 7, 521, 80, 11, 293, 13565, 997, 262, 4304, 47354, 10973, 9764, 30183, 12864, 6732, 8, 1990, 8668, 9246, 14781, 262, 2105, 2479, 7, 521, 80, 8, 624, 2479, 1921, 13565, 340, 262, 471, 2694, 2948, 624, 293, 198, 2342, 369, 264, 11, 293, 304, 10521, 7, 521, 80, 11, 293, 13565, 340, 2342, 422, 539, 320, 64, 304, 7944, 3238, 323, 293, 304, 7944, 13, 7132, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 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,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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, 47354, 10973, 9764, 30183, 12864, 6732, 8, 1990, 8668, 9246, 382, 14711, 6075, 512, 755, 9764, 32270, 7, 521, 80, 11, 293, 13565, 997, 262, 4304, 47354, 10973, 9764, 30183, 12864, 6732, 8, 1990, 8668, 9246, 14781, 262, 2105, 2479, 7, 521, 80, 8, 624, 2479, 1921, 13565, 340, 262, 471, 2694, 2948, 624, 293, 198, 2342, 369, 264, 11, 293, 304, 10521, 7, 521, 80, 11, 293, 13565, 340, 2342, 422, 539, 320, 64, 304, 7944, 3238, 323, 293, 304, 7944, 13, 7132, 27, 91, 8862, 728, 428, 91, 29, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009, 128009 ]
quantmind/pulsar
examples/philosophers/manage.py
DiningPhilosophers.release_forks
async def release_forks(self, philosopher): '''The ``philosopher`` has just eaten and is ready to release both forks. This method releases them, one by one, by sending the ``put_down`` action to the monitor. ''' forks = self.forks self.forks = [] self.started_waiting = 0 for fork in forks: philosopher.logger.debug('Putting down fork %s', fork) await philosopher.send('monitor', 'putdown_fork', fork) await sleep(self.cfg.waiting_period)
python
async def release_forks(self, philosopher): '''The ``philosopher`` has just eaten and is ready to release both forks. This method releases them, one by one, by sending the ``put_down`` action to the monitor. ''' forks = self.forks self.forks = [] self.started_waiting = 0 for fork in forks: philosopher.logger.debug('Putting down fork %s', fork) await philosopher.send('monitor', 'putdown_fork', fork) await sleep(self.cfg.waiting_period)
[ "async", "def", "release_forks", "(", "self", ",", "philosopher", ")", ":", "forks", "=", "self", ".", "forks", "self", ".", "forks", "=", "[", "]", "self", ".", "started_waiting", "=", "0", "for", "fork", "in", "forks", ":", "philosopher", ".", "logger", ".", "debug", "(", "'Putting down fork %s'", ",", "fork", ")", "await", "philosopher", ".", "send", "(", "'monitor'", ",", "'putdown_fork'", ",", "fork", ")", "await", "sleep", "(", "self", ".", "cfg", ".", "waiting_period", ")" ]
The ``philosopher`` has just eaten and is ready to release both forks. This method releases them, one by one, by sending the ``put_down`` action to the monitor.
[ "The", "philosopher", "has", "just", "eaten", "and", "is", "ready", "to", "release", "both", "forks", "." ]
train
https://github.com/quantmind/pulsar/blob/fee44e871954aa6ca36d00bb5a3739abfdb89b26/examples/philosophers/manage.py#L177-L190
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: The ``philosopher`` has just eaten and is ready to release both forks. This method releases them, one by one, by sending the ``put_down`` action to the monitor. ### Response: async def release_forks(self, philosopher): '''The ``philosopher`` has just eaten and is ready to release both forks. This method releases them, one by one, by sending the ``put_down`` action to the monitor. ''' forks = self.forks self.forks = [] self.started_waiting = 0 for fork in forks: philosopher.logger.debug('Putting down fork %s', fork) await philosopher.send('monitor', 'putdown_fork', fork) await sleep(self.cfg.waiting_period) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 791, 10103, 46185, 46459, 14196, 706, 1120, 35661, 323, 374, 5644, 311, 4984, 2225, 198, 286, 74674, 382, 286, 1115, 1749, 19786, 1124, 11, 832, 555, 832, 11, 555, 11889, 279, 10103, 631, 14325, 85374, 286, 1957, 311, 279, 8891, 382, 14711, 6075, 512, 7847, 711, 4984, 766, 74402, 1214, 11, 55475, 997, 286, 11712, 791, 10103, 46185, 46459, 14196, 706, 1120, 35661, 323, 374, 5644, 311, 4984, 2225, 198, 286, 74674, 382, 286, 1115, 1749, 19786, 1124, 11, 832, 555, 832, 11, 555, 11889, 279, 10103, 631, 14325, 85374, 286, 1957, 311, 279, 8891, 627, 286, 11414, 286, 74674, 284, 659, 840, 74402, 198, 286, 659, 840, 74402, 284, 4260, 286, 659, 81548, 85783, 284, 220, 15, 198, 286, 369, 23243, 304, 74674, 512, 310, 55475, 16465, 8042, 493, 99004, 1523, 23243, 1034, 82, 518, 23243, 340, 310, 2597, 55475, 5331, 493, 33325, 518, 364, 631, 2996, 766, 672, 518, 23243, 340, 286, 2597, 6212, 1214, 31581, 16693, 287, 21485, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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14196, 706, 1120, 35661, 323, 374, 5644, 311, 4984, 2225, 198, 286, 74674, 382, 286, 1115, 1749, 19786, 1124, 11, 832, 555, 832, 11, 555, 11889, 279, 10103, 631, 14325, 85374, 286, 1957, 311, 279, 8891, 382, 14711, 6075, 512, 7847, 711, 4984, 766, 74402, 1214, 11, 55475, 997, 286, 11712, 791, 10103, 46185, 46459, 14196, 706, 1120, 35661, 323, 374, 5644, 311, 4984, 2225, 198, 286, 74674, 382, 286, 1115, 1749, 19786, 1124, 11, 832, 555, 832, 11, 555, 11889, 279, 10103, 631, 14325, 85374, 286, 1957, 311, 279, 8891, 627, 286, 11414, 286, 74674, 284, 659, 840, 74402, 198, 286, 659, 840, 74402, 284, 4260, 286, 659, 81548, 85783, 284, 220, 15, 198, 286, 369, 23243, 304, 74674, 512, 310, 55475, 16465, 8042, 493, 99004, 1523, 23243, 1034, 82, 518, 23243, 340, 310, 2597, 55475, 5331, 493, 33325, 518, 364, 631, 2996, 766, 672, 518, 23243, 340, 286, 2597, 6212, 1214, 31581, 16693, 287, 21485, 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 ]
Microsoft/LightGBM
python-package/lightgbm/engine.py
train
def train(params, train_set, num_boost_round=100, valid_sets=None, valid_names=None, fobj=None, feval=None, init_model=None, feature_name='auto', categorical_feature='auto', early_stopping_rounds=None, evals_result=None, verbose_eval=True, learning_rates=None, keep_training_booster=False, callbacks=None): """Perform the training with given parameters. Parameters ---------- params : dict Parameters for training. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. valid_sets : list of Datasets or None, optional (default=None) List of data to be evaluated on during training. valid_names : list of strings or None, optional (default=None) Names of ``valid_sets``. fobj : callable or None, optional (default=None) Customized objective function. feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_result, is_higher_better) or list of such tuples. For multi-class task, the preds is group by class_id first, then group by row_id. If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i]. To ignore the default metric corresponding to the used objective, set the ``metric`` parameter to the string ``"None"`` in ``params``. init_model : string, Booster or None, optional (default=None) Filename of LightGBM model or Booster instance used for continue training. feature_name : list of strings or 'auto', optional (default="auto") Feature names. If 'auto' and data is pandas DataFrame, data columns names are used. categorical_feature : list of strings or int, or 'auto', optional (default="auto") Categorical features. If list of int, interpreted as indices. If list of strings, interpreted as feature names (need to specify ``feature_name`` as well). If 'auto' and data is pandas DataFrame, pandas unordered categorical columns are used. All values in categorical features should be less than int32 max value (2147483647). Large values could be memory consuming. Consider using consecutive integers starting from zero. All negative values in categorical features will be treated as missing values. early_stopping_rounds : int or None, optional (default=None) Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_rounds`` round(s) to continue training. Requires at least one validation data and one metric. If there's more than one, will check all of them. But the training data is ignored anyway. To check only the first metric you can pass in ``callbacks`` ``early_stopping`` callback with ``first_metric_only=True``. The index of iteration that has the best performance will be saved in the ``best_iteration`` field if early stopping logic is enabled by setting ``early_stopping_rounds``. evals_result: dict or None, optional (default=None) This dictionary used to store all evaluation results of all the items in ``valid_sets``. Example ------- With a ``valid_sets`` = [valid_set, train_set], ``valid_names`` = ['eval', 'train'] and a ``params`` = {'metric': 'logloss'} returns {'train': {'logloss': ['0.48253', '0.35953', ...]}, 'eval': {'logloss': ['0.480385', '0.357756', ...]}}. verbose_eval : bool or int, optional (default=True) Requires at least one validation data. If True, the eval metric on the valid set is printed at each boosting stage. If int, the eval metric on the valid set is printed at every ``verbose_eval`` boosting stage. The last boosting stage or the boosting stage found by using ``early_stopping_rounds`` is also printed. Example ------- With ``verbose_eval`` = 4 and at least one item in ``valid_sets``, an evaluation metric is printed every 4 (instead of 1) boosting stages. learning_rates : list, callable or None, optional (default=None) List of learning rates for each boosting round or a customized function that calculates ``learning_rate`` in terms of current number of round (e.g. yields learning rate decay). keep_training_booster : bool, optional (default=False) Whether the returned Booster will be used to keep training. If False, the returned value will be converted into _InnerPredictor before returning. You can still use _InnerPredictor as ``init_model`` for future continue training. callbacks : list of callables or None, optional (default=None) List of callback functions that are applied at each iteration. See Callbacks in Python API for more information. Returns ------- booster : Booster The trained Booster model. """ # create predictor first params = copy.deepcopy(params) if fobj is not None: params['objective'] = 'none' for alias in ["num_iterations", "num_iteration", "n_iter", "num_tree", "num_trees", "num_round", "num_rounds", "num_boost_round", "n_estimators"]: if alias in params: num_boost_round = int(params.pop(alias)) warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias)) break for alias in ["early_stopping_round", "early_stopping_rounds", "early_stopping"]: if alias in params and params[alias] is not None: early_stopping_rounds = int(params.pop(alias)) warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias)) break if num_boost_round <= 0: raise ValueError("num_boost_round should be greater than zero.") if isinstance(init_model, string_type): predictor = _InnerPredictor(model_file=init_model, pred_parameter=params) elif isinstance(init_model, Booster): predictor = init_model._to_predictor(dict(init_model.params, **params)) else: predictor = None init_iteration = predictor.num_total_iteration if predictor is not None else 0 # check dataset if not isinstance(train_set, Dataset): raise TypeError("Training only accepts Dataset object") train_set._update_params(params) \ ._set_predictor(predictor) \ .set_feature_name(feature_name) \ .set_categorical_feature(categorical_feature) is_valid_contain_train = False train_data_name = "training" reduced_valid_sets = [] name_valid_sets = [] if valid_sets is not None: if isinstance(valid_sets, Dataset): valid_sets = [valid_sets] if isinstance(valid_names, string_type): valid_names = [valid_names] for i, valid_data in enumerate(valid_sets): # reduce cost for prediction training data if valid_data is train_set: is_valid_contain_train = True if valid_names is not None: train_data_name = valid_names[i] continue if not isinstance(valid_data, Dataset): raise TypeError("Traninig only accepts Dataset object") reduced_valid_sets.append(valid_data._update_params(params).set_reference(train_set)) if valid_names is not None and len(valid_names) > i: name_valid_sets.append(valid_names[i]) else: name_valid_sets.append('valid_' + str(i)) # process callbacks if callbacks is None: callbacks = set() else: for i, cb in enumerate(callbacks): cb.__dict__.setdefault('order', i - len(callbacks)) callbacks = set(callbacks) # Most of legacy advanced options becomes callbacks if verbose_eval is True: callbacks.add(callback.print_evaluation()) elif isinstance(verbose_eval, integer_types): callbacks.add(callback.print_evaluation(verbose_eval)) if early_stopping_rounds is not None: callbacks.add(callback.early_stopping(early_stopping_rounds, verbose=bool(verbose_eval))) if learning_rates is not None: callbacks.add(callback.reset_parameter(learning_rate=learning_rates)) if evals_result is not None: callbacks.add(callback.record_evaluation(evals_result)) callbacks_before_iter = {cb for cb in callbacks if getattr(cb, 'before_iteration', False)} callbacks_after_iter = callbacks - callbacks_before_iter callbacks_before_iter = sorted(callbacks_before_iter, key=attrgetter('order')) callbacks_after_iter = sorted(callbacks_after_iter, key=attrgetter('order')) # construct booster try: booster = Booster(params=params, train_set=train_set) if is_valid_contain_train: booster.set_train_data_name(train_data_name) for valid_set, name_valid_set in zip_(reduced_valid_sets, name_valid_sets): booster.add_valid(valid_set, name_valid_set) finally: train_set._reverse_update_params() for valid_set in reduced_valid_sets: valid_set._reverse_update_params() booster.best_iteration = 0 # start training for i in range_(init_iteration, init_iteration + num_boost_round): for cb in callbacks_before_iter: cb(callback.CallbackEnv(model=booster, params=params, iteration=i, begin_iteration=init_iteration, end_iteration=init_iteration + num_boost_round, evaluation_result_list=None)) booster.update(fobj=fobj) evaluation_result_list = [] # check evaluation result. if valid_sets is not None: if is_valid_contain_train: evaluation_result_list.extend(booster.eval_train(feval)) evaluation_result_list.extend(booster.eval_valid(feval)) try: for cb in callbacks_after_iter: cb(callback.CallbackEnv(model=booster, params=params, iteration=i, begin_iteration=init_iteration, end_iteration=init_iteration + num_boost_round, evaluation_result_list=evaluation_result_list)) except callback.EarlyStopException as earlyStopException: booster.best_iteration = earlyStopException.best_iteration + 1 evaluation_result_list = earlyStopException.best_score break booster.best_score = collections.defaultdict(dict) for dataset_name, eval_name, score, _ in evaluation_result_list: booster.best_score[dataset_name][eval_name] = score if not keep_training_booster: booster.model_from_string(booster.model_to_string(), False).free_dataset() return booster
python
def train(params, train_set, num_boost_round=100, valid_sets=None, valid_names=None, fobj=None, feval=None, init_model=None, feature_name='auto', categorical_feature='auto', early_stopping_rounds=None, evals_result=None, verbose_eval=True, learning_rates=None, keep_training_booster=False, callbacks=None): """Perform the training with given parameters. Parameters ---------- params : dict Parameters for training. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. valid_sets : list of Datasets or None, optional (default=None) List of data to be evaluated on during training. valid_names : list of strings or None, optional (default=None) Names of ``valid_sets``. fobj : callable or None, optional (default=None) Customized objective function. feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_result, is_higher_better) or list of such tuples. For multi-class task, the preds is group by class_id first, then group by row_id. If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i]. To ignore the default metric corresponding to the used objective, set the ``metric`` parameter to the string ``"None"`` in ``params``. init_model : string, Booster or None, optional (default=None) Filename of LightGBM model or Booster instance used for continue training. feature_name : list of strings or 'auto', optional (default="auto") Feature names. If 'auto' and data is pandas DataFrame, data columns names are used. categorical_feature : list of strings or int, or 'auto', optional (default="auto") Categorical features. If list of int, interpreted as indices. If list of strings, interpreted as feature names (need to specify ``feature_name`` as well). If 'auto' and data is pandas DataFrame, pandas unordered categorical columns are used. All values in categorical features should be less than int32 max value (2147483647). Large values could be memory consuming. Consider using consecutive integers starting from zero. All negative values in categorical features will be treated as missing values. early_stopping_rounds : int or None, optional (default=None) Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_rounds`` round(s) to continue training. Requires at least one validation data and one metric. If there's more than one, will check all of them. But the training data is ignored anyway. To check only the first metric you can pass in ``callbacks`` ``early_stopping`` callback with ``first_metric_only=True``. The index of iteration that has the best performance will be saved in the ``best_iteration`` field if early stopping logic is enabled by setting ``early_stopping_rounds``. evals_result: dict or None, optional (default=None) This dictionary used to store all evaluation results of all the items in ``valid_sets``. Example ------- With a ``valid_sets`` = [valid_set, train_set], ``valid_names`` = ['eval', 'train'] and a ``params`` = {'metric': 'logloss'} returns {'train': {'logloss': ['0.48253', '0.35953', ...]}, 'eval': {'logloss': ['0.480385', '0.357756', ...]}}. verbose_eval : bool or int, optional (default=True) Requires at least one validation data. If True, the eval metric on the valid set is printed at each boosting stage. If int, the eval metric on the valid set is printed at every ``verbose_eval`` boosting stage. The last boosting stage or the boosting stage found by using ``early_stopping_rounds`` is also printed. Example ------- With ``verbose_eval`` = 4 and at least one item in ``valid_sets``, an evaluation metric is printed every 4 (instead of 1) boosting stages. learning_rates : list, callable or None, optional (default=None) List of learning rates for each boosting round or a customized function that calculates ``learning_rate`` in terms of current number of round (e.g. yields learning rate decay). keep_training_booster : bool, optional (default=False) Whether the returned Booster will be used to keep training. If False, the returned value will be converted into _InnerPredictor before returning. You can still use _InnerPredictor as ``init_model`` for future continue training. callbacks : list of callables or None, optional (default=None) List of callback functions that are applied at each iteration. See Callbacks in Python API for more information. Returns ------- booster : Booster The trained Booster model. """ # create predictor first params = copy.deepcopy(params) if fobj is not None: params['objective'] = 'none' for alias in ["num_iterations", "num_iteration", "n_iter", "num_tree", "num_trees", "num_round", "num_rounds", "num_boost_round", "n_estimators"]: if alias in params: num_boost_round = int(params.pop(alias)) warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias)) break for alias in ["early_stopping_round", "early_stopping_rounds", "early_stopping"]: if alias in params and params[alias] is not None: early_stopping_rounds = int(params.pop(alias)) warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias)) break if num_boost_round <= 0: raise ValueError("num_boost_round should be greater than zero.") if isinstance(init_model, string_type): predictor = _InnerPredictor(model_file=init_model, pred_parameter=params) elif isinstance(init_model, Booster): predictor = init_model._to_predictor(dict(init_model.params, **params)) else: predictor = None init_iteration = predictor.num_total_iteration if predictor is not None else 0 # check dataset if not isinstance(train_set, Dataset): raise TypeError("Training only accepts Dataset object") train_set._update_params(params) \ ._set_predictor(predictor) \ .set_feature_name(feature_name) \ .set_categorical_feature(categorical_feature) is_valid_contain_train = False train_data_name = "training" reduced_valid_sets = [] name_valid_sets = [] if valid_sets is not None: if isinstance(valid_sets, Dataset): valid_sets = [valid_sets] if isinstance(valid_names, string_type): valid_names = [valid_names] for i, valid_data in enumerate(valid_sets): # reduce cost for prediction training data if valid_data is train_set: is_valid_contain_train = True if valid_names is not None: train_data_name = valid_names[i] continue if not isinstance(valid_data, Dataset): raise TypeError("Traninig only accepts Dataset object") reduced_valid_sets.append(valid_data._update_params(params).set_reference(train_set)) if valid_names is not None and len(valid_names) > i: name_valid_sets.append(valid_names[i]) else: name_valid_sets.append('valid_' + str(i)) # process callbacks if callbacks is None: callbacks = set() else: for i, cb in enumerate(callbacks): cb.__dict__.setdefault('order', i - len(callbacks)) callbacks = set(callbacks) # Most of legacy advanced options becomes callbacks if verbose_eval is True: callbacks.add(callback.print_evaluation()) elif isinstance(verbose_eval, integer_types): callbacks.add(callback.print_evaluation(verbose_eval)) if early_stopping_rounds is not None: callbacks.add(callback.early_stopping(early_stopping_rounds, verbose=bool(verbose_eval))) if learning_rates is not None: callbacks.add(callback.reset_parameter(learning_rate=learning_rates)) if evals_result is not None: callbacks.add(callback.record_evaluation(evals_result)) callbacks_before_iter = {cb for cb in callbacks if getattr(cb, 'before_iteration', False)} callbacks_after_iter = callbacks - callbacks_before_iter callbacks_before_iter = sorted(callbacks_before_iter, key=attrgetter('order')) callbacks_after_iter = sorted(callbacks_after_iter, key=attrgetter('order')) # construct booster try: booster = Booster(params=params, train_set=train_set) if is_valid_contain_train: booster.set_train_data_name(train_data_name) for valid_set, name_valid_set in zip_(reduced_valid_sets, name_valid_sets): booster.add_valid(valid_set, name_valid_set) finally: train_set._reverse_update_params() for valid_set in reduced_valid_sets: valid_set._reverse_update_params() booster.best_iteration = 0 # start training for i in range_(init_iteration, init_iteration + num_boost_round): for cb in callbacks_before_iter: cb(callback.CallbackEnv(model=booster, params=params, iteration=i, begin_iteration=init_iteration, end_iteration=init_iteration + num_boost_round, evaluation_result_list=None)) booster.update(fobj=fobj) evaluation_result_list = [] # check evaluation result. if valid_sets is not None: if is_valid_contain_train: evaluation_result_list.extend(booster.eval_train(feval)) evaluation_result_list.extend(booster.eval_valid(feval)) try: for cb in callbacks_after_iter: cb(callback.CallbackEnv(model=booster, params=params, iteration=i, begin_iteration=init_iteration, end_iteration=init_iteration + num_boost_round, evaluation_result_list=evaluation_result_list)) except callback.EarlyStopException as earlyStopException: booster.best_iteration = earlyStopException.best_iteration + 1 evaluation_result_list = earlyStopException.best_score break booster.best_score = collections.defaultdict(dict) for dataset_name, eval_name, score, _ in evaluation_result_list: booster.best_score[dataset_name][eval_name] = score if not keep_training_booster: booster.model_from_string(booster.model_to_string(), False).free_dataset() return booster
[ "def", "train", "(", "params", ",", "train_set", ",", "num_boost_round", "=", "100", ",", "valid_sets", "=", "None", ",", "valid_names", "=", "None", ",", "fobj", "=", "None", ",", "feval", "=", "None", ",", "init_model", "=", "None", ",", "feature_name", "=", "'auto'", ",", "categorical_feature", "=", "'auto'", ",", "early_stopping_rounds", "=", "None", ",", "evals_result", "=", "None", ",", "verbose_eval", "=", "True", ",", "learning_rates", "=", "None", ",", "keep_training_booster", "=", "False", ",", "callbacks", "=", "None", ")", ":", "# create predictor first", "params", "=", "copy", ".", "deepcopy", "(", "params", ")", "if", "fobj", "is", "not", "None", ":", "params", "[", "'objective'", "]", "=", "'none'", "for", "alias", "in", "[", "\"num_iterations\"", ",", "\"num_iteration\"", ",", "\"n_iter\"", ",", "\"num_tree\"", ",", "\"num_trees\"", ",", "\"num_round\"", ",", "\"num_rounds\"", ",", "\"num_boost_round\"", ",", "\"n_estimators\"", "]", ":", "if", "alias", "in", "params", ":", "num_boost_round", "=", "int", "(", "params", ".", "pop", "(", "alias", ")", ")", "warnings", ".", "warn", "(", "\"Found `{}` in params. Will use it instead of argument\"", ".", "format", "(", "alias", ")", ")", "break", "for", "alias", "in", "[", "\"early_stopping_round\"", ",", "\"early_stopping_rounds\"", ",", "\"early_stopping\"", "]", ":", "if", "alias", "in", "params", "and", "params", "[", "alias", "]", "is", "not", "None", ":", "early_stopping_rounds", "=", "int", "(", "params", ".", "pop", "(", "alias", ")", ")", "warnings", ".", "warn", "(", "\"Found `{}` in params. Will use it instead of argument\"", ".", "format", "(", "alias", ")", ")", "break", "if", "num_boost_round", "<=", "0", ":", "raise", "ValueError", "(", "\"num_boost_round should be greater than zero.\"", ")", "if", "isinstance", "(", "init_model", ",", "string_type", ")", ":", "predictor", "=", "_InnerPredictor", "(", "model_file", "=", "init_model", ",", "pred_parameter", "=", "params", ")", "elif", "isinstance", "(", "init_model", ",", "Booster", ")", ":", "predictor", "=", "init_model", ".", "_to_predictor", "(", "dict", "(", "init_model", ".", "params", ",", "*", "*", "params", ")", ")", "else", ":", "predictor", "=", "None", "init_iteration", "=", "predictor", ".", "num_total_iteration", "if", "predictor", "is", "not", "None", "else", "0", "# check dataset", "if", "not", "isinstance", "(", "train_set", ",", "Dataset", ")", ":", "raise", "TypeError", "(", "\"Training only accepts Dataset object\"", ")", "train_set", ".", "_update_params", "(", "params", ")", ".", "_set_predictor", "(", "predictor", ")", ".", "set_feature_name", "(", "feature_name", ")", ".", "set_categorical_feature", "(", "categorical_feature", ")", "is_valid_contain_train", "=", "False", "train_data_name", "=", "\"training\"", "reduced_valid_sets", "=", "[", "]", "name_valid_sets", "=", "[", "]", "if", "valid_sets", "is", "not", "None", ":", "if", "isinstance", "(", "valid_sets", ",", "Dataset", ")", ":", "valid_sets", "=", "[", "valid_sets", "]", "if", "isinstance", "(", "valid_names", ",", "string_type", ")", ":", "valid_names", "=", "[", "valid_names", "]", "for", "i", ",", "valid_data", "in", "enumerate", "(", "valid_sets", ")", ":", "# reduce cost for prediction training data", "if", "valid_data", "is", "train_set", ":", "is_valid_contain_train", "=", "True", "if", "valid_names", "is", "not", "None", ":", "train_data_name", "=", "valid_names", "[", "i", "]", "continue", "if", "not", "isinstance", "(", "valid_data", ",", "Dataset", ")", ":", "raise", "TypeError", "(", "\"Traninig only accepts Dataset object\"", ")", "reduced_valid_sets", ".", "append", "(", "valid_data", ".", "_update_params", "(", "params", ")", ".", "set_reference", "(", "train_set", ")", ")", "if", "valid_names", "is", "not", "None", "and", "len", "(", "valid_names", ")", ">", "i", ":", "name_valid_sets", ".", "append", "(", "valid_names", "[", "i", "]", ")", "else", ":", "name_valid_sets", ".", "append", "(", "'valid_'", "+", "str", "(", "i", ")", ")", "# process callbacks", "if", "callbacks", "is", "None", ":", "callbacks", "=", "set", "(", ")", "else", ":", "for", "i", ",", "cb", "in", "enumerate", "(", "callbacks", ")", ":", "cb", ".", "__dict__", ".", "setdefault", "(", "'order'", ",", "i", "-", "len", "(", "callbacks", ")", ")", "callbacks", "=", "set", "(", "callbacks", ")", "# Most of legacy advanced options becomes callbacks", "if", "verbose_eval", "is", "True", ":", "callbacks", ".", "add", "(", "callback", ".", "print_evaluation", "(", ")", ")", "elif", "isinstance", "(", "verbose_eval", ",", "integer_types", ")", ":", "callbacks", ".", "add", "(", "callback", ".", "print_evaluation", "(", "verbose_eval", ")", ")", "if", "early_stopping_rounds", "is", "not", "None", ":", "callbacks", ".", "add", "(", "callback", ".", "early_stopping", "(", "early_stopping_rounds", ",", "verbose", "=", "bool", "(", "verbose_eval", ")", ")", ")", "if", "learning_rates", "is", "not", "None", ":", "callbacks", ".", "add", "(", "callback", ".", "reset_parameter", "(", "learning_rate", "=", "learning_rates", ")", ")", "if", "evals_result", "is", "not", "None", ":", "callbacks", ".", "add", "(", "callback", ".", "record_evaluation", "(", "evals_result", ")", ")", "callbacks_before_iter", "=", "{", "cb", "for", "cb", "in", "callbacks", "if", "getattr", "(", "cb", ",", "'before_iteration'", ",", "False", ")", "}", "callbacks_after_iter", "=", "callbacks", "-", "callbacks_before_iter", "callbacks_before_iter", "=", "sorted", "(", "callbacks_before_iter", ",", "key", "=", "attrgetter", "(", "'order'", ")", ")", "callbacks_after_iter", "=", "sorted", "(", "callbacks_after_iter", ",", "key", "=", "attrgetter", "(", "'order'", ")", ")", "# construct booster", "try", ":", "booster", "=", "Booster", "(", "params", "=", "params", ",", "train_set", "=", "train_set", ")", "if", "is_valid_contain_train", ":", "booster", ".", "set_train_data_name", "(", "train_data_name", ")", "for", "valid_set", ",", "name_valid_set", "in", "zip_", "(", "reduced_valid_sets", ",", "name_valid_sets", ")", ":", "booster", ".", "add_valid", "(", "valid_set", ",", "name_valid_set", ")", "finally", ":", "train_set", ".", "_reverse_update_params", "(", ")", "for", "valid_set", "in", "reduced_valid_sets", ":", "valid_set", ".", "_reverse_update_params", "(", ")", "booster", ".", "best_iteration", "=", "0", "# start training", "for", "i", "in", "range_", "(", "init_iteration", ",", "init_iteration", "+", "num_boost_round", ")", ":", "for", "cb", "in", "callbacks_before_iter", ":", "cb", "(", "callback", ".", "CallbackEnv", "(", "model", "=", "booster", ",", "params", "=", "params", ",", "iteration", "=", "i", ",", "begin_iteration", "=", "init_iteration", ",", "end_iteration", "=", "init_iteration", "+", "num_boost_round", ",", "evaluation_result_list", "=", "None", ")", ")", "booster", ".", "update", "(", "fobj", "=", "fobj", ")", "evaluation_result_list", "=", "[", "]", "# check evaluation result.", "if", "valid_sets", "is", "not", "None", ":", "if", "is_valid_contain_train", ":", "evaluation_result_list", ".", "extend", "(", "booster", ".", "eval_train", "(", "feval", ")", ")", "evaluation_result_list", ".", "extend", "(", "booster", ".", "eval_valid", "(", "feval", ")", ")", "try", ":", "for", "cb", "in", "callbacks_after_iter", ":", "cb", "(", "callback", ".", "CallbackEnv", "(", "model", "=", "booster", ",", "params", "=", "params", ",", "iteration", "=", "i", ",", "begin_iteration", "=", "init_iteration", ",", "end_iteration", "=", "init_iteration", "+", "num_boost_round", ",", "evaluation_result_list", "=", "evaluation_result_list", ")", ")", "except", "callback", ".", "EarlyStopException", "as", "earlyStopException", ":", "booster", ".", "best_iteration", "=", "earlyStopException", ".", "best_iteration", "+", "1", "evaluation_result_list", "=", "earlyStopException", ".", "best_score", "break", "booster", ".", "best_score", "=", "collections", ".", "defaultdict", "(", "dict", ")", "for", "dataset_name", ",", "eval_name", ",", "score", ",", "_", "in", "evaluation_result_list", ":", "booster", ".", "best_score", "[", "dataset_name", "]", "[", "eval_name", "]", "=", "score", "if", "not", "keep_training_booster", ":", "booster", ".", "model_from_string", "(", "booster", ".", "model_to_string", "(", ")", ",", "False", ")", ".", "free_dataset", "(", ")", "return", "booster" ]
Perform the training with given parameters. Parameters ---------- params : dict Parameters for training. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. valid_sets : list of Datasets or None, optional (default=None) List of data to be evaluated on during training. valid_names : list of strings or None, optional (default=None) Names of ``valid_sets``. fobj : callable or None, optional (default=None) Customized objective function. feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_result, is_higher_better) or list of such tuples. For multi-class task, the preds is group by class_id first, then group by row_id. If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i]. To ignore the default metric corresponding to the used objective, set the ``metric`` parameter to the string ``"None"`` in ``params``. init_model : string, Booster or None, optional (default=None) Filename of LightGBM model or Booster instance used for continue training. feature_name : list of strings or 'auto', optional (default="auto") Feature names. If 'auto' and data is pandas DataFrame, data columns names are used. categorical_feature : list of strings or int, or 'auto', optional (default="auto") Categorical features. If list of int, interpreted as indices. If list of strings, interpreted as feature names (need to specify ``feature_name`` as well). If 'auto' and data is pandas DataFrame, pandas unordered categorical columns are used. All values in categorical features should be less than int32 max value (2147483647). Large values could be memory consuming. Consider using consecutive integers starting from zero. All negative values in categorical features will be treated as missing values. early_stopping_rounds : int or None, optional (default=None) Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_rounds`` round(s) to continue training. Requires at least one validation data and one metric. If there's more than one, will check all of them. But the training data is ignored anyway. To check only the first metric you can pass in ``callbacks`` ``early_stopping`` callback with ``first_metric_only=True``. The index of iteration that has the best performance will be saved in the ``best_iteration`` field if early stopping logic is enabled by setting ``early_stopping_rounds``. evals_result: dict or None, optional (default=None) This dictionary used to store all evaluation results of all the items in ``valid_sets``. Example ------- With a ``valid_sets`` = [valid_set, train_set], ``valid_names`` = ['eval', 'train'] and a ``params`` = {'metric': 'logloss'} returns {'train': {'logloss': ['0.48253', '0.35953', ...]}, 'eval': {'logloss': ['0.480385', '0.357756', ...]}}. verbose_eval : bool or int, optional (default=True) Requires at least one validation data. If True, the eval metric on the valid set is printed at each boosting stage. If int, the eval metric on the valid set is printed at every ``verbose_eval`` boosting stage. The last boosting stage or the boosting stage found by using ``early_stopping_rounds`` is also printed. Example ------- With ``verbose_eval`` = 4 and at least one item in ``valid_sets``, an evaluation metric is printed every 4 (instead of 1) boosting stages. learning_rates : list, callable or None, optional (default=None) List of learning rates for each boosting round or a customized function that calculates ``learning_rate`` in terms of current number of round (e.g. yields learning rate decay). keep_training_booster : bool, optional (default=False) Whether the returned Booster will be used to keep training. If False, the returned value will be converted into _InnerPredictor before returning. You can still use _InnerPredictor as ``init_model`` for future continue training. callbacks : list of callables or None, optional (default=None) List of callback functions that are applied at each iteration. See Callbacks in Python API for more information. Returns ------- booster : Booster The trained Booster model.
[ "Perform", "the", "training", "with", "given", "parameters", "." ]
train
https://github.com/Microsoft/LightGBM/blob/8d2ec69f4f685b0ab1c4624d59ee2d3287bb3147/python-package/lightgbm/engine.py#L19-L245
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Perform the training with given parameters. Parameters ---------- params : dict Parameters for training. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. valid_sets : list of Datasets or None, optional (default=None) List of data to be evaluated on during training. valid_names : list of strings or None, optional (default=None) Names of ``valid_sets``. fobj : callable or None, optional (default=None) Customized objective function. feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_result, is_higher_better) or list of such tuples. For multi-class task, the preds is group by class_id first, then group by row_id. If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i]. To ignore the default metric corresponding to the used objective, set the ``metric`` parameter to the string ``"None"`` in ``params``. init_model : string, Booster or None, optional (default=None) Filename of LightGBM model or Booster instance used for continue training. feature_name : list of strings or 'auto', optional (default="auto") Feature names. If 'auto' and data is pandas DataFrame, data columns names are used. categorical_feature : list of strings or int, or 'auto', optional (default="auto") Categorical features. If list of int, interpreted as indices. If list of strings, interpreted as feature names (need to specify ``feature_name`` as well). If 'auto' and data is pandas DataFrame, pandas unordered categorical columns are used. All values in categorical features should be less than int32 max value (2147483647). Large values could be memory consuming. Consider using consecutive integers starting from zero. All negative values in categorical features will be treated as missing values. early_stopping_rounds : int or None, optional (default=None) Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_rounds`` round(s) to continue training. Requires at least one validation data and one metric. If there's more than one, will check all of them. But the training data is ignored anyway. To check only the first metric you can pass in ``callbacks`` ``early_stopping`` callback with ``first_metric_only=True``. The index of iteration that has the best performance will be saved in the ``best_iteration`` field if early stopping logic is enabled by setting ``early_stopping_rounds``. evals_result: dict or None, optional (default=None) This dictionary used to store all evaluation results of all the items in ``valid_sets``. Example ------- With a ``valid_sets`` = [valid_set, train_set], ``valid_names`` = ['eval', 'train'] and a ``params`` = {'metric': 'logloss'} returns {'train': {'logloss': ['0.48253', '0.35953', ...]}, 'eval': {'logloss': ['0.480385', '0.357756', ...]}}. verbose_eval : bool or int, optional (default=True) Requires at least one validation data. If True, the eval metric on the valid set is printed at each boosting stage. If int, the eval metric on the valid set is printed at every ``verbose_eval`` boosting stage. The last boosting stage or the boosting stage found by using ``early_stopping_rounds`` is also printed. Example ------- With ``verbose_eval`` = 4 and at least one item in ``valid_sets``, an evaluation metric is printed every 4 (instead of 1) boosting stages. learning_rates : list, callable or None, optional (default=None) List of learning rates for each boosting round or a customized function that calculates ``learning_rate`` in terms of current number of round (e.g. yields learning rate decay). keep_training_booster : bool, optional (default=False) Whether the returned Booster will be used to keep training. If False, the returned value will be converted into _InnerPredictor before returning. You can still use _InnerPredictor as ``init_model`` for future continue training. callbacks : list of callables or None, optional (default=None) List of callback functions that are applied at each iteration. See Callbacks in Python API for more information. Returns ------- booster : Booster The trained Booster model. ### Response: def train(params, train_set, num_boost_round=100, valid_sets=None, valid_names=None, fobj=None, feval=None, init_model=None, feature_name='auto', categorical_feature='auto', early_stopping_rounds=None, evals_result=None, verbose_eval=True, learning_rates=None, keep_training_booster=False, callbacks=None): """Perform the training with given parameters. Parameters ---------- params : dict Parameters for training. train_set : Dataset Data to be trained on. num_boost_round : int, optional (default=100) Number of boosting iterations. valid_sets : list of Datasets or None, optional (default=None) List of data to be evaluated on during training. valid_names : list of strings or None, optional (default=None) Names of ``valid_sets``. fobj : callable or None, optional (default=None) Customized objective function. feval : callable or None, optional (default=None) Customized evaluation function. Should accept two parameters: preds, train_data, and return (eval_name, eval_result, is_higher_better) or list of such tuples. For multi-class task, the preds is group by class_id first, then group by row_id. If you want to get i-th row preds in j-th class, the access way is preds[j * num_data + i]. To ignore the default metric corresponding to the used objective, set the ``metric`` parameter to the string ``"None"`` in ``params``. init_model : string, Booster or None, optional (default=None) Filename of LightGBM model or Booster instance used for continue training. feature_name : list of strings or 'auto', optional (default="auto") Feature names. If 'auto' and data is pandas DataFrame, data columns names are used. categorical_feature : list of strings or int, or 'auto', optional (default="auto") Categorical features. If list of int, interpreted as indices. If list of strings, interpreted as feature names (need to specify ``feature_name`` as well). If 'auto' and data is pandas DataFrame, pandas unordered categorical columns are used. All values in categorical features should be less than int32 max value (2147483647). Large values could be memory consuming. Consider using consecutive integers starting from zero. All negative values in categorical features will be treated as missing values. early_stopping_rounds : int or None, optional (default=None) Activates early stopping. The model will train until the validation score stops improving. Validation score needs to improve at least every ``early_stopping_rounds`` round(s) to continue training. Requires at least one validation data and one metric. If there's more than one, will check all of them. But the training data is ignored anyway. To check only the first metric you can pass in ``callbacks`` ``early_stopping`` callback with ``first_metric_only=True``. The index of iteration that has the best performance will be saved in the ``best_iteration`` field if early stopping logic is enabled by setting ``early_stopping_rounds``. evals_result: dict or None, optional (default=None) This dictionary used to store all evaluation results of all the items in ``valid_sets``. Example ------- With a ``valid_sets`` = [valid_set, train_set], ``valid_names`` = ['eval', 'train'] and a ``params`` = {'metric': 'logloss'} returns {'train': {'logloss': ['0.48253', '0.35953', ...]}, 'eval': {'logloss': ['0.480385', '0.357756', ...]}}. verbose_eval : bool or int, optional (default=True) Requires at least one validation data. If True, the eval metric on the valid set is printed at each boosting stage. If int, the eval metric on the valid set is printed at every ``verbose_eval`` boosting stage. The last boosting stage or the boosting stage found by using ``early_stopping_rounds`` is also printed. Example ------- With ``verbose_eval`` = 4 and at least one item in ``valid_sets``, an evaluation metric is printed every 4 (instead of 1) boosting stages. learning_rates : list, callable or None, optional (default=None) List of learning rates for each boosting round or a customized function that calculates ``learning_rate`` in terms of current number of round (e.g. yields learning rate decay). keep_training_booster : bool, optional (default=False) Whether the returned Booster will be used to keep training. If False, the returned value will be converted into _InnerPredictor before returning. You can still use _InnerPredictor as ``init_model`` for future continue training. callbacks : list of callables or None, optional (default=None) List of callback functions that are applied at each iteration. See Callbacks in Python API for more information. Returns ------- booster : Booster The trained Booster model. """ # create predictor first params = copy.deepcopy(params) if fobj is not None: params['objective'] = 'none' for alias in ["num_iterations", "num_iteration", "n_iter", "num_tree", "num_trees", "num_round", "num_rounds", "num_boost_round", "n_estimators"]: if alias in params: num_boost_round = int(params.pop(alias)) warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias)) break for alias in ["early_stopping_round", "early_stopping_rounds", "early_stopping"]: if alias in params and params[alias] is not None: early_stopping_rounds = int(params.pop(alias)) warnings.warn("Found `{}` in params. Will use it instead of argument".format(alias)) break if num_boost_round <= 0: raise ValueError("num_boost_round should be greater than zero.") if isinstance(init_model, string_type): predictor = _InnerPredictor(model_file=init_model, pred_parameter=params) elif isinstance(init_model, Booster): predictor = init_model._to_predictor(dict(init_model.params, **params)) else: predictor = None init_iteration = predictor.num_total_iteration if predictor is not None else 0 # check dataset if not isinstance(train_set, Dataset): raise TypeError("Training only accepts Dataset object") train_set._update_params(params) \ ._set_predictor(predictor) \ .set_feature_name(feature_name) \ .set_categorical_feature(categorical_feature) is_valid_contain_train = False train_data_name = "training" reduced_valid_sets = [] name_valid_sets = [] if valid_sets is not None: if isinstance(valid_sets, Dataset): valid_sets = [valid_sets] if isinstance(valid_names, string_type): valid_names = [valid_names] for i, valid_data in enumerate(valid_sets): # reduce cost for prediction training data if valid_data is train_set: is_valid_contain_train = True if valid_names is not None: train_data_name = valid_names[i] continue if not isinstance(valid_data, Dataset): raise TypeError("Traninig only accepts Dataset object") reduced_valid_sets.append(valid_data._update_params(params).set_reference(train_set)) if valid_names is not None and len(valid_names) > i: name_valid_sets.append(valid_names[i]) else: name_valid_sets.append('valid_' + str(i)) # process callbacks if callbacks is None: callbacks = set() else: for i, cb in enumerate(callbacks): cb.__dict__.setdefault('order', i - len(callbacks)) callbacks = set(callbacks) # Most of legacy advanced options becomes callbacks if verbose_eval is True: callbacks.add(callback.print_evaluation()) elif isinstance(verbose_eval, integer_types): callbacks.add(callback.print_evaluation(verbose_eval)) if early_stopping_rounds is not None: callbacks.add(callback.early_stopping(early_stopping_rounds, verbose=bool(verbose_eval))) if learning_rates is not None: callbacks.add(callback.reset_parameter(learning_rate=learning_rates)) if evals_result is not None: callbacks.add(callback.record_evaluation(evals_result)) callbacks_before_iter = {cb for cb in callbacks if getattr(cb, 'before_iteration', False)} callbacks_after_iter = callbacks - callbacks_before_iter callbacks_before_iter = sorted(callbacks_before_iter, key=attrgetter('order')) callbacks_after_iter = sorted(callbacks_after_iter, key=attrgetter('order')) # construct booster try: booster = Booster(params=params, train_set=train_set) if is_valid_contain_train: booster.set_train_data_name(train_data_name) for valid_set, name_valid_set in zip_(reduced_valid_sets, name_valid_sets): booster.add_valid(valid_set, name_valid_set) finally: train_set._reverse_update_params() for valid_set in reduced_valid_sets: valid_set._reverse_update_params() booster.best_iteration = 0 # start training for i in range_(init_iteration, init_iteration + num_boost_round): for cb in callbacks_before_iter: cb(callback.CallbackEnv(model=booster, params=params, iteration=i, begin_iteration=init_iteration, end_iteration=init_iteration + num_boost_round, evaluation_result_list=None)) booster.update(fobj=fobj) evaluation_result_list = [] # check evaluation result. if valid_sets is not None: if is_valid_contain_train: evaluation_result_list.extend(booster.eval_train(feval)) evaluation_result_list.extend(booster.eval_valid(feval)) try: for cb in callbacks_after_iter: cb(callback.CallbackEnv(model=booster, params=params, iteration=i, begin_iteration=init_iteration, end_iteration=init_iteration + num_boost_round, evaluation_result_list=evaluation_result_list)) except callback.EarlyStopException as earlyStopException: booster.best_iteration = earlyStopException.best_iteration + 1 evaluation_result_list = earlyStopException.best_score break booster.best_score = collections.defaultdict(dict) for dataset_name, eval_name, score, _ in evaluation_result_list: booster.best_score[dataset_name][eval_name] = score if not keep_training_booster: booster.model_from_string(booster.model_to_string(), False).free_dataset() return booster <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 48051, 279, 4967, 449, 2728, 5137, 382, 262, 13831, 198, 262, 31423, 262, 3712, 551, 6587, 198, 286, 13831, 369, 4967, 627, 262, 5542, 2667, 551, 40283, 198, 286, 2956, 311, 387, 16572, 389, 627, 262, 1661, 86013, 30996, 551, 528, 11, 10309, 320, 2309, 28, 1041, 340, 286, 5742, 315, 56028, 26771, 627, 262, 2764, 21992, 551, 1160, 315, 423, 77749, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 1796, 315, 828, 311, 387, 26126, 389, 2391, 4967, 627, 262, 2764, 9366, 551, 1160, 315, 9246, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 35975, 315, 10103, 1930, 21992, 14196, 627, 262, 282, 2347, 551, 42022, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 8572, 1534, 16945, 734, 627, 262, 1172, 838, 551, 42022, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 8572, 1534, 16865, 734, 627, 286, 12540, 4287, 1403, 5137, 25, 61821, 11, 5542, 1807, 345, 286, 323, 471, 320, 14504, 1292, 11, 5720, 5400, 11, 374, 23512, 261, 890, 22120, 8, 477, 1160, 315, 1778, 46325, 627, 286, 1789, 7447, 15144, 3465, 11, 279, 61821, 374, 1912, 555, 538, 851, 1176, 11, 1243, 1912, 555, 2872, 851, 627, 286, 1442, 499, 1390, 311, 636, 602, 7716, 2872, 61821, 304, 503, 7716, 538, 11, 279, 2680, 1648, 374, 61821, 3894, 353, 1661, 1807, 489, 602, 27218, 286, 2057, 10240, 279, 1670, 18767, 12435, 311, 279, 1511, 16945, 345, 286, 743, 279, 10103, 16282, 14196, 5852, 311, 279, 925, 10103, 1, 4155, 1, 14196, 304, 10103, 3603, 14196, 627, 262, 3003, 5156, 551, 925, 11, 75292, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 50911, 315, 8828, 5494, 44, 1646, 477, 75292, 2937, 1511, 369, 3136, 4967, 627, 262, 4668, 1292, 551, 1160, 315, 9246, 477, 364, 3989, 518, 10309, 320, 2309, 429, 3989, 1158, 286, 20595, 5144, 627, 286, 1442, 364, 3989, 6, 323, 828, 374, 19130, 46886, 11, 828, 8310, 5144, 527, 1511, 627, 262, 70636, 17506, 551, 1160, 315, 9246, 477, 528, 11, 477, 364, 3989, 518, 10309, 320, 2309, 429, 3989, 1158, 286, 356, 47147, 4519, 627, 286, 1442, 1160, 315, 528, 11, 33398, 439, 15285, 627, 286, 1442, 1160, 315, 9246, 11, 33398, 439, 4668, 5144, 320, 17483, 311, 14158, 10103, 13043, 1292, 14196, 439, 1664, 4390, 286, 1442, 364, 3989, 6, 323, 828, 374, 19130, 46886, 11, 19130, 56833, 70636, 8310, 527, 1511, 627, 286, 2052, 2819, 304, 70636, 4519, 1288, 387, 2753, 1109, 528, 843, 1973, 907, 320, 11584, 20338, 15951, 22, 4390, 286, 20902, 2819, 1436, 387, 5044, 35208, 13, 21829, 1701, 24871, 26864, 6041, 505, 7315, 627, 286, 2052, 8389, 2819, 304, 70636, 4519, 690, 387, 12020, 439, 7554, 2819, 627, 262, 4216, 1284, 7153, 30996, 82, 551, 528, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 15050, 988, 4216, 23351, 13, 578, 1646, 690, 5542 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 48051, 279, 4967, 449, 2728, 5137, 382, 262, 13831, 198, 262, 31423, 262, 3712, 551, 6587, 198, 286, 13831, 369, 4967, 627, 262, 5542, 2667, 551, 40283, 198, 286, 2956, 311, 387, 16572, 389, 627, 262, 1661, 86013, 30996, 551, 528, 11, 10309, 320, 2309, 28, 1041, 340, 286, 5742, 315, 56028, 26771, 627, 262, 2764, 21992, 551, 1160, 315, 423, 77749, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 1796, 315, 828, 311, 387, 26126, 389, 2391, 4967, 627, 262, 2764, 9366, 551, 1160, 315, 9246, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 35975, 315, 10103, 1930, 21992, 14196, 627, 262, 282, 2347, 551, 42022, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 8572, 1534, 16945, 734, 627, 262, 1172, 838, 551, 42022, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 8572, 1534, 16865, 734, 627, 286, 12540, 4287, 1403, 5137, 25, 61821, 11, 5542, 1807, 345, 286, 323, 471, 320, 14504, 1292, 11, 5720, 5400, 11, 374, 23512, 261, 890, 22120, 8, 477, 1160, 315, 1778, 46325, 627, 286, 1789, 7447, 15144, 3465, 11, 279, 61821, 374, 1912, 555, 538, 851, 1176, 11, 1243, 1912, 555, 2872, 851, 627, 286, 1442, 499, 1390, 311, 636, 602, 7716, 2872, 61821, 304, 503, 7716, 538, 11, 279, 2680, 1648, 374, 61821, 3894, 353, 1661, 1807, 489, 602, 27218, 286, 2057, 10240, 279, 1670, 18767, 12435, 311, 279, 1511, 16945, 345, 286, 743, 279, 10103, 16282, 14196, 5852, 311, 279, 925, 10103, 1, 4155, 1, 14196, 304, 10103, 3603, 14196, 627, 262, 3003, 5156, 551, 925, 11, 75292, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 50911, 315, 8828, 5494, 44, 1646, 477, 75292, 2937, 1511, 369, 3136, 4967, 627, 262, 4668, 1292, 551, 1160, 315, 9246, 477, 364, 3989, 518, 10309, 320, 2309, 429, 3989, 1158, 286, 20595, 5144, 627, 286, 1442, 364, 3989, 6, 323, 828, 374, 19130, 46886, 11, 828, 8310, 5144, 527, 1511, 627, 262, 70636, 17506, 551, 1160, 315, 9246, 477, 528, 11, 477, 364, 3989, 518, 10309, 320, 2309, 429, 3989, 1158, 286, 356, 47147, 4519, 627, 286, 1442, 1160, 315, 528, 11, 33398, 439, 15285, 627, 286, 1442, 1160, 315, 9246, 11, 33398, 439, 4668, 5144, 320, 17483, 311, 14158, 10103, 13043, 1292, 14196, 439, 1664, 4390, 286, 1442, 364, 3989, 6, 323, 828, 374, 19130, 46886, 11, 19130, 56833, 70636, 8310, 527, 1511, 627, 286, 2052, 2819, 304, 70636, 4519, 1288, 387, 2753, 1109, 528, 843, 1973, 907, 320, 11584, 20338, 15951, 22, 4390, 286, 20902, 2819, 1436, 387, 5044, 35208, 13, 21829, 1701, 24871, 26864, 6041, 505, 7315, 627, 286, 2052, 8389, 2819, 304, 70636, 4519, 690, 387, 12020, 439, 7554, 2819, 627, 262, 4216, 1284, 7153, 30996, 82, 551, 528, 477, 2290, 11, 10309, 320, 2309, 5980, 340, 286, 15050, 988, 4216, 23351, 13, 578, 1646, 690, 5542 ]
adaptive-learning/proso-apps
proso_models/models.py
ItemManager.get_graph
def get_graph(self, item_ids, language=None): """ Get a subgraph of items reachable from the given set of items through any relation. Args: item_ids (list): items which are taken as roots for the reachability language (str): if specified, filter out items which are not available in the given language Returns: dict: item id -> list of items (parent items), root items are referenced by None key """ def _related(item_ids): if item_ids is None: items = Item.objects.filter(active=True).prefetch_related('parents', 'children') else: item_ids = [ii for iis in item_ids.values() for ii in iis] items = Item.objects.filter(id__in=item_ids, active=True).prefetch_related('parents', 'children') return {item.id: sorted([_item.id for rel in [item.parents.all(), item.children.all()] for _item in rel]) for item in items} if item_ids is None: return self._reachable_graph(None, _related, language=language) else: graph = self.get_graph(None, language) return self._subset_graph(graph, item_ids)
python
def get_graph(self, item_ids, language=None): """ Get a subgraph of items reachable from the given set of items through any relation. Args: item_ids (list): items which are taken as roots for the reachability language (str): if specified, filter out items which are not available in the given language Returns: dict: item id -> list of items (parent items), root items are referenced by None key """ def _related(item_ids): if item_ids is None: items = Item.objects.filter(active=True).prefetch_related('parents', 'children') else: item_ids = [ii for iis in item_ids.values() for ii in iis] items = Item.objects.filter(id__in=item_ids, active=True).prefetch_related('parents', 'children') return {item.id: sorted([_item.id for rel in [item.parents.all(), item.children.all()] for _item in rel]) for item in items} if item_ids is None: return self._reachable_graph(None, _related, language=language) else: graph = self.get_graph(None, language) return self._subset_graph(graph, item_ids)
[ "def", "get_graph", "(", "self", ",", "item_ids", ",", "language", "=", "None", ")", ":", "def", "_related", "(", "item_ids", ")", ":", "if", "item_ids", "is", "None", ":", "items", "=", "Item", ".", "objects", ".", "filter", "(", "active", "=", "True", ")", ".", "prefetch_related", "(", "'parents'", ",", "'children'", ")", "else", ":", "item_ids", "=", "[", "ii", "for", "iis", "in", "item_ids", ".", "values", "(", ")", "for", "ii", "in", "iis", "]", "items", "=", "Item", ".", "objects", ".", "filter", "(", "id__in", "=", "item_ids", ",", "active", "=", "True", ")", ".", "prefetch_related", "(", "'parents'", ",", "'children'", ")", "return", "{", "item", ".", "id", ":", "sorted", "(", "[", "_item", ".", "id", "for", "rel", "in", "[", "item", ".", "parents", ".", "all", "(", ")", ",", "item", ".", "children", ".", "all", "(", ")", "]", "for", "_item", "in", "rel", "]", ")", "for", "item", "in", "items", "}", "if", "item_ids", "is", "None", ":", "return", "self", ".", "_reachable_graph", "(", "None", ",", "_related", ",", "language", "=", "language", ")", "else", ":", "graph", "=", "self", ".", "get_graph", "(", "None", ",", "language", ")", "return", "self", ".", "_subset_graph", "(", "graph", ",", "item_ids", ")" ]
Get a subgraph of items reachable from the given set of items through any relation. Args: item_ids (list): items which are taken as roots for the reachability language (str): if specified, filter out items which are not available in the given language Returns: dict: item id -> list of items (parent items), root items are referenced by None key
[ "Get", "a", "subgraph", "of", "items", "reachable", "from", "the", "given", "set", "of", "items", "through", "any", "relation", "." ]
train
https://github.com/adaptive-learning/proso-apps/blob/8278c72e498d6ef8d392cc47b48473f4ec037142/proso_models/models.py#L507-L532
<|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 subgraph of items reachable from the given set of items through any relation. Args: item_ids (list): items which are taken as roots for the reachability language (str): if specified, filter out items which are not available in the given language Returns: dict: item id -> list of items (parent items), root items are referenced by None key ### Response: def get_graph(self, item_ids, language=None): """ Get a subgraph of items reachable from the given set of items through any relation. Args: item_ids (list): items which are taken as roots for the reachability language (str): if specified, filter out items which are not available in the given language Returns: dict: item id -> list of items (parent items), root items are referenced by None key """ def _related(item_ids): if item_ids is None: items = Item.objects.filter(active=True).prefetch_related('parents', 'children') else: item_ids = [ii for iis in item_ids.values() for ii in iis] items = Item.objects.filter(id__in=item_ids, active=True).prefetch_related('parents', 'children') return {item.id: sorted([_item.id for rel in [item.parents.all(), item.children.all()] for _item in rel]) for item in items} if item_ids is None: return self._reachable_graph(None, _related, language=language) else: graph = self.get_graph(None, language) return self._subset_graph(graph, item_ids) <|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, 1207, 4539, 315, 3673, 69384, 505, 279, 2728, 743, 315, 3673, 1555, 198, 286, 904, 12976, 382, 286, 18161, 512, 310, 1537, 8237, 320, 1638, 1680, 3673, 902, 527, 4529, 439, 20282, 369, 279, 5662, 2968, 198, 310, 4221, 320, 496, 1680, 422, 5300, 11, 4141, 704, 3673, 902, 527, 539, 198, 394, 2561, 304, 279, 2728, 4221, 271, 286, 5295, 512, 310, 6587, 25, 1537, 887, 1492, 1160, 315, 3673, 320, 3850, 3673, 705, 3789, 3673, 527, 198, 310, 25819, 555, 2290, 1401, 271, 14711, 6075, 512, 755, 636, 15080, 1214, 11, 1537, 8237, 11, 4221, 5980, 997, 286, 3270, 286, 2175, 264, 1207, 4539, 315, 3673, 69384, 505, 279, 2728, 743, 315, 3673, 1555, 198, 286, 904, 12976, 382, 286, 18161, 512, 310, 1537, 8237, 320, 1638, 1680, 3673, 902, 527, 4529, 439, 20282, 369, 279, 5662, 2968, 198, 310, 4221, 320, 496, 1680, 422, 5300, 11, 4141, 704, 3673, 902, 527, 539, 198, 394, 2561, 304, 279, 2728, 4221, 271, 286, 5295, 512, 310, 6587, 25, 1537, 887, 1492, 1160, 315, 3673, 320, 3850, 3673, 705, 3789, 3673, 527, 198, 310, 25819, 555, 2290, 1401, 198, 286, 3270, 286, 711, 721, 9920, 5508, 8237, 997, 310, 422, 1537, 8237, 374, 2290, 512, 394, 3673, 284, 5858, 8549, 7081, 47029, 3702, 570, 31652, 3068, 54356, 493, 26534, 518, 364, 5988, 1329, 310, 775, 512, 394, 1537, 8237, 284, 510, 3893, 369, 602, 285, 304, 1537, 8237, 10883, 368, 369, 14799, 304, 602, 285, 933, 394, 3673, 284, 5858, 8549, 7081, 3809, 565, 258, 33662, 8237, 11, 4642, 3702, 570, 31652, 3068, 54356, 493, 26534, 518, 364, 5988, 1329, 310, 471, 314, 1224, 1801, 25, 10839, 2625, 62, 1224, 1801, 369, 1375, 304, 510, 1224, 73861, 7825, 1535, 1537, 13664, 7825, 27654, 369, 721, 1224, 304, 1375, 2526, 369, 1537, 304, 3673, 534, 286, 422, 1537, 8237, 374, 2290, 512, 310, 471, 659, 1462, 47650, 15080, 27815, 11, 721, 9920, 11, 4221, 28, 11789, 340, 286, 775, 512, 310, 4876, 284, 659, 673, 15080, 27815, 11, 4221, 340, 310, 471, 659, 1462, 39353, 15080, 25301, 11, 1537, 8237, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 1207, 4539, 315, 3673, 69384, 505, 279, 2728, 743, 315, 3673, 1555, 198, 286, 904, 12976, 382, 286, 18161, 512, 310, 1537, 8237, 320, 1638, 1680, 3673, 902, 527, 4529, 439, 20282, 369, 279, 5662, 2968, 198, 310, 4221, 320, 496, 1680, 422, 5300, 11, 4141, 704, 3673, 902, 527, 539, 198, 394, 2561, 304, 279, 2728, 4221, 271, 286, 5295, 512, 310, 6587, 25, 1537, 887, 1492, 1160, 315, 3673, 320, 3850, 3673, 705, 3789, 3673, 527, 198, 310, 25819, 555, 2290, 1401, 271, 14711, 6075, 512, 755, 636, 15080, 1214, 11, 1537, 8237, 11, 4221, 5980, 997, 286, 3270, 286, 2175, 264, 1207, 4539, 315, 3673, 69384, 505, 279, 2728, 743, 315, 3673, 1555, 198, 286, 904, 12976, 382, 286, 18161, 512, 310, 1537, 8237, 320, 1638, 1680, 3673, 902, 527, 4529, 439, 20282, 369, 279, 5662, 2968, 198, 310, 4221, 320, 496, 1680, 422, 5300, 11, 4141, 704, 3673, 902, 527, 539, 198, 394, 2561, 304, 279, 2728, 4221, 271, 286, 5295, 512, 310, 6587, 25, 1537, 887, 1492, 1160, 315, 3673, 320, 3850, 3673, 705, 3789, 3673, 527, 198, 310, 25819, 555, 2290, 1401, 198, 286, 3270, 286, 711, 721, 9920, 5508, 8237, 997, 310, 422, 1537, 8237, 374, 2290, 512, 394, 3673, 284, 5858, 8549, 7081, 47029, 3702, 570, 31652, 3068, 54356, 493, 26534, 518, 364, 5988, 1329, 310, 775, 512, 394, 1537, 8237, 284, 510, 3893, 369, 602, 285, 304, 1537, 8237, 10883, 368, 369, 14799, 304, 602, 285, 933, 394, 3673, 284, 5858, 8549, 7081, 3809, 565, 258, 33662, 8237, 11, 4642, 3702, 570, 31652, 3068, 54356, 493, 26534, 518, 364, 5988, 1329, 310, 471, 314, 1224, 1801, 25, 10839, 2625, 62, 1224, 1801, 369, 1375, 304, 510, 1224, 73861, 7825, 1535, 1537, 13664, 7825, 27654, 369, 721, 1224, 304, 1375, 2526, 369, 1537, 304, 3673, 534, 286, 422, 1537, 8237, 374, 2290, 512, 310, 471, 659, 1462, 47650, 15080, 27815, 11, 721, 9920, 11, 4221, 28, 11789, 340, 286, 775, 512, 310, 4876, 284, 659, 673, 15080, 27815, 11, 4221, 340, 310, 471, 659, 1462, 39353, 15080, 25301, 11, 1537, 8237, 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 ]
ipfs/py-ipfs-api
ipfsapi/client.py
Client.pin_rm
def pin_rm(self, path, *paths, **kwargs): """Removes a pinned object from local storage. Removes the pin from the given object allowing it to be garbage collected if needed. .. code-block:: python >>> c.pin_rm('QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d') {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d']} Parameters ---------- path : str Path to object(s) to be unpinned recursive : bool Recursively unpin the object linked to by the specified object(s) Returns ------- dict : List of IPFS objects that have been unpinned """ #PY2: No support for kw-only parameters after glob parameters if "recursive" in kwargs: kwargs.setdefault("opts", {"recursive": kwargs["recursive"]}) del kwargs["recursive"] args = (path,) + paths return self._client.request('/pin/rm', args, decoder='json', **kwargs)
python
def pin_rm(self, path, *paths, **kwargs): """Removes a pinned object from local storage. Removes the pin from the given object allowing it to be garbage collected if needed. .. code-block:: python >>> c.pin_rm('QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d') {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d']} Parameters ---------- path : str Path to object(s) to be unpinned recursive : bool Recursively unpin the object linked to by the specified object(s) Returns ------- dict : List of IPFS objects that have been unpinned """ #PY2: No support for kw-only parameters after glob parameters if "recursive" in kwargs: kwargs.setdefault("opts", {"recursive": kwargs["recursive"]}) del kwargs["recursive"] args = (path,) + paths return self._client.request('/pin/rm', args, decoder='json', **kwargs)
[ "def", "pin_rm", "(", "self", ",", "path", ",", "*", "paths", ",", "*", "*", "kwargs", ")", ":", "#PY2: No support for kw-only parameters after glob parameters", "if", "\"recursive\"", "in", "kwargs", ":", "kwargs", ".", "setdefault", "(", "\"opts\"", ",", "{", "\"recursive\"", ":", "kwargs", "[", "\"recursive\"", "]", "}", ")", "del", "kwargs", "[", "\"recursive\"", "]", "args", "=", "(", "path", ",", ")", "+", "paths", "return", "self", ".", "_client", ".", "request", "(", "'/pin/rm'", ",", "args", ",", "decoder", "=", "'json'", ",", "*", "*", "kwargs", ")" ]
Removes a pinned object from local storage. Removes the pin from the given object allowing it to be garbage collected if needed. .. code-block:: python >>> c.pin_rm('QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d') {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d']} Parameters ---------- path : str Path to object(s) to be unpinned recursive : bool Recursively unpin the object linked to by the specified object(s) Returns ------- dict : List of IPFS objects that have been unpinned
[ "Removes", "a", "pinned", "object", "from", "local", "storage", "." ]
train
https://github.com/ipfs/py-ipfs-api/blob/7574dad04877b45dbe4ad321dcfa9e880eb2d90c/ipfsapi/client.py#L1055-L1083
<|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 a pinned object from local storage. Removes the pin from the given object allowing it to be garbage collected if needed. .. code-block:: python >>> c.pin_rm('QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d') {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d']} Parameters ---------- path : str Path to object(s) to be unpinned recursive : bool Recursively unpin the object linked to by the specified object(s) Returns ------- dict : List of IPFS objects that have been unpinned ### Response: def pin_rm(self, path, *paths, **kwargs): """Removes a pinned object from local storage. Removes the pin from the given object allowing it to be garbage collected if needed. .. code-block:: python >>> c.pin_rm('QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d') {'Pins': ['QmfZY61ukoQuCX8e5Pt7v8pRfhkyxwZKZMTodAtmvyGZ5d']} Parameters ---------- path : str Path to object(s) to be unpinned recursive : bool Recursively unpin the object linked to by the specified object(s) Returns ------- dict : List of IPFS objects that have been unpinned """ #PY2: No support for kw-only parameters after glob parameters if "recursive" in kwargs: kwargs.setdefault("opts", {"recursive": kwargs["recursive"]}) del kwargs["recursive"] args = (path,) + paths return self._client.request('/pin/rm', args, decoder='json', **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, 6728, 10296, 264, 48809, 1665, 505, 2254, 5942, 382, 286, 39875, 279, 9160, 505, 279, 2728, 1665, 10923, 433, 311, 387, 26964, 198, 286, 14890, 422, 4460, 382, 286, 5354, 2082, 9612, 487, 10344, 271, 310, 12382, 272, 51742, 59637, 493, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 1329, 310, 5473, 47, 1354, 1232, 2570, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 663, 633, 286, 13831, 198, 286, 31423, 286, 1853, 551, 610, 198, 310, 8092, 311, 1665, 1161, 8, 311, 387, 22355, 21203, 198, 286, 31919, 551, 1845, 198, 310, 4158, 80837, 653, 13576, 279, 1665, 10815, 311, 555, 279, 5300, 1665, 1161, 696, 286, 5295, 198, 286, 39707, 310, 6587, 551, 1796, 315, 6933, 8653, 6302, 430, 617, 1027, 22355, 21203, 271, 14711, 6075, 512, 755, 9160, 59637, 1214, 11, 1853, 11, 353, 22354, 11, 3146, 9872, 997, 286, 4304, 6728, 10296, 264, 48809, 1665, 505, 2254, 5942, 382, 286, 39875, 279, 9160, 505, 279, 2728, 1665, 10923, 433, 311, 387, 26964, 198, 286, 14890, 422, 4460, 382, 286, 5354, 2082, 9612, 487, 10344, 271, 310, 12382, 272, 51742, 59637, 493, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 1329, 310, 5473, 47, 1354, 1232, 2570, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 663, 633, 286, 13831, 198, 286, 31423, 286, 1853, 551, 610, 198, 310, 8092, 311, 1665, 1161, 8, 311, 387, 22355, 21203, 198, 286, 31919, 551, 1845, 198, 310, 4158, 80837, 653, 13576, 279, 1665, 10815, 311, 555, 279, 5300, 1665, 1161, 696, 286, 5295, 198, 286, 39707, 310, 6587, 551, 1796, 315, 6933, 8653, 6302, 430, 617, 1027, 22355, 21203, 198, 286, 3270, 286, 674, 38981, 17, 25, 2360, 1862, 369, 30625, 15744, 5137, 1306, 13509, 5137, 198, 286, 422, 330, 50612, 1, 304, 16901, 512, 310, 16901, 54114, 446, 10740, 498, 5324, 50612, 794, 16901, 1204, 50612, 1365, 3602, 310, 1624, 16901, 1204, 50612, 27001, 286, 2897, 284, 320, 2398, 47121, 489, 13006, 198, 286, 471, 659, 1462, 3045, 8387, 3478, 13576, 7534, 76, 518, 2897, 11, 25569, 1151, 2285, 518, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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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397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 264, 48809, 1665, 505, 2254, 5942, 382, 286, 39875, 279, 9160, 505, 279, 2728, 1665, 10923, 433, 311, 387, 26964, 198, 286, 14890, 422, 4460, 382, 286, 5354, 2082, 9612, 487, 10344, 271, 310, 12382, 272, 51742, 59637, 493, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 1329, 310, 5473, 47, 1354, 1232, 2570, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 663, 633, 286, 13831, 198, 286, 31423, 286, 1853, 551, 610, 198, 310, 8092, 311, 1665, 1161, 8, 311, 387, 22355, 21203, 198, 286, 31919, 551, 1845, 198, 310, 4158, 80837, 653, 13576, 279, 1665, 10815, 311, 555, 279, 5300, 1665, 1161, 696, 286, 5295, 198, 286, 39707, 310, 6587, 551, 1796, 315, 6933, 8653, 6302, 430, 617, 1027, 22355, 21203, 271, 14711, 6075, 512, 755, 9160, 59637, 1214, 11, 1853, 11, 353, 22354, 11, 3146, 9872, 997, 286, 4304, 6728, 10296, 264, 48809, 1665, 505, 2254, 5942, 382, 286, 39875, 279, 9160, 505, 279, 2728, 1665, 10923, 433, 311, 387, 26964, 198, 286, 14890, 422, 4460, 382, 286, 5354, 2082, 9612, 487, 10344, 271, 310, 12382, 272, 51742, 59637, 493, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 1329, 310, 5473, 47, 1354, 1232, 2570, 48, 29224, 81601, 5547, 72158, 2232, 66340, 23, 68, 20, 35956, 22, 85, 23, 79, 49, 32204, 8050, 87, 86, 57, 42, 57, 8673, 347, 1688, 76, 14029, 38, 57, 20, 67, 663, 633, 286, 13831, 198, 286, 31423, 286, 1853, 551, 610, 198, 310, 8092, 311, 1665, 1161, 8, 311, 387, 22355, 21203, 198, 286, 31919, 551, 1845, 198, 310, 4158, 80837, 653, 13576, 279, 1665, 10815, 311, 555, 279, 5300, 1665, 1161, 696, 286, 5295, 198, 286, 39707, 310, 6587, 551, 1796, 315, 6933, 8653, 6302, 430, 617, 1027, 22355, 21203, 198, 286, 3270, 286, 674, 38981, 17, 25, 2360, 1862, 369, 30625, 15744, 5137, 1306, 13509, 5137, 198, 286, 422, 330, 50612, 1, 304, 16901, 512, 310, 16901, 54114, 446, 10740, 498, 5324, 50612, 794, 16901, 1204, 50612, 1365, 3602, 310, 1624, 16901, 1204, 50612, 27001, 286, 2897, 284, 320, 2398, 47121, 489, 13006, 198, 286, 471, 659, 1462, 3045, 8387, 3478, 13576, 7534, 76, 518, 2897, 11, 25569, 1151, 2285, 518, 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 ]
davidfokkema/artist
artist/utils.py
create_graph_name
def create_graph_name(suffix='', dirname=None): """Create a graph name using the name of the caller. :param suffix: optional suffix to add to name :param dirname: optional directory name :return: path for the named graph :rtype: string """ if suffix: suffix = '-%s' % suffix caller = get_callers_name(level=3) name = '%s%s%s%s' % (__prefix, caller, suffix, __suffix) if dirname: name = os.path.join(dirname, name) return name
python
def create_graph_name(suffix='', dirname=None): """Create a graph name using the name of the caller. :param suffix: optional suffix to add to name :param dirname: optional directory name :return: path for the named graph :rtype: string """ if suffix: suffix = '-%s' % suffix caller = get_callers_name(level=3) name = '%s%s%s%s' % (__prefix, caller, suffix, __suffix) if dirname: name = os.path.join(dirname, name) return name
[ "def", "create_graph_name", "(", "suffix", "=", "''", ",", "dirname", "=", "None", ")", ":", "if", "suffix", ":", "suffix", "=", "'-%s'", "%", "suffix", "caller", "=", "get_callers_name", "(", "level", "=", "3", ")", "name", "=", "'%s%s%s%s'", "%", "(", "__prefix", ",", "caller", ",", "suffix", ",", "__suffix", ")", "if", "dirname", ":", "name", "=", "os", ".", "path", ".", "join", "(", "dirname", ",", "name", ")", "return", "name" ]
Create a graph name using the name of the caller. :param suffix: optional suffix to add to name :param dirname: optional directory name :return: path for the named graph :rtype: string
[ "Create", "a", "graph", "name", "using", "the", "name", "of", "the", "caller", "." ]
train
https://github.com/davidfokkema/artist/blob/26ae7987522622710f2910980770c50012fda47d/artist/utils.py#L51-L67
<|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 graph name using the name of the caller. :param suffix: optional suffix to add to name :param dirname: optional directory name :return: path for the named graph :rtype: string ### Response: def create_graph_name(suffix='', dirname=None): """Create a graph name using the name of the caller. :param suffix: optional suffix to add to name :param dirname: optional directory name :return: path for the named graph :rtype: string """ if suffix: suffix = '-%s' % suffix caller = get_callers_name(level=3) name = '%s%s%s%s' % (__prefix, caller, suffix, __suffix) if dirname: name = os.path.join(dirname, name) return 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, 4110, 264, 4876, 836, 1701, 279, 836, 315, 279, 20456, 382, 262, 551, 913, 21166, 25, 10309, 21166, 311, 923, 311, 836, 198, 262, 551, 913, 31008, 25, 10309, 6352, 836, 271, 262, 551, 693, 25, 1853, 369, 279, 7086, 4876, 198, 262, 551, 33613, 25, 925, 271, 14711, 6075, 512, 755, 1893, 15080, 1292, 97566, 41662, 31008, 5980, 997, 262, 4304, 4110, 264, 4876, 836, 1701, 279, 836, 315, 279, 20456, 382, 262, 551, 913, 21166, 25, 10309, 21166, 311, 923, 311, 836, 198, 262, 551, 913, 31008, 25, 10309, 6352, 836, 271, 262, 551, 693, 25, 1853, 369, 279, 7086, 4876, 198, 262, 551, 33613, 25, 925, 271, 262, 3270, 262, 422, 21166, 512, 286, 21166, 284, 7944, 4, 82, 6, 1034, 21166, 198, 262, 20456, 284, 636, 13735, 388, 1292, 24593, 28, 18, 340, 262, 836, 284, 7832, 82, 13249, 13249, 13249, 6, 1034, 23374, 12113, 11, 20456, 11, 21166, 11, 1328, 27884, 340, 262, 422, 31008, 512, 286, 836, 284, 2709, 3960, 5563, 39902, 11, 836, 340, 262, 471, 836, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 4876, 836, 1701, 279, 836, 315, 279, 20456, 382, 262, 551, 913, 21166, 25, 10309, 21166, 311, 923, 311, 836, 198, 262, 551, 913, 31008, 25, 10309, 6352, 836, 271, 262, 551, 693, 25, 1853, 369, 279, 7086, 4876, 198, 262, 551, 33613, 25, 925, 271, 14711, 6075, 512, 755, 1893, 15080, 1292, 97566, 41662, 31008, 5980, 997, 262, 4304, 4110, 264, 4876, 836, 1701, 279, 836, 315, 279, 20456, 382, 262, 551, 913, 21166, 25, 10309, 21166, 311, 923, 311, 836, 198, 262, 551, 913, 31008, 25, 10309, 6352, 836, 271, 262, 551, 693, 25, 1853, 369, 279, 7086, 4876, 198, 262, 551, 33613, 25, 925, 271, 262, 3270, 262, 422, 21166, 512, 286, 21166, 284, 7944, 4, 82, 6, 1034, 21166, 198, 262, 20456, 284, 636, 13735, 388, 1292, 24593, 28, 18, 340, 262, 836, 284, 7832, 82, 13249, 13249, 13249, 6, 1034, 23374, 12113, 11, 20456, 11, 21166, 11, 1328, 27884, 340, 262, 422, 31008, 512, 286, 836, 284, 2709, 3960, 5563, 39902, 11, 836, 340, 262, 471, 836, 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 ]
elifesciences/elife-tools
elifetools/parseJATS.py
version_history
def version_history(soup, html_flag=True): "extract the article version history details" convert = lambda xml_string: xml_to_html(html_flag, xml_string) version_history = [] related_object_tags = raw_parser.related_object(raw_parser.article_meta(soup)) for tag in related_object_tags: article_version = OrderedDict() date_tag = first(raw_parser.date(tag)) if date_tag: copy_attribute(date_tag.attrs, 'date-type', article_version, 'version') (day, month, year) = ymd(date_tag) article_version['day'] = day article_version['month'] = month article_version['year'] = year article_version['date'] = date_struct_nn(year, month, day) copy_attribute(tag.attrs, 'xlink:href', article_version, 'xlink_href') set_if_value(article_version, "comment", convert(node_contents_str(first(raw_parser.comment(tag))))) version_history.append(article_version) return version_history
python
def version_history(soup, html_flag=True): "extract the article version history details" convert = lambda xml_string: xml_to_html(html_flag, xml_string) version_history = [] related_object_tags = raw_parser.related_object(raw_parser.article_meta(soup)) for tag in related_object_tags: article_version = OrderedDict() date_tag = first(raw_parser.date(tag)) if date_tag: copy_attribute(date_tag.attrs, 'date-type', article_version, 'version') (day, month, year) = ymd(date_tag) article_version['day'] = day article_version['month'] = month article_version['year'] = year article_version['date'] = date_struct_nn(year, month, day) copy_attribute(tag.attrs, 'xlink:href', article_version, 'xlink_href') set_if_value(article_version, "comment", convert(node_contents_str(first(raw_parser.comment(tag))))) version_history.append(article_version) return version_history
[ "def", "version_history", "(", "soup", ",", "html_flag", "=", "True", ")", ":", "convert", "=", "lambda", "xml_string", ":", "xml_to_html", "(", "html_flag", ",", "xml_string", ")", "version_history", "=", "[", "]", "related_object_tags", "=", "raw_parser", ".", "related_object", "(", "raw_parser", ".", "article_meta", "(", "soup", ")", ")", "for", "tag", "in", "related_object_tags", ":", "article_version", "=", "OrderedDict", "(", ")", "date_tag", "=", "first", "(", "raw_parser", ".", "date", "(", "tag", ")", ")", "if", "date_tag", ":", "copy_attribute", "(", "date_tag", ".", "attrs", ",", "'date-type'", ",", "article_version", ",", "'version'", ")", "(", "day", ",", "month", ",", "year", ")", "=", "ymd", "(", "date_tag", ")", "article_version", "[", "'day'", "]", "=", "day", "article_version", "[", "'month'", "]", "=", "month", "article_version", "[", "'year'", "]", "=", "year", "article_version", "[", "'date'", "]", "=", "date_struct_nn", "(", "year", ",", "month", ",", "day", ")", "copy_attribute", "(", "tag", ".", "attrs", ",", "'xlink:href'", ",", "article_version", ",", "'xlink_href'", ")", "set_if_value", "(", "article_version", ",", "\"comment\"", ",", "convert", "(", "node_contents_str", "(", "first", "(", "raw_parser", ".", "comment", "(", "tag", ")", ")", ")", ")", ")", "version_history", ".", "append", "(", "article_version", ")", "return", "version_history" ]
extract the article version history details
[ "extract", "the", "article", "version", "history", "details" ]
train
https://github.com/elifesciences/elife-tools/blob/4b9e38cbe485c61a4ed7cbd8970c6b318334fd86/elifetools/parseJATS.py#L131-L150
<|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: extract the article version history details ### Response: def version_history(soup, html_flag=True): "extract the article version history details" convert = lambda xml_string: xml_to_html(html_flag, xml_string) version_history = [] related_object_tags = raw_parser.related_object(raw_parser.article_meta(soup)) for tag in related_object_tags: article_version = OrderedDict() date_tag = first(raw_parser.date(tag)) if date_tag: copy_attribute(date_tag.attrs, 'date-type', article_version, 'version') (day, month, year) = ymd(date_tag) article_version['day'] = day article_version['month'] = month article_version['year'] = year article_version['date'] = date_struct_nn(year, month, day) copy_attribute(tag.attrs, 'xlink:href', article_version, 'xlink_href') set_if_value(article_version, "comment", convert(node_contents_str(first(raw_parser.comment(tag))))) version_history.append(article_version) return version_history <|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, 24396, 279, 4652, 2373, 3925, 3649, 271, 14711, 6075, 512, 755, 2373, 20389, 1161, 13649, 11, 5385, 11173, 3702, 997, 262, 330, 24396, 279, 4652, 2373, 3925, 3649, 702, 262, 5625, 284, 12741, 8562, 3991, 25, 8562, 2401, 9759, 23745, 11173, 11, 8562, 3991, 340, 262, 2373, 20389, 284, 4260, 262, 5552, 5427, 16735, 284, 7257, 19024, 48503, 5427, 23269, 19024, 52516, 13686, 1161, 13649, 1192, 262, 369, 4877, 304, 5552, 5427, 16735, 512, 286, 4652, 9625, 284, 54313, 746, 286, 2457, 9556, 284, 1176, 23269, 19024, 10108, 19904, 1192, 286, 422, 2457, 9556, 512, 310, 3048, 17209, 12237, 9556, 46596, 11, 364, 1045, 10827, 518, 4652, 9625, 11, 364, 4464, 1329, 310, 320, 1316, 11, 2305, 11, 1060, 8, 284, 379, 2329, 12237, 9556, 340, 310, 4652, 9625, 681, 1316, 663, 284, 1938, 198, 310, 4652, 9625, 681, 10460, 663, 284, 2305, 198, 310, 4652, 9625, 681, 3236, 663, 284, 1060, 198, 310, 4652, 9625, 681, 1045, 663, 284, 2457, 15477, 71062, 29381, 11, 2305, 11, 1938, 340, 286, 3048, 17209, 19904, 46596, 11, 364, 87, 2125, 96897, 518, 4652, 9625, 11, 364, 87, 2125, 64088, 1329, 286, 743, 11366, 3220, 52048, 9625, 11, 330, 6313, 761, 3909, 5625, 7103, 17096, 2966, 18465, 23269, 19024, 32070, 19904, 72075, 286, 2373, 20389, 2102, 52048, 9625, 340, 262, 471, 2373, 20389, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 24396, 279, 4652, 2373, 3925, 3649, 271, 14711, 6075, 512, 755, 2373, 20389, 1161, 13649, 11, 5385, 11173, 3702, 997, 262, 330, 24396, 279, 4652, 2373, 3925, 3649, 702, 262, 5625, 284, 12741, 8562, 3991, 25, 8562, 2401, 9759, 23745, 11173, 11, 8562, 3991, 340, 262, 2373, 20389, 284, 4260, 262, 5552, 5427, 16735, 284, 7257, 19024, 48503, 5427, 23269, 19024, 52516, 13686, 1161, 13649, 1192, 262, 369, 4877, 304, 5552, 5427, 16735, 512, 286, 4652, 9625, 284, 54313, 746, 286, 2457, 9556, 284, 1176, 23269, 19024, 10108, 19904, 1192, 286, 422, 2457, 9556, 512, 310, 3048, 17209, 12237, 9556, 46596, 11, 364, 1045, 10827, 518, 4652, 9625, 11, 364, 4464, 1329, 310, 320, 1316, 11, 2305, 11, 1060, 8, 284, 379, 2329, 12237, 9556, 340, 310, 4652, 9625, 681, 1316, 663, 284, 1938, 198, 310, 4652, 9625, 681, 10460, 663, 284, 2305, 198, 310, 4652, 9625, 681, 3236, 663, 284, 1060, 198, 310, 4652, 9625, 681, 1045, 663, 284, 2457, 15477, 71062, 29381, 11, 2305, 11, 1938, 340, 286, 3048, 17209, 19904, 46596, 11, 364, 87, 2125, 96897, 518, 4652, 9625, 11, 364, 87, 2125, 64088, 1329, 286, 743, 11366, 3220, 52048, 9625, 11, 330, 6313, 761, 3909, 5625, 7103, 17096, 2966, 18465, 23269, 19024, 32070, 19904, 72075, 286, 2373, 20389, 2102, 52048, 9625, 340, 262, 471, 2373, 20389, 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 ]
SBRG/ssbio
ssbio/protein/sequence/properties/scratch.py
SCRATCH.sspro_summary
def sspro_summary(self): """Parse the SSpro output file and return a summary of secondary structure composition. The output file is just a FASTA formatted file, so you can get residue level information by parsing it like a normal sequence file. Returns: dict: Percentage of: H: helix E: strand C: the rest """ summary = {} records = ssbio.protein.sequence.utils.fasta.load_fasta_file(self.out_sspro) for r in records: seq_summary = {} seq_summary['percent_H-sspro'] = r.seq.count('H')/float(len(r)) seq_summary['percent_E-sspro'] = r.seq.count('E')/float(len(r)) seq_summary['percent_C-sspro'] = r.seq.count('C')/float(len(r)) summary[r.id] = seq_summary return summary
python
def sspro_summary(self): """Parse the SSpro output file and return a summary of secondary structure composition. The output file is just a FASTA formatted file, so you can get residue level information by parsing it like a normal sequence file. Returns: dict: Percentage of: H: helix E: strand C: the rest """ summary = {} records = ssbio.protein.sequence.utils.fasta.load_fasta_file(self.out_sspro) for r in records: seq_summary = {} seq_summary['percent_H-sspro'] = r.seq.count('H')/float(len(r)) seq_summary['percent_E-sspro'] = r.seq.count('E')/float(len(r)) seq_summary['percent_C-sspro'] = r.seq.count('C')/float(len(r)) summary[r.id] = seq_summary return summary
[ "def", "sspro_summary", "(", "self", ")", ":", "summary", "=", "{", "}", "records", "=", "ssbio", ".", "protein", ".", "sequence", ".", "utils", ".", "fasta", ".", "load_fasta_file", "(", "self", ".", "out_sspro", ")", "for", "r", "in", "records", ":", "seq_summary", "=", "{", "}", "seq_summary", "[", "'percent_H-sspro'", "]", "=", "r", ".", "seq", ".", "count", "(", "'H'", ")", "/", "float", "(", "len", "(", "r", ")", ")", "seq_summary", "[", "'percent_E-sspro'", "]", "=", "r", ".", "seq", ".", "count", "(", "'E'", ")", "/", "float", "(", "len", "(", "r", ")", ")", "seq_summary", "[", "'percent_C-sspro'", "]", "=", "r", ".", "seq", ".", "count", "(", "'C'", ")", "/", "float", "(", "len", "(", "r", ")", ")", "summary", "[", "r", ".", "id", "]", "=", "seq_summary", "return", "summary" ]
Parse the SSpro output file and return a summary of secondary structure composition. The output file is just a FASTA formatted file, so you can get residue level information by parsing it like a normal sequence file. Returns: dict: Percentage of: H: helix E: strand C: the rest
[ "Parse", "the", "SSpro", "output", "file", "and", "return", "a", "summary", "of", "secondary", "structure", "composition", "." ]
train
https://github.com/SBRG/ssbio/blob/e9449e64ffc1a1f5ad07e5849aa12a650095f8a2/ssbio/protein/sequence/properties/scratch.py#L80-L104
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Parse the SSpro output file and return a summary of secondary structure composition. The output file is just a FASTA formatted file, so you can get residue level information by parsing it like a normal sequence file. Returns: dict: Percentage of: H: helix E: strand C: the rest ### Response: def sspro_summary(self): """Parse the SSpro output file and return a summary of secondary structure composition. The output file is just a FASTA formatted file, so you can get residue level information by parsing it like a normal sequence file. Returns: dict: Percentage of: H: helix E: strand C: the rest """ summary = {} records = ssbio.protein.sequence.utils.fasta.load_fasta_file(self.out_sspro) for r in records: seq_summary = {} seq_summary['percent_H-sspro'] = r.seq.count('H')/float(len(r)) seq_summary['percent_E-sspro'] = r.seq.count('E')/float(len(r)) seq_summary['percent_C-sspro'] = r.seq.count('C')/float(len(r)) summary[r.id] = seq_summary return summary <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 14802, 279, 18679, 782, 2612, 1052, 323, 471, 264, 12399, 315, 14580, 6070, 18528, 382, 286, 578, 2612, 1052, 374, 1120, 264, 51833, 32, 24001, 1052, 11, 779, 499, 649, 636, 49232, 2237, 198, 310, 2038, 555, 23115, 433, 1093, 264, 4725, 8668, 1052, 382, 286, 5295, 512, 310, 6587, 25, 64341, 315, 512, 394, 473, 25, 11591, 953, 198, 394, 469, 25, 42589, 198, 394, 356, 25, 279, 2800, 271, 14711, 6075, 512, 755, 11107, 782, 28350, 1214, 997, 286, 4304, 14802, 279, 18679, 782, 2612, 1052, 323, 471, 264, 12399, 315, 14580, 6070, 18528, 382, 286, 578, 2612, 1052, 374, 1120, 264, 51833, 32, 24001, 1052, 11, 779, 499, 649, 636, 49232, 2237, 198, 310, 2038, 555, 23115, 433, 1093, 264, 4725, 8668, 1052, 382, 286, 5295, 512, 310, 6587, 25, 64341, 315, 512, 394, 473, 25, 11591, 953, 198, 394, 469, 25, 42589, 198, 394, 356, 25, 279, 2800, 271, 286, 3270, 286, 12399, 284, 10294, 286, 7576, 284, 11107, 38423, 2776, 39340, 47386, 8576, 100150, 5214, 766, 14635, 2517, 1214, 2594, 42948, 782, 340, 286, 369, 436, 304, 7576, 512, 310, 13278, 28350, 284, 5731, 310, 13278, 28350, 681, 25426, 2083, 12, 784, 782, 663, 284, 436, 44967, 6637, 493, 39, 873, 14, 3733, 7046, 2666, 1192, 310, 13278, 28350, 681, 25426, 2135, 12, 784, 782, 663, 284, 436, 44967, 6637, 493, 36, 873, 14, 3733, 7046, 2666, 1192, 310, 13278, 28350, 681, 25426, 932, 12, 784, 782, 663, 284, 436, 44967, 6637, 493, 34, 873, 14, 3733, 7046, 2666, 4489, 310, 12399, 16523, 1801, 60, 284, 13278, 28350, 271, 286, 471, 12399, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 14802, 279, 18679, 782, 2612, 1052, 323, 471, 264, 12399, 315, 14580, 6070, 18528, 382, 286, 578, 2612, 1052, 374, 1120, 264, 51833, 32, 24001, 1052, 11, 779, 499, 649, 636, 49232, 2237, 198, 310, 2038, 555, 23115, 433, 1093, 264, 4725, 8668, 1052, 382, 286, 5295, 512, 310, 6587, 25, 64341, 315, 512, 394, 473, 25, 11591, 953, 198, 394, 469, 25, 42589, 198, 394, 356, 25, 279, 2800, 271, 14711, 6075, 512, 755, 11107, 782, 28350, 1214, 997, 286, 4304, 14802, 279, 18679, 782, 2612, 1052, 323, 471, 264, 12399, 315, 14580, 6070, 18528, 382, 286, 578, 2612, 1052, 374, 1120, 264, 51833, 32, 24001, 1052, 11, 779, 499, 649, 636, 49232, 2237, 198, 310, 2038, 555, 23115, 433, 1093, 264, 4725, 8668, 1052, 382, 286, 5295, 512, 310, 6587, 25, 64341, 315, 512, 394, 473, 25, 11591, 953, 198, 394, 469, 25, 42589, 198, 394, 356, 25, 279, 2800, 271, 286, 3270, 286, 12399, 284, 10294, 286, 7576, 284, 11107, 38423, 2776, 39340, 47386, 8576, 100150, 5214, 766, 14635, 2517, 1214, 2594, 42948, 782, 340, 286, 369, 436, 304, 7576, 512, 310, 13278, 28350, 284, 5731, 310, 13278, 28350, 681, 25426, 2083, 12, 784, 782, 663, 284, 436, 44967, 6637, 493, 39, 873, 14, 3733, 7046, 2666, 1192, 310, 13278, 28350, 681, 25426, 2135, 12, 784, 782, 663, 284, 436, 44967, 6637, 493, 36, 873, 14, 3733, 7046, 2666, 1192, 310, 13278, 28350, 681, 25426, 932, 12, 784, 782, 663, 284, 436, 44967, 6637, 493, 34, 873, 14, 3733, 7046, 2666, 4489, 310, 12399, 16523, 1801, 60, 284, 13278, 28350, 271, 286, 471, 12399, 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 ]
trezor/python-trezor
trezorlib/cosi.py
sign_with_privkey
def sign_with_privkey( digest: bytes, privkey: Ed25519PrivateKey, global_pubkey: Ed25519PublicPoint, nonce: int, global_commit: Ed25519PublicPoint, ) -> Ed25519Signature: """Create a CoSi signature of `digest` with the supplied private key. This function needs to know the global public key and global commitment. """ h = _ed25519.H(privkey) a = _ed25519.decodecoord(h) S = (nonce + _ed25519.Hint(global_commit + global_pubkey + digest) * a) % _ed25519.l return Ed25519Signature(_ed25519.encodeint(S))
python
def sign_with_privkey( digest: bytes, privkey: Ed25519PrivateKey, global_pubkey: Ed25519PublicPoint, nonce: int, global_commit: Ed25519PublicPoint, ) -> Ed25519Signature: """Create a CoSi signature of `digest` with the supplied private key. This function needs to know the global public key and global commitment. """ h = _ed25519.H(privkey) a = _ed25519.decodecoord(h) S = (nonce + _ed25519.Hint(global_commit + global_pubkey + digest) * a) % _ed25519.l return Ed25519Signature(_ed25519.encodeint(S))
[ "def", "sign_with_privkey", "(", "digest", ":", "bytes", ",", "privkey", ":", "Ed25519PrivateKey", ",", "global_pubkey", ":", "Ed25519PublicPoint", ",", "nonce", ":", "int", ",", "global_commit", ":", "Ed25519PublicPoint", ",", ")", "->", "Ed25519Signature", ":", "h", "=", "_ed25519", ".", "H", "(", "privkey", ")", "a", "=", "_ed25519", ".", "decodecoord", "(", "h", ")", "S", "=", "(", "nonce", "+", "_ed25519", ".", "Hint", "(", "global_commit", "+", "global_pubkey", "+", "digest", ")", "*", "a", ")", "%", "_ed25519", ".", "l", "return", "Ed25519Signature", "(", "_ed25519", ".", "encodeint", "(", "S", ")", ")" ]
Create a CoSi signature of `digest` with the supplied private key. This function needs to know the global public key and global commitment.
[ "Create", "a", "CoSi", "signature", "of", "digest", "with", "the", "supplied", "private", "key", ".", "This", "function", "needs", "to", "know", "the", "global", "public", "key", "and", "global", "commitment", "." ]
train
https://github.com/trezor/python-trezor/blob/2813522b05cef4e0e545a101f8b3559a3183b45b/trezorlib/cosi.py#L104-L118
<|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 CoSi signature of `digest` with the supplied private key. This function needs to know the global public key and global commitment. ### Response: def sign_with_privkey( digest: bytes, privkey: Ed25519PrivateKey, global_pubkey: Ed25519PublicPoint, nonce: int, global_commit: Ed25519PublicPoint, ) -> Ed25519Signature: """Create a CoSi signature of `digest` with the supplied private key. This function needs to know the global public key and global commitment. """ h = _ed25519.H(privkey) a = _ed25519.decodecoord(h) S = (nonce + _ed25519.Hint(global_commit + global_pubkey + digest) * a) % _ed25519.l return Ed25519Signature(_ed25519.encodeint(S)) <|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, 3623, 22771, 12223, 315, 1595, 37439, 63, 449, 279, 17665, 879, 1401, 627, 262, 1115, 734, 3966, 311, 1440, 279, 3728, 586, 1401, 323, 3728, 15507, 382, 14711, 6075, 512, 755, 1879, 6753, 25757, 798, 1021, 262, 21552, 25, 5943, 345, 262, 6223, 798, 25, 3279, 3192, 777, 77081, 345, 262, 3728, 35114, 798, 25, 3279, 3192, 777, 12965, 2674, 345, 262, 40776, 25, 528, 345, 262, 3728, 37446, 25, 3279, 3192, 777, 12965, 2674, 345, 8, 1492, 3279, 3192, 777, 26144, 512, 262, 4304, 4110, 264, 3623, 22771, 12223, 315, 1595, 37439, 63, 449, 279, 17665, 879, 1401, 627, 262, 1115, 734, 3966, 311, 1440, 279, 3728, 586, 1401, 323, 3728, 15507, 627, 262, 3270, 262, 305, 284, 721, 291, 3192, 777, 3924, 52850, 798, 340, 262, 264, 284, 721, 291, 3192, 777, 16301, 27500, 3283, 696, 262, 328, 284, 320, 40693, 489, 721, 291, 3192, 777, 3924, 396, 33051, 37446, 489, 3728, 35114, 798, 489, 21552, 8, 353, 264, 8, 1034, 721, 291, 3192, 777, 929, 198, 262, 471, 3279, 3192, 777, 26144, 2551, 291, 3192, 777, 17762, 396, 3844, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 3623, 22771, 12223, 315, 1595, 37439, 63, 449, 279, 17665, 879, 1401, 627, 262, 1115, 734, 3966, 311, 1440, 279, 3728, 586, 1401, 323, 3728, 15507, 382, 14711, 6075, 512, 755, 1879, 6753, 25757, 798, 1021, 262, 21552, 25, 5943, 345, 262, 6223, 798, 25, 3279, 3192, 777, 77081, 345, 262, 3728, 35114, 798, 25, 3279, 3192, 777, 12965, 2674, 345, 262, 40776, 25, 528, 345, 262, 3728, 37446, 25, 3279, 3192, 777, 12965, 2674, 345, 8, 1492, 3279, 3192, 777, 26144, 512, 262, 4304, 4110, 264, 3623, 22771, 12223, 315, 1595, 37439, 63, 449, 279, 17665, 879, 1401, 627, 262, 1115, 734, 3966, 311, 1440, 279, 3728, 586, 1401, 323, 3728, 15507, 627, 262, 3270, 262, 305, 284, 721, 291, 3192, 777, 3924, 52850, 798, 340, 262, 264, 284, 721, 291, 3192, 777, 16301, 27500, 3283, 696, 262, 328, 284, 320, 40693, 489, 721, 291, 3192, 777, 3924, 396, 33051, 37446, 489, 3728, 35114, 798, 489, 21552, 8, 353, 264, 8, 1034, 721, 291, 3192, 777, 929, 198, 262, 471, 3279, 3192, 777, 26144, 2551, 291, 3192, 777, 17762, 396, 3844, 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 ]
botswana-harvard/edc-registration
edc_registration/signals.py
update_registered_subject_from_model_on_post_save
def update_registered_subject_from_model_on_post_save(sender, instance, raw, created, using, **kwargs): """Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin.""" if not raw and not kwargs.get('update_fields'): try: instance.registration_update_or_create() except AttributeError as e: if 'registration_update_or_create' not in str(e): raise AttributeError(str(e))
python
def update_registered_subject_from_model_on_post_save(sender, instance, raw, created, using, **kwargs): """Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin.""" if not raw and not kwargs.get('update_fields'): try: instance.registration_update_or_create() except AttributeError as e: if 'registration_update_or_create' not in str(e): raise AttributeError(str(e))
[ "def", "update_registered_subject_from_model_on_post_save", "(", "sender", ",", "instance", ",", "raw", ",", "created", ",", "using", ",", "*", "*", "kwargs", ")", ":", "if", "not", "raw", "and", "not", "kwargs", ".", "get", "(", "'update_fields'", ")", ":", "try", ":", "instance", ".", "registration_update_or_create", "(", ")", "except", "AttributeError", "as", "e", ":", "if", "'registration_update_or_create'", "not", "in", "str", "(", "e", ")", ":", "raise", "AttributeError", "(", "str", "(", "e", ")", ")" ]
Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin.
[ "Updates", "RegisteredSubject", "from", "models", "using", "UpdatesOrCreatesRegistrationModelMixin", "." ]
train
https://github.com/botswana-harvard/edc-registration/blob/3daca624a496945fd4536488f6f80790bbecc081/edc_registration/signals.py#L7-L14
<|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: Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin. ### Response: def update_registered_subject_from_model_on_post_save(sender, instance, raw, created, using, **kwargs): """Updates RegisteredSubject from models using UpdatesOrCreatesRegistrationModelMixin.""" if not raw and not kwargs.get('update_fields'): try: instance.registration_update_or_create() except AttributeError as e: if 'registration_update_or_create' not in str(e): raise AttributeError(str(e)) <|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, 38191, 36639, 13317, 505, 4211, 1701, 28600, 2244, 55968, 24253, 1747, 39556, 382, 14711, 6075, 512, 755, 2713, 73783, 29934, 5791, 5156, 4570, 6467, 15737, 19939, 11, 2937, 11, 7257, 11, 3549, 11, 1701, 11, 3146, 9872, 997, 262, 4304, 38191, 36639, 13317, 505, 4211, 1701, 28600, 2244, 55968, 24253, 1747, 39556, 14781, 262, 422, 539, 7257, 323, 539, 16901, 673, 493, 2443, 12406, 11290, 286, 1456, 512, 310, 2937, 74936, 9058, 8908, 8827, 746, 286, 3734, 54731, 439, 384, 512, 310, 422, 364, 26947, 9058, 8908, 8827, 6, 539, 304, 610, 2069, 997, 394, 4933, 54731, 4293, 2069, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0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264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 38191, 36639, 13317, 505, 4211, 1701, 28600, 2244, 55968, 24253, 1747, 39556, 382, 14711, 6075, 512, 755, 2713, 73783, 29934, 5791, 5156, 4570, 6467, 15737, 19939, 11, 2937, 11, 7257, 11, 3549, 11, 1701, 11, 3146, 9872, 997, 262, 4304, 38191, 36639, 13317, 505, 4211, 1701, 28600, 2244, 55968, 24253, 1747, 39556, 14781, 262, 422, 539, 7257, 323, 539, 16901, 673, 493, 2443, 12406, 11290, 286, 1456, 512, 310, 2937, 74936, 9058, 8908, 8827, 746, 286, 3734, 54731, 439, 384, 512, 310, 422, 364, 26947, 9058, 8908, 8827, 6, 539, 304, 610, 2069, 997, 394, 4933, 54731, 4293, 2069, 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 ]
sigsep/sigsep-mus-eval
museval/metrics.py
_zeropad
def _zeropad(sig, N, axis=0): """pads with N zeros at the end of the signal, along given axis""" # ensures concatenation dimension is the first sig = np.moveaxis(sig, axis, 0) # zero pad out = np.zeros((sig.shape[0] + N,) + sig.shape[1:]) out[:sig.shape[0], ...] = sig # put back axis in place out = np.moveaxis(out, 0, axis) return out
python
def _zeropad(sig, N, axis=0): """pads with N zeros at the end of the signal, along given axis""" # ensures concatenation dimension is the first sig = np.moveaxis(sig, axis, 0) # zero pad out = np.zeros((sig.shape[0] + N,) + sig.shape[1:]) out[:sig.shape[0], ...] = sig # put back axis in place out = np.moveaxis(out, 0, axis) return out
[ "def", "_zeropad", "(", "sig", ",", "N", ",", "axis", "=", "0", ")", ":", "# ensures concatenation dimension is the first", "sig", "=", "np", ".", "moveaxis", "(", "sig", ",", "axis", ",", "0", ")", "# zero pad", "out", "=", "np", ".", "zeros", "(", "(", "sig", ".", "shape", "[", "0", "]", "+", "N", ",", ")", "+", "sig", ".", "shape", "[", "1", ":", "]", ")", "out", "[", ":", "sig", ".", "shape", "[", "0", "]", ",", "...", "]", "=", "sig", "# put back axis in place", "out", "=", "np", ".", "moveaxis", "(", "out", ",", "0", ",", "axis", ")", "return", "out" ]
pads with N zeros at the end of the signal, along given axis
[ "pads", "with", "N", "zeros", "at", "the", "end", "of", "the", "signal", "along", "given", "axis" ]
train
https://github.com/sigsep/sigsep-mus-eval/blob/a7c9af3647f0c0bb9bbaeccec0b1a6a9e09d1e2d/museval/metrics.py#L488-L497
<|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: pads with N zeros at the end of the signal, along given axis ### Response: def _zeropad(sig, N, axis=0): """pads with N zeros at the end of the signal, along given axis""" # ensures concatenation dimension is the first sig = np.moveaxis(sig, axis, 0) # zero pad out = np.zeros((sig.shape[0] + N,) + sig.shape[1:]) out[:sig.shape[0], ...] = sig # put back axis in place out = np.moveaxis(out, 0, axis) 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, 79, 7819, 449, 452, 17975, 520, 279, 842, 315, 279, 8450, 11, 3235, 2728, 8183, 271, 14711, 6075, 512, 755, 721, 7215, 454, 329, 50229, 11, 452, 11, 8183, 28, 15, 997, 262, 4304, 79, 7819, 449, 452, 17975, 520, 279, 842, 315, 279, 8450, 11, 3235, 2728, 8183, 7275, 262, 674, 26420, 41072, 367, 13167, 374, 279, 1176, 198, 262, 8531, 284, 2660, 13949, 7332, 50229, 11, 8183, 11, 220, 15, 340, 262, 674, 7315, 11262, 198, 262, 704, 284, 2660, 13064, 1209, 22046, 7201, 58, 15, 60, 489, 452, 47121, 489, 8531, 7201, 58, 16, 44157, 262, 704, 3530, 22046, 7201, 58, 15, 1145, 2564, 60, 284, 8531, 198, 262, 674, 2231, 1203, 8183, 304, 2035, 198, 262, 704, 284, 2660, 13949, 7332, 10029, 11, 220, 15, 11, 8183, 340, 262, 471, 704, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 79, 7819, 449, 452, 17975, 520, 279, 842, 315, 279, 8450, 11, 3235, 2728, 8183, 271, 14711, 6075, 512, 755, 721, 7215, 454, 329, 50229, 11, 452, 11, 8183, 28, 15, 997, 262, 4304, 79, 7819, 449, 452, 17975, 520, 279, 842, 315, 279, 8450, 11, 3235, 2728, 8183, 7275, 262, 674, 26420, 41072, 367, 13167, 374, 279, 1176, 198, 262, 8531, 284, 2660, 13949, 7332, 50229, 11, 8183, 11, 220, 15, 340, 262, 674, 7315, 11262, 198, 262, 704, 284, 2660, 13064, 1209, 22046, 7201, 58, 15, 60, 489, 452, 47121, 489, 8531, 7201, 58, 16, 44157, 262, 704, 3530, 22046, 7201, 58, 15, 1145, 2564, 60, 284, 8531, 198, 262, 674, 2231, 1203, 8183, 304, 2035, 198, 262, 704, 284, 2660, 13949, 7332, 10029, 11, 220, 15, 11, 8183, 340, 262, 471, 704, 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 ]
JasonKessler/scattertext
scattertext/TermDocMatrixFactory.py
TermDocMatrixFactory.censor_entity_types
def censor_entity_types(self, entity_types): # type: (set) -> TermDocMatrixFactory ''' Entity types to exclude from feature construction. Terms matching specificed entities, instead of labeled by their lower case orthographic form or lemma, will be labeled by their entity type. Parameters ---------- entity_types : set of entity types outputted by spaCy 'TIME', 'WORK_OF_ART', 'PERSON', 'MONEY', 'ORG', 'ORDINAL', 'DATE', 'CARDINAL', 'LAW', 'QUANTITY', 'GPE', 'PERCENT' Returns --------- self ''' assert type(entity_types) == set self._entity_types_to_censor = entity_types self._feats_from_spacy_doc = FeatsFromSpacyDoc( use_lemmas=self._use_lemmas, entity_types_to_censor=self._entity_types_to_censor ) return self
python
def censor_entity_types(self, entity_types): # type: (set) -> TermDocMatrixFactory ''' Entity types to exclude from feature construction. Terms matching specificed entities, instead of labeled by their lower case orthographic form or lemma, will be labeled by their entity type. Parameters ---------- entity_types : set of entity types outputted by spaCy 'TIME', 'WORK_OF_ART', 'PERSON', 'MONEY', 'ORG', 'ORDINAL', 'DATE', 'CARDINAL', 'LAW', 'QUANTITY', 'GPE', 'PERCENT' Returns --------- self ''' assert type(entity_types) == set self._entity_types_to_censor = entity_types self._feats_from_spacy_doc = FeatsFromSpacyDoc( use_lemmas=self._use_lemmas, entity_types_to_censor=self._entity_types_to_censor ) return self
[ "def", "censor_entity_types", "(", "self", ",", "entity_types", ")", ":", "# type: (set) -> TermDocMatrixFactory", "assert", "type", "(", "entity_types", ")", "==", "set", "self", ".", "_entity_types_to_censor", "=", "entity_types", "self", ".", "_feats_from_spacy_doc", "=", "FeatsFromSpacyDoc", "(", "use_lemmas", "=", "self", ".", "_use_lemmas", ",", "entity_types_to_censor", "=", "self", ".", "_entity_types_to_censor", ")", "return", "self" ]
Entity types to exclude from feature construction. Terms matching specificed entities, instead of labeled by their lower case orthographic form or lemma, will be labeled by their entity type. Parameters ---------- entity_types : set of entity types outputted by spaCy 'TIME', 'WORK_OF_ART', 'PERSON', 'MONEY', 'ORG', 'ORDINAL', 'DATE', 'CARDINAL', 'LAW', 'QUANTITY', 'GPE', 'PERCENT' Returns --------- self
[ "Entity", "types", "to", "exclude", "from", "feature", "construction", ".", "Terms", "matching", "specificed", "entities", "instead", "of", "labeled", "by", "their", "lower", "case", "orthographic", "form", "or", "lemma", "will", "be", "labeled", "by", "their", "entity", "type", "." ]
train
https://github.com/JasonKessler/scattertext/blob/cacf1f687d218ee8cae3fc05cc901db824bb1b81/scattertext/TermDocMatrixFactory.py#L149-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: Entity types to exclude from feature construction. Terms matching specificed entities, instead of labeled by their lower case orthographic form or lemma, will be labeled by their entity type. Parameters ---------- entity_types : set of entity types outputted by spaCy 'TIME', 'WORK_OF_ART', 'PERSON', 'MONEY', 'ORG', 'ORDINAL', 'DATE', 'CARDINAL', 'LAW', 'QUANTITY', 'GPE', 'PERCENT' Returns --------- self ### Response: def censor_entity_types(self, entity_types): # type: (set) -> TermDocMatrixFactory ''' Entity types to exclude from feature construction. Terms matching specificed entities, instead of labeled by their lower case orthographic form or lemma, will be labeled by their entity type. Parameters ---------- entity_types : set of entity types outputted by spaCy 'TIME', 'WORK_OF_ART', 'PERSON', 'MONEY', 'ORG', 'ORDINAL', 'DATE', 'CARDINAL', 'LAW', 'QUANTITY', 'GPE', 'PERCENT' Returns --------- self ''' assert type(entity_types) == set self._entity_types_to_censor = entity_types self._feats_from_spacy_doc = FeatsFromSpacyDoc( use_lemmas=self._use_lemmas, entity_types_to_censor=self._entity_types_to_censor ) 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, 3106, 4595, 311, 22429, 505, 4668, 8246, 13, 20163, 12864, 198, 286, 3230, 291, 15086, 11, 4619, 315, 30929, 555, 872, 4827, 1162, 30299, 12968, 198, 286, 1376, 477, 19340, 11, 690, 387, 30929, 555, 872, 5502, 955, 382, 286, 13831, 198, 286, 31423, 286, 5502, 9962, 551, 743, 315, 5502, 4595, 2612, 6702, 555, 31493, 57815, 198, 692, 364, 18621, 518, 364, 18977, 14568, 60256, 518, 364, 94283, 518, 364, 44, 55753, 518, 364, 46027, 518, 364, 4373, 30546, 518, 364, 7242, 756, 692, 364, 60319, 30546, 518, 364, 43, 14757, 518, 364, 5876, 74392, 518, 364, 38, 1777, 518, 364, 9851, 37438, 3961, 286, 5295, 198, 286, 220, 29547, 286, 659, 271, 14711, 6075, 512, 755, 40065, 19719, 9962, 1214, 11, 5502, 9962, 997, 286, 674, 955, 25, 320, 751, 8, 1492, 17978, 9743, 6828, 4246, 198, 286, 11414, 286, 10606, 4595, 311, 22429, 505, 4668, 8246, 13, 20163, 12864, 198, 286, 3230, 291, 15086, 11, 4619, 315, 30929, 555, 872, 4827, 1162, 30299, 12968, 198, 286, 1376, 477, 19340, 11, 690, 387, 30929, 555, 872, 5502, 955, 382, 286, 13831, 198, 286, 31423, 286, 5502, 9962, 551, 743, 315, 5502, 4595, 2612, 6702, 555, 31493, 57815, 198, 692, 364, 18621, 518, 364, 18977, 14568, 60256, 518, 364, 94283, 518, 364, 44, 55753, 518, 364, 46027, 518, 364, 4373, 30546, 518, 364, 7242, 756, 692, 364, 60319, 30546, 518, 364, 43, 14757, 518, 364, 5876, 74392, 518, 364, 38, 1777, 518, 364, 9851, 37438, 3961, 286, 5295, 198, 286, 220, 29547, 286, 659, 198, 286, 11414, 286, 2105, 955, 17803, 9962, 8, 624, 743, 198, 286, 659, 1462, 3069, 9962, 2401, 669, 3890, 284, 5502, 9962, 198, 286, 659, 1462, 1897, 1900, 5791, 10331, 2826, 19401, 284, 3926, 1900, 3915, 6540, 2826, 9743, 1021, 310, 1005, 62, 3516, 7044, 7822, 1462, 817, 62, 3516, 7044, 345, 310, 5502, 9962, 2401, 669, 3890, 7822, 1462, 3069, 9962, 2401, 669, 3890, 198, 286, 1763, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,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0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 3106, 4595, 311, 22429, 505, 4668, 8246, 13, 20163, 12864, 198, 286, 3230, 291, 15086, 11, 4619, 315, 30929, 555, 872, 4827, 1162, 30299, 12968, 198, 286, 1376, 477, 19340, 11, 690, 387, 30929, 555, 872, 5502, 955, 382, 286, 13831, 198, 286, 31423, 286, 5502, 9962, 551, 743, 315, 5502, 4595, 2612, 6702, 555, 31493, 57815, 198, 692, 364, 18621, 518, 364, 18977, 14568, 60256, 518, 364, 94283, 518, 364, 44, 55753, 518, 364, 46027, 518, 364, 4373, 30546, 518, 364, 7242, 756, 692, 364, 60319, 30546, 518, 364, 43, 14757, 518, 364, 5876, 74392, 518, 364, 38, 1777, 518, 364, 9851, 37438, 3961, 286, 5295, 198, 286, 220, 29547, 286, 659, 271, 14711, 6075, 512, 755, 40065, 19719, 9962, 1214, 11, 5502, 9962, 997, 286, 674, 955, 25, 320, 751, 8, 1492, 17978, 9743, 6828, 4246, 198, 286, 11414, 286, 10606, 4595, 311, 22429, 505, 4668, 8246, 13, 20163, 12864, 198, 286, 3230, 291, 15086, 11, 4619, 315, 30929, 555, 872, 4827, 1162, 30299, 12968, 198, 286, 1376, 477, 19340, 11, 690, 387, 30929, 555, 872, 5502, 955, 382, 286, 13831, 198, 286, 31423, 286, 5502, 9962, 551, 743, 315, 5502, 4595, 2612, 6702, 555, 31493, 57815, 198, 692, 364, 18621, 518, 364, 18977, 14568, 60256, 518, 364, 94283, 518, 364, 44, 55753, 518, 364, 46027, 518, 364, 4373, 30546, 518, 364, 7242, 756, 692, 364, 60319, 30546, 518, 364, 43, 14757, 518, 364, 5876, 74392, 518, 364, 38, 1777, 518, 364, 9851, 37438, 3961, 286, 5295, 198, 286, 220, 29547, 286, 659, 198, 286, 11414, 286, 2105, 955, 17803, 9962, 8, 624, 743, 198, 286, 659, 1462, 3069, 9962, 2401, 669, 3890, 284, 5502, 9962, 198, 286, 659, 1462, 1897, 1900, 5791, 10331, 2826, 19401, 284, 3926, 1900, 3915, 6540, 2826, 9743, 1021, 310, 1005, 62, 3516, 7044, 7822, 1462, 817, 62, 3516, 7044, 345, 310, 5502, 9962, 2401, 669, 3890, 7822, 1462, 3069, 9962, 2401, 669, 3890, 198, 286, 1763, 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 ]
erikrose/more-itertools
more_itertools/more.py
map_reduce
def map_reduce(iterable, keyfunc, valuefunc=None, reducefunc=None): """Return a dictionary that maps the items in *iterable* to categories defined by *keyfunc*, transforms them with *valuefunc*, and then summarizes them by category with *reducefunc*. *valuefunc* defaults to the identity function if it is unspecified. If *reducefunc* is unspecified, no summarization takes place: >>> keyfunc = lambda x: x.upper() >>> result = map_reduce('abbccc', keyfunc) >>> sorted(result.items()) [('A', ['a']), ('B', ['b', 'b']), ('C', ['c', 'c', 'c'])] Specifying *valuefunc* transforms the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> result = map_reduce('abbccc', keyfunc, valuefunc) >>> sorted(result.items()) [('A', [1]), ('B', [1, 1]), ('C', [1, 1, 1])] Specifying *reducefunc* summarizes the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> reducefunc = sum >>> result = map_reduce('abbccc', keyfunc, valuefunc, reducefunc) >>> sorted(result.items()) [('A', 1), ('B', 2), ('C', 3)] You may want to filter the input iterable before applying the map/reduce procedure: >>> all_items = range(30) >>> items = [x for x in all_items if 10 <= x <= 20] # Filter >>> keyfunc = lambda x: x % 2 # Evens map to 0; odds to 1 >>> categories = map_reduce(items, keyfunc=keyfunc) >>> sorted(categories.items()) [(0, [10, 12, 14, 16, 18, 20]), (1, [11, 13, 15, 17, 19])] >>> summaries = map_reduce(items, keyfunc=keyfunc, reducefunc=sum) >>> sorted(summaries.items()) [(0, 90), (1, 75)] Note that all items in the iterable are gathered into a list before the summarization step, which may require significant storage. The returned object is a :obj:`collections.defaultdict` with the ``default_factory`` set to ``None``, such that it behaves like a normal dictionary. """ valuefunc = (lambda x: x) if (valuefunc is None) else valuefunc ret = defaultdict(list) for item in iterable: key = keyfunc(item) value = valuefunc(item) ret[key].append(value) if reducefunc is not None: for key, value_list in ret.items(): ret[key] = reducefunc(value_list) ret.default_factory = None return ret
python
def map_reduce(iterable, keyfunc, valuefunc=None, reducefunc=None): """Return a dictionary that maps the items in *iterable* to categories defined by *keyfunc*, transforms them with *valuefunc*, and then summarizes them by category with *reducefunc*. *valuefunc* defaults to the identity function if it is unspecified. If *reducefunc* is unspecified, no summarization takes place: >>> keyfunc = lambda x: x.upper() >>> result = map_reduce('abbccc', keyfunc) >>> sorted(result.items()) [('A', ['a']), ('B', ['b', 'b']), ('C', ['c', 'c', 'c'])] Specifying *valuefunc* transforms the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> result = map_reduce('abbccc', keyfunc, valuefunc) >>> sorted(result.items()) [('A', [1]), ('B', [1, 1]), ('C', [1, 1, 1])] Specifying *reducefunc* summarizes the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> reducefunc = sum >>> result = map_reduce('abbccc', keyfunc, valuefunc, reducefunc) >>> sorted(result.items()) [('A', 1), ('B', 2), ('C', 3)] You may want to filter the input iterable before applying the map/reduce procedure: >>> all_items = range(30) >>> items = [x for x in all_items if 10 <= x <= 20] # Filter >>> keyfunc = lambda x: x % 2 # Evens map to 0; odds to 1 >>> categories = map_reduce(items, keyfunc=keyfunc) >>> sorted(categories.items()) [(0, [10, 12, 14, 16, 18, 20]), (1, [11, 13, 15, 17, 19])] >>> summaries = map_reduce(items, keyfunc=keyfunc, reducefunc=sum) >>> sorted(summaries.items()) [(0, 90), (1, 75)] Note that all items in the iterable are gathered into a list before the summarization step, which may require significant storage. The returned object is a :obj:`collections.defaultdict` with the ``default_factory`` set to ``None``, such that it behaves like a normal dictionary. """ valuefunc = (lambda x: x) if (valuefunc is None) else valuefunc ret = defaultdict(list) for item in iterable: key = keyfunc(item) value = valuefunc(item) ret[key].append(value) if reducefunc is not None: for key, value_list in ret.items(): ret[key] = reducefunc(value_list) ret.default_factory = None return ret
[ "def", "map_reduce", "(", "iterable", ",", "keyfunc", ",", "valuefunc", "=", "None", ",", "reducefunc", "=", "None", ")", ":", "valuefunc", "=", "(", "lambda", "x", ":", "x", ")", "if", "(", "valuefunc", "is", "None", ")", "else", "valuefunc", "ret", "=", "defaultdict", "(", "list", ")", "for", "item", "in", "iterable", ":", "key", "=", "keyfunc", "(", "item", ")", "value", "=", "valuefunc", "(", "item", ")", "ret", "[", "key", "]", ".", "append", "(", "value", ")", "if", "reducefunc", "is", "not", "None", ":", "for", "key", ",", "value_list", "in", "ret", ".", "items", "(", ")", ":", "ret", "[", "key", "]", "=", "reducefunc", "(", "value_list", ")", "ret", ".", "default_factory", "=", "None", "return", "ret" ]
Return a dictionary that maps the items in *iterable* to categories defined by *keyfunc*, transforms them with *valuefunc*, and then summarizes them by category with *reducefunc*. *valuefunc* defaults to the identity function if it is unspecified. If *reducefunc* is unspecified, no summarization takes place: >>> keyfunc = lambda x: x.upper() >>> result = map_reduce('abbccc', keyfunc) >>> sorted(result.items()) [('A', ['a']), ('B', ['b', 'b']), ('C', ['c', 'c', 'c'])] Specifying *valuefunc* transforms the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> result = map_reduce('abbccc', keyfunc, valuefunc) >>> sorted(result.items()) [('A', [1]), ('B', [1, 1]), ('C', [1, 1, 1])] Specifying *reducefunc* summarizes the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> reducefunc = sum >>> result = map_reduce('abbccc', keyfunc, valuefunc, reducefunc) >>> sorted(result.items()) [('A', 1), ('B', 2), ('C', 3)] You may want to filter the input iterable before applying the map/reduce procedure: >>> all_items = range(30) >>> items = [x for x in all_items if 10 <= x <= 20] # Filter >>> keyfunc = lambda x: x % 2 # Evens map to 0; odds to 1 >>> categories = map_reduce(items, keyfunc=keyfunc) >>> sorted(categories.items()) [(0, [10, 12, 14, 16, 18, 20]), (1, [11, 13, 15, 17, 19])] >>> summaries = map_reduce(items, keyfunc=keyfunc, reducefunc=sum) >>> sorted(summaries.items()) [(0, 90), (1, 75)] Note that all items in the iterable are gathered into a list before the summarization step, which may require significant storage. The returned object is a :obj:`collections.defaultdict` with the ``default_factory`` set to ``None``, such that it behaves like a normal dictionary.
[ "Return", "a", "dictionary", "that", "maps", "the", "items", "in", "*", "iterable", "*", "to", "categories", "defined", "by", "*", "keyfunc", "*", "transforms", "them", "with", "*", "valuefunc", "*", "and", "then", "summarizes", "them", "by", "category", "with", "*", "reducefunc", "*", "." ]
train
https://github.com/erikrose/more-itertools/blob/6a91b4e25c8e12fcf9fc2b53cf8ee0fba293e6f9/more_itertools/more.py#L2190-L2254
<|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 dictionary that maps the items in *iterable* to categories defined by *keyfunc*, transforms them with *valuefunc*, and then summarizes them by category with *reducefunc*. *valuefunc* defaults to the identity function if it is unspecified. If *reducefunc* is unspecified, no summarization takes place: >>> keyfunc = lambda x: x.upper() >>> result = map_reduce('abbccc', keyfunc) >>> sorted(result.items()) [('A', ['a']), ('B', ['b', 'b']), ('C', ['c', 'c', 'c'])] Specifying *valuefunc* transforms the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> result = map_reduce('abbccc', keyfunc, valuefunc) >>> sorted(result.items()) [('A', [1]), ('B', [1, 1]), ('C', [1, 1, 1])] Specifying *reducefunc* summarizes the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> reducefunc = sum >>> result = map_reduce('abbccc', keyfunc, valuefunc, reducefunc) >>> sorted(result.items()) [('A', 1), ('B', 2), ('C', 3)] You may want to filter the input iterable before applying the map/reduce procedure: >>> all_items = range(30) >>> items = [x for x in all_items if 10 <= x <= 20] # Filter >>> keyfunc = lambda x: x % 2 # Evens map to 0; odds to 1 >>> categories = map_reduce(items, keyfunc=keyfunc) >>> sorted(categories.items()) [(0, [10, 12, 14, 16, 18, 20]), (1, [11, 13, 15, 17, 19])] >>> summaries = map_reduce(items, keyfunc=keyfunc, reducefunc=sum) >>> sorted(summaries.items()) [(0, 90), (1, 75)] Note that all items in the iterable are gathered into a list before the summarization step, which may require significant storage. The returned object is a :obj:`collections.defaultdict` with the ``default_factory`` set to ``None``, such that it behaves like a normal dictionary. ### Response: def map_reduce(iterable, keyfunc, valuefunc=None, reducefunc=None): """Return a dictionary that maps the items in *iterable* to categories defined by *keyfunc*, transforms them with *valuefunc*, and then summarizes them by category with *reducefunc*. *valuefunc* defaults to the identity function if it is unspecified. If *reducefunc* is unspecified, no summarization takes place: >>> keyfunc = lambda x: x.upper() >>> result = map_reduce('abbccc', keyfunc) >>> sorted(result.items()) [('A', ['a']), ('B', ['b', 'b']), ('C', ['c', 'c', 'c'])] Specifying *valuefunc* transforms the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> result = map_reduce('abbccc', keyfunc, valuefunc) >>> sorted(result.items()) [('A', [1]), ('B', [1, 1]), ('C', [1, 1, 1])] Specifying *reducefunc* summarizes the categorized items: >>> keyfunc = lambda x: x.upper() >>> valuefunc = lambda x: 1 >>> reducefunc = sum >>> result = map_reduce('abbccc', keyfunc, valuefunc, reducefunc) >>> sorted(result.items()) [('A', 1), ('B', 2), ('C', 3)] You may want to filter the input iterable before applying the map/reduce procedure: >>> all_items = range(30) >>> items = [x for x in all_items if 10 <= x <= 20] # Filter >>> keyfunc = lambda x: x % 2 # Evens map to 0; odds to 1 >>> categories = map_reduce(items, keyfunc=keyfunc) >>> sorted(categories.items()) [(0, [10, 12, 14, 16, 18, 20]), (1, [11, 13, 15, 17, 19])] >>> summaries = map_reduce(items, keyfunc=keyfunc, reducefunc=sum) >>> sorted(summaries.items()) [(0, 90), (1, 75)] Note that all items in the iterable are gathered into a list before the summarization step, which may require significant storage. The returned object is a :obj:`collections.defaultdict` with the ``default_factory`` set to ``None``, such that it behaves like a normal dictionary. """ valuefunc = (lambda x: x) if (valuefunc is None) else valuefunc ret = defaultdict(list) for item in iterable: key = keyfunc(item) value = valuefunc(item) ret[key].append(value) if reducefunc is not None: for key, value_list in ret.items(): ret[key] = reducefunc(value_list) ret.default_factory = None 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, 5715, 264, 11240, 430, 14370, 279, 3673, 304, 353, 2058, 481, 9, 311, 11306, 198, 262, 4613, 555, 353, 798, 2900, 12594, 29575, 1124, 449, 353, 970, 2900, 12594, 323, 198, 262, 1243, 94594, 1124, 555, 5699, 449, 353, 27369, 2900, 9, 382, 262, 353, 970, 2900, 9, 17088, 311, 279, 9764, 734, 422, 433, 374, 55411, 627, 262, 1442, 353, 27369, 2900, 9, 374, 55411, 11, 912, 29385, 2065, 5097, 2035, 1473, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 34764, 746, 286, 12382, 1121, 284, 2472, 65696, 493, 12806, 38154, 518, 1401, 2900, 340, 286, 12382, 10839, 4556, 9812, 2455, 286, 52228, 32, 518, 2570, 64, 33187, 4417, 33, 518, 2570, 65, 518, 364, 65, 33187, 4417, 34, 518, 2570, 66, 518, 364, 66, 518, 364, 66, 5188, 2595, 262, 11197, 7922, 353, 970, 2900, 9, 29575, 279, 71974, 3673, 1473, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 34764, 746, 286, 12382, 907, 2900, 284, 12741, 865, 25, 220, 16, 198, 286, 12382, 1121, 284, 2472, 65696, 493, 12806, 38154, 518, 1401, 2900, 11, 907, 2900, 340, 286, 12382, 10839, 4556, 9812, 2455, 286, 52228, 32, 518, 510, 16, 9918, 4417, 33, 518, 510, 16, 11, 220, 16, 9918, 4417, 34, 518, 510, 16, 11, 220, 16, 11, 220, 16, 2526, 2595, 262, 11197, 7922, 353, 27369, 2900, 9, 94594, 279, 71974, 3673, 1473, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 34764, 746, 286, 12382, 907, 2900, 284, 12741, 865, 25, 220, 16, 198, 286, 12382, 8108, 2900, 284, 2694, 198, 286, 12382, 1121, 284, 2472, 65696, 493, 12806, 38154, 518, 1401, 2900, 11, 907, 2900, 11, 8108, 2900, 340, 286, 12382, 10839, 4556, 9812, 2455, 286, 52228, 32, 518, 220, 16, 705, 4417, 33, 518, 220, 17, 705, 4417, 34, 518, 220, 18, 28871, 262, 1472, 1253, 1390, 311, 4141, 279, 1988, 51934, 1603, 19486, 279, 2472, 10991, 13677, 198, 262, 10537, 1473, 286, 12382, 682, 12408, 284, 2134, 7, 966, 340, 286, 12382, 3673, 284, 510, 87, 369, 865, 304, 682, 12408, 422, 220, 605, 2717, 865, 2717, 220, 508, 60, 220, 674, 12619, 198, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 1034, 220, 17, 220, 674, 10641, 729, 2472, 311, 220, 15, 26, 21448, 311, 220, 16, 198, 286, 12382, 11306, 284, 2472, 65696, 25331, 11, 1401, 2900, 87682, 2900, 340, 286, 12382, 10839, 91021, 9812, 2455, 286, 18305, 15, 11, 510, 605, 11, 220, 717, 11, 220, 975, 11, 220, 845, 11, 220, 972, 11, 220, 508, 9918, 320, 16, 11, 510, 806, 11, 220, 1032, 11, 220, 868, 11, 220, 1114, 11, 220, 777, 76126, 286, 12382, 70022, 284, 2472, 65696, 25331, 11, 1401, 2900, 87682, 2900, 11, 8108, 2900, 69915, 340, 286, 12382, 10839, 20292, 90433, 9812, 2455, 286, 18305, 15, 11, 220, 1954, 705, 320, 16, 11 ]
[ 1, 1, 1, 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, 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, 11240, 430, 14370, 279, 3673, 304, 353, 2058, 481, 9, 311, 11306, 198, 262, 4613, 555, 353, 798, 2900, 12594, 29575, 1124, 449, 353, 970, 2900, 12594, 323, 198, 262, 1243, 94594, 1124, 555, 5699, 449, 353, 27369, 2900, 9, 382, 262, 353, 970, 2900, 9, 17088, 311, 279, 9764, 734, 422, 433, 374, 55411, 627, 262, 1442, 353, 27369, 2900, 9, 374, 55411, 11, 912, 29385, 2065, 5097, 2035, 1473, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 34764, 746, 286, 12382, 1121, 284, 2472, 65696, 493, 12806, 38154, 518, 1401, 2900, 340, 286, 12382, 10839, 4556, 9812, 2455, 286, 52228, 32, 518, 2570, 64, 33187, 4417, 33, 518, 2570, 65, 518, 364, 65, 33187, 4417, 34, 518, 2570, 66, 518, 364, 66, 518, 364, 66, 5188, 2595, 262, 11197, 7922, 353, 970, 2900, 9, 29575, 279, 71974, 3673, 1473, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 34764, 746, 286, 12382, 907, 2900, 284, 12741, 865, 25, 220, 16, 198, 286, 12382, 1121, 284, 2472, 65696, 493, 12806, 38154, 518, 1401, 2900, 11, 907, 2900, 340, 286, 12382, 10839, 4556, 9812, 2455, 286, 52228, 32, 518, 510, 16, 9918, 4417, 33, 518, 510, 16, 11, 220, 16, 9918, 4417, 34, 518, 510, 16, 11, 220, 16, 11, 220, 16, 2526, 2595, 262, 11197, 7922, 353, 27369, 2900, 9, 94594, 279, 71974, 3673, 1473, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 34764, 746, 286, 12382, 907, 2900, 284, 12741, 865, 25, 220, 16, 198, 286, 12382, 8108, 2900, 284, 2694, 198, 286, 12382, 1121, 284, 2472, 65696, 493, 12806, 38154, 518, 1401, 2900, 11, 907, 2900, 11, 8108, 2900, 340, 286, 12382, 10839, 4556, 9812, 2455, 286, 52228, 32, 518, 220, 16, 705, 4417, 33, 518, 220, 17, 705, 4417, 34, 518, 220, 18, 28871, 262, 1472, 1253, 1390, 311, 4141, 279, 1988, 51934, 1603, 19486, 279, 2472, 10991, 13677, 198, 262, 10537, 1473, 286, 12382, 682, 12408, 284, 2134, 7, 966, 340, 286, 12382, 3673, 284, 510, 87, 369, 865, 304, 682, 12408, 422, 220, 605, 2717, 865, 2717, 220, 508, 60, 220, 674, 12619, 198, 286, 12382, 1401, 2900, 284, 12741, 865, 25, 865, 1034, 220, 17, 220, 674, 10641, 729, 2472, 311, 220, 15, 26, 21448, 311, 220, 16, 198, 286, 12382, 11306, 284, 2472, 65696, 25331, 11, 1401, 2900, 87682, 2900, 340, 286, 12382, 10839, 91021, 9812, 2455, 286, 18305, 15, 11, 510, 605, 11, 220, 717, 11, 220, 975, 11, 220, 845, 11, 220, 972, 11, 220, 508, 9918, 320, 16, 11, 510, 806, 11, 220, 1032, 11, 220, 868, 11, 220, 1114, 11, 220, 777, 76126, 286, 12382, 70022, 284, 2472, 65696, 25331, 11, 1401, 2900, 87682, 2900, 11, 8108, 2900, 69915, 340, 286, 12382, 10839, 20292, 90433, 9812, 2455, 286, 18305, 15, 11, 220, 1954, 705, 320, 16, 11 ]
ikegami-yukino/jaconv
jaconv/jaconv.py
normalize
def normalize(text, mode='NFKC', ignore=''): """Convert Half-width (Hankaku) Katakana to Full-width (Zenkaku) Katakana, Full-width (Zenkaku) ASCII and DIGIT to Half-width (Hankaku) ASCII and DIGIT. Additionally, Full-width wave dash (〜) etc. are normalized Parameters ---------- text : str Source string. mode : str Unicode normalization mode. ignore : str Characters to be ignored in converting. Return ------ str Normalized string. Examples -------- >>> print(jaconv.normalize('ティロ・フィナ〜レ', 'NFKC')) ティロ・フィナーレ """ text = text.replace('〜', 'ー').replace('~', 'ー') text = text.replace("’", "'").replace('”', '"').replace('“', '``') text = text.replace('―', '-').replace('‐', '-').replace('˗', '-').replace('֊', '-') text = text.replace('‐', '-').replace('‑', '-').replace('‒', '-').replace('–', '-') text = text.replace('⁃', '-').replace('⁻', '-').replace('₋', '-').replace('−', '-') text = text.replace('﹣', 'ー').replace('-', 'ー').replace('—', 'ー').replace('―', 'ー') text = text.replace('━', 'ー').replace('─', 'ー') return unicodedata.normalize(mode, text)
python
def normalize(text, mode='NFKC', ignore=''): """Convert Half-width (Hankaku) Katakana to Full-width (Zenkaku) Katakana, Full-width (Zenkaku) ASCII and DIGIT to Half-width (Hankaku) ASCII and DIGIT. Additionally, Full-width wave dash (〜) etc. are normalized Parameters ---------- text : str Source string. mode : str Unicode normalization mode. ignore : str Characters to be ignored in converting. Return ------ str Normalized string. Examples -------- >>> print(jaconv.normalize('ティロ・フィナ〜レ', 'NFKC')) ティロ・フィナーレ """ text = text.replace('〜', 'ー').replace('~', 'ー') text = text.replace("’", "'").replace('”', '"').replace('“', '``') text = text.replace('―', '-').replace('‐', '-').replace('˗', '-').replace('֊', '-') text = text.replace('‐', '-').replace('‑', '-').replace('‒', '-').replace('–', '-') text = text.replace('⁃', '-').replace('⁻', '-').replace('₋', '-').replace('−', '-') text = text.replace('﹣', 'ー').replace('-', 'ー').replace('—', 'ー').replace('―', 'ー') text = text.replace('━', 'ー').replace('─', 'ー') return unicodedata.normalize(mode, text)
[ "def", "normalize", "(", "text", ",", "mode", "=", "'NFKC'", ",", "ignore", "=", "''", ")", ":", "text", "=", "text", ".", "replace", "(", "'〜', ", "'", "').re", "p", "l", "ace('~'", ",", " 'ー')", "", "", "", "text", "=", "text", ".", "replace", "(", "\"’\", ", "\"", "\").", "r", "e", "place('", "”", "', '\"", "'", ".re", "p", "l", "ace('“'", ",", " '``'", ")", "", "", "text", "=", "text", ".", "replace", "(", "'―', ", "'", "').", "r", "e", "place('", "‐", "', '-", "'", ".re", "p", "l", "ace('˗'", ",", " '-'", ")", "rep", "l", "a", "ce('֊',", " ", "'-')", "", "", "", "text", "=", "text", ".", "replace", "(", "'‐', ", "'", "').", "r", "e", "place('", "‑", "', '-", "'", ".re", "p", "l", "ace('‒'", ",", " '-')", ".", "epl", "a", "c", "e('–', ", "'", "-')", "", "", "", "text", "=", "text", ".", "replace", "(", "'⁃', ", "'", "').", "r", "e", "place('", "⁻", "', '-", "'", ".re", "p", "l", "ace('₋'", ",", " '-')", ".", "epl", "a", "c", "e('−', ", "'", "-')", "", "", "", "text", "=", "text", ".", "replace", "(", "'﹣', ", "'", "').re", "p", "l", "ace('-'", ",", " 'ー')", ".", "eplac", "e", "(", "'—', 'ー", "'", ").rep", "l", "ce('―", "'", ",", " 'ー')", "", "", "", "", "", "text", "=", "text", ".", "replace", "(", "'━', ", "'", "').re", "p", "l", "ace('─'", ",", " 'ー')", "", "", "", "return", "unicodedata", ".", "normalize", "(", "mode", ",", "text", ")" ]
Convert Half-width (Hankaku) Katakana to Full-width (Zenkaku) Katakana, Full-width (Zenkaku) ASCII and DIGIT to Half-width (Hankaku) ASCII and DIGIT. Additionally, Full-width wave dash (〜) etc. are normalized Parameters ---------- text : str Source string. mode : str Unicode normalization mode. ignore : str Characters to be ignored in converting. Return ------ str Normalized string. Examples -------- >>> print(jaconv.normalize('ティロ・フィナ〜レ', 'NFKC')) ティロ・フィナーレ
[ "Convert", "Half", "-", "width", "(", "Hankaku", ")", "Katakana", "to", "Full", "-", "width", "(", "Zenkaku", ")", "Katakana", "Full", "-", "width", "(", "Zenkaku", ")", "ASCII", "and", "DIGIT", "to", "Half", "-", "width", "(", "Hankaku", ")", "ASCII", "and", "DIGIT", ".", "Additionally", "Full", "-", "width", "wave", "dash", "(", "〜", ")", "etc", ".", "are", "normalized" ]
train
https://github.com/ikegami-yukino/jaconv/blob/5319e4c6b4676ab27b5e9ebec9a299d09a5a62d7/jaconv/jaconv.py#L232-L264
<|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 Half-width (Hankaku) Katakana to Full-width (Zenkaku) Katakana, Full-width (Zenkaku) ASCII and DIGIT to Half-width (Hankaku) ASCII and DIGIT. Additionally, Full-width wave dash (〜) etc. are normalized Parameters ---------- text : str Source string. mode : str Unicode normalization mode. ignore : str Characters to be ignored in converting. Return ------ str Normalized string. Examples -------- >>> print(jaconv.normalize('ティロ・フィナ〜レ', 'NFKC')) ティロ・フィナーレ ### Response: def normalize(text, mode='NFKC', ignore=''): """Convert Half-width (Hankaku) Katakana to Full-width (Zenkaku) Katakana, Full-width (Zenkaku) ASCII and DIGIT to Half-width (Hankaku) ASCII and DIGIT. Additionally, Full-width wave dash (〜) etc. are normalized Parameters ---------- text : str Source string. mode : str Unicode normalization mode. ignore : str Characters to be ignored in converting. Return ------ str Normalized string. Examples -------- >>> print(jaconv.normalize('ティロ・フィナ〜レ', 'NFKC')) ティロ・フィナーレ """ text = text.replace('〜', 'ー').replace('~', 'ー') text = text.replace("’", "'").replace('”', '"').replace('“', '``') text = text.replace('―', '-').replace('‐', '-').replace('˗', '-').replace('֊', '-') text = text.replace('‐', '-').replace('‑', '-').replace('‒', '-').replace('–', '-') text = text.replace('⁃', '-').replace('⁻', '-').replace('₋', '-').replace('−', '-') text = text.replace('﹣', 'ー').replace('-', 'ー').replace('—', 'ー').replace('―', 'ー') text = text.replace('━', 'ー').replace('─', 'ー') return unicodedata.normalize(mode, text) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 12281, 26924, 9531, 320, 39, 1201, 24468, 8, 735, 69828, 3444, 311, 8797, 9531, 320, 57, 79671, 24468, 8, 735, 69828, 3444, 345, 262, 8797, 9531, 320, 57, 79671, 24468, 8, 40416, 323, 56396, 964, 311, 26924, 9531, 320, 39, 1201, 24468, 8, 40416, 198, 262, 323, 56396, 964, 627, 262, 23212, 11, 8797, 9531, 12330, 24858, 320, 56040, 8, 5099, 13, 527, 30510, 271, 262, 13831, 198, 262, 31423, 262, 1495, 551, 610, 198, 286, 8922, 925, 627, 262, 3941, 551, 610, 198, 286, 36997, 49823, 3941, 627, 262, 10240, 551, 610, 198, 286, 45616, 311, 387, 12305, 304, 34537, 382, 262, 3494, 198, 262, 11556, 7233, 262, 610, 198, 286, 18944, 1534, 925, 382, 262, 26379, 198, 262, 90238, 262, 12382, 1194, 3406, 64, 12296, 45757, 493, 69505, 225, 106452, 69505, 249, 58246, 106384, 96452, 56040, 44971, 518, 364, 45, 28096, 34, 7132, 262, 113545, 57183, 42634, 9458, 106384, 96452, 117163, 271, 14711, 6075, 512, 755, 22436, 7383, 11, 3941, 1151, 45, 28096, 34, 518, 10240, 95227, 262, 4304, 12281, 26924, 9531, 320, 39, 1201, 24468, 8, 735, 69828, 3444, 311, 8797, 9531, 320, 57, 79671, 24468, 8, 735, 69828, 3444, 345, 262, 8797, 9531, 320, 57, 79671, 24468, 8, 40416, 323, 56396, 964, 311, 26924, 9531, 320, 39, 1201, 24468, 8, 40416, 198, 262, 323, 56396, 964, 627, 262, 23212, 11, 8797, 9531, 12330, 24858, 320, 56040, 8, 5099, 13, 527, 30510, 271, 262, 13831, 198, 262, 31423, 262, 1495, 551, 610, 198, 286, 8922, 925, 627, 262, 3941, 551, 610, 198, 286, 36997, 49823, 3941, 627, 262, 10240, 551, 610, 198, 286, 45616, 311, 387, 12305, 304, 34537, 382, 262, 3494, 198, 262, 11556, 7233, 262, 610, 198, 286, 18944, 1534, 925, 382, 262, 26379, 198, 262, 90238, 262, 12382, 1194, 3406, 64, 12296, 45757, 493, 69505, 225, 106452, 69505, 249, 58246, 106384, 96452, 56040, 44971, 518, 364, 45, 28096, 34, 7132, 262, 113545, 57183, 42634, 9458, 106384, 96452, 117163, 198, 262, 3270, 262, 1495, 284, 1495, 7125, 493, 56040, 518, 364, 11972, 1861, 8319, 493, 21909, 518, 364, 11972, 1329, 262, 1495, 284, 1495, 7125, 446, 529, 498, 7326, 1865, 8319, 493, 863, 518, 7273, 1861, 8319, 493, 2118, 518, 364, 14196, 1329, 262, 1495, 284, 1495, 7125, 493, 63072, 518, 7944, 1861, 8319, 493, 31021, 518, 7944, 1861, 8319, 493, 135, 245, 518, 7944, 1861, 8319, 493, 146, 232, 518, 91196, 262, 1495, 284, 1495, 7125, 493, 31021, 518, 7944, 1861, 8319, 493, 57064, 518, 7944, 1861, 8319, 493, 378, 240, 518, 7944, 1861, 8319, 493, 4235, 518, 91196, 262, 1495, 284, 1495, 7125, 493, 53233, 225, 518, 7944, 1861, 8319, 493, 53233, 119, 518, 7944, 1861, 8319, 493, 16275, 233, 518, 7944, 1861, 8319, 493, 34363, 518, 91196, 262, 1495, 284, 1495, 7125, 493, 171, 117, 96, 518, 364, 11972, 1861, 8319, 493, 90581, 518, 364 ]
[ 1, 1, 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, 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, 26924, 9531, 320, 39, 1201, 24468, 8, 735, 69828, 3444, 311, 8797, 9531, 320, 57, 79671, 24468, 8, 735, 69828, 3444, 345, 262, 8797, 9531, 320, 57, 79671, 24468, 8, 40416, 323, 56396, 964, 311, 26924, 9531, 320, 39, 1201, 24468, 8, 40416, 198, 262, 323, 56396, 964, 627, 262, 23212, 11, 8797, 9531, 12330, 24858, 320, 56040, 8, 5099, 13, 527, 30510, 271, 262, 13831, 198, 262, 31423, 262, 1495, 551, 610, 198, 286, 8922, 925, 627, 262, 3941, 551, 610, 198, 286, 36997, 49823, 3941, 627, 262, 10240, 551, 610, 198, 286, 45616, 311, 387, 12305, 304, 34537, 382, 262, 3494, 198, 262, 11556, 7233, 262, 610, 198, 286, 18944, 1534, 925, 382, 262, 26379, 198, 262, 90238, 262, 12382, 1194, 3406, 64, 12296, 45757, 493, 69505, 225, 106452, 69505, 249, 58246, 106384, 96452, 56040, 44971, 518, 364, 45, 28096, 34, 7132, 262, 113545, 57183, 42634, 9458, 106384, 96452, 117163, 271, 14711, 6075, 512, 755, 22436, 7383, 11, 3941, 1151, 45, 28096, 34, 518, 10240, 95227, 262, 4304, 12281, 26924, 9531, 320, 39, 1201, 24468, 8, 735, 69828, 3444, 311, 8797, 9531, 320, 57, 79671, 24468, 8, 735, 69828, 3444, 345, 262, 8797, 9531, 320, 57, 79671, 24468, 8, 40416, 323, 56396, 964, 311, 26924, 9531, 320, 39, 1201, 24468, 8, 40416, 198, 262, 323, 56396, 964, 627, 262, 23212, 11, 8797, 9531, 12330, 24858, 320, 56040, 8, 5099, 13, 527, 30510, 271, 262, 13831, 198, 262, 31423, 262, 1495, 551, 610, 198, 286, 8922, 925, 627, 262, 3941, 551, 610, 198, 286, 36997, 49823, 3941, 627, 262, 10240, 551, 610, 198, 286, 45616, 311, 387, 12305, 304, 34537, 382, 262, 3494, 198, 262, 11556, 7233, 262, 610, 198, 286, 18944, 1534, 925, 382, 262, 26379, 198, 262, 90238, 262, 12382, 1194, 3406, 64, 12296, 45757, 493, 69505, 225, 106452, 69505, 249, 58246, 106384, 96452, 56040, 44971, 518, 364, 45, 28096, 34, 7132, 262, 113545, 57183, 42634, 9458, 106384, 96452, 117163, 198, 262, 3270, 262, 1495, 284, 1495, 7125, 493, 56040, 518, 364, 11972, 1861, 8319, 493, 21909, 518, 364, 11972, 1329, 262, 1495, 284, 1495, 7125, 446, 529, 498, 7326, 1865, 8319, 493, 863, 518, 7273, 1861, 8319, 493, 2118, 518, 364, 14196, 1329, 262, 1495, 284, 1495, 7125, 493, 63072, 518, 7944, 1861, 8319, 493, 31021, 518, 7944, 1861, 8319, 493, 135, 245, 518, 7944, 1861, 8319, 493, 146, 232, 518, 91196, 262, 1495, 284, 1495, 7125, 493, 31021, 518, 7944, 1861, 8319, 493, 57064, 518, 7944, 1861, 8319, 493, 378, 240, 518, 7944, 1861, 8319, 493, 4235, 518, 91196, 262, 1495, 284, 1495, 7125, 493, 53233, 225, 518, 7944, 1861, 8319, 493, 53233, 119, 518, 7944, 1861, 8319, 493, 16275, 233, 518, 7944, 1861, 8319, 493, 34363, 518, 91196, 262, 1495, 284, 1495, 7125, 493, 171, 117, 96, 518, 364, 11972, 1861, 8319, 493, 90581, 518, 364 ]
pytroll/satpy
satpy/readers/goes_imager_nc.py
GOESNCFileHandler.calibrate
def calibrate(self, counts, calibration, channel): """Perform calibration""" # Convert 16bit counts from netCDF4 file to the original 10bit # GVAR counts by dividing by 32. See [FAQ]. counts = counts / 32. coefs = CALIB_COEFS[self.platform_name][channel] if calibration == 'counts': return counts elif calibration in ['radiance', 'reflectance', 'brightness_temperature']: radiance = self._counts2radiance(counts=counts, coefs=coefs, channel=channel) if calibration == 'radiance': return radiance return self._calibrate(radiance=radiance, coefs=coefs, channel=channel, calibration=calibration) else: raise ValueError('Unsupported calibration for channel {}: {}' .format(channel, calibration))
python
def calibrate(self, counts, calibration, channel): """Perform calibration""" # Convert 16bit counts from netCDF4 file to the original 10bit # GVAR counts by dividing by 32. See [FAQ]. counts = counts / 32. coefs = CALIB_COEFS[self.platform_name][channel] if calibration == 'counts': return counts elif calibration in ['radiance', 'reflectance', 'brightness_temperature']: radiance = self._counts2radiance(counts=counts, coefs=coefs, channel=channel) if calibration == 'radiance': return radiance return self._calibrate(radiance=radiance, coefs=coefs, channel=channel, calibration=calibration) else: raise ValueError('Unsupported calibration for channel {}: {}' .format(channel, calibration))
[ "def", "calibrate", "(", "self", ",", "counts", ",", "calibration", ",", "channel", ")", ":", "# Convert 16bit counts from netCDF4 file to the original 10bit", "# GVAR counts by dividing by 32. See [FAQ].", "counts", "=", "counts", "/", "32.", "coefs", "=", "CALIB_COEFS", "[", "self", ".", "platform_name", "]", "[", "channel", "]", "if", "calibration", "==", "'counts'", ":", "return", "counts", "elif", "calibration", "in", "[", "'radiance'", ",", "'reflectance'", ",", "'brightness_temperature'", "]", ":", "radiance", "=", "self", ".", "_counts2radiance", "(", "counts", "=", "counts", ",", "coefs", "=", "coefs", ",", "channel", "=", "channel", ")", "if", "calibration", "==", "'radiance'", ":", "return", "radiance", "return", "self", ".", "_calibrate", "(", "radiance", "=", "radiance", ",", "coefs", "=", "coefs", ",", "channel", "=", "channel", ",", "calibration", "=", "calibration", ")", "else", ":", "raise", "ValueError", "(", "'Unsupported calibration for channel {}: {}'", ".", "format", "(", "channel", ",", "calibration", ")", ")" ]
Perform calibration
[ "Perform", "calibration" ]
train
https://github.com/pytroll/satpy/blob/1f21d20ac686b745fb0da9b4030d139893e066dd/satpy/readers/goes_imager_nc.py#L1001-L1021
<|startoftext|> ### Instruction: You are a Senior Software Developer and a helpful AI programming assistant. Generate only Python code without explanations. Respond only in English. ### Task: Perform calibration ### Response: def calibrate(self, counts, calibration, channel): """Perform calibration""" # Convert 16bit counts from netCDF4 file to the original 10bit # GVAR counts by dividing by 32. See [FAQ]. counts = counts / 32. coefs = CALIB_COEFS[self.platform_name][channel] if calibration == 'counts': return counts elif calibration in ['radiance', 'reflectance', 'brightness_temperature']: radiance = self._counts2radiance(counts=counts, coefs=coefs, channel=channel) if calibration == 'radiance': return radiance return self._calibrate(radiance=radiance, coefs=coefs, channel=channel, calibration=calibration) else: raise ValueError('Unsupported calibration for channel {}: {}' .format(channel, calibration)) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 48051, 38711, 271, 14711, 6075, 512, 755, 1652, 44192, 1214, 11, 14921, 11, 38711, 11, 5613, 997, 286, 4304, 48051, 38711, 7275, 286, 674, 7316, 220, 845, 4590, 14921, 505, 4272, 72078, 19, 1052, 311, 279, 4113, 220, 605, 4590, 198, 286, 674, 480, 34140, 14921, 555, 50802, 555, 220, 843, 13, 3580, 510, 56032, 27218, 286, 14921, 284, 14921, 611, 220, 843, 382, 286, 1080, 45062, 284, 34007, 3336, 20201, 36, 8653, 14664, 25723, 1292, 1483, 10327, 933, 286, 422, 38711, 624, 364, 45959, 3730, 310, 471, 14921, 198, 286, 4508, 38711, 304, 2570, 70312, 685, 518, 364, 36013, 685, 756, 6663, 364, 100156, 54625, 18888, 310, 12164, 685, 284, 659, 1462, 45959, 17, 70312, 685, 11773, 82, 28, 45959, 11, 1080, 45062, 28, 1030, 45062, 345, 15791, 5613, 28, 10327, 340, 310, 422, 38711, 624, 364, 70312, 685, 3730, 394, 471, 12164, 685, 271, 310, 471, 659, 1462, 5531, 44192, 2666, 2836, 685, 32220, 2836, 685, 11, 1080, 45062, 28, 1030, 45062, 345, 9898, 5613, 28, 10327, 11, 38711, 28, 5531, 18856, 340, 286, 775, 512, 310, 4933, 15764, 493, 42984, 38711, 369, 5613, 92012, 4792, 1270, 6663, 662, 2293, 27012, 11, 38711, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 48051, 38711, 271, 14711, 6075, 512, 755, 1652, 44192, 1214, 11, 14921, 11, 38711, 11, 5613, 997, 286, 4304, 48051, 38711, 7275, 286, 674, 7316, 220, 845, 4590, 14921, 505, 4272, 72078, 19, 1052, 311, 279, 4113, 220, 605, 4590, 198, 286, 674, 480, 34140, 14921, 555, 50802, 555, 220, 843, 13, 3580, 510, 56032, 27218, 286, 14921, 284, 14921, 611, 220, 843, 382, 286, 1080, 45062, 284, 34007, 3336, 20201, 36, 8653, 14664, 25723, 1292, 1483, 10327, 933, 286, 422, 38711, 624, 364, 45959, 3730, 310, 471, 14921, 198, 286, 4508, 38711, 304, 2570, 70312, 685, 518, 364, 36013, 685, 756, 6663, 364, 100156, 54625, 18888, 310, 12164, 685, 284, 659, 1462, 45959, 17, 70312, 685, 11773, 82, 28, 45959, 11, 1080, 45062, 28, 1030, 45062, 345, 15791, 5613, 28, 10327, 340, 310, 422, 38711, 624, 364, 70312, 685, 3730, 394, 471, 12164, 685, 271, 310, 471, 659, 1462, 5531, 44192, 2666, 2836, 685, 32220, 2836, 685, 11, 1080, 45062, 28, 1030, 45062, 345, 9898, 5613, 28, 10327, 11, 38711, 28, 5531, 18856, 340, 286, 775, 512, 310, 4933, 15764, 493, 42984, 38711, 369, 5613, 92012, 4792, 1270, 6663, 662, 2293, 27012, 11, 38711, 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 ]
prompt-toolkit/pymux
pymux/key_bindings.py
PymuxKeyBindings._load_prefix_binding
def _load_prefix_binding(self): """ Load the prefix key binding. """ pymux = self.pymux # Remove previous binding. if self._prefix_binding: self.custom_key_bindings.remove_binding(self._prefix_binding) # Create new Python binding. @self.custom_key_bindings.add(*self._prefix, filter= ~(HasPrefix(pymux) | has_focus(COMMAND) | has_focus(PROMPT) | WaitsForConfirmation(pymux))) def enter_prefix_handler(event): " Enter prefix mode. " pymux.get_client_state().has_prefix = True self._prefix_binding = enter_prefix_handler
python
def _load_prefix_binding(self): """ Load the prefix key binding. """ pymux = self.pymux # Remove previous binding. if self._prefix_binding: self.custom_key_bindings.remove_binding(self._prefix_binding) # Create new Python binding. @self.custom_key_bindings.add(*self._prefix, filter= ~(HasPrefix(pymux) | has_focus(COMMAND) | has_focus(PROMPT) | WaitsForConfirmation(pymux))) def enter_prefix_handler(event): " Enter prefix mode. " pymux.get_client_state().has_prefix = True self._prefix_binding = enter_prefix_handler
[ "def", "_load_prefix_binding", "(", "self", ")", ":", "pymux", "=", "self", ".", "pymux", "# Remove previous binding.", "if", "self", ".", "_prefix_binding", ":", "self", ".", "custom_key_bindings", ".", "remove_binding", "(", "self", ".", "_prefix_binding", ")", "# Create new Python binding.", "@", "self", ".", "custom_key_bindings", ".", "add", "(", "*", "self", ".", "_prefix", ",", "filter", "=", "~", "(", "HasPrefix", "(", "pymux", ")", "|", "has_focus", "(", "COMMAND", ")", "|", "has_focus", "(", "PROMPT", ")", "|", "WaitsForConfirmation", "(", "pymux", ")", ")", ")", "def", "enter_prefix_handler", "(", "event", ")", ":", "\" Enter prefix mode. \"", "pymux", ".", "get_client_state", "(", ")", ".", "has_prefix", "=", "True", "self", ".", "_prefix_binding", "=", "enter_prefix_handler" ]
Load the prefix key binding.
[ "Load", "the", "prefix", "key", "binding", "." ]
train
https://github.com/prompt-toolkit/pymux/blob/3f66e62b9de4b2251c7f9afad6c516dc5a30ec67/pymux/key_bindings.py#L50-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: Load the prefix key binding. ### Response: def _load_prefix_binding(self): """ Load the prefix key binding. """ pymux = self.pymux # Remove previous binding. if self._prefix_binding: self.custom_key_bindings.remove_binding(self._prefix_binding) # Create new Python binding. @self.custom_key_bindings.add(*self._prefix, filter= ~(HasPrefix(pymux) | has_focus(COMMAND) | has_focus(PROMPT) | WaitsForConfirmation(pymux))) def enter_prefix_handler(event): " Enter prefix mode. " pymux.get_client_state().has_prefix = True self._prefix_binding = enter_prefix_handler <|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, 9436, 1401, 11212, 382, 14711, 6075, 512, 755, 721, 1096, 14301, 61915, 1214, 997, 286, 3270, 286, 9069, 279, 9436, 1401, 11212, 627, 286, 3270, 286, 46860, 2249, 284, 659, 558, 1631, 2249, 271, 286, 674, 11016, 3766, 11212, 627, 286, 422, 659, 1462, 12113, 61915, 512, 310, 659, 25254, 3173, 95616, 4955, 61915, 1214, 1462, 12113, 61915, 696, 286, 674, 4324, 502, 13325, 11212, 627, 286, 571, 726, 25254, 3173, 95616, 1388, 4163, 726, 1462, 12113, 11, 4141, 15092, 310, 35646, 10493, 14672, 1319, 1631, 2249, 8, 765, 706, 48592, 71649, 26003, 8, 765, 706, 48592, 5417, 3442, 2898, 8, 9432, 1078, 29614, 1220, 2520, 54640, 1319, 1631, 2249, 6054, 286, 711, 3810, 14301, 10393, 6368, 997, 310, 330, 11502, 9436, 3941, 13, 6360, 310, 46860, 2249, 673, 8342, 4486, 1020, 4752, 14301, 284, 3082, 271, 286, 659, 1462, 12113, 61915, 284, 3810, 14301, 10393, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 9436, 1401, 11212, 382, 14711, 6075, 512, 755, 721, 1096, 14301, 61915, 1214, 997, 286, 3270, 286, 9069, 279, 9436, 1401, 11212, 627, 286, 3270, 286, 46860, 2249, 284, 659, 558, 1631, 2249, 271, 286, 674, 11016, 3766, 11212, 627, 286, 422, 659, 1462, 12113, 61915, 512, 310, 659, 25254, 3173, 95616, 4955, 61915, 1214, 1462, 12113, 61915, 696, 286, 674, 4324, 502, 13325, 11212, 627, 286, 571, 726, 25254, 3173, 95616, 1388, 4163, 726, 1462, 12113, 11, 4141, 15092, 310, 35646, 10493, 14672, 1319, 1631, 2249, 8, 765, 706, 48592, 71649, 26003, 8, 765, 706, 48592, 5417, 3442, 2898, 8, 9432, 1078, 29614, 1220, 2520, 54640, 1319, 1631, 2249, 6054, 286, 711, 3810, 14301, 10393, 6368, 997, 310, 330, 11502, 9436, 3941, 13, 6360, 310, 46860, 2249, 673, 8342, 4486, 1020, 4752, 14301, 284, 3082, 271, 286, 659, 1462, 12113, 61915, 284, 3810, 14301, 10393, 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 ]
happyleavesaoc/aoc-mgz
mgz/enums.py
GameActionModeEnum
def GameActionModeEnum(ctx): """Game Action Modes.""" return Enum( ctx, diplomacy=0, speed=1, instant_build=2, quick_build=4, allied_victory=5, cheat=6, unk0=9, spy=10, unk1=11, farm_queue=13, farm_unqueue=14, default=Pass )
python
def GameActionModeEnum(ctx): """Game Action Modes.""" return Enum( ctx, diplomacy=0, speed=1, instant_build=2, quick_build=4, allied_victory=5, cheat=6, unk0=9, spy=10, unk1=11, farm_queue=13, farm_unqueue=14, default=Pass )
[ "def", "GameActionModeEnum", "(", "ctx", ")", ":", "return", "Enum", "(", "ctx", ",", "diplomacy", "=", "0", ",", "speed", "=", "1", ",", "instant_build", "=", "2", ",", "quick_build", "=", "4", ",", "allied_victory", "=", "5", ",", "cheat", "=", "6", ",", "unk0", "=", "9", ",", "spy", "=", "10", ",", "unk1", "=", "11", ",", "farm_queue", "=", "13", ",", "farm_unqueue", "=", "14", ",", "default", "=", "Pass", ")" ]
Game Action Modes.
[ "Game", "Action", "Modes", "." ]
train
https://github.com/happyleavesaoc/aoc-mgz/blob/13fc379cc062d7640bfa028eed9c0d45d37a7b2b/mgz/enums.py#L250-L266
<|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: Game Action Modes. ### Response: def GameActionModeEnum(ctx): """Game Action Modes.""" return Enum( ctx, diplomacy=0, speed=1, instant_build=2, quick_build=4, allied_victory=5, cheat=6, unk0=9, spy=10, unk1=11, farm_queue=13, farm_unqueue=14, default=Pass ) <|endoftext|>
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 4973, 5703, 82789, 382, 14711, 6075, 512, 755, 4140, 2573, 3720, 10999, 7654, 997, 262, 4304, 4973, 5703, 82789, 14781, 262, 471, 14416, 1021, 286, 5753, 345, 286, 62340, 28, 15, 345, 286, 4732, 28, 16, 345, 286, 9888, 21465, 28, 17, 345, 286, 4062, 21465, 28, 19, 345, 286, 54502, 2325, 91133, 28, 20, 345, 286, 41868, 28, 21, 345, 286, 65531, 15, 28, 24, 345, 286, 21930, 28, 605, 345, 286, 65531, 16, 28, 806, 345, 286, 8961, 11078, 28, 1032, 345, 286, 8961, 5012, 4687, 28, 975, 345, 286, 1670, 28, 12465, 198, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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,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5703, 82789, 382, 14711, 6075, 512, 755, 4140, 2573, 3720, 10999, 7654, 997, 262, 4304, 4973, 5703, 82789, 14781, 262, 471, 14416, 1021, 286, 5753, 345, 286, 62340, 28, 15, 345, 286, 4732, 28, 16, 345, 286, 9888, 21465, 28, 17, 345, 286, 4062, 21465, 28, 19, 345, 286, 54502, 2325, 91133, 28, 20, 345, 286, 41868, 28, 21, 345, 286, 65531, 15, 28, 24, 345, 286, 21930, 28, 605, 345, 286, 65531, 16, 28, 806, 345, 286, 8961, 11078, 28, 1032, 345, 286, 8961, 5012, 4687, 28, 975, 345, 286, 1670, 28, 12465, 198, 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 ]
DarkEnergySurvey/ugali
ugali/utils/config.py
Config._createFilenames
def _createFilenames(self): """ Create a masked records array of all filenames for the given set of pixels and store the existence of those files in the mask values. Parameters: ----------- None Returns: -------- recarray : pixels and mask value """ nside_catalog = self['coords']['nside_catalog'] npix = hp.nside2npix(nside_catalog) pixels = np.arange(npix) catalog_dir = self['catalog']['dirname'] catalog_base = self['catalog']['basename'] catalog_path = os.path.join(catalog_dir,catalog_base) mask_dir = self['mask']['dirname'] mask_base_1 = self['mask']['basename_1'] mask_base_2 = self['mask']['basename_2'] mask_path_1 = os.path.join(mask_dir,mask_base_1) mask_path_2 = os.path.join(mask_dir,mask_base_2) data = np.ma.empty(npix,dtype=[('pix',int), ('catalog',object), ('mask_1',object), ('mask_2',object)]) mask = np.ma.empty(npix,dtype=[('pix',bool), ('catalog',bool), ('mask_1',bool), ('mask_2',bool)]) # Build the filenames data['pix'] = pixels data['catalog'] = np.char.mod(catalog_path,pixels) data['mask_1'] = np.char.mod(mask_path_1,pixels) data['mask_2'] = np.char.mod(mask_path_2,pixels) # Build the mask of existing files using glob mask['catalog'] = ~np.in1d(data['catalog'],glob.glob(catalog_dir+'/*')) mask['mask_1'] = ~np.in1d(data['mask_1'],glob.glob(mask_dir+'/*')) mask['mask_2'] = ~np.in1d(data['mask_2'],glob.glob(mask_dir+'/*')) for name in ['catalog','mask_1','mask_2']: if np.all(mask[name]): logger.warn("All '%s' files masked"%name) # mask 'pix' if all files not present mask['pix'] = mask['catalog'] | mask['mask_1'] | mask['mask_2'] if np.all(mask['pix']): logger.warn("All pixels masked") return np.ma.MaskedArray(data, mask, fill_value=[-1,'','',''])
python
def _createFilenames(self): """ Create a masked records array of all filenames for the given set of pixels and store the existence of those files in the mask values. Parameters: ----------- None Returns: -------- recarray : pixels and mask value """ nside_catalog = self['coords']['nside_catalog'] npix = hp.nside2npix(nside_catalog) pixels = np.arange(npix) catalog_dir = self['catalog']['dirname'] catalog_base = self['catalog']['basename'] catalog_path = os.path.join(catalog_dir,catalog_base) mask_dir = self['mask']['dirname'] mask_base_1 = self['mask']['basename_1'] mask_base_2 = self['mask']['basename_2'] mask_path_1 = os.path.join(mask_dir,mask_base_1) mask_path_2 = os.path.join(mask_dir,mask_base_2) data = np.ma.empty(npix,dtype=[('pix',int), ('catalog',object), ('mask_1',object), ('mask_2',object)]) mask = np.ma.empty(npix,dtype=[('pix',bool), ('catalog',bool), ('mask_1',bool), ('mask_2',bool)]) # Build the filenames data['pix'] = pixels data['catalog'] = np.char.mod(catalog_path,pixels) data['mask_1'] = np.char.mod(mask_path_1,pixels) data['mask_2'] = np.char.mod(mask_path_2,pixels) # Build the mask of existing files using glob mask['catalog'] = ~np.in1d(data['catalog'],glob.glob(catalog_dir+'/*')) mask['mask_1'] = ~np.in1d(data['mask_1'],glob.glob(mask_dir+'/*')) mask['mask_2'] = ~np.in1d(data['mask_2'],glob.glob(mask_dir+'/*')) for name in ['catalog','mask_1','mask_2']: if np.all(mask[name]): logger.warn("All '%s' files masked"%name) # mask 'pix' if all files not present mask['pix'] = mask['catalog'] | mask['mask_1'] | mask['mask_2'] if np.all(mask['pix']): logger.warn("All pixels masked") return np.ma.MaskedArray(data, mask, fill_value=[-1,'','',''])
[ "def", "_createFilenames", "(", "self", ")", ":", "nside_catalog", "=", "self", "[", "'coords'", "]", "[", "'nside_catalog'", "]", "npix", "=", "hp", ".", "nside2npix", "(", "nside_catalog", ")", "pixels", "=", "np", ".", "arange", "(", "npix", ")", "catalog_dir", "=", "self", "[", "'catalog'", "]", "[", "'dirname'", "]", "catalog_base", "=", "self", "[", "'catalog'", "]", "[", "'basename'", "]", "catalog_path", "=", "os", ".", "path", ".", "join", "(", "catalog_dir", ",", "catalog_base", ")", "mask_dir", "=", "self", "[", "'mask'", "]", "[", "'dirname'", "]", "mask_base_1", "=", "self", "[", "'mask'", "]", "[", "'basename_1'", "]", "mask_base_2", "=", "self", "[", "'mask'", "]", "[", "'basename_2'", "]", "mask_path_1", "=", "os", ".", "path", ".", "join", "(", "mask_dir", ",", "mask_base_1", ")", "mask_path_2", "=", "os", ".", "path", ".", "join", "(", "mask_dir", ",", "mask_base_2", ")", "data", "=", "np", ".", "ma", ".", "empty", "(", "npix", ",", "dtype", "=", "[", "(", "'pix'", ",", "int", ")", ",", "(", "'catalog'", ",", "object", ")", ",", "(", "'mask_1'", ",", "object", ")", ",", "(", "'mask_2'", ",", "object", ")", "]", ")", "mask", "=", "np", ".", "ma", ".", "empty", "(", "npix", ",", "dtype", "=", "[", "(", "'pix'", ",", "bool", ")", ",", "(", "'catalog'", ",", "bool", ")", ",", "(", "'mask_1'", ",", "bool", ")", ",", "(", "'mask_2'", ",", "bool", ")", "]", ")", "# Build the filenames", "data", "[", "'pix'", "]", "=", "pixels", "data", "[", "'catalog'", "]", "=", "np", ".", "char", ".", "mod", "(", "catalog_path", ",", "pixels", ")", "data", "[", "'mask_1'", "]", "=", "np", ".", "char", ".", "mod", "(", "mask_path_1", ",", "pixels", ")", "data", "[", "'mask_2'", "]", "=", "np", ".", "char", ".", "mod", "(", "mask_path_2", ",", "pixels", ")", "# Build the mask of existing files using glob", "mask", "[", "'catalog'", "]", "=", "~", "np", ".", "in1d", "(", "data", "[", "'catalog'", "]", ",", "glob", ".", "glob", "(", "catalog_dir", "+", "'/*'", ")", ")", "mask", "[", "'mask_1'", "]", "=", "~", "np", ".", "in1d", "(", "data", "[", "'mask_1'", "]", ",", "glob", ".", "glob", "(", "mask_dir", "+", "'/*'", ")", ")", "mask", "[", "'mask_2'", "]", "=", "~", "np", ".", "in1d", "(", "data", "[", "'mask_2'", "]", ",", "glob", ".", "glob", "(", "mask_dir", "+", "'/*'", ")", ")", "for", "name", "in", "[", "'catalog'", ",", "'mask_1'", ",", "'mask_2'", "]", ":", "if", "np", ".", "all", "(", "mask", "[", "name", "]", ")", ":", "logger", ".", "warn", "(", "\"All '%s' files masked\"", "%", "name", ")", "# mask 'pix' if all files not present", "mask", "[", "'pix'", "]", "=", "mask", "[", "'catalog'", "]", "|", "mask", "[", "'mask_1'", "]", "|", "mask", "[", "'mask_2'", "]", "if", "np", ".", "all", "(", "mask", "[", "'pix'", "]", ")", ":", "logger", ".", "warn", "(", "\"All pixels masked\"", ")", "return", "np", ".", "ma", ".", "MaskedArray", "(", "data", ",", "mask", ",", "fill_value", "=", "[", "-", "1", ",", "''", ",", "''", ",", "''", "]", ")" ]
Create a masked records array of all filenames for the given set of pixels and store the existence of those files in the mask values. Parameters: ----------- None Returns: -------- recarray : pixels and mask value
[ "Create", "a", "masked", "records", "array", "of", "all", "filenames", "for", "the", "given", "set", "of", "pixels", "and", "store", "the", "existence", "of", "those", "files", "in", "the", "mask", "values", "." ]
train
https://github.com/DarkEnergySurvey/ugali/blob/21e890b4117fc810afb6fb058e8055d564f03382/ugali/utils/config.py#L252-L303
<|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 masked records array of all filenames for the given set of pixels and store the existence of those files in the mask values. Parameters: ----------- None Returns: -------- recarray : pixels and mask value ### Response: def _createFilenames(self): """ Create a masked records array of all filenames for the given set of pixels and store the existence of those files in the mask values. Parameters: ----------- None Returns: -------- recarray : pixels and mask value """ nside_catalog = self['coords']['nside_catalog'] npix = hp.nside2npix(nside_catalog) pixels = np.arange(npix) catalog_dir = self['catalog']['dirname'] catalog_base = self['catalog']['basename'] catalog_path = os.path.join(catalog_dir,catalog_base) mask_dir = self['mask']['dirname'] mask_base_1 = self['mask']['basename_1'] mask_base_2 = self['mask']['basename_2'] mask_path_1 = os.path.join(mask_dir,mask_base_1) mask_path_2 = os.path.join(mask_dir,mask_base_2) data = np.ma.empty(npix,dtype=[('pix',int), ('catalog',object), ('mask_1',object), ('mask_2',object)]) mask = np.ma.empty(npix,dtype=[('pix',bool), ('catalog',bool), ('mask_1',bool), ('mask_2',bool)]) # Build the filenames data['pix'] = pixels data['catalog'] = np.char.mod(catalog_path,pixels) data['mask_1'] = np.char.mod(mask_path_1,pixels) data['mask_2'] = np.char.mod(mask_path_2,pixels) # Build the mask of existing files using glob mask['catalog'] = ~np.in1d(data['catalog'],glob.glob(catalog_dir+'/*')) mask['mask_1'] = ~np.in1d(data['mask_1'],glob.glob(mask_dir+'/*')) mask['mask_2'] = ~np.in1d(data['mask_2'],glob.glob(mask_dir+'/*')) for name in ['catalog','mask_1','mask_2']: if np.all(mask[name]): logger.warn("All '%s' files masked"%name) # mask 'pix' if all files not present mask['pix'] = mask['catalog'] | mask['mask_1'] | mask['mask_2'] if np.all(mask['pix']): logger.warn("All pixels masked") return np.ma.MaskedArray(data, mask, fill_value=[-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, 4110, 264, 43248, 7576, 1358, 315, 682, 41640, 369, 279, 2728, 743, 315, 198, 286, 16128, 323, 3637, 279, 14209, 315, 1884, 3626, 304, 279, 7056, 2819, 382, 286, 13831, 512, 286, 220, 26999, 286, 2290, 271, 286, 5295, 512, 286, 90238, 286, 1421, 1686, 551, 16128, 323, 7056, 907, 271, 14711, 6075, 512, 755, 721, 3261, 37, 53868, 1214, 997, 286, 3270, 286, 4324, 264, 43248, 7576, 1358, 315, 682, 41640, 369, 279, 2728, 743, 315, 198, 286, 16128, 323, 3637, 279, 14209, 315, 1884, 3626, 304, 279, 7056, 2819, 382, 286, 13831, 512, 286, 220, 26999, 286, 2290, 271, 286, 5295, 512, 286, 90238, 286, 1421, 1686, 551, 16128, 323, 7056, 907, 198, 286, 3270, 286, 308, 3002, 48410, 284, 659, 681, 36130, 4274, 77, 3002, 48410, 4532, 286, 2660, 953, 284, 21280, 1276, 3002, 17, 6331, 953, 1471, 3002, 48410, 340, 286, 16128, 284, 2660, 25306, 10101, 953, 696, 286, 16808, 4432, 284, 659, 681, 27637, 4274, 14772, 4532, 286, 16808, 7806, 284, 659, 681, 27637, 4274, 44053, 4532, 286, 16808, 2703, 284, 2709, 3960, 5563, 1361, 7906, 4432, 10317, 7906, 7806, 696, 286, 7056, 4432, 262, 284, 659, 681, 11508, 4274, 14772, 4532, 286, 7056, 7806, 62, 16, 284, 659, 681, 11508, 4274, 44053, 62, 16, 4532, 286, 7056, 7806, 62, 17, 284, 659, 681, 11508, 4274, 44053, 62, 17, 4532, 286, 7056, 2703, 62, 16, 284, 2709, 3960, 5563, 36406, 4432, 11, 11508, 7806, 62, 16, 340, 286, 7056, 2703, 62, 17, 284, 2709, 3960, 5563, 36406, 4432, 11, 11508, 7806, 62, 17, 696, 286, 828, 284, 2660, 63902, 9357, 10101, 953, 12260, 1337, 5941, 493, 36584, 518, 396, 705, 4417, 27637, 518, 1735, 705, 720, 11317, 4417, 11508, 62, 16, 518, 1735, 705, 4417, 11508, 62, 17, 518, 1735, 28243, 286, 7056, 284, 2660, 63902, 9357, 10101, 953, 12260, 1337, 5941, 493, 36584, 518, 2707, 705, 4417, 27637, 518, 2707, 705, 720, 11317, 4417, 11508, 62, 16, 518, 2707, 705, 4417, 11508, 62, 17, 518, 2707, 68964, 286, 674, 8012, 279, 41640, 198, 286, 828, 681, 36584, 663, 257, 284, 16128, 198, 286, 828, 681, 27637, 663, 284, 2660, 11402, 11169, 1361, 7906, 2703, 7385, 10486, 340, 286, 828, 681, 11508, 62, 16, 663, 220, 284, 2660, 11402, 11169, 36406, 2703, 62, 16, 7385, 10486, 340, 286, 828, 681, 11508, 62, 17, 663, 220, 284, 2660, 11402, 11169, 36406, 2703, 62, 17, 7385, 10486, 696, 286, 674, 8012, 279, 7056, 315, 6484, 3626, 1701, 13509, 198, 286, 7056, 681, 27637, 663, 284, 4056, 6331, 1896, 16, 67, 2657, 681, 27637, 4181, 60026, 45471, 1361, 7906, 4432, 6972, 1075, 7132, 286, 7056, 681, 11508, 62, 16, 663, 220, 284, 4056, 6331, 1896, 16, 67, 2657, 681, 11508, 62, 16, 4181, 60026, 45471, 36406, 4432, 6972, 1075, 7132, 286, 7056, 681, 11508, 62, 17, 663, 220, 284, 4056, 6331 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 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, 43248, 7576, 1358, 315, 682, 41640, 369, 279, 2728, 743, 315, 198, 286, 16128, 323, 3637, 279, 14209, 315, 1884, 3626, 304, 279, 7056, 2819, 382, 286, 13831, 512, 286, 220, 26999, 286, 2290, 271, 286, 5295, 512, 286, 90238, 286, 1421, 1686, 551, 16128, 323, 7056, 907, 271, 14711, 6075, 512, 755, 721, 3261, 37, 53868, 1214, 997, 286, 3270, 286, 4324, 264, 43248, 7576, 1358, 315, 682, 41640, 369, 279, 2728, 743, 315, 198, 286, 16128, 323, 3637, 279, 14209, 315, 1884, 3626, 304, 279, 7056, 2819, 382, 286, 13831, 512, 286, 220, 26999, 286, 2290, 271, 286, 5295, 512, 286, 90238, 286, 1421, 1686, 551, 16128, 323, 7056, 907, 198, 286, 3270, 286, 308, 3002, 48410, 284, 659, 681, 36130, 4274, 77, 3002, 48410, 4532, 286, 2660, 953, 284, 21280, 1276, 3002, 17, 6331, 953, 1471, 3002, 48410, 340, 286, 16128, 284, 2660, 25306, 10101, 953, 696, 286, 16808, 4432, 284, 659, 681, 27637, 4274, 14772, 4532, 286, 16808, 7806, 284, 659, 681, 27637, 4274, 44053, 4532, 286, 16808, 2703, 284, 2709, 3960, 5563, 1361, 7906, 4432, 10317, 7906, 7806, 696, 286, 7056, 4432, 262, 284, 659, 681, 11508, 4274, 14772, 4532, 286, 7056, 7806, 62, 16, 284, 659, 681, 11508, 4274, 44053, 62, 16, 4532, 286, 7056, 7806, 62, 17, 284, 659, 681, 11508, 4274, 44053, 62, 17, 4532, 286, 7056, 2703, 62, 16, 284, 2709, 3960, 5563, 36406, 4432, 11, 11508, 7806, 62, 16, 340, 286, 7056, 2703, 62, 17, 284, 2709, 3960, 5563, 36406, 4432, 11, 11508, 7806, 62, 17, 696, 286, 828, 284, 2660, 63902, 9357, 10101, 953, 12260, 1337, 5941, 493, 36584, 518, 396, 705, 4417, 27637, 518, 1735, 705, 720, 11317, 4417, 11508, 62, 16, 518, 1735, 705, 4417, 11508, 62, 17, 518, 1735, 28243, 286, 7056, 284, 2660, 63902, 9357, 10101, 953, 12260, 1337, 5941, 493, 36584, 518, 2707, 705, 4417, 27637, 518, 2707, 705, 720, 11317, 4417, 11508, 62, 16, 518, 2707, 705, 4417, 11508, 62, 17, 518, 2707, 68964, 286, 674, 8012, 279, 41640, 198, 286, 828, 681, 36584, 663, 257, 284, 16128, 198, 286, 828, 681, 27637, 663, 284, 2660, 11402, 11169, 1361, 7906, 2703, 7385, 10486, 340, 286, 828, 681, 11508, 62, 16, 663, 220, 284, 2660, 11402, 11169, 36406, 2703, 62, 16, 7385, 10486, 340, 286, 828, 681, 11508, 62, 17, 663, 220, 284, 2660, 11402, 11169, 36406, 2703, 62, 17, 7385, 10486, 696, 286, 674, 8012, 279, 7056, 315, 6484, 3626, 1701, 13509, 198, 286, 7056, 681, 27637, 663, 284, 4056, 6331, 1896, 16, 67, 2657, 681, 27637, 4181, 60026, 45471, 1361, 7906, 4432, 6972, 1075, 7132, 286, 7056, 681, 11508, 62, 16, 663, 220, 284, 4056, 6331, 1896, 16, 67, 2657, 681, 11508, 62, 16, 4181, 60026, 45471, 36406, 4432, 6972, 1075, 7132, 286, 7056, 681, 11508, 62, 17, 663, 220, 284, 4056, 6331 ]
uber/tchannel-python
tchannel/tornado/message_factory.py
MessageFactory.build
def build(self, message): """buffer all the streaming messages based on the message id. Reconstruct all fragments together. :param message: incoming message :return: next complete message or None if streaming is not done """ context = None if message.message_type in [Types.CALL_REQ, Types.CALL_RES]: self.verify_message(message) context = self.build_context(message) # streaming message if message.flags == common.FlagsType.fragment: self.message_buffer[message.id] = context # find the incompleted stream num = 0 for i, arg in enumerate(context.argstreams): if arg.state != StreamState.completed: num = i break self.close_argstream(context, num) return context elif message.message_type in [Types.CALL_REQ_CONTINUE, Types.CALL_RES_CONTINUE]: context = self.message_buffer.get(message.id) if context is None: # missing call msg before continue msg raise FatalProtocolError( "missing call message after receiving continue message", message.id, ) # find the incompleted stream dst = 0 for i, arg in enumerate(context.argstreams): if arg.state != StreamState.completed: dst = i break try: self.verify_message(message) except InvalidChecksumError as e: context.argstreams[dst].set_exception(e) raise src = 0 while src < len(message.args): context.argstreams[dst].write(message.args[src]) dst += 1 src += 1 if message.flags != FlagsType.fragment: # get last fragment. mark it as completed assert (len(context.argstreams) == CallContinueMessage.max_args_num) self.message_buffer.pop(message.id, None) context.flags = FlagsType.none self.close_argstream(context, dst - 1) return None elif message.message_type == Types.ERROR: context = self.message_buffer.pop(message.id, None) if context is None: log.info('Unconsumed error %s', message) return None else: error = TChannelError.from_code( message.code, description=message.description, tracing=context.tracing, ) context.set_exception(error) return error else: return message
python
def build(self, message): """buffer all the streaming messages based on the message id. Reconstruct all fragments together. :param message: incoming message :return: next complete message or None if streaming is not done """ context = None if message.message_type in [Types.CALL_REQ, Types.CALL_RES]: self.verify_message(message) context = self.build_context(message) # streaming message if message.flags == common.FlagsType.fragment: self.message_buffer[message.id] = context # find the incompleted stream num = 0 for i, arg in enumerate(context.argstreams): if arg.state != StreamState.completed: num = i break self.close_argstream(context, num) return context elif message.message_type in [Types.CALL_REQ_CONTINUE, Types.CALL_RES_CONTINUE]: context = self.message_buffer.get(message.id) if context is None: # missing call msg before continue msg raise FatalProtocolError( "missing call message after receiving continue message", message.id, ) # find the incompleted stream dst = 0 for i, arg in enumerate(context.argstreams): if arg.state != StreamState.completed: dst = i break try: self.verify_message(message) except InvalidChecksumError as e: context.argstreams[dst].set_exception(e) raise src = 0 while src < len(message.args): context.argstreams[dst].write(message.args[src]) dst += 1 src += 1 if message.flags != FlagsType.fragment: # get last fragment. mark it as completed assert (len(context.argstreams) == CallContinueMessage.max_args_num) self.message_buffer.pop(message.id, None) context.flags = FlagsType.none self.close_argstream(context, dst - 1) return None elif message.message_type == Types.ERROR: context = self.message_buffer.pop(message.id, None) if context is None: log.info('Unconsumed error %s', message) return None else: error = TChannelError.from_code( message.code, description=message.description, tracing=context.tracing, ) context.set_exception(error) return error else: return message
[ "def", "build", "(", "self", ",", "message", ")", ":", "context", "=", "None", "if", "message", ".", "message_type", "in", "[", "Types", ".", "CALL_REQ", ",", "Types", ".", "CALL_RES", "]", ":", "self", ".", "verify_message", "(", "message", ")", "context", "=", "self", ".", "build_context", "(", "message", ")", "# streaming message", "if", "message", ".", "flags", "==", "common", ".", "FlagsType", ".", "fragment", ":", "self", ".", "message_buffer", "[", "message", ".", "id", "]", "=", "context", "# find the incompleted stream", "num", "=", "0", "for", "i", ",", "arg", "in", "enumerate", "(", "context", ".", "argstreams", ")", ":", "if", "arg", ".", "state", "!=", "StreamState", ".", "completed", ":", "num", "=", "i", "break", "self", ".", "close_argstream", "(", "context", ",", "num", ")", "return", "context", "elif", "message", ".", "message_type", "in", "[", "Types", ".", "CALL_REQ_CONTINUE", ",", "Types", ".", "CALL_RES_CONTINUE", "]", ":", "context", "=", "self", ".", "message_buffer", ".", "get", "(", "message", ".", "id", ")", "if", "context", "is", "None", ":", "# missing call msg before continue msg", "raise", "FatalProtocolError", "(", "\"missing call message after receiving continue message\"", ",", "message", ".", "id", ",", ")", "# find the incompleted stream", "dst", "=", "0", "for", "i", ",", "arg", "in", "enumerate", "(", "context", ".", "argstreams", ")", ":", "if", "arg", ".", "state", "!=", "StreamState", ".", "completed", ":", "dst", "=", "i", "break", "try", ":", "self", ".", "verify_message", "(", "message", ")", "except", "InvalidChecksumError", "as", "e", ":", "context", ".", "argstreams", "[", "dst", "]", ".", "set_exception", "(", "e", ")", "raise", "src", "=", "0", "while", "src", "<", "len", "(", "message", ".", "args", ")", ":", "context", ".", "argstreams", "[", "dst", "]", ".", "write", "(", "message", ".", "args", "[", "src", "]", ")", "dst", "+=", "1", "src", "+=", "1", "if", "message", ".", "flags", "!=", "FlagsType", ".", "fragment", ":", "# get last fragment. mark it as completed", "assert", "(", "len", "(", "context", ".", "argstreams", ")", "==", "CallContinueMessage", ".", "max_args_num", ")", "self", ".", "message_buffer", ".", "pop", "(", "message", ".", "id", ",", "None", ")", "context", ".", "flags", "=", "FlagsType", ".", "none", "self", ".", "close_argstream", "(", "context", ",", "dst", "-", "1", ")", "return", "None", "elif", "message", ".", "message_type", "==", "Types", ".", "ERROR", ":", "context", "=", "self", ".", "message_buffer", ".", "pop", "(", "message", ".", "id", ",", "None", ")", "if", "context", "is", "None", ":", "log", ".", "info", "(", "'Unconsumed error %s'", ",", "message", ")", "return", "None", "else", ":", "error", "=", "TChannelError", ".", "from_code", "(", "message", ".", "code", ",", "description", "=", "message", ".", "description", ",", "tracing", "=", "context", ".", "tracing", ",", ")", "context", ".", "set_exception", "(", "error", ")", "return", "error", "else", ":", "return", "message" ]
buffer all the streaming messages based on the message id. Reconstruct all fragments together. :param message: incoming message :return: next complete message or None if streaming is not done
[ "buffer", "all", "the", "streaming", "messages", "based", "on", "the", "message", "id", ".", "Reconstruct", "all", "fragments", "together", "." ]
train
https://github.com/uber/tchannel-python/blob/ee08cce6234f24fd2373774988186dd374306c43/tchannel/tornado/message_factory.py#L226-L309
<|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: buffer all the streaming messages based on the message id. Reconstruct all fragments together. :param message: incoming message :return: next complete message or None if streaming is not done ### Response: def build(self, message): """buffer all the streaming messages based on the message id. Reconstruct all fragments together. :param message: incoming message :return: next complete message or None if streaming is not done """ context = None if message.message_type in [Types.CALL_REQ, Types.CALL_RES]: self.verify_message(message) context = self.build_context(message) # streaming message if message.flags == common.FlagsType.fragment: self.message_buffer[message.id] = context # find the incompleted stream num = 0 for i, arg in enumerate(context.argstreams): if arg.state != StreamState.completed: num = i break self.close_argstream(context, num) return context elif message.message_type in [Types.CALL_REQ_CONTINUE, Types.CALL_RES_CONTINUE]: context = self.message_buffer.get(message.id) if context is None: # missing call msg before continue msg raise FatalProtocolError( "missing call message after receiving continue message", message.id, ) # find the incompleted stream dst = 0 for i, arg in enumerate(context.argstreams): if arg.state != StreamState.completed: dst = i break try: self.verify_message(message) except InvalidChecksumError as e: context.argstreams[dst].set_exception(e) raise src = 0 while src < len(message.args): context.argstreams[dst].write(message.args[src]) dst += 1 src += 1 if message.flags != FlagsType.fragment: # get last fragment. mark it as completed assert (len(context.argstreams) == CallContinueMessage.max_args_num) self.message_buffer.pop(message.id, None) context.flags = FlagsType.none self.close_argstream(context, dst - 1) return None elif message.message_type == Types.ERROR: context = self.message_buffer.pop(message.id, None) if context is None: log.info('Unconsumed error %s', message) return None else: error = TChannelError.from_code( message.code, description=message.description, tracing=context.tracing, ) context.set_exception(error) return error else: return message <|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, 7726, 682, 279, 17265, 6743, 3196, 389, 279, 198, 286, 1984, 887, 13, 1050, 7750, 682, 35603, 3871, 382, 286, 551, 913, 1984, 512, 310, 19957, 1984, 198, 286, 551, 693, 25, 1828, 4686, 1984, 477, 2290, 422, 17265, 198, 310, 374, 539, 2884, 271, 14711, 6075, 512, 755, 1977, 1214, 11, 1984, 997, 286, 4304, 7726, 682, 279, 17265, 6743, 3196, 389, 279, 198, 286, 1984, 887, 13, 1050, 7750, 682, 35603, 3871, 382, 286, 551, 913, 1984, 512, 310, 19957, 1984, 198, 286, 551, 693, 25, 1828, 4686, 1984, 477, 2290, 422, 17265, 198, 310, 374, 539, 2884, 198, 286, 3270, 286, 2317, 284, 2290, 271, 286, 422, 1984, 6837, 1857, 304, 510, 4266, 732, 4006, 31856, 345, 1961, 21431, 732, 4006, 11225, 10556, 310, 659, 28620, 6598, 7483, 696, 310, 2317, 284, 659, 13542, 8634, 7483, 340, 310, 674, 17265, 1984, 198, 310, 422, 1984, 28302, 624, 4279, 52987, 941, 21212, 512, 394, 659, 6837, 7932, 58, 2037, 1801, 60, 284, 2317, 271, 310, 674, 1505, 279, 304, 35835, 4365, 198, 310, 1661, 284, 220, 15, 198, 310, 369, 602, 11, 1417, 304, 13555, 5491, 21875, 62075, 997, 394, 422, 1417, 3551, 976, 9384, 1423, 59163, 512, 504, 1661, 284, 602, 198, 504, 1464, 271, 310, 659, 4757, 6185, 4116, 5491, 11, 1661, 340, 310, 471, 2317, 271, 286, 4508, 1984, 6837, 1857, 304, 510, 4266, 732, 4006, 31856, 80166, 345, 8497, 21431, 732, 4006, 11225, 80166, 10556, 310, 2317, 284, 659, 6837, 7932, 673, 7483, 1801, 340, 310, 422, 2317, 374, 2290, 512, 394, 674, 7554, 1650, 3835, 1603, 3136, 3835, 198, 394, 4933, 66729, 21346, 1480, 1021, 504, 330, 31716, 1650, 1984, 1306, 12588, 3136, 1984, 761, 504, 1984, 1801, 345, 394, 5235, 310, 674, 1505, 279, 304, 35835, 4365, 198, 310, 10875, 284, 220, 15, 198, 310, 369, 602, 11, 1417, 304, 13555, 5491, 21875, 62075, 997, 394, 422, 1417, 3551, 976, 9384, 1423, 59163, 512, 504, 10875, 284, 602, 198, 504, 1464, 271, 310, 1456, 512, 394, 659, 28620, 6598, 7483, 340, 310, 3734, 14204, 74290, 1480, 439, 384, 512, 394, 2317, 21875, 62075, 58, 16032, 948, 751, 17957, 2069, 340, 394, 4933, 271, 310, 2338, 284, 220, 15, 198, 310, 1418, 2338, 366, 2479, 7483, 16769, 997, 394, 2317, 21875, 62075, 58, 16032, 948, 5040, 7483, 16769, 64776, 2608, 394, 10875, 1447, 220, 16, 198, 394, 2338, 1447, 220, 16, 271, 310, 422, 1984, 28302, 976, 34305, 941, 21212, 512, 394, 674, 636, 1566, 12569, 13, 1906, 433, 439, 8308, 198, 394, 2105, 320, 2963, 5491, 21875, 62075, 8, 48861, 667, 7290, 24433, 2097, 6817, 8550, 4369, 340, 394, 659, 6837, 7932, 8452, 7483, 1801, 11, 2290, 340, 394, 2317, 28302, 284, 34305, 941, 53163, 271, 310, 659, 4757, 6185, 4116, 5491, 11, 10875, 482, 220, 16, 340, 310, 471, 2290, 198, 286, 4508, 1984 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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 ]
[ 128000, 27, 91, 2527, 14450, 428, 91, 397, 14711, 30151, 512, 2675, 527, 264, 19903, 4476, 25922, 323, 264, 11190, 15592, 15840, 18328, 13, 20400, 1193, 13325, 2082, 2085, 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 7726, 682, 279, 17265, 6743, 3196, 389, 279, 198, 286, 1984, 887, 13, 1050, 7750, 682, 35603, 3871, 382, 286, 551, 913, 1984, 512, 310, 19957, 1984, 198, 286, 551, 693, 25, 1828, 4686, 1984, 477, 2290, 422, 17265, 198, 310, 374, 539, 2884, 271, 14711, 6075, 512, 755, 1977, 1214, 11, 1984, 997, 286, 4304, 7726, 682, 279, 17265, 6743, 3196, 389, 279, 198, 286, 1984, 887, 13, 1050, 7750, 682, 35603, 3871, 382, 286, 551, 913, 1984, 512, 310, 19957, 1984, 198, 286, 551, 693, 25, 1828, 4686, 1984, 477, 2290, 422, 17265, 198, 310, 374, 539, 2884, 198, 286, 3270, 286, 2317, 284, 2290, 271, 286, 422, 1984, 6837, 1857, 304, 510, 4266, 732, 4006, 31856, 345, 1961, 21431, 732, 4006, 11225, 10556, 310, 659, 28620, 6598, 7483, 696, 310, 2317, 284, 659, 13542, 8634, 7483, 340, 310, 674, 17265, 1984, 198, 310, 422, 1984, 28302, 624, 4279, 52987, 941, 21212, 512, 394, 659, 6837, 7932, 58, 2037, 1801, 60, 284, 2317, 271, 310, 674, 1505, 279, 304, 35835, 4365, 198, 310, 1661, 284, 220, 15, 198, 310, 369, 602, 11, 1417, 304, 13555, 5491, 21875, 62075, 997, 394, 422, 1417, 3551, 976, 9384, 1423, 59163, 512, 504, 1661, 284, 602, 198, 504, 1464, 271, 310, 659, 4757, 6185, 4116, 5491, 11, 1661, 340, 310, 471, 2317, 271, 286, 4508, 1984, 6837, 1857, 304, 510, 4266, 732, 4006, 31856, 80166, 345, 8497, 21431, 732, 4006, 11225, 80166, 10556, 310, 2317, 284, 659, 6837, 7932, 673, 7483, 1801, 340, 310, 422, 2317, 374, 2290, 512, 394, 674, 7554, 1650, 3835, 1603, 3136, 3835, 198, 394, 4933, 66729, 21346, 1480, 1021, 504, 330, 31716, 1650, 1984, 1306, 12588, 3136, 1984, 761, 504, 1984, 1801, 345, 394, 5235, 310, 674, 1505, 279, 304, 35835, 4365, 198, 310, 10875, 284, 220, 15, 198, 310, 369, 602, 11, 1417, 304, 13555, 5491, 21875, 62075, 997, 394, 422, 1417, 3551, 976, 9384, 1423, 59163, 512, 504, 10875, 284, 602, 198, 504, 1464, 271, 310, 1456, 512, 394, 659, 28620, 6598, 7483, 340, 310, 3734, 14204, 74290, 1480, 439, 384, 512, 394, 2317, 21875, 62075, 58, 16032, 948, 751, 17957, 2069, 340, 394, 4933, 271, 310, 2338, 284, 220, 15, 198, 310, 1418, 2338, 366, 2479, 7483, 16769, 997, 394, 2317, 21875, 62075, 58, 16032, 948, 5040, 7483, 16769, 64776, 2608, 394, 10875, 1447, 220, 16, 198, 394, 2338, 1447, 220, 16, 271, 310, 422, 1984, 28302, 976, 34305, 941, 21212, 512, 394, 674, 636, 1566, 12569, 13, 1906, 433, 439, 8308, 198, 394, 2105, 320, 2963, 5491, 21875, 62075, 8, 48861, 667, 7290, 24433, 2097, 6817, 8550, 4369, 340, 394, 659, 6837, 7932, 8452, 7483, 1801, 11, 2290, 340, 394, 2317, 28302, 284, 34305, 941, 53163, 271, 310, 659, 4757, 6185, 4116, 5491, 11, 10875, 482, 220, 16, 340, 310, 471, 2290, 198, 286, 4508, 1984 ]
geertj/gruvi
lib/gruvi/http.py
HttpRequest.end_request
def end_request(self): """End the request body.""" if not self._chunked: return trailers = [(n, get_header(self._headers, n)) for n in self._trailer] \ if self._trailer else None ending = create_chunked_body_end(trailers) self._protocol.writer.write(ending)
python
def end_request(self): """End the request body.""" if not self._chunked: return trailers = [(n, get_header(self._headers, n)) for n in self._trailer] \ if self._trailer else None ending = create_chunked_body_end(trailers) self._protocol.writer.write(ending)
[ "def", "end_request", "(", "self", ")", ":", "if", "not", "self", ".", "_chunked", ":", "return", "trailers", "=", "[", "(", "n", ",", "get_header", "(", "self", ".", "_headers", ",", "n", ")", ")", "for", "n", "in", "self", ".", "_trailer", "]", "if", "self", ".", "_trailer", "else", "None", "ending", "=", "create_chunked_body_end", "(", "trailers", ")", "self", ".", "_protocol", ".", "writer", ".", "write", "(", "ending", ")" ]
End the request body.
[ "End", "the", "request", "body", "." ]
train
https://github.com/geertj/gruvi/blob/1d77ca439600b6ea7a19aa1ee85dca0f3be3f3f8/lib/gruvi/http.py#L600-L607
<|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: End the request body. ### Response: def end_request(self): """End the request body.""" if not self._chunked: return trailers = [(n, get_header(self._headers, n)) for n in self._trailer] \ if self._trailer else None ending = create_chunked_body_end(trailers) self._protocol.writer.write(ending) <|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, 3812, 279, 1715, 2547, 382, 14711, 6075, 512, 755, 842, 8052, 1214, 997, 286, 4304, 3812, 279, 1715, 2547, 14781, 286, 422, 539, 659, 1462, 27069, 291, 512, 310, 471, 198, 286, 50805, 284, 18305, 77, 11, 636, 8932, 1214, 1462, 7869, 11, 308, 595, 369, 308, 304, 659, 1462, 376, 39882, 60, 3120, 667, 422, 659, 1462, 376, 39882, 775, 2290, 198, 286, 13696, 284, 1893, 31639, 291, 14446, 6345, 7779, 607, 388, 340, 286, 659, 1462, 17447, 31932, 3921, 7, 2518, 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 ]
[ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 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, 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 41941, 13, 40633, 1193, 304, 6498, 382, 14711, 5546, 512, 3812, 279, 1715, 2547, 382, 14711, 6075, 512, 755, 842, 8052, 1214, 997, 286, 4304, 3812, 279, 1715, 2547, 14781, 286, 422, 539, 659, 1462, 27069, 291, 512, 310, 471, 198, 286, 50805, 284, 18305, 77, 11, 636, 8932, 1214, 1462, 7869, 11, 308, 595, 369, 308, 304, 659, 1462, 376, 39882, 60, 3120, 667, 422, 659, 1462, 376, 39882, 775, 2290, 198, 286, 13696, 284, 1893, 31639, 291, 14446, 6345, 7779, 607, 388, 340, 286, 659, 1462, 17447, 31932, 3921, 7, 2518, 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 ]