code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def iter_rows(self, start=None, end=None): start = start or 0 end = end or self.nrows for i in range(start, end): yield self.iloc[i, :]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iter_rows'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '18', '26']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '17'], 'value': 'or'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '21', 'type': 'boolean_operator', 'children': ['22', '23'], 'value': 'or'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'nrows'}; {'id': '26', 'type': 'for_statement', 'children': ['27', '28', '33']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'yield', 'children': ['36']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40', '41']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'iloc'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '41', 'type': 'slice', 'children': ['42']}; {'id': '42', 'type': 'colon', 'children': []}
Iterate each of the Region rows in this region
def debug(self, key): return (not self.quiet and not self.debug_none and (self.debug_all or getattr(self, "debug_%s" % key)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'debug'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': '()', 'children': ['9']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '19'], 'value': 'and'}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '15'], 'value': 'and'}; {'id': '11', 'type': 'not_operator', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'quiet'}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'debug_none'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'boolean_operator', 'children': ['21', '24'], 'value': 'or'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'debug_all'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '30'], 'value': '%'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"debug_%s"'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'key'}
Returns True if the debug setting is enabled.
def logs(self): for record in self.history: if (record["when"] >= self.options.since.date and record["when"] < self.options.until.date): for change in record["changes"]: yield record["who"], change
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'logs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'history'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '37']}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '26'], 'value': 'and'}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '19'], 'value': '>='}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"when"'}; {'id': '19', 'type': 'attribute', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'since'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '30'], 'value': '<'}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"when"'}; {'id': '30', 'type': 'attribute', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'until'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'date'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'for_statement', 'children': ['39', '40', '43']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'change'}; {'id': '40', 'type': 'subscript', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"changes"'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'yield', 'children': ['46']}; {'id': '46', 'type': 'expression_list', 'children': ['47', '50']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"who"'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'change'}
Return relevant who-did-what pairs from the bug history
def _remap_tag_to_tag_id(cls, tag, new_data): try: value = new_data[tag] except: return tag_id = tag + '_id' try: new_data[tag_id] = value['id'] except: try: new_data[tag_id] = value.id except AttributeError: new_data[tag_id] = value del new_data[tag]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_remap_tag_to_tag_id'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '7', 'type': 'block', 'children': ['8', '19', '25', '56']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '16']}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '13', 'type': 'subscript', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '16', 'type': 'except_clause', 'children': ['17']}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': []}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tag_id'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '+'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'_id'"}; {'id': '25', 'type': 'try_statement', 'children': ['26', '35']}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tag_id'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '35', 'type': 'except_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'try_statement', 'children': ['38', '47']}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'tag_id'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '47', 'type': 'except_clause', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'tag_id'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '56', 'type': 'delete_statement', 'children': ['57']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'tag'}
Remaps a given changed field from tag to tag_id.
def task_detail(job_id=None, task_name=None): jobs = get_jobs() job = [job for job in jobs if str(job['job_id']) == job_id][0] return render_template('task_detail.html', job=job, task_name=task_name, task=[task for task in job['tasks'] if task['name'] == task_name][0])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'task_detail'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'job_id'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'task_name'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '17', '36']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get_jobs'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '20', 'type': 'subscript', 'children': ['21', '35']}; {'id': '21', 'type': 'list_comprehension', 'children': ['22', '23', '26']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '23', 'type': 'for_in_clause', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'jobs'}; {'id': '26', 'type': 'if_clause', 'children': ['27']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '34'], 'value': '=='}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'job_id'"}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'job_id'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'render_template'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41', '44', '47']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'task_detail.html'"}; {'id': '41', 'type': 'keyword_argument', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '44', 'type': 'keyword_argument', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'task_name'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'task_name'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '49', 'type': 'subscript', 'children': ['50', '63']}; {'id': '50', 'type': 'list_comprehension', 'children': ['51', '52', '57']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '52', 'type': 'for_in_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'job'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'tasks'"}; {'id': '57', 'type': 'if_clause', 'children': ['58']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '62'], 'value': '=='}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'task'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'task_name'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '0'}
Show a detailed description of a specific task.
def run(self, matches): def _run(matches): group_starting_pos = 0 for current_pos, (group_length, group_function) in enumerate(zip(self.group_lengths, self.group_functions)): start_pos = current_pos + group_starting_pos end_pos = current_pos + group_starting_pos + group_length yield group_function(matches[start_pos:end_pos]) group_starting_pos += group_length - 1 return self.final_function(list(_run(matches)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '6', 'type': 'block', 'children': ['7', '66']}; {'id': '7', 'type': 'function_definition', 'children': ['8', '9', '11']}; {'id': '8', 'type': 'function_name', 'children': [], 'value': '_run'}; {'id': '9', 'type': 'parameters', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '11', 'type': 'block', 'children': ['12', '16']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'group_starting_pos'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '16', 'type': 'for_statement', 'children': ['17', '22', '34']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'current_pos'}; {'id': '19', 'type': 'tuple_pattern', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'group_length'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'group_function'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'group_lengths'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'group_functions'}; {'id': '34', 'type': 'block', 'children': ['35', '41', '49', '60']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'start_pos'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '+'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'current_pos'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'group_starting_pos'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'end_pos'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '48'], 'value': '+'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47'], 'value': '+'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'current_pos'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'group_starting_pos'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'group_length'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'yield', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'group_function'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '56', 'type': 'slice', 'children': ['57', '58', '59']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'start_pos'}; {'id': '58', 'type': 'colon', 'children': []}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'end_pos'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'augmented_assignment', 'children': ['62', '63'], 'value': '+='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'group_starting_pos'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '-'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'group_length'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'final_function'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_run'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'matches'}
Run group functions over matches
def value_for_key(membersuite_object_data, key): key_value_dicts = { d['Key']: d['Value'] for d in membersuite_object_data["Fields"]["KeyValueOfstringanyType"]} return key_value_dicts[key]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'value_for_key'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'membersuite_object_data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'block', 'children': ['7', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'key_value_dicts'}; {'id': '10', 'type': 'dictionary_comprehension', 'children': ['11', '18']}; {'id': '11', 'type': 'pair', 'children': ['12', '15']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'Key'"}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '17', 'type': 'string', 'children': [], 'value': "'Value'"}; {'id': '18', 'type': 'for_in_clause', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '20', 'type': 'subscript', 'children': ['21', '24']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'membersuite_object_data'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"Fields"'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"KeyValueOfstringanyType"'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'key_value_dicts'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'key'}
Return the value for `key` of membersuite_object_data.
def rotateX(self, angle): rad = angle * math.pi / 180 cosa = math.cos(rad) sina = math.sin(rad) y = self.y * cosa - self.z * sina z = self.y * sina + self.z * cosa return Point3D(self.x, y, z)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rotateX'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '26', '35', '49', '63']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'rad'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '16'], 'value': '/'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '13'], 'value': '*'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'pi'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '180'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'cosa'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cos'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'rad'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sina'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sin'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'rad'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '44'], 'value': '-'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '43'], 'value': '*'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'cosa'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '48'], 'value': '*'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'sina'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '58'], 'value': '+'}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '57'], 'value': '*'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'sina'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '62'], 'value': '*'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'z'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'cosa'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'Point3D'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '70', '71']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'z'}
Rotates the point around the X axis by the given angle in degrees.
def send_invitation(request, project_id=None): project = None if project_id is not None: project = get_object_or_404(Project, id=project_id) if project is None: if not is_admin(request): return HttpResponseForbidden('<h1>Access Denied</h1>') else: if not project.can_edit(request): return HttpResponseForbidden('<h1>Access Denied</h1>') return _send_invitation(request, project)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'send_invitation'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '13', '28', '61']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'is not'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'get_object_or_404'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Project'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'project_id'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32', '45']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': 'is'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'if_statement', 'children': ['34', '39']}; {'id': '34', 'type': 'not_operator', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'is_admin'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'HttpResponseForbidden'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'<h1>Access Denied</h1>'"}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'if_statement', 'children': ['48', '55']}; {'id': '48', 'type': 'not_operator', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'can_edit'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'HttpResponseForbidden'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'<h1>Access Denied</h1>'"}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_send_invitation'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'project'}
The logged in project leader wants to invite somebody to their project.
def iter_components(self): names = self.list_components() for name in names: yield self.get_component(name)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'iter_components'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'list_components'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'for_statement', 'children': ['15', '16', '17']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'yield', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_component'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'name'}
Iterate over all defined components yielding IOTile objects.
def CollectionItemToClientPath(item, client_id=None): if isinstance(item, rdf_flows.GrrMessage): client_id = item.source item = item.payload elif isinstance(item, rdf_flow_objects.FlowResult): client_id = item.client_id item = item.payload if client_id is None: raise ValueError("Could not determine client_id.") elif isinstance(client_id, rdfvalue.RDFURN): client_id = client_id.Basename() if isinstance(item, rdf_client_fs.StatEntry): return db.ClientPath.FromPathSpec(client_id, item.pathspec) elif isinstance(item, rdf_file_finder.FileFinderResult): return db.ClientPath.FromPathSpec(client_id, item.stat_entry.pathspec) elif isinstance(item, collectors.ArtifactFilesDownloaderResult): if item.HasField("downloaded_file"): return db.ClientPath.FromPathSpec(client_id, item.downloaded_file.pathspec) raise ItemNotExportableError(item)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'CollectionItemToClientPath'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '51', '78', '153']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '17', '30']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'rdf_flows'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'GrrMessage'}; {'id': '17', 'type': 'block', 'children': ['18', '24']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '30', 'type': 'elif_clause', 'children': ['31', '38']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'rdf_flow_objects'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'FlowResult'}; {'id': '38', 'type': 'block', 'children': ['39', '45']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '55', '61']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': 'is'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '54', 'type': 'None', 'children': []}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'raise_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'string', 'children': [], 'value': '"Could not determine client_id."'}; {'id': '61', 'type': 'elif_clause', 'children': ['62', '69']}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'rdfvalue'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'RDFURN'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'Basename'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'if_statement', 'children': ['79', '86', '99', '122']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '81', 'type': 'argument_list', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'rdf_client_fs'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'StatEntry'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'return_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '94']}; {'id': '89', 'type': 'attribute', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ClientPath'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'FromPathSpec'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'pathspec'}; {'id': '99', 'type': 'elif_clause', 'children': ['100', '107']}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'rdf_file_finder'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'FileFinderResult'}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '115']}; {'id': '110', 'type': 'attribute', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ClientPath'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'FromPathSpec'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '117', 'type': 'attribute', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'stat_entry'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'pathspec'}; {'id': '122', 'type': 'elif_clause', 'children': ['123', '130']}; {'id': '123', 'type': 'call', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'collectors'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'ArtifactFilesDownloaderResult'}; {'id': '130', 'type': 'block', 'children': ['131']}; {'id': '131', 'type': 'if_statement', 'children': ['132', '138']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'HasField'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'string', 'children': [], 'value': '"downloaded_file"'}; {'id': '138', 'type': 'block', 'children': ['139']}; {'id': '139', 'type': 'return_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '146']}; {'id': '141', 'type': 'attribute', 'children': ['142', '145']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'ClientPath'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'FromPathSpec'}; {'id': '146', 'type': 'argument_list', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '148', 'type': 'attribute', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'downloaded_file'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'pathspec'}; {'id': '153', 'type': 'raise_statement', 'children': ['154']}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'ItemNotExportableError'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'item'}
Converts given RDFValue to a ClientPath of a file to be downloaded.
def choices(klass): _choices = [] for attr in user_attributes(klass.Meta): val = getattr(klass.Meta, attr) setattr(klass, attr, val[0]) _choices.append((val[0], val[1])) setattr(klass, 'CHOICES', tuple(_choices)) return klass
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'choices'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '51', '61']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_choices'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '18']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'user_attributes'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Meta'}; {'id': '18', 'type': 'block', 'children': ['19', '29', '38']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'Meta'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_choices'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'tuple', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '47', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56', '57']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'klass'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'CHOICES'"}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_choices'}; {'id': '61', 'type': 'return_statement', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'klass'}
Decorator to set `CHOICES` and other attributes
def _ratio_scores(parameters_value, clusteringmodel_gmm_good, clusteringmodel_gmm_bad): ratio = clusteringmodel_gmm_good.score([parameters_value]) / clusteringmodel_gmm_bad.score([parameters_value]) sigma = 0 return ratio, sigma
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_ratio_scores'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'parameters_value'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'clusteringmodel_gmm_good'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'clusteringmodel_gmm_bad'}; {'id': '7', 'type': 'block', 'children': ['8', '26', '30']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'ratio'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '19'], 'value': '/'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'clusteringmodel_gmm_good'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'score'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'list', 'children': ['18'], 'value': '[parameters_value]'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parameters_value'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'clusteringmodel_gmm_bad'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'score'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'list', 'children': ['25'], 'value': '[parameters_value]'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'parameters_value'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sigma'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'expression_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ratio'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sigma'}
The ratio is smaller the better
def check_cups_allowed(func): @wraps(func) def decorator(*args, **kwargs): cups = kwargs.get('cups') if (cups and current_user.is_authenticated() and not current_user.allowed(cups, 'cups')): return current_app.login_manager.unauthorized() return func(*args, **kwargs) return decorator
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_cups_allowed'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '64']}; {'id': '6', 'type': 'decorated_definition', 'children': ['7', '12']}; {'id': '7', 'type': 'decorator', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'wraps'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '12', 'type': 'function_definition', 'children': ['13', '14', '19']}; {'id': '13', 'type': 'function_name', 'children': [], 'value': 'decorator'}; {'id': '14', 'type': 'parameters', 'children': ['15', '17']}; {'id': '15', 'type': 'list_splat_pattern', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '17', 'type': 'dictionary_splat_pattern', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '19', 'type': 'block', 'children': ['20', '29', '56']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cups'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'cups'"}; {'id': '29', 'type': 'if_statement', 'children': ['30', '47']}; {'id': '30', 'type': '()', 'children': ['31']}; {'id': '31', 'type': 'boolean_operator', 'children': ['32', '39'], 'value': 'and'}; {'id': '32', 'type': 'boolean_operator', 'children': ['33', '34'], 'value': 'and'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cups'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'current_user'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'is_authenticated'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'current_user'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'allowed'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'cups'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'cups'"}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'login_manager'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'unauthorized'}; {'id': '55', 'type': 'argument_list', 'children': []}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '62']}; {'id': '60', 'type': 'list_splat', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '62', 'type': 'dictionary_splat', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'decorator'}
Check if CUPS is allowd by token
def Flow(self, flow_id): return flow.FlowRef( client_id=self.client_id, flow_id=flow_id, context=self._context)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'Flow'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'flow_id'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'flow'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'FlowRef'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '18', '21']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'flow_id'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'flow_id'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_context'}
Return a reference to a flow with a given id on this client.
def _validate_args(self, args): assert(args.bucket) if args.subscribers: for _subscriber in args.subscribers: assert(isinstance(_subscriber, AsperaBaseSubscriber)) if (args.transfer_config): assert(isinstance(args.transfer_config, AsperaConfig)) if args.transfer_config.multi_session > self._config.ascp_max_concurrent: raise ValueError("Max sessions is %d" % self._config.ascp_max_concurrent) for _pair in args.file_pair_list: if not _pair.key or not _pair.fileobj: raise ValueError("Invalid file pair")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_validate_args'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '12', '30', '69']}; {'id': '7', 'type': 'assert_statement', 'children': ['8']}; {'id': '8', 'type': '()', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'bucket'}; {'id': '12', 'type': 'if_statement', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'subscribers'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '22']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_subscriber'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'subscribers'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'assert_statement', 'children': ['24']}; {'id': '24', 'type': '()', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_subscriber'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'AsperaBaseSubscriber'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '35']}; {'id': '31', 'type': '()', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'transfer_config'}; {'id': '35', 'type': 'block', 'children': ['36', '45']}; {'id': '36', 'type': 'assert_statement', 'children': ['37']}; {'id': '37', 'type': '()', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'transfer_config'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'AsperaConfig'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '57']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '52'], 'value': '>'}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'transfer_config'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'multi_session'}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_config'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ascp_max_concurrent'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'raise_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '%'}; {'id': '63', 'type': 'string', 'children': [], 'value': '"Max sessions is %d"'}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_config'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ascp_max_concurrent'}; {'id': '69', 'type': 'for_statement', 'children': ['70', '71', '74']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_pair'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'file_pair_list'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'if_statement', 'children': ['76', '85']}; {'id': '76', 'type': 'boolean_operator', 'children': ['77', '81'], 'value': 'or'}; {'id': '77', 'type': 'not_operator', 'children': ['78']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '_pair'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '81', 'type': 'not_operator', 'children': ['82']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': '_pair'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'fileobj'}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'raise_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'string', 'children': [], 'value': '"Invalid file pair"'}
validate the user arguments
def spawn_managed_host(config_file, manager, connect_on_start=True): data = manager.request_host_status(config_file) is_running = data['started'] if is_running: host_status = json.loads(data['host']['output']) logfile = data['host']['logfile'] else: data = manager.start_host(config_file) host_status = json.loads(data['output']) logfile = data['logfile'] host = JSHost( status=host_status, logfile=logfile, config_file=config_file, manager=manager ) if not is_running and settings.VERBOSITY >= verbosity.PROCESS_START: print('Started {}'.format(host.get_name())) if connect_on_start: host.connect() return host
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spawn_managed_host'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config_file'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'connect_on_start'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '19', '25', '77', '95', '121', '130']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'request_host_status'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'config_file'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'is_running'}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'started'"}; {'id': '25', 'type': 'if_statement', 'children': ['26', '27', '49']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'is_running'}; {'id': '27', 'type': 'block', 'children': ['28', '41']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'host_status'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'host'"}; {'id': '40', 'type': 'string', 'children': [], 'value': "'output'"}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '44', 'type': 'subscript', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '47', 'type': 'string', 'children': [], 'value': "'host'"}; {'id': '48', 'type': 'string', 'children': [], 'value': "'logfile'"}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'id': '50', 'type': 'block', 'children': ['51', '60', '71']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'start_host'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'config_file'}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'host_status'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '70', 'type': 'string', 'children': [], 'value': "'output'"}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'logfile'"}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'JSHost'}; {'id': '82', 'type': 'argument_list', 'children': ['83', '86', '89', '92']}; {'id': '83', 'type': 'keyword_argument', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'host_status'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'logfile'}; {'id': '89', 'type': 'keyword_argument', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'config_file'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'config_file'}; {'id': '92', 'type': 'keyword_argument', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'manager'}; {'id': '95', 'type': 'if_statement', 'children': ['96', '106']}; {'id': '96', 'type': 'boolean_operator', 'children': ['97', '99'], 'value': 'and'}; {'id': '97', 'type': 'not_operator', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'is_running'}; {'id': '99', 'type': 'comparison_operator', 'children': ['100', '103'], 'value': '>='}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'VERBOSITY'}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'PROCESS_START'}; {'id': '106', 'type': 'block', 'children': ['107']}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'string', 'children': [], 'value': "'Started {}'"}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'call', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'get_name'}; {'id': '120', 'type': 'argument_list', 'children': []}; {'id': '121', 'type': 'if_statement', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'connect_on_start'}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '129', 'type': 'argument_list', 'children': []}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'host'}
Spawns a managed host, if it is not already running
def input_to_phase(data, rate, data_type): if data_type == "phase": return data elif data_type == "freq": return frequency2phase(data, rate) else: raise Exception("unknown data_type: " + data_type)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'input_to_phase'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'rate'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12', '15', '26']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': '=='}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"phase"'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '15', 'type': 'elif_clause', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': '=='}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"freq"'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'frequency2phase'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'rate'}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'raise_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '+'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"unknown data_type: "'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'data_type'}
Take either phase or frequency as input and return phase
def setnx(self, key, value): return self.set(key, value, nx=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setnx'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'nx'}; {'id': '18', 'type': 'True', 'children': []}
Set the value of ``key`` to ``value`` if key doesn't exist
def close(self): close_command = StandardSend(self._address, COMMAND_LIGHT_OFF_0X13_0X00) self._send_method(close_command, self._close_message_received)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'close'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'close_command'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'StandardSend'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_address'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'COMMAND_LIGHT_OFF_0X13_0X00'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_send_method'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'close_command'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_close_message_received'}
Send CLOSE command to device.
def path_exists(self, path, follow_symlinks=True): "test if path exists" return ( self.file_exists(path, follow_symlinks) or self.symlink_exists(path, follow_symlinks) or self.directory_exists(path, follow_symlinks) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'path_exists'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'follow_symlinks'}; {'id': '8', 'type': 'True', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '12']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"test if path exists"'}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '30'], 'value': 'or'}; {'id': '15', 'type': 'boolean_operator', 'children': ['16', '23'], 'value': 'or'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'file_exists'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'follow_symlinks'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'symlink_exists'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'follow_symlinks'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'directory_exists'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'follow_symlinks'}
test if path exists
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)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'end_request'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '37', '44']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_chunked'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'trailers'}; {'id': '16', 'type': 'conditional_expression', 'children': ['17', '32', '33', '36'], 'value': 'if'}; {'id': '17', 'type': 'list_comprehension', 'children': ['18', '27']}; {'id': '18', 'type': 'tuple', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get_header'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_headers'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '27', 'type': 'for_in_clause', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_trailer'}; {'id': '32', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_trailer'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ending'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'create_chunked_body_end'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'trailers'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '53']}; {'id': '46', 'type': 'attribute', 'children': ['47', '52']}; {'id': '47', 'type': 'attribute', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_protocol'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'writer'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ending'}
End the request body.
def diffpow(self, x, rot=0): N = len(x) if rot: x = rotate(x) return sum(np.abs(x)**(2. + 4.*np.arange(N) / (N - 1.)))**0.5
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'diffpow'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'rot'}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '9', 'type': 'block', 'children': ['10', '17', '27']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rot'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'rotate'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'binary_operator', 'children': ['29', '55'], 'value': '**'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '39'], 'value': '**'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '39', 'type': '()', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '+'}; {'id': '41', 'type': 'float', 'children': [], 'value': '2.'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '51'], 'value': '/'}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '*'}; {'id': '44', 'type': 'float', 'children': [], 'value': '4.'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'arange'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '51', 'type': '()', 'children': ['52']}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '54'], 'value': '-'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '54', 'type': 'float', 'children': [], 'value': '1.'}; {'id': '55', 'type': 'float', 'children': [], 'value': '0.5'}
Diffpow test objective function
def postprocessor(prediction): prediction = prediction.data.numpy()[0] top_predictions = prediction.argsort()[-3:][::-1] return [labels[prediction] for prediction in top_predictions]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'postprocessor'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '37']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '9', 'type': 'subscript', 'children': ['10', '17']}; {'id': '10', 'type': 'call', 'children': ['11', '16']}; {'id': '11', 'type': 'attribute', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'numpy'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'top_predictions'}; {'id': '21', 'type': 'subscript', 'children': ['22', '32']}; {'id': '22', 'type': 'subscript', 'children': ['23', '28']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'argsort'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'slice', 'children': ['29', '31']}; {'id': '29', 'type': 'unary_operator', 'children': ['30'], 'value': '-'}; {'id': '30', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '31', 'type': 'colon', 'children': []}; {'id': '32', 'type': 'slice', 'children': ['33', '34', '35']}; {'id': '33', 'type': 'colon', 'children': []}; {'id': '34', 'type': 'colon', 'children': []}; {'id': '35', 'type': 'unary_operator', 'children': ['36'], 'value': '-'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'list_comprehension', 'children': ['39', '42']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'labels'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '42', 'type': 'for_in_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'prediction'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'top_predictions'}
Map prediction tensor to labels.
def order_module_dependencies(modules, parser): result = [] for modk in modules: if modk not in result: result.append(modk) recursed = list(result) for i in range(len(result)): module = result[i] _process_module_order(parser, module, i, recursed) return recursed
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'order_module_dependencies'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '27', '34', '58']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '10', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '11', 'type': 'for_statement', 'children': ['12', '13', '14']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'modk'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '19']}; {'id': '16', 'type': 'comparison_operator', 'children': ['17', '18'], 'value': 'not in'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'modk'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'modk'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'recursed'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '34', 'type': 'for_statement', 'children': ['35', '36', '43']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '43', 'type': 'block', 'children': ['44', '50']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '_process_module_order'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55', '56', '57']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'module'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'recursed'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'recursed'}
Orders the specified list of modules based on their inter-dependencies.
def remove_spin(self): for site in self.sites: new_sp = collections.defaultdict(float) for sp, occu in site.species.items(): oxi_state = getattr(sp, "oxi_state", None) new_sp[Specie(sp.symbol, oxidation_state=oxi_state)] += occu site.species = new_sp
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_spin'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'site'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sites'}; {'id': '11', 'type': 'block', 'children': ['12', '21', '56']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'new_sp'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'collections'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'defaultdict'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '25', '32']}; {'id': '22', 'type': 'pattern_list', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'occu'}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'site'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'species'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33', '42']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'oxi_state'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40', '41']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"oxi_state"'}; {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'augmented_assignment', 'children': ['44', '55'], 'value': '+='}; {'id': '44', 'type': 'subscript', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'new_sp'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'Specie'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'symbol'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'oxidation_state'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'oxi_state'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'occu'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'site'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'species'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'new_sp'}
Removes spin states from a structure.
def find_lt(a, x): i = bisect.bisect_left(a, x) if i: return a[i-1] raise ValueError
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_lt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '26']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bisect'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'bisect_left'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '17', 'type': 'if_statement', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '-'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'raise_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'ValueError'}
Find rightmost value less than x
def build_tree(self, name, props, resource_name=None): n = Node(name, props, resource_name) prop_type_list = self._get_type_list(props) if not prop_type_list: return n prop_type_list = sorted(prop_type_list) for prop_name in prop_type_list: if prop_name == 'Tag': continue child = self.build_tree(prop_name, self.properties[prop_name]) if child is not None: n.add_child(child) return n
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_tree'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'props'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'resource_name'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '20', '29', '35', '42', '78']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Node'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'props'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'resource_name'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'prop_type_list'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_get_type_list'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'props'}; {'id': '29', 'type': 'if_statement', 'children': ['30', '32']}; {'id': '30', 'type': 'not_operator', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'prop_type_list'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'prop_type_list'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'prop_type_list'}; {'id': '42', 'type': 'for_statement', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'prop_name'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'prop_type_list'}; {'id': '45', 'type': 'block', 'children': ['46', '52', '66']}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': '=='}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'prop_name'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'Tag'"}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'continue_statement', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'build_tree'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'prop_name'}; {'id': '61', 'type': 'subscript', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'prop_name'}; {'id': '66', 'type': 'if_statement', 'children': ['67', '70']}; {'id': '67', 'type': 'comparison_operator', 'children': ['68', '69'], 'value': 'is not'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '69', 'type': 'None', 'children': []}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'add_child'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'child'}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'n'}
Build a tree of non-primitive typed dependency order.
def after_scenario(context, scenario): os.chdir(context.old_cwd) context.directory.cleanup()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'after_scenario'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'scenario'}; {'id': '6', 'type': 'block', 'children': ['7', '16']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'chdir'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'old_cwd'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '23']}; {'id': '18', 'type': 'attribute', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'directory'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cleanup'}; {'id': '23', 'type': 'argument_list', 'children': []}
Leave the environment fresh after each scenario.
async def list(source): result = [] async with streamcontext(source) as streamer: async for item in streamer: result.append(item) yield result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '32']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'with_statement', 'children': ['11', '20']}; {'id': '11', 'type': 'with_clause', 'children': ['12']}; {'id': '12', 'type': 'with_item', 'children': ['13']}; {'id': '13', 'type': 'as_pattern', 'children': ['14', '18']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'streamcontext'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '18', 'type': 'as_pattern_target', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'streamer'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'streamer'}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'yield', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'result'}
Generate a single list from an asynchronous sequence.
def unpause_trial(self, trial): assert trial.status == Trial.PAUSED, trial.status self.set_status(trial, Trial.PENDING)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unpause_trial'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'trial'}; {'id': '6', 'type': 'block', 'children': ['7', '18']}; {'id': '7', 'type': 'assert_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': '=='}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'trial'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Trial'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'PAUSED'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'trial'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'set_status'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'trial'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Trial'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'PENDING'}
Sets PAUSED trial to pending to allow scheduler to start.
def _wmi_to_ts(self, wmi_ts): year, month, day, hour, minute, second, microsecond, tz = to_time(wmi_ts) tz_delta = timedelta(minutes=int(tz)) if '+' in wmi_ts: tz_delta = -tz_delta dt = ( datetime(year=year, month=month, day=day, hour=hour, minute=minute, second=second, microsecond=microsecond) + tz_delta ) return int(calendar.timegm(dt.timetuple()))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_wmi_to_ts'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'wmi_ts'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '34', '44', '74']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '18']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11', '12', '13', '14', '15', '16', '17']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'hour'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'minute'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'second'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'microsecond'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'to_time'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'wmi_ts'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tz_delta'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'minutes'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'tz'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'in'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'+'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'wmi_ts'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'tz_delta'}; {'id': '42', 'type': 'unary_operator', 'children': ['43'], 'value': '-'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'tz_delta'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '47', 'type': '()', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '73'], 'value': '+'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '55', '58', '61', '64', '67', '70']}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'hour'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'hour'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'minute'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'minute'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'second'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'second'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'microsecond'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'microsecond'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'tz_delta'}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'calendar'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'timegm'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'timetuple'}; {'id': '87', 'type': 'argument_list', 'children': []}
Convert a wmi formatted timestamp into an epoch.
def find_link(cls, plot, link=None): registry = Link.registry.items() for source in plot.link_sources: if link is None: links = [ l for src, links in registry for l in links if src is source or (src._plot_id is not None and src._plot_id == source._plot_id)] if links: return (plot, links) else: if ((link.target is source) or (link.target is not None and link.target._plot_id is not None and link.target._plot_id == source._plot_id)): return (plot, [link])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_link'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '20']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '13', 'type': 'call', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Link'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '25']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'link_sources'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30', '70']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31', '63']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '34', 'type': 'list_comprehension', 'children': ['35', '36', '41', '44']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '36', 'type': 'for_in_clause', 'children': ['37', '40']}; {'id': '37', 'type': 'pattern_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '41', 'type': 'for_in_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '44', 'type': 'if_clause', 'children': ['45']}; {'id': '45', 'type': 'boolean_operator', 'children': ['46', '49'], 'value': 'or'}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'is'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '49', 'type': '()', 'children': ['50']}; {'id': '50', 'type': 'boolean_operator', 'children': ['51', '56'], 'value': 'and'}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '55'], 'value': 'is not'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_plot_id'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '60'], 'value': '=='}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': '_plot_id'}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_plot_id'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'tuple', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'links'}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'if_statement', 'children': ['73', '105']}; {'id': '73', 'type': '()', 'children': ['74']}; {'id': '74', 'type': 'boolean_operator', 'children': ['75', '81'], 'value': 'or'}; {'id': '75', 'type': '()', 'children': ['76']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '80'], 'value': 'is'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '81', 'type': '()', 'children': ['82']}; {'id': '82', 'type': 'boolean_operator', 'children': ['83', '96'], 'value': 'and'}; {'id': '83', 'type': 'boolean_operator', 'children': ['84', '89'], 'value': 'and'}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '88'], 'value': 'is not'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '88', 'type': 'None', 'children': []}; {'id': '89', 'type': 'comparison_operator', 'children': ['90', '95'], 'value': 'is not'}; {'id': '90', 'type': 'attribute', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_plot_id'}; {'id': '95', 'type': 'None', 'children': []}; {'id': '96', 'type': 'comparison_operator', 'children': ['97', '102'], 'value': '=='}; {'id': '97', 'type': 'attribute', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': '_plot_id'}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_plot_id'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'tuple', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'plot'}; {'id': '109', 'type': 'list', 'children': ['110'], 'value': '[link]'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'link'}
Searches a GenericElementPlot for a Link.
def identify(self, obj): hash_ = hash(obj) type_id = self.to_id(type(obj)) return (hash_, TypeId(type_id))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'identify'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '26']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'hash_'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'hash'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'type_id'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'to_id'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'obj'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'tuple', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'hash_'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'TypeId'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'type_id'}
Return an Ident-shaped tuple for the given object.
def umi_cycles(self) -> int: return sum((int(re.sub(r'\D', '', op)) for op in self.umi_tokens))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'umi_cycles'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'generator_expression', 'children': ['13', '24']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'string', 'children': [], 'value': "r'\\D'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "''"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '24', 'type': 'for_in_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'umi_tokens'}
The number of cycles dedicated to UMI.
def read(filename, loader=None, implicit_tuple=True, allow_errors=False): with open(filename, 'r') as f: return reads(f.read(), filename=filename, loader=loader, implicit_tuple=implicit_tuple, allow_errors=allow_errors)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'implicit_tuple'}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'allow_errors'}; {'id': '13', 'type': 'False', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'with_statement', 'children': ['16', '26']}; {'id': '16', 'type': 'with_clause', 'children': ['17']}; {'id': '17', 'type': 'with_item', 'children': ['18']}; {'id': '18', 'type': 'as_pattern', 'children': ['19', '24']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '24', 'type': 'as_pattern_target', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'reads'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '36', '39', '42', '45']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'loader'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'implicit_tuple'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'implicit_tuple'}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'allow_errors'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'allow_errors'}
Load but don't evaluate a GCL expression from a file.
def sort_candidate_pairs(pairs, ice_controlling): def pair_priority(pair): return -candidate_pair_priority(pair.local_candidate, pair.remote_candidate, ice_controlling) pairs.sort(key=pair_priority)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_candidate_pairs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pairs'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ice_controlling'}; {'id': '6', 'type': 'block', 'children': ['7', '24']}; {'id': '7', 'type': 'function_definition', 'children': ['8', '9', '11']}; {'id': '8', 'type': 'function_name', 'children': [], 'value': 'pair_priority'}; {'id': '9', 'type': 'parameters', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'unary_operator', 'children': ['14'], 'value': '-'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'candidate_pair_priority'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20', '23']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'local_candidate'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'pair'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'remote_candidate'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'ice_controlling'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pairs'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'pair_priority'}
Sort a list of candidate pairs.
def finite_datetimes(self, finite_start, finite_stop): date_start = datetime(finite_start.year, finite_start.month, finite_start.day) dates = [] for i in itertools.count(): t = date_start + timedelta(days=i) if t >= finite_stop: return dates if t >= finite_start: dates.append(t)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'finite_datetimes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'finite_start'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'finite_stop'}; {'id': '7', 'type': 'block', 'children': ['8', '23', '27']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'date_start'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '17', '20']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'finite_start'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'finite_start'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'finite_start'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dates'}; {'id': '26', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '27', 'type': 'for_statement', 'children': ['28', '29', '34']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'itertools'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'count'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35', '46', '53']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '40'], 'value': '+'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'date_start'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '46', 'type': 'if_statement', 'children': ['47', '50']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': '>='}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'finite_stop'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dates'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '57']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': '>='}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'finite_start'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'dates'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 't'}
Simply returns the points in time that correspond to turn of day.
def info(self, i: int=None) -> str: head = "[" + colors.blue("info") + "]" if i is not None: head = str(i) + " " + head return head
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'info'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_default_parameter', 'children': ['6', '7', '9']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '12', 'type': 'block', 'children': ['13', '26', '42']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '25'], 'value': '+'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '19'], 'value': '+'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"["'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'colors'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'blue'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"info"'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"]"'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is not'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '34', 'type': 'binary_operator', 'children': ['35', '41'], 'value': '+'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '40'], 'value': '+'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '40', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'head'}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'head'}
Returns an info message
def _add_custom_headers(self, dct): if self.client_id is None: self.client_id = os.environ.get("CLOUD_QUEUES_ID") if self.client_id: dct["Client-ID"] = self.client_id
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_custom_headers'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dct'}; {'id': '6', 'type': 'block', 'children': ['7', '27']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': 'is'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"CLOUD_QUEUES_ID"'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'client_id'}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'dct'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"Client-ID"'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'client_id'}
Add the Client-ID header required by Cloud Queues
def models_of_config(config): resources = resources_of_config(config) models = [] for resource in resources: if not hasattr(resource, '__table__') and hasattr(resource, 'model'): models.append(resource.model) else: models.append(resource) return models
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'models_of_config'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '17', '53']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'resources_of_config'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '16', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'resources'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '34', '44']}; {'id': '22', 'type': 'boolean_operator', 'children': ['23', '29'], 'value': 'and'}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'__table__'"}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'model'"}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '44', 'type': 'else_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'models'}
Return list of models from all resources in config.
def run(host: Optional[str] = None, port: Optional[int] = None, *args, **kwargs) -> None: get_bot().run(host=host, port=port, *args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '13', '22', '24']}; {'id': '4', 'type': 'typed_default_parameter', 'children': ['5', '6', '12']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '9', 'type': 'type_parameter', 'children': ['10']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'typed_default_parameter', 'children': ['14', '15', '21']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '15', 'type': 'type', 'children': ['16']}; {'id': '16', 'type': 'generic_type', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '18', 'type': 'type_parameter', 'children': ['19']}; {'id': '19', 'type': 'type', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'list_splat_pattern', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '24', 'type': 'dictionary_splat_pattern', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'type', 'children': ['27']}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '36']}; {'id': '31', 'type': 'attribute', 'children': ['32', '35']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get_bot'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '40', '43', '45']}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '43', 'type': 'list_splat', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '45', 'type': 'dictionary_splat', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Run the NoneBot instance.
def cast_to_swimlane(self, value): value = super(ListField, self).cast_to_swimlane(value) if not value: return None value_ids = deepcopy(self._initial_value_to_ids_map) return [self._build_list_item(item, value_ids[item].pop(0) if value_ids[item] else None) for item in value]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cast_to_swimlane'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '26', '35']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '10', 'type': 'call', 'children': ['11', '18']}; {'id': '11', 'type': 'attribute', 'children': ['12', '17']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ListField'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'cast_to_swimlane'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '23']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'value_ids'}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_initial_value_to_ids_map'}; {'id': '35', 'type': 'return_statement', 'children': ['36']}; {'id': '36', 'type': 'list_comprehension', 'children': ['37', '56']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_build_list_item'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '43', 'type': 'conditional_expression', 'children': ['44', '52', '55'], 'value': 'if'}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'value_ids'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'value_ids'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '55', 'type': 'None', 'children': []}; {'id': '56', 'type': 'for_in_clause', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'value'}
Restore swimlane format, attempting to keep initial IDs for any previously existing values
def generateProjectFiles(self, dir=os.getcwd(), args=[]): if os.path.exists(os.path.join(dir, 'Source')) == False: Utility.printStderr('Pure Blueprint project, nothing to generate project files for.') return genScript = self.getGenerateScript() projectFile = self.getProjectDescriptor(dir) Utility.run([genScript, '-project=' + projectFile, '-game', '-engine'] + args, cwd=os.path.dirname(genScript), raiseOnError=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generateProjectFiles'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '12']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'getcwd'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '14', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '15', 'type': 'block', 'children': ['16', '44', '52', '61']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '35']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '34'], 'value': '=='}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '31']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '33', 'type': 'string', 'children': [], 'value': "'Source'"}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36', '43']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Utility'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'printStderr'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'Pure Blueprint project, nothing to generate project files for.'"}; {'id': '43', 'type': 'return_statement', 'children': []}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'genScript'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'getGenerateScript'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'projectFile'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'getProjectDescriptor'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dir'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'Utility'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '76', '86']}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '75'], 'value': '+'}; {'id': '68', 'type': 'list', 'children': ['69', '70', '73', '74'], 'value': "[genScript, '-project=' + projectFile, '-game', '-engine']"}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'genScript'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '+'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'-project='"}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'projectFile'}; {'id': '73', 'type': 'string', 'children': [], 'value': "'-game'"}; {'id': '74', 'type': 'string', 'children': [], 'value': "'-engine'"}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '76', 'type': 'keyword_argument', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cwd'}; {'id': '78', 'type': 'call', 'children': ['79', '84']}; {'id': '79', 'type': 'attribute', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'genScript'}; {'id': '86', 'type': 'keyword_argument', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'raiseOnError'}; {'id': '88', 'type': 'True', 'children': []}
Generates IDE project files for the Unreal project in the specified directory
def transcribe(decoder, audio_file, libdir=None): decoder = get_decoder() decoder.start_utt() stream = open(audio_file, 'rb') while True: buf = stream.read(1024) if buf: decoder.process_raw(buf, False, False) else: break decoder.end_utt() return evaluate_results(decoder)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transcribe'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'decoder'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'audio_file'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'libdir'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '16', '22', '30', '57', '63']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'decoder'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_decoder'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'decoder'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'start_utt'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'audio_file'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '30', 'type': 'while_statement', 'children': ['31', '32']}; {'id': '31', 'type': 'True', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33', '42']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1024'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '44', '54']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'decoder'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'process_raw'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52', '53']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '52', 'type': 'False', 'children': []}; {'id': '53', 'type': 'False', 'children': []}; {'id': '54', 'type': 'else_clause', 'children': ['55']}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'break_statement', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'decoder'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'end_utt'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'evaluate_results'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'decoder'}
Decode streaming audio data from raw binary file on disk.
def _strip(self, tokens, criteria, prop, rev=False): num = len(tokens) res = [] for i, token in enumerate(reversed(tokens) if rev else tokens): if criteria(token) and num > i + 1: res.insert(0, tokens.pop()) if rev else res.append(tokens.pop(0)) else: break if res: self[prop] = self._clean(' '.join(res)) return tokens
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_strip'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'criteria'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '19', '23', '78', '97']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '22', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '23', 'type': 'for_statement', 'children': ['24', '27', '37']}; {'id': '24', 'type': 'pattern_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'conditional_expression', 'children': ['31', '35', '36'], 'value': 'if'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'reversed'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'if_statement', 'children': ['39', '49', '75']}; {'id': '39', 'type': 'boolean_operator', 'children': ['40', '44'], 'value': 'and'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'criteria'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': '>'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'num'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '+'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '48', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'conditional_expression', 'children': ['52', '63', '64'], 'value': 'if'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'rev'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '75', 'type': 'else_clause', 'children': ['76']}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'break_statement', 'children': []}; {'id': '78', 'type': 'if_statement', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '86']}; {'id': '83', 'type': 'subscript', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'prop'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_clean'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '97', 'type': 'return_statement', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'tokens'}
Strip off contiguous tokens from the start or end of the list that meet the criteria.
def annotate_diamond(fasta_path: 'path to fasta input', diamond_path: 'path to Diamond taxonomic classification output'): records = tictax.parse_seqs(fasta_path) annotated_records = tictax.annotate_diamond(records, diamond_path) SeqIO.write(annotated_records, sys.stdout, 'fasta')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'annotate_diamond'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fasta_path'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'string', 'children': [], 'value': "'path to fasta input'"}; {'id': '8', 'type': 'typed_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'diamond_path'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'path to Diamond taxonomic classification output'"}; {'id': '12', 'type': 'block', 'children': ['13', '22', '32']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'records'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tictax'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'parse_seqs'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'fasta_path'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'annotated_records'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tictax'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'annotate_diamond'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'records'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'diamond_path'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'SeqIO'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39', '42']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'annotated_records'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'fasta'"}
Annotate fasta headers with taxonomy information from Diamond
def convert_timestamp(timestamp): timestamp = timestamp.strip() chunk, millis = timestamp.split(',') hours, minutes, seconds = chunk.split(':') hours = int(hours) minutes = int(minutes) seconds = int(seconds) seconds = seconds + hours * 60 * 60 + minutes * 60 + float(millis) / 1000 return seconds
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_timestamp'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '25', '37', '44', '51', '58', '79']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '19']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'chunk'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'millis'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'timestamp'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'string', 'children': [], 'value': "','"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '31']}; {'id': '27', 'type': 'pattern_list', 'children': ['28', '29', '30']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'hours'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'minutes'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'chunk'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "':'"}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'hours'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'hours'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'minutes'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'minutes'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '73'], 'value': '+'}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '70'], 'value': '+'}; {'id': '63', 'type': 'binary_operator', 'children': ['64', '65'], 'value': '+'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '69'], 'value': '*'}; {'id': '66', 'type': 'binary_operator', 'children': ['67', '68'], 'value': '*'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'hours'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '*'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'minutes'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '60'}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '78'], 'value': '/'}; {'id': '74', 'type': 'call', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '76', 'type': 'argument_list', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'millis'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '79', 'type': 'return_statement', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'seconds'}
Convert an srt timestamp into seconds.
def _parse_date_greek(dateString): m = _greek_date_format_re.match(dateString) if not m: return wday = _greek_wdays[m.group(1)] month = _greek_months[m.group(3)] rfc822date = '%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(minute)s:%(second)s %(zonediff)s' % \ {'wday': wday, 'day': m.group(2), 'month': month, 'year': m.group(4),\ 'hour': m.group(5), 'minute': m.group(6), 'second': m.group(7),\ 'zonediff': m.group(8)} return _parse_date_rfc822(rfc822date)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_date_greek'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'dateString'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '20', '31', '42', '103']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_greek_date_format_re'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'match'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dateString'}; {'id': '15', 'type': 'if_statement', 'children': ['16', '18']}; {'id': '16', 'type': 'not_operator', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'wday'}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_greek_wdays'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_greek_months'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'rfc822date'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '47', '48'], 'value': '%'}; {'id': '46', 'type': 'string', 'children': [], 'value': "'%(wday)s, %(day)s %(month)s %(year)s %(hour)s:%(minute)s:%(second)s %(zonediff)s'"}; {'id': '47', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '48', 'type': 'dictionary', 'children': ['49', '52', '60', '63', '71', '79', '87', '95']}; {'id': '49', 'type': 'pair', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'wday'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'wday'}; {'id': '52', 'type': 'pair', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'day'"}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'month'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '63', 'type': 'pair', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': "'year'"}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '71', 'type': 'pair', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': "'hour'"}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '79', 'type': 'pair', 'children': ['80', '81']}; {'id': '80', 'type': 'string', 'children': [], 'value': "'minute'"}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '87', 'type': 'pair', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': "'second'"}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '95', 'type': 'pair', 'children': ['96', '97']}; {'id': '96', 'type': 'string', 'children': [], 'value': "'zonediff'"}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': '_parse_date_rfc822'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'rfc822date'}
Parse a string according to a Greek 8-bit date format.
def from_list(cls, database, key, data, clear=False): arr = cls(database, key) if clear: arr.clear() arr.extend(data) return arr
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_list'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '20', '29', '36']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'arr'}
Create and populate an Array object from a data dictionary.
def load(self, filename=None): DataFile.load(self, filename) self.spectrum.filename = filename
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '17']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'DataFile'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'spectrum'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'filename'}
Method was overriden to set spectrum.filename as well
def selecttrue(table, field, complement=False): return select(table, field, lambda v: bool(v), complement=complement)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'selecttrue'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'complement'}; {'id': '8', 'type': 'False', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '16', '23']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '16', 'type': 'lambda', 'children': ['17', '19']}; {'id': '17', 'type': 'lambda_parameters', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'complement'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'complement'}
Select rows where the given field evaluates `True`.
def catch_timeout(f): def new_f(self, *args, **kwargs): try: return f(self, *args, **kwargs) except (requests.exceptions.ReadTimeout, requests.packages.urllib3.exceptions.ReadTimeoutError) as e: log.warning("caught read timeout: %s", e) self.connect() return f(self, *args, **kwargs) return new_f
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'catch_timeout'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '5', 'type': 'block', 'children': ['6', '69']}; {'id': '6', 'type': 'function_definition', 'children': ['7', '8', '14']}; {'id': '7', 'type': 'function_name', 'children': [], 'value': 'new_f'}; {'id': '8', 'type': 'parameters', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'list_splat_pattern', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '12', 'type': 'dictionary_splat_pattern', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'try_statement', 'children': ['16', '26']}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '22', '24']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'list_splat', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '24', 'type': 'dictionary_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'except_clause', 'children': ['27', '45']}; {'id': '27', 'type': 'as_pattern', 'children': ['28', '43']}; {'id': '28', 'type': 'tuple', 'children': ['29', '34']}; {'id': '29', 'type': 'attribute', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'ReadTimeout'}; {'id': '34', 'type': 'attribute', 'children': ['35', '42']}; {'id': '35', 'type': 'attribute', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'packages'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'urllib3'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'ReadTimeoutError'}; {'id': '43', 'type': 'as_pattern_target', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '45', 'type': 'block', 'children': ['46', '54', '60']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"caught read timeout: %s"'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'return_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65', '67']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'list_splat', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '67', 'type': 'dictionary_splat', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'new_f'}
A decorator to handle read timeouts from Twitter.
def find_target_migration_file(database=DEFAULT_DB_ALIAS, changelog_file=None): if not database: database = DEFAULT_DB_ALIAS if not changelog_file: changelog_file = get_changelog_file_for_database(database) try: doc = minidom.parse(changelog_file) except ExpatError as ex: raise InvalidChangelogFile( 'Could not parse XML file %s: %s' % (changelog_file, ex)) try: dbchglog = doc.getElementsByTagName('databaseChangeLog')[0] except IndexError: raise InvalidChangelogFile( 'Missing <databaseChangeLog> node in file %s' % ( changelog_file)) else: nodes = list(filter(lambda x: x.nodeType is x.ELEMENT_NODE, dbchglog.childNodes)) if not nodes: return changelog_file last_node = nodes[-1] if last_node.tagName == 'include': last_file = last_node.attributes.get('file').firstChild.data return find_target_migration_file( database=database, changelog_file=last_file) else: return changelog_file
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_target_migration_file'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_DB_ALIAS'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '19', '30', '56']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '14']}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'DEFAULT_DB_ALIAS'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '22']}; {'id': '20', 'type': 'not_operator', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get_changelog_file_for_database'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '30', 'type': 'try_statement', 'children': ['31', '41']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'minidom'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '41', 'type': 'except_clause', 'children': ['42', '46']}; {'id': '42', 'type': 'as_pattern', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ExpatError'}; {'id': '44', 'type': 'as_pattern_target', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'raise_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'InvalidChangelogFile'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '%'}; {'id': '52', 'type': 'string', 'children': [], 'value': "'Could not parse XML file %s: %s'"}; {'id': '53', 'type': 'tuple', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '56', 'type': 'try_statement', 'children': ['57', '69', '80']}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dbchglog'}; {'id': '61', 'type': 'subscript', 'children': ['62', '68']}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'getElementsByTagName'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'string', 'children': [], 'value': "'databaseChangeLog'"}; {'id': '68', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '69', 'type': 'except_clause', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'raise_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'InvalidChangelogFile'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'binary_operator', 'children': ['77', '78'], 'value': '%'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'Missing <databaseChangeLog> node in file %s'"}; {'id': '78', 'type': '()', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '80', 'type': 'else_clause', 'children': ['81']}; {'id': '81', 'type': 'block', 'children': ['82', '104', '110', '117']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '101']}; {'id': '91', 'type': 'lambda', 'children': ['92', '94']}; {'id': '92', 'type': 'lambda_parameters', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '98'], 'value': 'is'}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'nodeType'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'ELEMENT_NODE'}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'dbchglog'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'childNodes'}; {'id': '104', 'type': 'if_statement', 'children': ['105', '107']}; {'id': '105', 'type': 'not_operator', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'last_node'}; {'id': '113', 'type': 'subscript', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '115', 'type': 'unary_operator', 'children': ['116'], 'value': '-'}; {'id': '116', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '117', 'type': 'if_statement', 'children': ['118', '123', '149']}; {'id': '118', 'type': 'comparison_operator', 'children': ['119', '122'], 'value': '=='}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'last_node'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'tagName'}; {'id': '122', 'type': 'string', 'children': [], 'value': "'include'"}; {'id': '123', 'type': 'block', 'children': ['124', '139']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'last_file'}; {'id': '127', 'type': 'attribute', 'children': ['128', '138']}; {'id': '128', 'type': 'attribute', 'children': ['129', '137']}; {'id': '129', 'type': 'call', 'children': ['130', '135']}; {'id': '130', 'type': 'attribute', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'last_node'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '135', 'type': 'argument_list', 'children': ['136']}; {'id': '136', 'type': 'string', 'children': [], 'value': "'file'"}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'firstChild'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '139', 'type': 'return_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'find_target_migration_file'}; {'id': '142', 'type': 'argument_list', 'children': ['143', '146']}; {'id': '143', 'type': 'keyword_argument', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'database'}; {'id': '146', 'type': 'keyword_argument', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'last_file'}; {'id': '149', 'type': 'else_clause', 'children': ['150']}; {'id': '150', 'type': 'block', 'children': ['151']}; {'id': '151', 'type': 'return_statement', 'children': ['152']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'changelog_file'}
Finds best matching target migration file
def mavset(self, mav, name, value, retries=3): got_ack = False while retries > 0 and not got_ack: retries -= 1 mav.param_set_send(name.upper(), float(value)) tstart = time.time() while time.time() - tstart < 1: ack = mav.recv_match(type='PARAM_VALUE', blocking=False) if ack == None: time.sleep(0.1) continue if str(name).upper() == str(ack.param_id).upper(): got_ack = True self.__setitem__(name, float(value)) break if not got_ack: print("timeout setting %s to %f" % (name, float(value))) return False return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mavset'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mav'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'retries'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '11', 'type': 'block', 'children': ['12', '16', '126', '144']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'got_ack'}; {'id': '15', 'type': 'False', 'children': []}; {'id': '16', 'type': 'while_statement', 'children': ['17', '23']}; {'id': '17', 'type': 'boolean_operator', 'children': ['18', '21'], 'value': 'and'}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': '>'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'retries'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'got_ack'}; {'id': '23', 'type': 'block', 'children': ['24', '28', '43', '51']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'augmented_assignment', 'children': ['26', '27'], 'value': '-='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'retries'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'mav'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'param_set_send'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '39']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'tstart'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '50', 'type': 'argument_list', 'children': []}; {'id': '51', 'type': 'while_statement', 'children': ['52', '61']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '60'], 'value': '<'}; {'id': '53', 'type': 'binary_operator', 'children': ['54', '59'], 'value': '-'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'tstart'}; {'id': '60', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '61', 'type': 'block', 'children': ['62', '76', '89']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'ack'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'mav'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'recv_match'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '73']}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '72', 'type': 'string', 'children': [], 'value': "'PARAM_VALUE'"}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'blocking'}; {'id': '75', 'type': 'False', 'children': []}; {'id': '76', 'type': 'if_statement', 'children': ['77', '80']}; {'id': '77', 'type': 'comparison_operator', 'children': ['78', '79'], 'value': '=='}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'ack'}; {'id': '79', 'type': 'None', 'children': []}; {'id': '80', 'type': 'block', 'children': ['81', '88']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'sleep'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'float', 'children': [], 'value': '0.1'}; {'id': '88', 'type': 'continue_statement', 'children': []}; {'id': '89', 'type': 'if_statement', 'children': ['90', '109']}; {'id': '90', 'type': 'comparison_operator', 'children': ['91', '99'], 'value': '=='}; {'id': '91', 'type': 'call', 'children': ['92', '98']}; {'id': '92', 'type': 'attribute', 'children': ['93', '97']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '98', 'type': 'argument_list', 'children': []}; {'id': '99', 'type': 'call', 'children': ['100', '108']}; {'id': '100', 'type': 'attribute', 'children': ['101', '107']}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'ack'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'param_id'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '108', 'type': 'argument_list', 'children': []}; {'id': '109', 'type': 'block', 'children': ['110', '114', '125']}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'got_ack'}; {'id': '113', 'type': 'True', 'children': []}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': '__setitem__'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '125', 'type': 'break_statement', 'children': []}; {'id': '126', 'type': 'if_statement', 'children': ['127', '129']}; {'id': '127', 'type': 'not_operator', 'children': ['128']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'got_ack'}; {'id': '129', 'type': 'block', 'children': ['130', '142']}; {'id': '130', 'type': 'expression_statement', 'children': ['131']}; {'id': '131', 'type': 'call', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'binary_operator', 'children': ['135', '136'], 'value': '%'}; {'id': '135', 'type': 'string', 'children': [], 'value': '"timeout setting %s to %f"'}; {'id': '136', 'type': 'tuple', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '142', 'type': 'return_statement', 'children': ['143']}; {'id': '143', 'type': 'False', 'children': []}; {'id': '144', 'type': 'return_statement', 'children': ['145']}; {'id': '145', 'type': 'True', 'children': []}
set a parameter on a mavlink connection
def fail(self, cmd, title=None, message=None): if message is None: message = self.handle_exc() else: message = escape(message) self.db.send( 'Echo|%s' % dump({ 'for': escape(title or '%s failed' % cmd), 'val': message }) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'fail'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '35']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17', '26']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': 'is'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '16', 'type': 'None', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'handle_exc'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'escape'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'binary_operator', 'children': ['44', '45'], 'value': '%'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'Echo|%s'"}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'dictionary', 'children': ['49', '59']}; {'id': '49', 'type': 'pair', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'for'"}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'escape'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'boolean_operator', 'children': ['55', '56'], 'value': 'or'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'title'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '%'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'%s failed'"}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '59', 'type': 'pair', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'val'"}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'message'}
Send back captured exceptions
def hasBidAsk(self) -> bool: return ( self.bid != -1 and not isNan(self.bid) and self.bidSize > 0 and self.ask != -1 and not isNan(self.ask) and self.askSize > 0)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hasBidAsk'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'type', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': '()', 'children': ['10']}; {'id': '10', 'type': 'boolean_operator', 'children': ['11', '46'], 'value': 'and'}; {'id': '11', 'type': 'boolean_operator', 'children': ['12', '39'], 'value': 'and'}; {'id': '12', 'type': 'boolean_operator', 'children': ['13', '33'], 'value': 'and'}; {'id': '13', 'type': 'boolean_operator', 'children': ['14', '28'], 'value': 'and'}; {'id': '14', 'type': 'boolean_operator', 'children': ['15', '21'], 'value': 'and'}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '19'], 'value': '!='}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'bid'}; {'id': '19', 'type': 'unary_operator', 'children': ['20'], 'value': '-'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'isNan'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'bid'}; {'id': '28', 'type': 'comparison_operator', 'children': ['29', '32'], 'value': '>'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'bidSize'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '37'], 'value': '!='}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'ask'}; {'id': '37', 'type': 'unary_operator', 'children': ['38'], 'value': '-'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'isNan'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'ask'}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '50'], 'value': '>'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'askSize'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}
See if this ticker has a valid bid and ask.
def config(conf, confdefs): conf = conf.copy() for name, info in confdefs: conf.setdefault(name, info.get('defval')) return conf
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'config'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conf'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'confdefs'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '34']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'conf'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'conf'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'for_statement', 'children': ['16', '19', '20']}; {'id': '16', 'type': 'pattern_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'confdefs'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'conf'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'setdefault'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'defval'"}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'conf'}
Initialize a config dict using the given confdef tuples.
def _get_alignment(self, pys_style): alignment_styles = ["justification", "vertical_align", "angle"] if not any(astyle in pys_style for astyle in alignment_styles): return def angle2xfrotation(angle): if 0 <= angle <= 90: return angle elif -90 <= angle < 0: return 90 - angle return 0 justification2xfalign = { "left": 1, "center": 2, "right": 3, } vertical_align2xfalign = { "top": 0, "middle": 1, "bottom": 2, } alignment = xlwt.Alignment() try: alignment.horz = justification2xfalign[pys_style["justification"]] except KeyError: pass try: alignment.vert = \ vertical_align2xfalign[pys_style["vertical_align"]] except KeyError: pass try: alignment.rota = angle2xfrotation(pys_style["angle"]) except KeyError: pass return alignment
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_alignment'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pys_style'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '27', '53', '66', '79', '87', '103', '120', '137']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'alignment_styles'}; {'id': '10', 'type': 'list', 'children': ['11', '12', '13'], 'value': '["justification", "vertical_align", "angle"]'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"justification"'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"vertical_align"'}; {'id': '13', 'type': 'string', 'children': [], 'value': '"angle"'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '25']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '18', 'type': 'generator_expression', 'children': ['19', '22']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'in'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'astyle'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'pys_style'}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'astyle'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'alignment_styles'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': []}; {'id': '27', 'type': 'function_definition', 'children': ['28', '29', '31']}; {'id': '28', 'type': 'function_name', 'children': [], 'value': 'angle2xfrotation'}; {'id': '29', 'type': 'parameters', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '31', 'type': 'block', 'children': ['32', '51']}; {'id': '32', 'type': 'if_statement', 'children': ['33', '37', '40']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35', '36'], 'value': '<='}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '90'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '40', 'type': 'elif_clause', 'children': ['41', '46']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '44', '45'], 'value': '<='}; {'id': '42', 'type': 'unary_operator', 'children': ['43'], 'value': '-'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '90'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '-'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '90'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'angle'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'justification2xfalign'}; {'id': '56', 'type': 'dictionary', 'children': ['57', '60', '63']}; {'id': '57', 'type': 'pair', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': '"left"'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '60', 'type': 'pair', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': '"center"'}; {'id': '62', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '63', 'type': 'pair', 'children': ['64', '65']}; {'id': '64', 'type': 'string', 'children': [], 'value': '"right"'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'vertical_align2xfalign'}; {'id': '69', 'type': 'dictionary', 'children': ['70', '73', '76']}; {'id': '70', 'type': 'pair', 'children': ['71', '72']}; {'id': '71', 'type': 'string', 'children': [], 'value': '"top"'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'pair', 'children': ['74', '75']}; {'id': '74', 'type': 'string', 'children': [], 'value': '"middle"'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '76', 'type': 'pair', 'children': ['77', '78']}; {'id': '77', 'type': 'string', 'children': [], 'value': '"bottom"'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'alignment'}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'xlwt'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'Alignment'}; {'id': '86', 'type': 'argument_list', 'children': []}; {'id': '87', 'type': 'try_statement', 'children': ['88', '99']}; {'id': '88', 'type': 'block', 'children': ['89']}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'alignment'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'horz'}; {'id': '94', 'type': 'subscript', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'justification2xfalign'}; {'id': '96', 'type': 'subscript', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'pys_style'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"justification"'}; {'id': '99', 'type': 'except_clause', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'pass_statement', 'children': []}; {'id': '103', 'type': 'try_statement', 'children': ['104', '116']}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '110', '111']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'alignment'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'vert'}; {'id': '110', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '111', 'type': 'subscript', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'vertical_align2xfalign'}; {'id': '113', 'type': 'subscript', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'pys_style'}; {'id': '115', 'type': 'string', 'children': [], 'value': '"vertical_align"'}; {'id': '116', 'type': 'except_clause', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'pass_statement', 'children': []}; {'id': '120', 'type': 'try_statement', 'children': ['121', '133']}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'alignment'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'rota'}; {'id': '127', 'type': 'call', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'angle2xfrotation'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'subscript', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'pys_style'}; {'id': '132', 'type': 'string', 'children': [], 'value': '"angle"'}; {'id': '133', 'type': 'except_clause', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'pass_statement', 'children': []}; {'id': '137', 'type': 'return_statement', 'children': ['138']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'alignment'}
Returns xlwt.Alignment for pyspread style
def envelope(**kwargs): e_oaipmh = Element(etree.QName(NS_OAIPMH, 'OAI-PMH'), nsmap=NSMAP) e_oaipmh.set(etree.QName(NS_XSI, 'schemaLocation'), '{0} {1}'.format(NS_OAIPMH, NS_OAIPMH_XSD)) e_tree = ElementTree(element=e_oaipmh) if current_app.config['OAISERVER_XSL_URL']: e_oaipmh.addprevious(etree.ProcessingInstruction( 'xml-stylesheet', 'type="text/xsl" href="{0}"' .format(current_app.config['OAISERVER_XSL_URL']))) e_responseDate = SubElement( e_oaipmh, etree.QName( NS_OAIPMH, 'responseDate')) e_responseDate.text = datetime_to_datestamp(datetime.utcnow()) e_request = SubElement(e_oaipmh, etree.QName(NS_OAIPMH, 'request')) for key, value in kwargs.items(): if key == 'from_' or key == 'until': value = datetime_to_datestamp(value) elif key == 'resumptionToken': value = value['token'] e_request.set(key, value) e_request.text = url_for('invenio_oaiserver.response', _external=True) return e_tree, e_oaipmh
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'envelope'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'dictionary_splat_pattern', 'children': ['5']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '6', 'type': 'block', 'children': ['7', '23', '43', '52', '81', '95', '108', '122', '167', '179']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'e_oaipmh'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'Element'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '20']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'QName'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'NS_OAIPMH'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'OAI-PMH'"}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'nsmap'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'NSMAP'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'e_oaipmh'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '36']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'QName'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'NS_XSI'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'schemaLocation'"}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'{0} {1}'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'NS_OAIPMH'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'NS_OAIPMH_XSD'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'e_tree'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'ElementTree'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'element'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'e_oaipmh'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '58']}; {'id': '53', 'type': 'subscript', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'OAISERVER_XSL_URL'"}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'e_oaipmh'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'addprevious'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ProcessingInstruction'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'string', 'children': [], 'value': "'xml-stylesheet'"}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'string', 'children': [], 'value': '\'type="text/xsl" href="{0}"\''}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'subscript', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'OAISERVER_XSL_URL'"}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'e_responseDate'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'SubElement'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'e_oaipmh'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'QName'}; {'id': '92', 'type': 'argument_list', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'NS_OAIPMH'}; {'id': '94', 'type': 'string', 'children': [], 'value': "'responseDate'"}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'e_responseDate'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '100', 'type': 'call', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'datetime_to_datestamp'}; {'id': '102', 'type': 'argument_list', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'utcnow'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'e_request'}; {'id': '111', 'type': 'call', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'SubElement'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'e_oaipmh'}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'QName'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'NS_OAIPMH'}; {'id': '121', 'type': 'string', 'children': [], 'value': "'request'"}; {'id': '122', 'type': 'for_statement', 'children': ['123', '126', '131']}; {'id': '123', 'type': 'pattern_list', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '130', 'type': 'argument_list', 'children': []}; {'id': '131', 'type': 'block', 'children': ['132', '159']}; {'id': '132', 'type': 'if_statement', 'children': ['133', '140', '148']}; {'id': '133', 'type': 'boolean_operator', 'children': ['134', '137'], 'value': 'or'}; {'id': '134', 'type': 'comparison_operator', 'children': ['135', '136'], 'value': '=='}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '136', 'type': 'string', 'children': [], 'value': "'from_'"}; {'id': '137', 'type': 'comparison_operator', 'children': ['138', '139'], 'value': '=='}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '139', 'type': 'string', 'children': [], 'value': "'until'"}; {'id': '140', 'type': 'block', 'children': ['141']}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '144', 'type': 'call', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'datetime_to_datestamp'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '148', 'type': 'elif_clause', 'children': ['149', '152']}; {'id': '149', 'type': 'comparison_operator', 'children': ['150', '151'], 'value': '=='}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '151', 'type': 'string', 'children': [], 'value': "'resumptionToken'"}; {'id': '152', 'type': 'block', 'children': ['153']}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '156', 'type': 'subscript', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '158', 'type': 'string', 'children': [], 'value': "'token'"}; {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'call', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'e_request'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '164', 'type': 'argument_list', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '167', 'type': 'expression_statement', 'children': ['168']}; {'id': '168', 'type': 'assignment', 'children': ['169', '172']}; {'id': '169', 'type': 'attribute', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'e_request'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '172', 'type': 'call', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'url_for'}; {'id': '174', 'type': 'argument_list', 'children': ['175', '176']}; {'id': '175', 'type': 'string', 'children': [], 'value': "'invenio_oaiserver.response'"}; {'id': '176', 'type': 'keyword_argument', 'children': ['177', '178']}; {'id': '177', 'type': 'identifier', 'children': [], 'value': '_external'}; {'id': '178', 'type': 'True', 'children': []}; {'id': '179', 'type': 'return_statement', 'children': ['180']}; {'id': '180', 'type': 'expression_list', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'e_tree'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'e_oaipmh'}
Create OAI-PMH envelope for response.
def tci_path(self): tci_paths = [ path for path in self.dataset._product_metadata.xpath( ".//Granule[@granuleIdentifier='%s']/IMAGE_FILE/text()" % self.granule_identifier ) if path.endswith('TCI') ] try: tci_path = tci_paths[0] except IndexError: return None return os.path.join( self.dataset._zip_root if self.dataset.is_zip else self.dataset.path, tci_path ) + '.jp2'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'tci_path'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '34', '47']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tci_paths'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '11', '27']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '11', 'type': 'for_in_clause', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '13', 'type': 'call', 'children': ['14', '21']}; {'id': '14', 'type': 'attribute', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_product_metadata'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'xpath'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '24'], 'value': '%'}; {'id': '23', 'type': 'string', 'children': [], 'value': '".//Granule[@granuleIdentifier=\'%s\']/IMAGE_FILE/text()"'}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'granule_identifier'}; {'id': '27', 'type': 'if_clause', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'string', 'children': [], 'value': "'TCI'"}; {'id': '34', 'type': 'try_statement', 'children': ['35', '42']}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'tci_path'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tci_paths'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'except_clause', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'None', 'children': []}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '73'], 'value': '+'}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '72']}; {'id': '56', 'type': 'conditional_expression', 'children': ['57', '62', '67'], 'value': 'if'}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': '_zip_root'}; {'id': '62', 'type': 'attribute', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'is_zip'}; {'id': '67', 'type': 'attribute', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'dataset'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'tci_path'}; {'id': '73', 'type': 'string', 'children': [], 'value': "'.jp2'"}
Return the path to the granules TrueColorImage.
def format_maxtime(self, maxtime): minutes = maxtime.get("minutes", "0") hours = maxtime.get("hours", "0") days = maxtime.get("days", "0") return u"{}: {} {}: {} {}: {}".format( _("days"), days, _("hours"), hours, _("minutes"), minutes)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_maxtime'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'maxtime'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '27', '37']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'minutes'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'maxtime'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"minutes"'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"0"'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'hours'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'maxtime'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"hours"'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"0"'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'maxtime'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"days"'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"0"'}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': 'u"{}: {} {}: {} {}: {}"'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '47', '48', '52', '53', '57']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"days"'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'days'}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"hours"'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'hours'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'string', 'children': [], 'value': '"minutes"'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'minutes'}
Formats the max time record to a days, hours, minutes string
def _copy_database_data_clientside(self, tables, source, destination): rows = self.get_database_rows(tables, source) cols = self.get_database_columns(tables, source) for r in list(rows.keys()): assert r in tables for c in list(cols.keys()): assert c in tables self.change_db(destination) insert_queries = self._get_insert_commands(rows, cols) self._execute_insert_commands(insert_queries)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_copy_database_data_clientside'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '8', 'type': 'block', 'children': ['9', '19', '29', '44', '59', '66', '76']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get_database_rows'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'get_database_columns'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '39']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'assert_statement', 'children': ['41']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': 'in'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '44', 'type': 'for_statement', 'children': ['45', '46', '54']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '46', 'type': 'call', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '53', 'type': 'argument_list', 'children': []}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'assert_statement', 'children': ['56']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'in'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'change_db'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'insert_queries'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_get_insert_commands'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': '_execute_insert_commands'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'insert_queries'}
Copy the data from a table into another table.
def getrefnames(idf, objname): iddinfo = idf.idd_info dtls = idf.model.dtls index = dtls.index(objname) fieldidds = iddinfo[index] for fieldidd in fieldidds: if 'field' in fieldidd: if fieldidd['field'][0].endswith('Name'): if 'reference' in fieldidd: return fieldidd['reference'] else: return []
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getrefnames'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'idf'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'objname'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '21', '30', '36']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'iddinfo'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'idf'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'idd_info'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dtls'}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'idf'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dtls'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dtls'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'objname'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'fieldidds'}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'iddinfo'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '36', 'type': 'for_statement', 'children': ['37', '38', '39']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'fieldidd'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fieldidds'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'if_statement', 'children': ['41', '44']}; {'id': '41', 'type': 'comparison_operator', 'children': ['42', '43'], 'value': 'in'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'field'"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'fieldidd'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'if_statement', 'children': ['46', '56']}; {'id': '46', 'type': 'call', 'children': ['47', '54']}; {'id': '47', 'type': 'attribute', 'children': ['48', '53']}; {'id': '48', 'type': 'subscript', 'children': ['49', '52']}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fieldidd'}; {'id': '51', 'type': 'string', 'children': [], 'value': "'field'"}; {'id': '52', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'Name'"}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61', '66']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'in'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'reference'"}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'fieldidd'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'fieldidd'}; {'id': '65', 'type': 'string', 'children': [], 'value': "'reference'"}; {'id': '66', 'type': 'else_clause', 'children': ['67']}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'list', 'children': [], 'value': '[]'}
get the reference names for this object
def format_decimal(self, altitude=None): coordinates = [str(self.latitude), str(self.longitude)] if altitude is None: altitude = bool(self.altitude) if altitude: if not isinstance(altitude, string_compare): altitude = 'km' coordinates.append(self.format_altitude(altitude)) return ", ".join(coordinates)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'format_decimal'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '25', '39', '66']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'coordinates'}; {'id': '12', 'type': 'list', 'children': ['13', '19'], 'value': '[str(self.latitude), str(self.longitude)]'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'latitude'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'longitude'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '39', 'type': 'if_statement', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '41', 'type': 'block', 'children': ['42', '54']}; {'id': '42', 'type': 'if_statement', 'children': ['43', '49']}; {'id': '43', 'type': 'not_operator', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'string_compare'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'km'"}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'coordinates'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'format_altitude'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'altitude'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'string', 'children': [], 'value': '", "'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'coordinates'}
Format decimal degrees with altitude
def zlines(f = None, sep = "\0", osep = None, size = 8192): if f is None: f = sys.stdin if osep is None: osep = sep buf = "" while True: chars = f.read(size) if not chars: break buf += chars; lines = buf.split(sep); buf = lines.pop() for line in lines: yield line + osep if buf: yield buf
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'zlines'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"\\0"'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'osep'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '8192'}; {'id': '16', 'type': 'block', 'children': ['17', '28', '37', '41', '88']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '21']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'is'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '20', 'type': 'None', 'children': []}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': 'is'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'osep'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'osep'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '40', 'type': 'string', 'children': [], 'value': '""'}; {'id': '41', 'type': 'while_statement', 'children': ['42', '43']}; {'id': '42', 'type': 'True', 'children': []}; {'id': '43', 'type': 'block', 'children': ['44', '53', '58', '62', '71', '79']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'chars'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '56']}; {'id': '54', 'type': 'not_operator', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'chars'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'break_statement', 'children': []}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'augmented_assignment', 'children': ['60', '61'], 'value': '+='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'chars'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '78', 'type': 'argument_list', 'children': []}; {'id': '79', 'type': 'for_statement', 'children': ['80', '81', '82']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'yield', 'children': ['85']}; {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '+'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'osep'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'yield', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'buf'}
File iterator that uses alternative line terminators.
def _clear_xauth(self): os.remove(self._xauth_filename) for varname in ['AUTHFILE', 'XAUTHORITY']: if self._old_xauth[varname] is None: del os.environ[varname] else: os.environ[varname] = self._old_xauth[varname] self._old_xauth = None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_clear_xauth'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '50']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_xauth_filename'}; {'id': '15', 'type': 'for_statement', 'children': ['16', '17', '20']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '17', 'type': 'list', 'children': ['18', '19'], 'value': "['AUTHFILE', 'XAUTHORITY']"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'AUTHFILE'"}; {'id': '19', 'type': 'string', 'children': [], 'value': "'XAUTHORITY'"}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '29', '36']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '28'], 'value': 'is'}; {'id': '23', 'type': 'subscript', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_old_xauth'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'delete_statement', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '45']}; {'id': '40', 'type': 'subscript', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'environ'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '45', 'type': 'subscript', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_old_xauth'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'varname'}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '_old_xauth'}; {'id': '55', 'type': 'None', 'children': []}
Clear the Xauthority file and restore the environment variables.
def smallest_signed_angle(source, target): dth = target - source dth = (dth + np.pi) % (2.0 * np.pi) - np.pi return dth
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'smallest_signed_angle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '33']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dth'}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '12'], 'value': '-'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dth'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '30'], 'value': '-'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '24'], 'value': '%'}; {'id': '18', 'type': '()', 'children': ['19']}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '+'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'dth'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pi'}; {'id': '24', 'type': '()', 'children': ['25']}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '27'], 'value': '*'}; {'id': '26', 'type': 'float', 'children': [], 'value': '2.0'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'pi'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'pi'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dth'}
Find the smallest angle going from angle `source` to angle `target`.
def write_byte_data(self, address, register, value): LOGGER.debug("Writing byte data %s to register %s on device %s", bin(value), hex(register), hex(address)) return self.driver.write_byte_data(address, register, value)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_byte_data'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'block', 'children': ['9', '28']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'LOGGER'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '20', '24']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"Writing byte data %s to register %s on device %s"'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'bin'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'hex'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hex'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'driver'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'write_byte_data'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37', '38']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'register'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'value'}
Write a byte value to a device's register.
def inline(self): tp_lines, tp_decl = self.get_decl_pair() tp_lines = " ".join(tp_lines) if tp_decl is None: return tp_lines else: return "%s %s" % (tp_lines, tp_decl)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inline'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '25']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'tp_lines'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'tp_decl'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_decl_pair'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'tp_lines'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tp_lines'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '29', '32']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'is'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tp_decl'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'tp_lines'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '%'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"%s %s"'}; {'id': '37', 'type': 'tuple', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'tp_lines'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'tp_decl'}
Return the declarator as a single line.
def _calculate_sv_bins_gatk(data, cnv_group, size_calc_fn): if dd.get_background_cnv_reference(data, "gatk-cnv"): target_bed = gatkcnv.pon_to_bed(dd.get_background_cnv_reference(data, "gatk-cnv"), cnv_group.work_dir, data) else: target_bed = gatkcnv.prepare_intervals(data, cnv_group.region_file, cnv_group.work_dir) gc_annotated_tsv = gatkcnv.annotate_intervals(target_bed, data) return target_bed, None, gc_annotated_tsv
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_calculate_sv_bins_gatk'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cnv_group'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'size_calc_fn'}; {'id': '7', 'type': 'block', 'children': ['8', '53', '63']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '16', '36']}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'dd'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_background_cnv_reference'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"gatk-cnv"'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'target_bed'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'gatkcnv'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'pon_to_bed'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '32', '35']}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dd'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'get_background_cnv_reference'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"gatk-cnv"'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cnv_group'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'work_dir'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '36', 'type': 'else_clause', 'children': ['37']}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'target_bed'}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'gatkcnv'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'prepare_intervals'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '50']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cnv_group'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'region_file'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cnv_group'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'work_dir'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'gc_annotated_tsv'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'gatkcnv'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'annotate_intervals'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'target_bed'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'expression_list', 'children': ['65', '66', '67']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'target_bed'}; {'id': '66', 'type': 'None', 'children': []}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'gc_annotated_tsv'}
Calculate structural variant bins using GATK4 CNV callers region or even intervals approach.
def _server_error_message(url, message): msg = _error_message.format(url=url, message=message) log.error(msg) return msg
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_server_error_message'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '28']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_error_message'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '18']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'msg'}
Log and return a server error message.
def element_not_contains(self, element_id, value): elem = world.browser.find_elements_by_xpath(str( 'id("{id}")[contains(., "{value}")]'.format( id=element_id, value=value))) assert not elem, \ "Expected element not to contain the given text."
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'element_not_contains'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'element_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8', '32']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'elem'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'world'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'browser'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'find_elements_by_xpath'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': '\'id("{id}")[contains(., "{value}")]\''}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '29']}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'element_id'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '32', 'type': 'assert_statement', 'children': ['33', '35']}; {'id': '33', 'type': 'not_operator', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'elem'}; {'id': '35', 'type': 'string', 'children': [], 'value': '"Expected element not to contain the given text."'}
Assert provided content is not contained within an element found by ``id``.
def protocol_names(self): l = self.protocols() retval = [str(k.name) for k in l] return retval
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'protocol_names'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '27']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'protocols'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'retval'}; {'id': '17', 'type': 'list_comprehension', 'children': ['18', '24']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '24', 'type': 'for_in_clause', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'l'}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'retval'}
Returns all registered protocol names
def remove(self, tab_index): _id = id(self.editor.tabs.widget(tab_index)) if _id in self.history: self.history.remove(_id)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tab_index'}; {'id': '6', 'type': 'block', 'children': ['7', '23']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_id'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '21']}; {'id': '14', 'type': 'attribute', 'children': ['15', '20']}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'editor'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tabs'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'widget'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tab_index'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '29']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'in'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_id'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'history'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '37']}; {'id': '32', 'type': 'attribute', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'history'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_id'}
Remove the widget at the corresponding tab_index.
def policy_error_scope(error, data): err_path = list(error.absolute_path) if err_path[0] != 'policies': return error pdata = data['policies'][err_path[1]] pdata.get('name', 'unknown') error.message = "Error on policy:{} resource:{}\n".format( pdata.get('name', 'unknown'), pdata.get('resource', 'unknown')) + error.message return error
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'policy_error_scope'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25', '35', '43', '71']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'err_path'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'absolute_path'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '22']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '21'], 'value': '!='}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'err_path'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'policies'"}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pdata'}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'policies'"}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'err_path'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'pdata'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '42', 'type': 'string', 'children': [], 'value': "'unknown'"}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '68'], 'value': '+'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"Error on policy:{} resource:{}\\n"'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '61']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'pdata'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '60', 'type': 'string', 'children': [], 'value': "'unknown'"}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'pdata'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'resource'"}; {'id': '67', 'type': 'string', 'children': [], 'value': "'unknown'"}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'error'}
Scope a schema error to its policy name and resource.
def post_register_hook(self, verbosity=1): if not getattr(settings, 'FLOW_DOCKER_DONT_PULL', False): call_command('list_docker_images', pull=True, verbosity=verbosity)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'post_register_hook'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '17']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'FLOW_DOCKER_DONT_PULL'"}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'call_command'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23', '26']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'list_docker_images'"}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pull'}; {'id': '25', 'type': 'True', 'children': []}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'verbosity'}
Pull Docker images needed by processes after registering.
def _filter_or_exclude(self, negate, *args, **kwargs): from .models import Translation new_args = self.get_cleaned_args(args) new_kwargs = self.get_cleaned_kwargs(kwargs) translation_args = self.get_translation_args(args) translation_kwargs = self.get_translation_kwargs(kwargs) has_linguist_args = self.has_linguist_args(args) has_linguist_kwargs = self.has_linguist_kwargs(kwargs) if translation_args or translation_kwargs: ids = list( set( Translation.objects.filter( *translation_args, **translation_kwargs ).values_list("object_id", flat=True) ) ) if ids: new_kwargs["id__in"] = ids has_kwargs = has_linguist_kwargs and not (new_kwargs or new_args) has_args = has_linguist_args and not (new_args or new_kwargs) if has_kwargs or has_args: return self._clone().none() return super(QuerySetMixin, self)._filter_or_exclude( negate, *new_args, **new_kwargs )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_filter_or_exclude'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'negate'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '18', '27', '36', '45', '54', '63', '72', '114', '124', '134', '149']}; {'id': '11', 'type': 'import_from_statement', 'children': ['12', '16']}; {'id': '12', 'type': 'relative_import', 'children': ['13', '14']}; {'id': '13', 'type': 'import_prefix', 'children': []}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '16', 'type': 'dotted_name', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Translation'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'new_args'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get_cleaned_args'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'new_kwargs'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'get_cleaned_kwargs'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'translation_args'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'get_translation_args'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'translation_kwargs'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'get_translation_kwargs'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'has_linguist_args'}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'has_linguist_args'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'has_linguist_kwargs'}; {'id': '66', 'type': 'call', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'has_linguist_kwargs'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '72', 'type': 'if_statement', 'children': ['73', '76']}; {'id': '73', 'type': 'boolean_operator', 'children': ['74', '75'], 'value': 'or'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'translation_args'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'translation_kwargs'}; {'id': '76', 'type': 'block', 'children': ['77', '105']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '100']}; {'id': '87', 'type': 'attribute', 'children': ['88', '99']}; {'id': '88', 'type': 'call', 'children': ['89', '94']}; {'id': '89', 'type': 'attribute', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'Translation'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '97']}; {'id': '95', 'type': 'list_splat', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'translation_args'}; {'id': '97', 'type': 'dictionary_splat', 'children': ['98']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'translation_kwargs'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'values_list'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '102']}; {'id': '101', 'type': 'string', 'children': [], 'value': '"object_id"'}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'flat'}; {'id': '104', 'type': 'True', 'children': []}; {'id': '105', 'type': 'if_statement', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '113']}; {'id': '110', 'type': 'subscript', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'new_kwargs'}; {'id': '112', 'type': 'string', 'children': [], 'value': '"id__in"'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ids'}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'has_kwargs'}; {'id': '117', 'type': 'boolean_operator', 'children': ['118', '119'], 'value': 'and'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'has_linguist_kwargs'}; {'id': '119', 'type': 'not_operator', 'children': ['120']}; {'id': '120', 'type': '()', 'children': ['121']}; {'id': '121', 'type': 'boolean_operator', 'children': ['122', '123'], 'value': 'or'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'new_kwargs'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'new_args'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'has_args'}; {'id': '127', 'type': 'boolean_operator', 'children': ['128', '129'], 'value': 'and'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'has_linguist_args'}; {'id': '129', 'type': 'not_operator', 'children': ['130']}; {'id': '130', 'type': '()', 'children': ['131']}; {'id': '131', 'type': 'boolean_operator', 'children': ['132', '133'], 'value': 'or'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'new_args'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'new_kwargs'}; {'id': '134', 'type': 'if_statement', 'children': ['135', '138']}; {'id': '135', 'type': 'boolean_operator', 'children': ['136', '137'], 'value': 'or'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'has_kwargs'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'has_args'}; {'id': '138', 'type': 'block', 'children': ['139']}; {'id': '139', 'type': 'return_statement', 'children': ['140']}; {'id': '140', 'type': 'call', 'children': ['141', '148']}; {'id': '141', 'type': 'attribute', 'children': ['142', '147']}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': '_clone'}; {'id': '146', 'type': 'argument_list', 'children': []}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'none'}; {'id': '148', 'type': 'argument_list', 'children': []}; {'id': '149', 'type': 'return_statement', 'children': ['150']}; {'id': '150', 'type': 'call', 'children': ['151', '158']}; {'id': '151', 'type': 'attribute', 'children': ['152', '157']}; {'id': '152', 'type': 'call', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '154', 'type': 'argument_list', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'QuerySetMixin'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': '_filter_or_exclude'}; {'id': '158', 'type': 'argument_list', 'children': ['159', '160', '162']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'negate'}; {'id': '160', 'type': 'list_splat', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'new_args'}; {'id': '162', 'type': 'dictionary_splat', 'children': ['163']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'new_kwargs'}
Overrides default behavior to handle linguist fields.
def _print_convergence(self): if self.verbosity: if (self.num_acquisitions == self.max_iter) and (not self.initial_iter): print(' ** Maximum number of iterations reached **') return 1 elif (self._distance_last_evaluations() < self.eps) and (not self.initial_iter): print(' ** Two equal location selected **') return 1 elif (self.max_time < self.cum_time) and not (self.initial_iter): print(' ** Evaluation time reached **') return 0 if self.initial_iter: print('** GPyOpt Bayesian Optimization class initialized successfully **') self.initial_iter = False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_print_convergence'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '10', 'type': 'block', 'children': ['11', '82']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '26', '34', '59']}; {'id': '12', 'type': 'boolean_operator', 'children': ['13', '21'], 'value': 'and'}; {'id': '13', 'type': '()', 'children': ['14']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '18'], 'value': '=='}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'num_acquisitions'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'max_iter'}; {'id': '21', 'type': '()', 'children': ['22']}; {'id': '22', 'type': 'not_operator', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'initial_iter'}; {'id': '26', 'type': 'block', 'children': ['27', '32']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "' ** Maximum number of iterations reached **'"}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '34', 'type': 'elif_clause', 'children': ['35', '51']}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '46'], 'value': 'and'}; {'id': '36', 'type': '()', 'children': ['37']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '43'], 'value': '<'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': '_distance_last_evaluations'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'eps'}; {'id': '46', 'type': '()', 'children': ['47']}; {'id': '47', 'type': 'not_operator', 'children': ['48']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'initial_iter'}; {'id': '51', 'type': 'block', 'children': ['52', '57']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'string', 'children': [], 'value': "' ** Two equal location selected **'"}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '59', 'type': 'elif_clause', 'children': ['60', '74']}; {'id': '60', 'type': 'boolean_operator', 'children': ['61', '69'], 'value': 'and'}; {'id': '61', 'type': '()', 'children': ['62']}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '66'], 'value': '<'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'max_time'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'cum_time'}; {'id': '69', 'type': 'not_operator', 'children': ['70']}; {'id': '70', 'type': '()', 'children': ['71']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'initial_iter'}; {'id': '74', 'type': 'block', 'children': ['75', '80']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'string', 'children': [], 'value': "' ** Evaluation time reached **'"}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '82', 'type': 'if_statement', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'initial_iter'}; {'id': '86', 'type': 'block', 'children': ['87', '92']}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'** GPyOpt Bayesian Optimization class initialized successfully **'"}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'initial_iter'}; {'id': '97', 'type': 'False', 'children': []}
Prints the reason why the optimization stopped.
def getNodeByName(node, name): if node is None: raise Exception( "Cannot search for a child '%s' in a None object" % (name,) ) if not name: raise Exception("Unspecified name to find node for.") try: childNode = node.xpath("*[local-name() = '%s']" % name)[0] except: return None return childNode
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getNodeByName'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '29', '48']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'is'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'raise_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '18'], 'value': '%'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"Cannot search for a child \'%s\' in a None object"'}; {'id': '18', 'type': 'tuple', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '23']}; {'id': '21', 'type': 'not_operator', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'raise_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"Unspecified name to find node for."'}; {'id': '29', 'type': 'try_statement', 'children': ['30', '44']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'childNode'}; {'id': '34', 'type': 'subscript', 'children': ['35', '43']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'xpath'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'binary_operator', 'children': ['41', '42'], 'value': '%'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"*[local-name() = \'%s\']"'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '44', 'type': 'except_clause', 'children': ['45']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'None', 'children': []}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'childNode'}
Get the first child node matching a given local name
def pluralize(data_type): known = { u"address": u"addresses", u"company": u"companies" } if data_type in known.keys(): return known[data_type] else: return u"%ss" % data_type
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pluralize'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '5', 'type': 'block', 'children': ['6', '16']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'known'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '13']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': 'u"address"'}; {'id': '12', 'type': 'string', 'children': [], 'value': 'u"addresses"'}; {'id': '13', 'type': 'pair', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': 'u"company"'}; {'id': '15', 'type': 'string', 'children': [], 'value': 'u"companies"'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '24', '29']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'in'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'known'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'known'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'data_type'}; {'id': '29', 'type': 'else_clause', 'children': ['30']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '%'}; {'id': '33', 'type': 'string', 'children': [], 'value': 'u"%ss"'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'data_type'}
adds s to the data type or the correct english plural form
def _find_new_partners(self): open_channels = views.get_channelstate_open( chain_state=views.state_from_raiden(self.raiden), payment_network_id=self.registry_address, token_address=self.token_address, ) known = set(channel_state.partner_state.address for channel_state in open_channels) known.add(self.BOOTSTRAP_ADDR) known.add(self.raiden.address) participants_addresses = views.get_participants_addresses( views.state_from_raiden(self.raiden), self.registry_address, self.token_address, ) available = participants_addresses - known available = list(available) shuffle(available) new_partners = available log.debug( 'Found partners', node=pex(self.raiden.address), number_of_partners=len(available), ) return new_partners
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_find_new_partners'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '34', '48', '57', '68', '90', '96', '103', '108', '112', '135']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'open_channels'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'views'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get_channelstate_open'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '24', '29']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'chain_state'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'views'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'state_from_raiden'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'raiden'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'payment_network_id'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'registry_address'}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'token_address'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'token_address'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'known'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '39', 'type': 'generator_expression', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'channel_state'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'partner_state'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '45', 'type': 'for_in_clause', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'channel_state'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'open_channels'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'known'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'BOOTSTRAP_ADDR'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'known'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'attribute', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'raiden'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'participants_addresses'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'views'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_participants_addresses'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '84', '87']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'views'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'state_from_raiden'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'raiden'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'registry_address'}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'token_address'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'available'}; {'id': '93', 'type': 'binary_operator', 'children': ['94', '95'], 'value': '-'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'participants_addresses'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'known'}; {'id': '96', 'type': 'expression_statement', 'children': ['97']}; {'id': '97', 'type': 'assignment', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'available'}; {'id': '99', 'type': 'call', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'available'}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'shuffle'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'available'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'new_partners'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'available'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '119', '129']}; {'id': '118', 'type': 'string', 'children': [], 'value': "'Found partners'"}; {'id': '119', 'type': 'keyword_argument', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '121', 'type': 'call', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'pex'}; {'id': '123', 'type': 'argument_list', 'children': ['124']}; {'id': '124', 'type': 'attribute', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'raiden'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '129', 'type': 'keyword_argument', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'number_of_partners'}; {'id': '131', 'type': 'call', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'available'}; {'id': '135', 'type': 'return_statement', 'children': ['136']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'new_partners'}
Search the token network for potential channel partners.
def parse_command_line_args(): parser = argparse.ArgumentParser(description='PipApp. {}'.format(DESCRIPTION)) parser.add_argument( '-d', '--dir', metavar='DIR', help='Root directory where to create new project files and dirs. Default is current directory.' ) parser.add_argument( '-v,', '--version', action='version', version='{} v{}'.format(PROGRAMNAME, VERSION) ) parser.add_argument( "project_name", metavar='PROJECTNAME', help="Name of the generated Project. Has to be a valid Python identifier." ) return parser.parse_args()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_command_line_args'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '21', '35', '55', '68']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'argparse'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ArgumentParser'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'keyword_argument', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'PipApp. {}'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'DESCRIPTION'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28', '29', '32']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'-d'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'--dir'"}; {'id': '29', 'type': 'keyword_argument', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'metavar'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'DIR'"}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'Root directory where to create new project files and dirs. Default is current directory.'"}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42', '43', '46']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'-v,'"}; {'id': '42', 'type': 'string', 'children': [], 'value': "'--version'"}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '45', 'type': 'string', 'children': [], 'value': "'version'"}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': "'{} v{}'"}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'PROGRAMNAME'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'VERSION'}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'add_argument'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '65']}; {'id': '61', 'type': 'string', 'children': [], 'value': '"project_name"'}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'metavar'}; {'id': '64', 'type': 'string', 'children': [], 'value': "'PROJECTNAME'"}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'help'}; {'id': '67', 'type': 'string', 'children': [], 'value': '"Name of the generated Project. Has to be a valid Python identifier."'}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'parse_args'}; {'id': '73', 'type': 'argument_list', 'children': []}
parse command line args
def collect_manifest_dependencies(manifest_data, lockfile_data): output = {} for dependencyName, dependencyConstraint in manifest_data.items(): output[dependencyName] = { 'source': 'example-package-manager', 'constraint': dependencyConstraint, 'available': [ {'name': '2.0.0'}, ], } return output
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'collect_manifest_dependencies'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'manifest_data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'lockfile_data'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '40']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'for_statement', 'children': ['12', '15', '20']}; {'id': '12', 'type': 'pattern_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'dependencyName'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dependencyConstraint'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'manifest_data'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dependencyName'}; {'id': '26', 'type': 'dictionary', 'children': ['27', '30', '33']}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'source'"}; {'id': '29', 'type': 'string', 'children': [], 'value': "'example-package-manager'"}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'constraint'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'dependencyConstraint'}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'available'"}; {'id': '35', 'type': 'list', 'children': ['36'], 'value': "[\n {'name': '2.0.0'},\n ]"}; {'id': '36', 'type': 'dictionary', 'children': ['37']}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '39', 'type': 'string', 'children': [], 'value': "'2.0.0'"}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'output'}
Convert the manifest format to the dependencies schema
def save(self, vs, filetype): 'Copy rows to the system clipboard.' with tempfile.NamedTemporaryFile(suffix='.'+filetype) as temp: saveSheets(temp.name, vs) sync(1) p = subprocess.Popen( self.command, stdin=open(temp.name, 'r', encoding=options.encoding), stdout=subprocess.DEVNULL, close_fds=True) p.communicate()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filetype'}; {'id': '7', 'type': 'block', 'children': ['8', '10']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'string', 'children': [], 'value': "'Copy rows to the system clipboard.'"}; {'id': '10', 'type': 'with_statement', 'children': ['11', '26']}; {'id': '11', 'type': 'with_clause', 'children': ['12']}; {'id': '12', 'type': 'with_item', 'children': ['13']}; {'id': '13', 'type': 'as_pattern', 'children': ['14', '24']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'tempfile'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'NamedTemporaryFile'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '+'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filetype'}; {'id': '24', 'type': 'as_pattern_target', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '26', 'type': 'block', 'children': ['27', '35', '40', '73']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'saveSheets'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'vs'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sync'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'Popen'}; {'id': '47', 'type': 'argument_list', 'children': ['48', '51', '65', '70']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '59', '60']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'temp'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'DEVNULL'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'close_fds'}; {'id': '72', 'type': 'True', 'children': []}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'communicate'}; {'id': '78', 'type': 'argument_list', 'children': []}
Copy rows to the system clipboard.
def _check_index(self): assert 0 <= self._index <= len(self._history) - 1 assert len(self._history) >= 1
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_check_index'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20']}; {'id': '6', 'type': 'assert_statement', 'children': ['7']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '9', '12'], 'value': '<='}; {'id': '8', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_index'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '19'], 'value': '-'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_history'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'assert_statement', 'children': ['21']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '28'], 'value': '>='}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': '_history'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '1'}
Check that the index is without the bounds of _history.
def descendents(self): for c in self.children: yield c for d in c.descendents: yield d
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'descendents'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '8', '11']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '11', 'type': 'block', 'children': ['12', '15']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'yield', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '15', 'type': 'for_statement', 'children': ['16', '17', '20']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'descendents'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'yield', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'd'}
Iterate over all descendent terms
def distance_measure_common(A, func, alpha, R, k, epsilon): x = relaxation_vectors(A, R, k, alpha) d = func(x) (rows, cols) = A.nonzero() weak = np.where(rows == cols)[0] d[weak] = 0 C = sparse.csr_matrix((d, (rows, cols)), shape=A.shape) C.eliminate_zeros() amg_core.apply_distance_filter(C.shape[0], epsilon, C.indptr, C.indices, C.data) C.eliminate_zeros() C.data = 1.0 / C.data C = C + sparse.eye(C.shape[0], C.shape[1], format='csr') C = scale_rows_by_largest_entry(C) return C
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distance_measure_common'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'alpha'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'epsilon'}; {'id': '10', 'type': 'block', 'children': ['11', '21', '28', '38', '51', '57', '75', '81', '102', '108', '118', '141', '148']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'relaxation_vectors'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19', '20']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'alpha'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'tuple_pattern', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'nonzero'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'weak'}; {'id': '41', 'type': 'subscript', 'children': ['42', '50']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'where'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': '=='}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '56']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'weak'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'sparse'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'csr_matrix'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '70']}; {'id': '65', 'type': 'tuple', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '67', 'type': 'tuple', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'cols'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'eliminate_zeros'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'amg_core'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'apply_distance_filter'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '92', '93', '96', '99']}; {'id': '87', 'type': 'subscript', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '91', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'epsilon'}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'indptr'}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'indices'}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'call', 'children': ['104', '107']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'eliminate_zeros'}; {'id': '107', 'type': 'argument_list', 'children': []}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '113', 'type': 'binary_operator', 'children': ['114', '115'], 'value': '/'}; {'id': '114', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '118', 'type': 'expression_statement', 'children': ['119']}; {'id': '119', 'type': 'assignment', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '121', 'type': 'binary_operator', 'children': ['122', '123'], 'value': '+'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '123', 'type': 'call', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'sparse'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'eye'}; {'id': '127', 'type': 'argument_list', 'children': ['128', '133', '138']}; {'id': '128', 'type': 'subscript', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '132', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '133', 'type': 'subscript', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '137', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '138', 'type': 'keyword_argument', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '140', 'type': 'string', 'children': [], 'value': "'csr'"}; {'id': '141', 'type': 'expression_statement', 'children': ['142']}; {'id': '142', 'type': 'assignment', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '144', 'type': 'call', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'scale_rows_by_largest_entry'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '148', 'type': 'return_statement', 'children': ['149']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'C'}
Create strength of connection matrixfrom a function applied to relaxation vectors.
def show_metering_label_rule(self, metering_label_rule, **_params): return self.get(self.metering_label_rule_path % (metering_label_rule), params=_params)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show_metering_label_rule'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'metering_label_rule'}; {'id': '6', 'type': 'dictionary_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': '_params'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '21']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '19'], 'value': '%'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'metering_label_rule_path'}; {'id': '19', 'type': '()', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'metering_label_rule'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_params'}
Fetches information of a certain metering label rule.
def generate_kubernetes(self): example = {} example['spec'] = {} example['spec']['containers'] = [] example['spec']['containers'].append({"name": '', "image": '', "env": []}) for key, value in self.spec.items(): if value['type'] in (dict, list): kvalue = f"\'{json.dumps(value.get('example', ''))}\'" else: kvalue = f"{value.get('example', '')}" entry = {"name": f"{self.env_prefix}_{key.upper()}", "value": kvalue} example['spec']['containers'][0]['env'].append(entry) print(yaml.dump(example, default_flow_style=False))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_kubernetes'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '16', '24', '44', '100']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '15']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'spec'"}; {'id': '15', 'type': 'dictionary', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '23']}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'subscript', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '21', 'type': 'string', 'children': [], 'value': "'spec'"}; {'id': '22', 'type': 'string', 'children': [], 'value': "'containers'"}; {'id': '23', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '33']}; {'id': '26', 'type': 'attribute', 'children': ['27', '32']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'spec'"}; {'id': '31', 'type': 'string', 'children': [], 'value': "'containers'"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'dictionary', 'children': ['35', '38', '41']}; {'id': '35', 'type': 'pair', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '37', 'type': 'string', 'children': [], 'value': "''"}; {'id': '38', 'type': 'pair', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"image"'}; {'id': '40', 'type': 'string', 'children': [], 'value': "''"}; {'id': '41', 'type': 'pair', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': '"env"'}; {'id': '43', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '44', 'type': 'for_statement', 'children': ['45', '48', '55']}; {'id': '45', 'type': 'pattern_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '54', 'type': 'argument_list', 'children': []}; {'id': '55', 'type': 'block', 'children': ['56', '75', '85']}; {'id': '56', 'type': 'if_statement', 'children': ['57', '64', '69']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '61'], 'value': 'in'}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '60', 'type': 'string', 'children': [], 'value': "'type'"}; {'id': '61', 'type': 'tuple', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'kvalue'}; {'id': '68', 'type': 'string', 'children': [], 'value': 'f"\\\'{json.dumps(value.get(\'example\', \'\'))}\\\'"'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'kvalue'}; {'id': '74', 'type': 'string', 'children': [], 'value': 'f"{value.get(\'example\', \'\')}"'}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '78', 'type': 'dictionary', 'children': ['79', '82']}; {'id': '79', 'type': 'pair', 'children': ['80', '81']}; {'id': '80', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '81', 'type': 'string', 'children': [], 'value': 'f"{self.env_prefix}_{key.upper()}"'}; {'id': '82', 'type': 'pair', 'children': ['83', '84']}; {'id': '83', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'kvalue'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '98']}; {'id': '87', 'type': 'attribute', 'children': ['88', '97']}; {'id': '88', 'type': 'subscript', 'children': ['89', '96']}; {'id': '89', 'type': 'subscript', 'children': ['90', '95']}; {'id': '90', 'type': 'subscript', 'children': ['91', '94']}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '93', 'type': 'string', 'children': [], 'value': "'spec'"}; {'id': '94', 'type': 'string', 'children': [], 'value': "'containers'"}; {'id': '95', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'env'"}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'example'}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'default_flow_style'}; {'id': '112', 'type': 'False', 'children': []}
Generate a sample kubernetes
async def _get_protocol(self): if self._protocol is None: self._protocol = asyncio.Task(Context.create_client_context( loop=self._loop)) return (await self._protocol)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_protocol'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '33']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_protocol'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_protocol'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'Task'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'Context'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'create_client_context'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_loop'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': '()', 'children': ['35']}; {'id': '35', 'type': 'await', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_protocol'}
Get the protocol for the request.
def symbols(): symbols = [] for line in symbols_stream(): symbols.append(line.decode('utf-8').strip()) return symbols
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'symbols'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '31']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '8', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '9', 'type': 'for_statement', 'children': ['10', '11', '14']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'symbols_stream'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'symbols'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '30']}; {'id': '22', 'type': 'attribute', 'children': ['23', '29']}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'symbols'}
Return a list of symbols.
def open_datasets(path, backend_kwargs={}, no_warn=False, **kwargs): if not no_warn: warnings.warn("open_datasets is an experimental API, DO NOT RELY ON IT!", FutureWarning) fbks = [] datasets = [] try: datasets.append(open_dataset(path, backend_kwargs=backend_kwargs, **kwargs)) except DatasetBuildError as ex: fbks.extend(ex.args[2]) for fbk in fbks: bks = backend_kwargs.copy() bks['filter_by_keys'] = fbk datasets.extend(open_datasets(path, backend_kwargs=bks, no_warn=True, **kwargs)) return datasets
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open_datasets'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'backend_kwargs'}; {'id': '7', 'type': 'dictionary', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'no_warn'}; {'id': '10', 'type': 'False', 'children': []}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '13', 'type': 'block', 'children': ['14', '26', '30', '34', '68', '104']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '17']}; {'id': '15', 'type': 'not_operator', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'no_warn'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'string', 'children': [], 'value': '"open_datasets is an experimental API, DO NOT RELY ON IT!"'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'FutureWarning'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'fbks'}; {'id': '29', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'datasets'}; {'id': '33', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '34', 'type': 'try_statement', 'children': ['35', '51']}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'datasets'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'open_dataset'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46', '49']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '46', 'type': 'keyword_argument', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'backend_kwargs'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'backend_kwargs'}; {'id': '49', 'type': 'dictionary_splat', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '51', 'type': 'except_clause', 'children': ['52', '56']}; {'id': '52', 'type': 'as_pattern', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'DatasetBuildError'}; {'id': '54', 'type': 'as_pattern_target', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'fbks'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '62', 'type': 'argument_list', 'children': ['63']}; {'id': '63', 'type': 'subscript', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '68', 'type': 'for_statement', 'children': ['69', '70', '71']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'fbk'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'fbks'}; {'id': '71', 'type': 'block', 'children': ['72', '80', '86']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'bks'}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'backend_kwargs'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '79', 'type': 'argument_list', 'children': []}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '85']}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'bks'}; {'id': '84', 'type': 'string', 'children': [], 'value': "'filter_by_keys'"}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'fbk'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'datasets'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'open_datasets'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96', '99', '102']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '96', 'type': 'keyword_argument', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'backend_kwargs'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'bks'}; {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'no_warn'}; {'id': '101', 'type': 'True', 'children': []}; {'id': '102', 'type': 'dictionary_splat', 'children': ['103']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'datasets'}
Open a GRIB file groupping incompatible hypercubes to different datasets via simple heuristics.
def reload_webservers(): if env.verbosity: print env.host, "RELOADING apache2" with settings(warn_only=True): a = sudo("/etc/init.d/apache2 reload") if env.verbosity: print '',a if env.verbosity: print env.host,"RELOADING nginx" with settings(warn_only=True): s = run("/etc/init.d/nginx status") if 'running' in s: n = sudo("/etc/init.d/nginx reload") else: n = sudo("/etc/init.d/nginx start") if env.verbosity: print ' *',n return True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reload_webservers'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '15', '40', '50', '88', '96']}; {'id': '5', 'type': 'if_statement', 'children': ['6', '9']}; {'id': '6', 'type': 'attribute', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'print_statement', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"RELOADING apache2"'}; {'id': '15', 'type': 'with_statement', 'children': ['16', '24']}; {'id': '16', 'type': 'with_clause', 'children': ['17']}; {'id': '17', 'type': 'with_item', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'warn_only'}; {'id': '23', 'type': 'True', 'children': []}; {'id': '24', 'type': 'block', 'children': ['25', '32']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'sudo'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"/etc/init.d/apache2 reload"'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'print_statement', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "''"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '40', 'type': 'if_statement', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '44', 'type': 'block', 'children': ['45']}; {'id': '45', 'type': 'print_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"RELOADING nginx"'}; {'id': '50', 'type': 'with_statement', 'children': ['51', '59']}; {'id': '51', 'type': 'with_clause', 'children': ['52']}; {'id': '52', 'type': 'with_item', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'warn_only'}; {'id': '58', 'type': 'True', 'children': []}; {'id': '59', 'type': 'block', 'children': ['60', '67']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': '"/etc/init.d/nginx status"'}; {'id': '67', 'type': 'if_statement', 'children': ['68', '71', '79']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '70'], 'value': 'in'}; {'id': '69', 'type': 'string', 'children': [], 'value': "'running'"}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'sudo'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'string', 'children': [], 'value': '"/etc/init.d/nginx reload"'}; {'id': '79', 'type': 'else_clause', 'children': ['80']}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'assignment', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'sudo'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'string', 'children': [], 'value': '"/etc/init.d/nginx start"'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'verbosity'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'print_statement', 'children': ['94', '95']}; {'id': '94', 'type': 'string', 'children': [], 'value': "' *'"}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '96', 'type': 'return_statement', 'children': ['97']}; {'id': '97', 'type': 'True', 'children': []}
Reload apache2 and nginx
def extract_image_size(self): width, _ = self._extract_alternative_fields( ['Image ImageWidth', 'EXIF ExifImageWidth'], -1, int) height, _ = self._extract_alternative_fields( ['Image ImageLength', 'EXIF ExifImageLength'], -1, int) return width, height
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_image_size'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '22', '38']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'pattern_list', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_extract_alternative_fields'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19', '21']}; {'id': '16', 'type': 'list', 'children': ['17', '18'], 'value': "['Image ImageWidth', 'EXIF ExifImageWidth']"}; {'id': '17', 'type': 'string', 'children': [], 'value': "'Image ImageWidth'"}; {'id': '18', 'type': 'string', 'children': [], 'value': "'EXIF ExifImageWidth'"}; {'id': '19', 'type': 'unary_operator', 'children': ['20'], 'value': '-'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'pattern_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_extract_alternative_fields'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '35', '37']}; {'id': '32', 'type': 'list', 'children': ['33', '34'], 'value': "['Image ImageLength', 'EXIF ExifImageLength']"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'Image ImageLength'"}; {'id': '34', 'type': 'string', 'children': [], 'value': "'EXIF ExifImageLength'"}; {'id': '35', 'type': 'unary_operator', 'children': ['36'], 'value': '-'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'expression_list', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'height'}
Extract image height and width
def lookup(img, **kwargs): luts = np.array(kwargs['luts'], dtype=np.float32) / 255.0 def func(band_data, luts=luts, index=-1): lut = luts[:, index] if len(luts.shape) == 2 else luts band_data = band_data.clip(0, lut.size - 1).astype(np.uint8) new_delay = dask.delayed(_lookup_delayed)(lut, band_data) new_data = da.from_delayed(new_delay, shape=band_data.shape, dtype=luts.dtype) return new_data return apply_enhancement(img.data, func, separate=True, pass_dask=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'lookup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '26', '111']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'luts'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '25'], 'value': '/'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'array'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20']}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'luts'"}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'float32'}; {'id': '25', 'type': 'float', 'children': [], 'value': '255.0'}; {'id': '26', 'type': 'function_definition', 'children': ['27', '28', '37']}; {'id': '27', 'type': 'function_name', 'children': [], 'value': 'func'}; {'id': '28', 'type': 'parameters', 'children': ['29', '30', '33']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'band_data'}; {'id': '30', 'type': 'default_parameter', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'luts'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'luts'}; {'id': '33', 'type': 'default_parameter', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '35', 'type': 'unary_operator', 'children': ['36'], 'value': '-'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'block', 'children': ['38', '56', '77', '90', '109']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'lut'}; {'id': '41', 'type': 'conditional_expression', 'children': ['42', '47', '55'], 'value': 'if'}; {'id': '42', 'type': 'subscript', 'children': ['43', '44', '46']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'luts'}; {'id': '44', 'type': 'slice', 'children': ['45']}; {'id': '45', 'type': 'colon', 'children': []}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '54'], 'value': '=='}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'luts'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'luts'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'band_data'}; {'id': '59', 'type': 'call', 'children': ['60', '73']}; {'id': '60', 'type': 'attribute', 'children': ['61', '72']}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'band_data'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '71'], 'value': '-'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'lut'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '71', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'astype'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'uint8'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'new_delay'}; {'id': '80', 'type': 'call', 'children': ['81', '87']}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'dask'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'delayed'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_lookup_delayed'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'lut'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'band_data'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'da'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'from_delayed'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '99', '104']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'new_delay'}; {'id': '99', 'type': 'keyword_argument', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'band_data'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '104', 'type': 'keyword_argument', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'luts'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '109', 'type': 'return_statement', 'children': ['110']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'new_data'}; {'id': '111', 'type': 'return_statement', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'apply_enhancement'}; {'id': '114', 'type': 'argument_list', 'children': ['115', '118', '119', '122']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '119', 'type': 'keyword_argument', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'separate'}; {'id': '121', 'type': 'True', 'children': []}; {'id': '122', 'type': 'keyword_argument', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'pass_dask'}; {'id': '124', 'type': 'True', 'children': []}
Assign values to channels based on a table.
def extract_cookies(self, response, request): _debug("extract_cookies: %s", response.info()) self._cookies_lock.acquire() try: self._policy._now = self._now = int(time.time()) for cookie in self.make_cookies(response, request): if self._policy.set_ok(cookie, request): _debug(" setting cookie: %s", cookie) self.set_cookie(cookie) finally: self._cookies_lock.release()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_cookies'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '26']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_debug'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"extract_cookies: %s"'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '25']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_cookies_lock'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'acquire'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'try_statement', 'children': ['27', '81']}; {'id': '27', 'type': 'block', 'children': ['28', '47']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_policy'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_now'}; {'id': '35', 'type': 'assignment', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_now'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'for_statement', 'children': ['48', '49', '56']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'cookie'}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'make_cookies'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '56', 'type': 'block', 'children': ['57']}; {'id': '57', 'type': 'if_statement', 'children': ['58', '67']}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_policy'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'set_ok'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cookie'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '67', 'type': 'block', 'children': ['68', '74']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_debug'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'string', 'children': [], 'value': '" setting cookie: %s"'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'cookie'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'set_cookie'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'cookie'}; {'id': '81', 'type': 'finally_clause', 'children': ['82']}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '90']}; {'id': '85', 'type': 'attribute', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_cookies_lock'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '90', 'type': 'argument_list', 'children': []}
Extract cookies from response, where allowable given the request.
def on(self, group): asyncio.ensure_future(self._send_led_on_off_request(group, 1), loop=self._loop)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ensure_future'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '20']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_send_led_on_off_request'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_loop'}
Turn the LED on for a group.
def _list_superclasses(class_def): superclasses = class_def.get('superClasses', []) if superclasses: return list(superclasses) sup = class_def.get('superClass', None) if sup: return [sup] else: return []
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_list_superclasses'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'class_def'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '24', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'superclasses'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'class_def'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'string', 'children': [], 'value': "'superClasses'"}; {'id': '15', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'superclasses'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'superclasses'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sup'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'class_def'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'superClass'"}; {'id': '33', 'type': 'None', 'children': []}; {'id': '34', 'type': 'if_statement', 'children': ['35', '36', '40']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'sup'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'list', 'children': ['39'], 'value': '[sup]'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sup'}; {'id': '40', 'type': 'else_clause', 'children': ['41']}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'return_statement', 'children': ['43']}; {'id': '43', 'type': 'list', 'children': [], 'value': '[]'}
Return a list of the superclasses of the given class
def mark_good(self, proxy): if proxy not in self.proxies: logger.warn("Proxy <%s> was not found in proxies list" % proxy) return if proxy not in self.good: logger.debug("Proxy <%s> is GOOD" % proxy) self.unchecked.discard(proxy) self.dead.discard(proxy) self.good.add(proxy) self.proxies[proxy].failed_attempts = 0
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'mark_good'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '6', 'type': 'block', 'children': ['7', '24', '40', '49', '58', '67']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': 'not in'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'proxies'}; {'id': '13', 'type': 'block', 'children': ['14', '23']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '%'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"Proxy <%s> was not found in proxies list"'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '23', 'type': 'return_statement', 'children': []}; {'id': '24', 'type': 'if_statement', 'children': ['25', '30']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'not in'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'good'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'binary_operator', 'children': ['38', '39'], 'value': '%'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"Proxy <%s> is GOOD"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'unchecked'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'discard'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dead'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'discard'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '65']}; {'id': '60', 'type': 'attribute', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'good'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '76']}; {'id': '69', 'type': 'attribute', 'children': ['70', '75']}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'proxies'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'proxy'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'failed_attempts'}; {'id': '76', 'type': 'integer', 'children': [], 'value': '0'}
Mark a proxy as good