code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def _init(self): self._line_number = next_line( self._communication.last_requested_line_number, self._file.read(1)[0])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_line_number'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'next_line'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '19']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_communication'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'last_requested_line_number'}; {'id': '19', 'type': 'subscript', 'children': ['20', '28']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_file'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}
Read the line number.
def list(ctx): log.debug('chemdataextractor.config.list') for k in config: click.echo('%s : %s' % (k, config[k]))
{'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': 'ctx'}; {'id': '5', 'type': 'block', 'children': ['6', '13']}; {'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': 'log'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'chemdataextractor.config.list'"}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'echo'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'binary_operator', 'children': ['24', '25'], 'value': '%'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'%s : %s'"}; {'id': '25', 'type': 'tuple', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'k'}
List all config values.
def equalize_terminal_double_bond(mol): for i, a in mol.atoms_iter(): if mol.neighbor_count(i) == 1: nb = list(mol.neighbors(i).values())[0] if nb.order == 2: nb.type = 2
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'equalize_terminal_double_bond'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'for_statement', 'children': ['7', '10', '15']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'a'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'atoms_iter'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '25']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '24'], 'value': '=='}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'neighbor_count'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '25', 'type': 'block', 'children': ['26', '44']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '29', 'type': 'subscript', 'children': ['30', '43']}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '42']}; {'id': '34', 'type': 'attribute', 'children': ['35', '41']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'mol'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'neighbors'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '50']}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '49'], 'value': '=='}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'order'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'nb'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '2'}
Show equalized double bond if it is connected to terminal atom.
def visit_Bytes(self, node: ast.Bytes) -> bytes: result = node.s self.recomputed_values[node] = result return node.s
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'visit_Bytes'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ast'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Bytes'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '13', 'type': 'block', 'children': ['14', '20', '28']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '27']}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'recomputed_values'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 's'}
Recompute the value as the bytes at the node.
def process_message(message, notification): if not set(VITAL_MESSAGE_FIELDS) <= set(message): logger.info('JSON Message Missing Vital Fields') return HttpResponse('Missing Vital Fields') if message['notificationType'] == 'Complaint': return process_complaint(message, notification) if message['notificationType'] == 'Bounce': return process_bounce(message, notification) if message['notificationType'] == 'Delivery': return process_delivery(message, notification) else: return HttpResponse('Unknown Notification Type')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'process_message'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'notification'}; {'id': '6', 'type': 'block', 'children': ['7', '31', '44', '57']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '14'], 'value': '<='}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'VITAL_MESSAGE_FIELDS'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '18', 'type': 'block', 'children': ['19', '26']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'JSON Message Missing Vital Fields'"}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'HttpResponse'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'Missing Vital Fields'"}; {'id': '31', 'type': 'if_statement', 'children': ['32', '37']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '36'], 'value': '=='}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'notificationType'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'Complaint'"}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'process_complaint'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'notification'}; {'id': '44', 'type': 'if_statement', 'children': ['45', '50']}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '49'], 'value': '=='}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'notificationType'"}; {'id': '49', 'type': 'string', 'children': [], 'value': "'Bounce'"}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'process_bounce'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'notification'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '63', '70']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '62'], 'value': '=='}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '61', 'type': 'string', 'children': [], 'value': "'notificationType'"}; {'id': '62', 'type': 'string', 'children': [], 'value': "'Delivery'"}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'return_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'process_delivery'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'notification'}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'HttpResponse'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'string', 'children': [], 'value': "'Unknown Notification Type'"}
Function to process a JSON message delivered from Amazon
def wipe_table(self, table: str) -> int: sql = "DELETE FROM " + self.delimit(table) return self.db_exec(sql)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wipe_table'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '11', 'type': 'block', 'children': ['12', '23']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'sql'}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '+'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"DELETE FROM "'}; {'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': 'delimit'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'db_exec'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'sql'}
Delete all records from a table. Use caution!
def getall(self, table): try: self._check_db() except Exception as e: self.err(e, "Can not connect to database") return if table not in self.db.tables: self.warning("The table " + table + " does not exists") return try: res = self.db[table].all() df = pd.DataFrame(list(res)) return df except Exception as e: self.err(e, "Error retrieving data in table")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getall'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '6', 'type': 'block', 'children': ['7', '30', '51']}; {'id': '7', 'type': 'try_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'block', 'children': ['9']}; {'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': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_check_db'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'except_clause', 'children': ['16', '20']}; {'id': '16', 'type': 'as_pattern', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '18', 'type': 'as_pattern_target', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '20', 'type': 'block', 'children': ['21', '29']}; {'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': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"Can not connect to database"'}; {'id': '29', 'type': 'return_statement', 'children': []}; {'id': '30', 'type': 'if_statement', 'children': ['31', '38']}; {'id': '31', 'type': 'comparison_operator', 'children': ['32', '33'], 'value': 'not in'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'tables'}; {'id': '38', 'type': 'block', 'children': ['39', '50']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '49'], 'value': '+'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '+'}; {'id': '47', 'type': 'string', 'children': [], 'value': '"The table "'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '49', 'type': 'string', 'children': [], 'value': '" does not exists"'}; {'id': '50', 'type': 'return_statement', 'children': []}; {'id': '51', 'type': 'try_statement', 'children': ['52', '79']}; {'id': '52', 'type': 'block', 'children': ['53', '65', '77']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '56', 'type': 'call', 'children': ['57', '64']}; {'id': '57', 'type': 'attribute', 'children': ['58', '63']}; {'id': '58', 'type': 'subscript', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '64', 'type': 'argument_list', 'children': []}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'pd'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'DataFrame'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '79', 'type': 'except_clause', 'children': ['80', '84']}; {'id': '80', 'type': 'as_pattern', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '82', 'type': 'as_pattern_target', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'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': 'err'}; {'id': '90', 'type': 'argument_list', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '92', 'type': 'string', 'children': [], 'value': '"Error retrieving data in table"'}
Get all rows values for a table
def build_day(self, dt): self.month = str(dt.month) self.year = str(dt.year) self.day = str(dt.day) logger.debug("Building %s-%s-%s" % (self.year, self.month, self.day)) self.request = self.create_request(self.get_url()) path = self.get_build_path() self.build_file(path, self.get_content())
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'build_day'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '29', '40', '58', '73', '81']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '%'}; {'id': '47', 'type': 'string', 'children': [], 'value': '"Building %s-%s-%s"'}; {'id': '48', 'type': 'tuple', 'children': ['49', '52', '55']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'day'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'create_request'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'get_url'}; {'id': '72', 'type': 'argument_list', 'children': []}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'get_build_path'}; {'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': 'self'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'build_file'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'get_content'}; {'id': '92', 'type': 'argument_list', 'children': []}
Build the page for the provided day.
def run_add_system(name, token, org, system, prompt): repo = get_repo(token=token, org=org, name=name) try: repo.create_label(name=system.strip(), color=SYSTEM_LABEL_COLOR) click.secho("Successfully added new system {}".format(system), fg="green") if prompt and click.confirm("Run update to re-generate the page?"): run_update(name=name, token=token, org=org) except GithubException as e: if e.status == 422: click.secho( "Unable to add new system {}, it already exists.".format(system), fg="yellow") return raise
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run_add_system'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'org'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'prompt'}; {'id': '9', 'type': 'block', 'children': ['10', '25']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_repo'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '19', '22']}; {'id': '16', 'type': 'keyword_argument', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'org'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'org'}; {'id': '22', 'type': 'keyword_argument', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'try_statement', 'children': ['26', '81']}; {'id': '26', 'type': 'block', 'children': ['27', '43', '58']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'create_label'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '40']}; {'id': '33', 'type': 'keyword_argument', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'color'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'SYSTEM_LABEL_COLOR'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '55']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"Successfully added new system {}"'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"green"'}; {'id': '58', 'type': 'if_statement', 'children': ['59', '67']}; {'id': '59', 'type': 'boolean_operator', 'children': ['60', '61'], 'value': 'and'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'prompt'}; {'id': '61', 'type': 'call', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'confirm'}; {'id': '65', 'type': 'argument_list', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': '"Run update to re-generate the page?"'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'run_update'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '75', '78']}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'org'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'org'}; {'id': '81', 'type': 'except_clause', 'children': ['82', '86']}; {'id': '82', 'type': 'as_pattern', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'GithubException'}; {'id': '84', 'type': 'as_pattern_target', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '86', 'type': 'block', 'children': ['87', '110']}; {'id': '87', 'type': 'if_statement', 'children': ['88', '93']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '92'], 'value': '=='}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '422'}; {'id': '93', 'type': 'block', 'children': ['94', '109']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'click'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'secho'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '106']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'string', 'children': [], 'value': '"Unable to add new system {}, it already exists."'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '106', 'type': 'keyword_argument', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'fg'}; {'id': '108', 'type': 'string', 'children': [], 'value': '"yellow"'}; {'id': '109', 'type': 'return_statement', 'children': []}; {'id': '110', 'type': 'raise_statement', 'children': []}
Adds a new system to the repo.
def R_isrk(self, k): ind = int(self.index[self.R_time_var_index, k]) R = self.R[:, :, ind] if (R.shape[0] == 1): inv_square_root = np.sqrt(1.0/R) else: if self.svd_each_time: (U, S, Vh) = sp.linalg.svd(R, full_matrices=False, compute_uv=True, overwrite_a=False, check_finite=True) inv_square_root = U * 1.0/np.sqrt(S) else: if ind in self.R_square_root: inv_square_root = self.R_square_root[ind] else: (U, S, Vh) = sp.linalg.svd(R, full_matrices=False, compute_uv=True, overwrite_a=False, check_finite=True) inv_square_root = U * 1.0/np.sqrt(S) self.R_square_root[ind] = inv_square_root return inv_square_root
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'R_isrk'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '33', '166']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'subscript', 'children': ['14', '17', '20']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'R_time_var_index'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '24', 'type': 'subscript', 'children': ['25', '28', '30', '32']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '28', 'type': 'slice', 'children': ['29']}; {'id': '29', 'type': 'colon', 'children': []}; {'id': '30', 'type': 'slice', 'children': ['31']}; {'id': '31', 'type': 'colon', 'children': []}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '42', '54']}; {'id': '34', 'type': '()', 'children': ['35']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '41'], 'value': '=='}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'inv_square_root'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '/'}; {'id': '52', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '54', 'type': 'else_clause', 'children': ['55']}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'if_statement', 'children': ['57', '60', '100']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'svd_each_time'}; {'id': '60', 'type': 'block', 'children': ['61', '87']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '67']}; {'id': '63', 'type': 'tuple_pattern', 'children': ['64', '65', '66']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'U'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'Vh'}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'linalg'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'svd'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75', '78', '81', '84']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '75', 'type': 'keyword_argument', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'full_matrices'}; {'id': '77', 'type': 'False', 'children': []}; {'id': '78', 'type': 'keyword_argument', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'compute_uv'}; {'id': '80', 'type': 'True', 'children': []}; {'id': '81', 'type': 'keyword_argument', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'overwrite_a'}; {'id': '83', 'type': 'False', 'children': []}; {'id': '84', 'type': 'keyword_argument', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'check_finite'}; {'id': '86', 'type': 'True', 'children': []}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'inv_square_root'}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '94'], 'value': '/'}; {'id': '91', 'type': 'binary_operator', 'children': ['92', '93'], 'value': '*'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'U'}; {'id': '93', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '100', 'type': 'else_clause', 'children': ['101']}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'if_statement', 'children': ['103', '108', '117']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '105'], 'value': 'in'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'R_square_root'}; {'id': '108', 'type': 'block', 'children': ['109']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'inv_square_root'}; {'id': '112', 'type': 'subscript', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'R_square_root'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '117', 'type': 'else_clause', 'children': ['118']}; {'id': '118', 'type': 'block', 'children': ['119', '145', '158']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '125']}; {'id': '121', 'type': 'tuple_pattern', 'children': ['122', '123', '124']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'U'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'Vh'}; {'id': '125', 'type': 'call', 'children': ['126', '131']}; {'id': '126', 'type': 'attribute', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'sp'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'linalg'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'svd'}; {'id': '131', 'type': 'argument_list', 'children': ['132', '133', '136', '139', '142']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'R'}; {'id': '133', 'type': 'keyword_argument', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'full_matrices'}; {'id': '135', 'type': 'False', 'children': []}; {'id': '136', 'type': 'keyword_argument', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'compute_uv'}; {'id': '138', 'type': 'True', 'children': []}; {'id': '139', 'type': 'keyword_argument', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'overwrite_a'}; {'id': '141', 'type': 'False', 'children': []}; {'id': '142', 'type': 'keyword_argument', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'check_finite'}; {'id': '144', 'type': 'True', 'children': []}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'inv_square_root'}; {'id': '148', 'type': 'binary_operator', 'children': ['149', '152'], 'value': '/'}; {'id': '149', 'type': 'binary_operator', 'children': ['150', '151'], 'value': '*'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'U'}; {'id': '151', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'S'}; {'id': '158', 'type': 'expression_statement', 'children': ['159']}; {'id': '159', 'type': 'assignment', 'children': ['160', '165']}; {'id': '160', 'type': 'subscript', 'children': ['161', '164']}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'R_square_root'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'ind'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'inv_square_root'}; {'id': '166', 'type': 'return_statement', 'children': ['167']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'inv_square_root'}
Function returns the inverse square root of R matrix on step k.
def getfields(comm): fields = [] for field in comm: if 'field' in field: fields.append(field) return fields
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getfields'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'comm'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '26']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'comm'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': 'in'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'field'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'fields'}
get all the fields that have the key 'field'
def _no_ntplt(self, ntplt): sys.stdout.write(" {GO_USR:>6,} usr {GO_ALL:>6,} GOs DID NOT WRITE: {B} {D}\n".format( B=self.grprobj.get_fout_base(ntplt.hdrgo), D=ntplt.desc, GO_USR=len(ntplt.gosubdag.go_sources), GO_ALL=len(ntplt.gosubdag.go2obj)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_no_ntplt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ntplt'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '14']}; {'id': '9', 'type': 'attribute', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'stdout'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '" {GO_USR:>6,} usr {GO_ALL:>6,} GOs DID NOT WRITE: {B} {D}\\n"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '32', '37', '47']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'B'}; {'id': '22', 'type': 'call', 'children': ['23', '28']}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'grprobj'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'get_fout_base'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'ntplt'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'hdrgo'}; {'id': '32', 'type': 'keyword_argument', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'D'}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ntplt'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'desc'}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'GO_USR'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ntplt'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'gosubdag'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'go_sources'}; {'id': '47', 'type': 'keyword_argument', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'GO_ALL'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ntplt'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'gosubdag'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'go2obj'}
Print a message about the GO DAG Plot we are NOT plotting.
def hash160(self, is_compressed=None): if is_compressed is None: is_compressed = self.is_compressed() if is_compressed: if self._hash160_compressed is None: self._hash160_compressed = hash160(self.sec(is_compressed=is_compressed)) return self._hash160_compressed if self._hash160_uncompressed is None: self._hash160_uncompressed = hash160(self.sec(is_compressed=is_compressed)) return self._hash160_uncompressed
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'hash160'}; {'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': 'is_compressed'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '22', '52', '75']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'is_compressed'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'is_compressed'}; {'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': 'is_compressed'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'is_compressed'}; {'id': '24', 'type': 'block', 'children': ['25', '48']}; {'id': '25', 'type': 'if_statement', 'children': ['26', '31']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '30'], 'value': 'is'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_hash160_compressed'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': '_hash160_compressed'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'hash160'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'sec'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'keyword_argument', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'is_compressed'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'is_compressed'}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_hash160_compressed'}; {'id': '52', 'type': 'if_statement', 'children': ['53', '58']}; {'id': '53', 'type': 'comparison_operator', 'children': ['54', '57'], 'value': 'is'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_hash160_uncompressed'}; {'id': '57', 'type': 'None', 'children': []}; {'id': '58', 'type': 'block', 'children': ['59']}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_hash160_uncompressed'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'hash160'}; {'id': '66', 'type': 'argument_list', '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': 'sec'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'keyword_argument', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'is_compressed'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'is_compressed'}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': '_hash160_uncompressed'}
Return the hash160 representation of this key, if available.
def transloadsForPeer(self, peer): for tl in self.transloads.itervalues(): if peer in tl.peers: yield tl
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transloadsForPeer'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'peer'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '16']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'tl'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'transloads'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'itervalues'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'if_statement', 'children': ['18', '23']}; {'id': '18', 'type': 'comparison_operator', 'children': ['19', '20'], 'value': 'in'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'peer'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'tl'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'peers'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'yield', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'tl'}
Returns an iterator of transloads that apply to a particular peer.
def transmit_tc_bpdu(self): if not self.send_tc_flg: timer = datetime.timedelta(seconds=self.port_times.max_age + self.port_times.forward_delay) self.send_tc_timer = datetime.datetime.today() + timer self.send_tc_flg = True
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transmit_tc_bpdu'}; {'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', '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': 'send_tc_flg'}; {'id': '11', 'type': 'block', 'children': ['12', '33', '47']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'timer'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'timedelta'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'seconds'}; {'id': '22', 'type': 'binary_operator', 'children': ['23', '28'], 'value': '+'}; {'id': '23', 'type': 'attribute', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'port_times'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'max_age'}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'port_times'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'forward_delay'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'send_tc_timer'}; {'id': '38', 'type': 'binary_operator', 'children': ['39', '46'], 'value': '+'}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'timer'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'send_tc_flg'}; {'id': '52', 'type': 'True', 'children': []}
Set send_tc_flg to send Topology Change BPDU.
def distances(self): from molmod.ext import graphs_floyd_warshall distances = np.zeros((self.num_vertices,)*2, dtype=int) for i, j in self.edges: distances[i, j] = 1 distances[j, i] = 1 graphs_floyd_warshall(distances) return distances
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'distances'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '29', '51', '56']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'dotted_name', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'molmod'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'graphs_floyd_warshall'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '26']}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '25'], 'value': '*'}; {'id': '21', 'type': 'tuple', 'children': ['22']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'num_vertices'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '26', 'type': 'keyword_argument', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '29', 'type': 'for_statement', 'children': ['30', '33', '36']}; {'id': '30', 'type': 'pattern_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'edges'}; {'id': '36', 'type': 'block', 'children': ['37', '44']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '43']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41', '42']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '50']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48', '49']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'i'}; {'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': 'graphs_floyd_warshall'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'distances'}
The matrix with the all-pairs shortest path lenghts
def load_cfg(self): if self.cfg_mode == 'json': with open(self.cfg_file) as opened_file: return json.load(opened_file) else: with open(self.cfg_file) as ymlfile: return yaml.safe_load(ymlfile)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_cfg'}; {'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', '12', '33']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': '=='}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cfg_mode'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'json'"}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'with_statement', 'children': ['14', '25']}; {'id': '14', 'type': 'with_clause', 'children': ['15']}; {'id': '15', 'type': 'with_item', 'children': ['16']}; {'id': '16', 'type': 'as_pattern', 'children': ['17', '23']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cfg_file'}; {'id': '23', 'type': 'as_pattern_target', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'opened_file'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'opened_file'}; {'id': '33', 'type': 'else_clause', 'children': ['34']}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'with_statement', 'children': ['36', '47']}; {'id': '36', 'type': 'with_clause', 'children': ['37']}; {'id': '37', 'type': 'with_item', 'children': ['38']}; {'id': '38', 'type': 'as_pattern', 'children': ['39', '45']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'cfg_file'}; {'id': '45', 'type': 'as_pattern_target', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ymlfile'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'return_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'yaml'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'safe_load'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ymlfile'}
loads our config object accessible via self.cfg
def refactor_ifs(stmnt, ifs): if isinstance(stmnt, _ast.BoolOp): test, right = stmnt.values if isinstance(stmnt.op, _ast.Or): test = _ast.UnaryOp(op=_ast.Not(), operand=test, lineno=0, col_offset=0) ifs.append(test) return refactor_ifs(right, ifs) return stmnt
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refactor_ifs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'stmnt'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ifs'}; {'id': '6', 'type': 'block', 'children': ['7', '72']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'stmnt'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_ast'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'BoolOp'}; {'id': '15', 'type': 'block', 'children': ['16', '24', '59', '66']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'pattern_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'stmnt'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '34']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'stmnt'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_ast'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Or'}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_ast'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'UnaryOp'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '50', '53', '56']}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '_ast'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Not'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'operand'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '53', 'type': 'keyword_argument', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'lineno'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'col_offset'}; {'id': '58', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'ifs'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'test'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'refactor_ifs'}; {'id': '69', 'type': 'argument_list', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'right'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ifs'}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'stmnt'}
for if statements in list comprehension
def _linear_seaborn_(self, label=None, style=None, opts=None): xticks, yticks = self._get_ticks(opts) try: fig = sns.lmplot(self.x, self.y, data=self.df) fig = self._set_with_height(fig, opts) return fig except Exception as e: self.err(e, self.linear_, "Can not draw linear regression chart")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_linear_seaborn_'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '26']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '20']}; {'id': '17', 'type': 'pattern_list', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'xticks'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'yticks'}; {'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_ticks'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '26', 'type': 'try_statement', 'children': ['27', '59']}; {'id': '27', 'type': 'block', 'children': ['28', '47', '57']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'sns'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'lmplot'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '39', '42']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'y'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'df'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '_set_with_height'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'opts'}; {'id': '57', 'type': 'return_statement', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'fig'}; {'id': '59', 'type': 'except_clause', 'children': ['60', '64']}; {'id': '60', 'type': 'as_pattern', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '62', 'type': 'as_pattern_target', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'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': 'err'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72', '75']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'linear_'}; {'id': '75', 'type': 'string', 'children': [], 'value': '"Can not draw linear regression chart"'}
Returns a Seaborn linear regression plot
def _parse_feature_names(feature_names, new_names): if isinstance(feature_names, set): return FeatureParser._parse_names_set(feature_names) if isinstance(feature_names, dict): return FeatureParser._parse_names_dict(feature_names) if isinstance(feature_names, (tuple, list)): return FeatureParser._parse_names_tuple(feature_names, new_names) raise ValueError('Failed to parse {}, expected dictionary, set or tuple'.format(feature_names))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parse_feature_names'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'feature_names'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'new_names'}; {'id': '6', 'type': 'block', 'children': ['7', '21', '35', '52']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'feature_names'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'FeatureParser'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_parse_names_set'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'feature_names'}; {'id': '21', 'type': 'if_statement', 'children': ['22', '27']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'feature_names'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'FeatureParser'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_parse_names_dict'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'feature_names'}; {'id': '35', 'type': 'if_statement', 'children': ['36', '43']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'feature_names'}; {'id': '40', 'type': 'tuple', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'return_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'FeatureParser'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_parse_names_tuple'}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'feature_names'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'new_names'}; {'id': '52', 'type': 'raise_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'string', 'children': [], 'value': "'Failed to parse {}, expected dictionary, set or tuple'"}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'feature_names'}
Helping function of `_parse_features` that parses a collection of feature names.
def _reset(self): with self._lock: self.stop() self.start() for svc_ref in self.get_bindings(): if not self.requirement.filter.matches( svc_ref.get_properties() ): self.on_service_departure(svc_ref)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_reset'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_lock'}; {'id': '12', 'type': 'block', 'children': ['13', '19', '25']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'stop'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'expression_statement', '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': 'start'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'for_statement', 'children': ['26', '27', '32']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'svc_ref'}; {'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': 'get_bindings'}; {'id': '31', 'type': 'argument_list', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'if_statement', 'children': ['34', '49']}; {'id': '34', 'type': 'not_operator', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '43']}; {'id': '36', 'type': 'attribute', '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': 'requirement'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'matches'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'svc_ref'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'get_properties'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'on_service_departure'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'svc_ref'}
Called when the filter has been changed
def run(self, args): args = vars(args) positionals = [] keywords = {} for action in self.argparser._actions: if not hasattr(action, 'label'): continue if action.label == 'positional': positionals.append(args[action.dest]) elif action.label == 'varargs': positionals.extend(args[action.dest]) elif action.label == 'keyword': keywords[action.dest] = args[action.dest] elif action.label == 'varkwargs': kwpairs = iter(args[action.dest] or []) for key in kwpairs: try: key, value = key.split('=', 1) except ValueError: value = next(kwpairs) key = key.strip('-') keywords[key] = value return self.func(*positionals, **keywords)
{'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': 'args'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '18', '22', '157']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'vars'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'positionals'}; {'id': '17', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'keywords'}; {'id': '21', 'type': 'dictionary', 'children': []}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '29']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'argparser'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_actions'}; {'id': '29', 'type': 'block', 'children': ['30', '39']}; {'id': '30', 'type': 'if_statement', 'children': ['31', '37']}; {'id': '31', 'type': 'not_operator', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'label'"}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'continue_statement', 'children': []}; {'id': '39', 'type': 'if_statement', 'children': ['40', '45', '57', '75', '94']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '44'], 'value': '=='}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'positional'"}; {'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': 'positionals'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '57', 'type': 'elif_clause', 'children': ['58', '63']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '62'], 'value': '=='}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'varargs'"}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'positionals'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '75', 'type': 'elif_clause', 'children': ['76', '81']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '80'], 'value': '=='}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '80', 'type': 'string', 'children': [], 'value': "'keyword'"}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '89']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'keywords'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '94', 'type': 'elif_clause', 'children': ['95', '100']}; {'id': '95', 'type': 'comparison_operator', 'children': ['96', '99'], 'value': '=='}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '99', 'type': 'string', 'children': [], 'value': "'varkwargs'"}; {'id': '100', 'type': 'block', 'children': ['101', '114']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'kwpairs'}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'iter'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'boolean_operator', 'children': ['108', '113'], 'value': 'or'}; {'id': '108', 'type': 'subscript', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '113', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '114', 'type': 'for_statement', 'children': ['115', '116', '117']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'kwpairs'}; {'id': '117', 'type': 'block', 'children': ['118', '151']}; {'id': '118', 'type': 'try_statement', 'children': ['119', '132']}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '125']}; {'id': '122', 'type': 'pattern_list', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '131']}; {'id': '130', 'type': 'string', 'children': [], 'value': "'='"}; {'id': '131', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '132', 'type': 'except_clause', 'children': ['133', '134']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '134', 'type': 'block', 'children': ['135', '142']}; {'id': '135', 'type': 'expression_statement', 'children': ['136']}; {'id': '136', 'type': 'assignment', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '138', 'type': 'call', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'next'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'kwpairs'}; {'id': '142', 'type': 'expression_statement', 'children': ['143']}; {'id': '143', 'type': 'assignment', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'string', 'children': [], 'value': "'-'"}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '156']}; {'id': '153', 'type': 'subscript', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'keywords'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '157', 'type': 'return_statement', 'children': ['158']}; {'id': '158', 'type': 'call', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '162', 'type': 'argument_list', 'children': ['163', '165']}; {'id': '163', 'type': 'list_splat', 'children': ['164']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'positionals'}; {'id': '165', 'type': 'dictionary_splat', 'children': ['166']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'keywords'}
Convert the unordered args into function arguments.
def clip_grad(learn:Learner, clip:float=0.1)->Learner: "Add gradient clipping of `clip` during training." learn.callback_fns.append(partial(GradientClipping, clip=clip)) return learn
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13', '15']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clip_grad'}; {'id': '3', 'type': 'parameters', 'children': ['4', '8']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'learn'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'Learner'}; {'id': '8', 'type': 'typed_default_parameter', 'children': ['9', '10', '12']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '12', 'type': 'float', 'children': [], 'value': '0.1'}; {'id': '13', 'type': 'type', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Learner'}; {'id': '15', 'type': 'block', 'children': ['16', '18', '33']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"Add gradient clipping of `clip` during training."'}; {'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': 'learn'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'callback_fns'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'GradientClipping'}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'clip'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'learn'}
Add gradient clipping of `clip` during training.
def unlock(name, zk_hosts=None, identifier=None, max_concurrency=1, ephemeral_lease=False, profile=None, scheme=None, username=None, password=None, default_acl=None): ret = {'name': name, 'changes': {}, 'result': False, 'comment': ''} conn_kwargs = {'profile': profile, 'scheme': scheme, 'username': username, 'password': password, 'default_acl': default_acl} if __opts__['test']: ret['result'] = None ret['comment'] = 'Released lock if it is here' return ret if identifier is None: identifier = __grains__['id'] unlocked = __salt__['zk_concurrency.unlock'](name, zk_hosts=zk_hosts, identifier=identifier, max_concurrency=max_concurrency, ephemeral_lease=ephemeral_lease, **conn_kwargs) if unlocked: ret['result'] = True else: ret['comment'] = 'Unable to find lease for path {0}'.format(name) return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '32']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unlock'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23', '26', '29']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'zk_hosts'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'max_concurrency'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ephemeral_lease'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'profile'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'scheme'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '25', 'type': 'None', 'children': []}; {'id': '26', 'type': 'default_parameter', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'default_parameter', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'default_acl'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33', '49', '68', '87', '98', '121', '143']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '36', 'type': 'dictionary', 'children': ['37', '40', '43', '46']}; {'id': '37', 'type': 'pair', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': "'name'"}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'pair', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': "'changes'"}; {'id': '42', 'type': 'dictionary', 'children': []}; {'id': '43', 'type': 'pair', 'children': ['44', '45']}; {'id': '44', 'type': 'string', 'children': [], 'value': "'result'"}; {'id': '45', 'type': 'False', 'children': []}; {'id': '46', 'type': 'pair', 'children': ['47', '48']}; {'id': '47', 'type': 'string', 'children': [], 'value': "'comment'"}; {'id': '48', 'type': 'string', 'children': [], 'value': "''"}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'conn_kwargs'}; {'id': '52', 'type': 'dictionary', 'children': ['53', '56', '59', '62', '65']}; {'id': '53', 'type': 'pair', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': "'profile'"}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'profile'}; {'id': '56', 'type': 'pair', 'children': ['57', '58']}; {'id': '57', 'type': 'string', 'children': [], 'value': "'scheme'"}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'scheme'}; {'id': '59', 'type': 'pair', 'children': ['60', '61']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'username'"}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '62', 'type': 'pair', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'password'"}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '65', 'type': 'pair', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': "'default_acl'"}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'default_acl'}; {'id': '68', 'type': 'if_statement', 'children': ['69', '72']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'test'"}; {'id': '72', 'type': 'block', 'children': ['73', '79', '85']}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '78']}; {'id': '75', 'type': 'subscript', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '77', 'type': 'string', 'children': [], 'value': "'result'"}; {'id': '78', 'type': 'None', 'children': []}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '84']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '83', 'type': 'string', 'children': [], 'value': "'comment'"}; {'id': '84', 'type': 'string', 'children': [], 'value': "'Released lock if it is here'"}; {'id': '85', 'type': 'return_statement', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '87', 'type': 'if_statement', 'children': ['88', '91']}; {'id': '88', 'type': 'comparison_operator', 'children': ['89', '90'], 'value': 'is'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '90', 'type': 'None', 'children': []}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': '__grains__'}; {'id': '97', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'unlocked'}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': '__salt__'}; {'id': '104', 'type': 'string', 'children': [], 'value': "'zk_concurrency.unlock'"}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107', '110', '113', '116', '119']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '107', 'type': 'keyword_argument', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'zk_hosts'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'zk_hosts'}; {'id': '110', 'type': 'keyword_argument', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'identifier'}; {'id': '113', 'type': 'keyword_argument', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'max_concurrency'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'max_concurrency'}; {'id': '116', 'type': 'keyword_argument', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'ephemeral_lease'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'ephemeral_lease'}; {'id': '119', 'type': 'dictionary_splat', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'conn_kwargs'}; {'id': '121', 'type': 'if_statement', 'children': ['122', '123', '130']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'unlocked'}; {'id': '123', 'type': 'block', 'children': ['124']}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '129']}; {'id': '126', 'type': 'subscript', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '128', 'type': 'string', 'children': [], 'value': "'result'"}; {'id': '129', 'type': 'True', 'children': []}; {'id': '130', 'type': 'else_clause', 'children': ['131']}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '137']}; {'id': '134', 'type': 'subscript', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '136', 'type': 'string', 'children': [], 'value': "'comment'"}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'string', 'children': [], 'value': "'Unable to find lease for path {0}'"}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '143', 'type': 'return_statement', 'children': ['144']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'ret'}
Remove lease from semaphore.
def _init_socket(self): if self.ddpsocket: self.ddpsocket.remove_all_listeners('received_message') self.ddpsocket.remove_all_listeners('closed') self.ddpsocket.remove_all_listeners('opened') self.ddpsocket.close_connection() self.ddpsocket = None self.ddpsocket = DDPSocket(self.url, self.debug) self.ddpsocket.on('received_message', self.received_message) self.ddpsocket.on('closed', self.closed) self.ddpsocket.on('opened', self.opened)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_init_socket'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '52', '66', '78', '90']}; {'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': 'ddpsocket'}; {'id': '10', 'type': 'block', 'children': ['11', '20', '29', '38', '46']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'remove_all_listeners'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'received_message'"}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'remove_all_listeners'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'closed'"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', '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': 'ddpsocket'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'remove_all_listeners'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'string', 'children': [], 'value': "'opened'"}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'close_connection'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '51', 'type': 'None', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'DDPSocket'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'string', 'children': [], 'value': "'received_message'"}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'received_message'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '85']}; {'id': '80', 'type': 'attribute', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87']}; {'id': '86', 'type': 'string', 'children': [], 'value': "'closed'"}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'closed'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '97']}; {'id': '92', 'type': 'attribute', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'ddpsocket'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '99']}; {'id': '98', 'type': 'string', 'children': [], 'value': "'opened'"}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'opened'}
Initialize the ddp socket
def check_extension(conn, extension: str) -> bool: query = 'SELECT installed_version FROM pg_available_extensions WHERE name=%s;' with conn.cursor() as cursor: cursor.execute(query, (extension,)) result = cursor.fetchone() if result is None: raise psycopg2.ProgrammingError( 'Extension is not available for installation.', extension ) else: extension_version = result[0] return bool(extension_version)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_extension'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'extension'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '11', 'type': 'block', 'children': ['12', '16', '45']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '15', 'type': 'string', 'children': [], 'value': "'SELECT installed_version FROM pg_available_extensions WHERE name=%s;'"}; {'id': '16', 'type': 'with_statement', 'children': ['17', '27']}; {'id': '17', 'type': 'with_clause', 'children': ['18']}; {'id': '18', 'type': 'with_item', 'children': ['19']}; {'id': '19', 'type': 'as_pattern', 'children': ['20', '25']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'as_pattern_target', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '27', 'type': 'block', 'children': ['28', '37']}; {'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': 'cursor'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '35', 'type': 'tuple', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'extension'}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'fetchone'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'if_statement', 'children': ['46', '49', '58']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'is'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '48', 'type': 'None', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'raise_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'psycopg2'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'ProgrammingError'}; {'id': '55', 'type': 'argument_list', 'children': ['56', '57']}; {'id': '56', 'type': 'string', 'children': [], 'value': "'Extension is not available for installation.'"}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'extension'}; {'id': '58', 'type': 'else_clause', 'children': ['59']}; {'id': '59', 'type': 'block', 'children': ['60', '66']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'extension_version'}; {'id': '63', 'type': 'subscript', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'bool'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'extension_version'}
Check to see if an extension is installed.
def close(self): self._input.close() self._call_parse() root = self._pop_message() assert not self._msgstack if root.get_content_maintype() == 'multipart' \ and not root.is_multipart(): defect = errors.MultipartInvariantViolationDefect() self.policy.handle_defect(root, defect) return root
{'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', '14', '20', '28', '33', '68']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '13']}; {'id': '8', 'type': 'attribute', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_input'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'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': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_call_parse'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'root'}; {'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': '_pop_message'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'assert_statement', 'children': ['29']}; {'id': '29', 'type': 'not_operator', 'children': ['30']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_msgstack'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '49']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '42', '43'], 'value': 'and'}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '41'], 'value': '=='}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get_content_maintype'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'string', 'children': [], 'value': "'multipart'"}; {'id': '42', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '43', 'type': 'not_operator', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'is_multipart'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50', '58']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'defect'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'MultipartInvariantViolationDefect'}; {'id': '57', 'type': 'argument_list', 'children': []}; {'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': 'policy'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'handle_defect'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'defect'}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'root'}
Parse all remaining data and return the root message object.
def cli(env): mgr = SoftLayer.LoadBalancerManager(env.client) table = formatting.Table(['price_id', 'capacity', 'description', 'price']) table.sortby = 'price' table.align['price'] = 'r' table.align['capacity'] = 'r' table.align['id'] = 'r' packages = mgr.get_lb_pkgs() for package in packages: table.add_row([ package['prices'][0]['id'], package.get('capacity'), package['description'], '%.2f' % float(package['prices'][0]['recurringFee']) ]) env.fout(table)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cli'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '5', 'type': 'block', 'children': ['6', '17', '30', '36', '44', '52', '60', '68', '107']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'mgr'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'SoftLayer'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'LoadBalancerManager'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'formatting'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'list', 'children': ['26', '27', '28', '29'], 'value': "['price_id', 'capacity', 'description', 'price']"}; {'id': '26', 'type': 'string', 'children': [], 'value': "'price_id'"}; {'id': '27', 'type': 'string', 'children': [], 'value': "'capacity'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'description'"}; {'id': '29', 'type': 'string', 'children': [], 'value': "'price'"}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'sortby'}; {'id': '35', 'type': 'string', 'children': [], 'value': "'price'"}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '43']}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '42', 'type': 'string', 'children': [], 'value': "'price'"}; {'id': '43', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '51']}; {'id': '46', 'type': 'subscript', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '50', 'type': 'string', 'children': [], 'value': "'capacity'"}; {'id': '51', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '59']}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'align'}; {'id': '58', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '59', 'type': 'string', 'children': [], 'value': "'r'"}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'packages'}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'mgr'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'get_lb_pkgs'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'for_statement', 'children': ['69', '70', '71']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'packages'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'add_row'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'list', 'children': ['79', '86', '92', '95'], 'value': "[\n package['prices'][0]['id'],\n package.get('capacity'),\n package['description'],\n '%.2f' % float(package['prices'][0]['recurringFee'])\n ]"}; {'id': '79', 'type': 'subscript', 'children': ['80', '85']}; {'id': '80', 'type': 'subscript', 'children': ['81', '84']}; {'id': '81', 'type': 'subscript', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '83', 'type': 'string', 'children': [], 'value': "'prices'"}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '85', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'string', 'children': [], 'value': "'capacity'"}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '94', 'type': 'string', 'children': [], 'value': "'description'"}; {'id': '95', 'type': 'binary_operator', 'children': ['96', '97'], 'value': '%'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'%.2f'"}; {'id': '97', 'type': 'call', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'subscript', 'children': ['101', '106']}; {'id': '101', 'type': 'subscript', 'children': ['102', '105']}; {'id': '102', 'type': 'subscript', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'package'}; {'id': '104', 'type': 'string', 'children': [], 'value': "'prices'"}; {'id': '105', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '106', 'type': 'string', 'children': [], 'value': "'recurringFee'"}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'call', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'fout'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'table'}
Get price options to create a load balancer with.
def relabel(self, qubits: Qubits) -> 'Gate': gate = copy(self) gate.vec = gate.vec.relabel(qubits) return gate
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'relabel'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'qubits'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Qubits'}; {'id': '9', 'type': 'type', 'children': ['10']}; {'id': '10', 'type': 'string', 'children': [], 'value': "'Gate'"}; {'id': '11', 'type': 'block', 'children': ['12', '19', '32']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'vec'}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'vec'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'relabel'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'qubits'}; {'id': '32', 'type': 'return_statement', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'gate'}
Return a copy of this Gate with new qubits
def setData(self, index, value, role=Qt.EditRole): item = self.itemAt(index) if not item: return False d = item.declaration if role == Qt.CheckStateRole: checked = value == Qt.Checked if checked != d.checked: d.checked = checked d.toggled(checked) return True elif role == Qt.EditRole: if value != d.text: d.text = value return True return super(QAbstractAtomItemModel, self).setData(index, value, role)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'setData'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'EditRole'}; {'id': '12', 'type': 'block', 'children': ['13', '22', '28', '34', '93']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'item'}; {'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': 'itemAt'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '22', 'type': 'if_statement', 'children': ['23', '25']}; {'id': '23', 'type': 'not_operator', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'False', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'declaration'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '40', '71']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': '=='}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'CheckStateRole'}; {'id': '40', 'type': 'block', 'children': ['41', '49', '69']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '46'], 'value': '=='}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'Checked'}; {'id': '49', 'type': 'if_statement', 'children': ['50', '55']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '52'], 'value': '!='}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '55', 'type': 'block', 'children': ['56', '62']}; {'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': 'd'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'toggled'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'checked'}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'True', 'children': []}; {'id': '71', 'type': 'elif_clause', 'children': ['72', '77']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': '=='}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'role'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'Qt'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'EditRole'}; {'id': '77', 'type': 'block', 'children': ['78', '91']}; {'id': '78', 'type': 'if_statement', 'children': ['79', '84']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '81'], 'value': '!='}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'True', 'children': []}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '102']}; {'id': '95', 'type': 'attribute', 'children': ['96', '101']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'QAbstractAtomItemModel'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'setData'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104', '105']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'role'}
Set the data for the item at the given index to the given value.
def wiki(searchterm): searchterm = quote(searchterm) url = "https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json" url = url.format(searchterm) result = requests.get(url).json() pages = result["query"]["search"] pages = [p for p in pages if 'may refer to' not in p["snippet"]] if not pages: return "" page = quote(pages[0]["title"].encode("utf8")) link = "http://en.wikipedia.org/wiki/{0}".format(page) r = requests.get( "http://en.wikipedia.org/w/api.php?format=json&action=parse&page={0}". format(page)).json() soup = BeautifulSoup(r["parse"]["text"]["*"], "html5lib") p = soup.find('p').get_text() p = p[:8000] return u"{0}\n{1}".format(p, link)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wiki'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'searchterm'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '17', '26', '39', '47', '61', '67', '83', '92', '110', '124', '137', '145']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'searchterm'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'quote'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'searchterm'}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"https://en.wikipedia.org/w/api.php?action=query&list=search&srsearch={0}&format=json"'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'searchterm'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '29', 'type': 'call', 'children': ['30', '38']}; {'id': '30', 'type': 'attribute', 'children': ['31', '37']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '38', 'type': 'argument_list', 'children': []}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '42', 'type': 'subscript', 'children': ['43', '46']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"query"'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"search"'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '50', 'type': 'list_comprehension', 'children': ['51', '52', '55']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '52', 'type': 'for_in_clause', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '55', 'type': 'if_clause', 'children': ['56']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '58'], 'value': 'not in'}; {'id': '57', 'type': 'string', 'children': [], 'value': "'may refer to'"}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"snippet"'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '64']}; {'id': '62', 'type': 'not_operator', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'return_statement', 'children': ['66']}; {'id': '66', 'type': 'string', 'children': [], 'value': '""'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'quote'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'call', 'children': ['74', '81']}; {'id': '74', 'type': 'attribute', 'children': ['75', '80']}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'pages'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '79', 'type': 'string', 'children': [], 'value': '"title"'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'string', 'children': [], 'value': '"utf8"'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'link'}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': '"http://en.wikipedia.org/wiki/{0}"'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '95', 'type': 'call', 'children': ['96', '109']}; {'id': '96', 'type': 'attribute', 'children': ['97', '108']}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'string', 'children': [], 'value': '"http://en.wikipedia.org/w/api.php?format=json&action=parse&page={0}"'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '109', 'type': 'argument_list', 'children': []}; {'id': '110', 'type': 'expression_statement', 'children': ['111']}; {'id': '111', 'type': 'assignment', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'BeautifulSoup'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '123']}; {'id': '116', 'type': 'subscript', 'children': ['117', '122']}; {'id': '117', 'type': 'subscript', 'children': ['118', '121']}; {'id': '118', 'type': 'subscript', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '120', 'type': 'string', 'children': [], 'value': '"parse"'}; {'id': '121', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '122', 'type': 'string', 'children': [], 'value': '"*"'}; {'id': '123', 'type': 'string', 'children': [], 'value': '"html5lib"'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'assignment', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '127', 'type': 'call', 'children': ['128', '136']}; {'id': '128', 'type': 'attribute', 'children': ['129', '135']}; {'id': '129', 'type': 'call', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'soup'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'find'}; {'id': '133', 'type': 'argument_list', 'children': ['134']}; {'id': '134', 'type': 'string', 'children': [], 'value': "'p'"}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'get_text'}; {'id': '136', 'type': 'argument_list', 'children': []}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'assignment', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '140', 'type': 'subscript', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '142', 'type': 'slice', 'children': ['143', '144']}; {'id': '143', 'type': 'colon', 'children': []}; {'id': '144', 'type': 'integer', 'children': [], 'value': '8000'}; {'id': '145', 'type': 'return_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'string', 'children': [], 'value': 'u"{0}\\n{1}"'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '150', 'type': 'argument_list', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'link'}
return the top wiki search result for the term
def __inner_predict(self, data_idx): if data_idx >= self.__num_dataset: raise ValueError("Data_idx should be smaller than number of dataset") if self.__inner_predict_buffer[data_idx] is None: if data_idx == 0: n_preds = self.train_set.num_data() * self.__num_class else: n_preds = self.valid_sets[data_idx - 1].num_data() * self.__num_class self.__inner_predict_buffer[data_idx] = np.zeros(n_preds, dtype=np.float64) if not self.__is_predicted_cur_iter[data_idx]: tmp_out_len = ctypes.c_int64(0) data_ptr = self.__inner_predict_buffer[data_idx].ctypes.data_as(ctypes.POINTER(ctypes.c_double)) _safe_call(_LIB.LGBM_BoosterGetPredict( self.handle, ctypes.c_int(data_idx), ctypes.byref(tmp_out_len), data_ptr)) if tmp_out_len.value != len(self.__inner_predict_buffer[data_idx]): raise ValueError("Wrong length of predict results for data %d" % (data_idx)) self.__is_predicted_cur_iter[data_idx] = True return self.__inner_predict_buffer[data_idx]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__inner_predict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '85', '179']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '>='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '__num_dataset'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'raise_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"Data_idx should be smaller than number of dataset"'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '27']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '26'], 'value': 'is'}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '__inner_predict_buffer'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28', '67']}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32', '47']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': '=='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'n_preds'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '44'], 'value': '*'}; {'id': '37', 'type': 'call', 'children': ['38', '43']}; {'id': '38', 'type': 'attribute', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'train_set'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'num_data'}; {'id': '43', 'type': 'argument_list', 'children': []}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '__num_class'}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'n_preds'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '64'], 'value': '*'}; {'id': '53', 'type': 'call', 'children': ['54', '63']}; {'id': '54', 'type': 'attribute', 'children': ['55', '62']}; {'id': '55', 'type': 'subscript', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'valid_sets'}; {'id': '59', 'type': 'binary_operator', 'children': ['60', '61'], 'value': '-'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'num_data'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '__num_class'}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '74']}; {'id': '69', 'type': 'subscript', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '__inner_predict_buffer'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'n_preds'}; {'id': '80', 'type': 'keyword_argument', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'float64'}; {'id': '85', 'type': 'if_statement', 'children': ['86', '92']}; {'id': '86', 'type': 'not_operator', 'children': ['87']}; {'id': '87', 'type': 'subscript', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '__is_predicted_cur_iter'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '92', 'type': 'block', 'children': ['93', '102', '124', '149', '171']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'tmp_out_len'}; {'id': '96', 'type': 'call', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'c_int64'}; {'id': '100', 'type': 'argument_list', 'children': ['101']}; {'id': '101', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'data_ptr'}; {'id': '105', 'type': 'call', 'children': ['106', '115']}; {'id': '106', 'type': 'attribute', 'children': ['107', '114']}; {'id': '107', 'type': 'attribute', 'children': ['108', '113']}; {'id': '108', 'type': 'subscript', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': '__inner_predict_buffer'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'data_as'}; {'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': 'ctypes'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'POINTER'}; {'id': '120', 'type': 'argument_list', 'children': ['121']}; {'id': '121', 'type': 'attribute', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'c_double'}; {'id': '124', 'type': 'expression_statement', 'children': ['125']}; {'id': '125', 'type': 'call', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': '_safe_call'}; {'id': '127', 'type': 'argument_list', 'children': ['128']}; {'id': '128', 'type': 'call', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': '_LIB'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'LGBM_BoosterGetPredict'}; {'id': '132', 'type': 'argument_list', 'children': ['133', '136', '142', '148']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'handle'}; {'id': '136', 'type': 'call', 'children': ['137', '140']}; {'id': '137', 'type': 'attribute', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'c_int'}; {'id': '140', 'type': 'argument_list', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'byref'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'tmp_out_len'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'data_ptr'}; {'id': '149', 'type': 'if_statement', 'children': ['150', '162']}; {'id': '150', 'type': 'comparison_operator', 'children': ['151', '154'], 'value': '!='}; {'id': '151', 'type': 'attribute', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'tmp_out_len'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '154', 'type': 'call', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '156', 'type': 'argument_list', 'children': ['157']}; {'id': '157', 'type': 'subscript', 'children': ['158', '161']}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': '__inner_predict_buffer'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '162', 'type': 'block', 'children': ['163']}; {'id': '163', 'type': 'raise_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '166', 'type': 'argument_list', 'children': ['167']}; {'id': '167', 'type': 'binary_operator', 'children': ['168', '169'], 'value': '%'}; {'id': '168', 'type': 'string', 'children': [], 'value': '"Wrong length of predict results for data %d"'}; {'id': '169', 'type': '()', 'children': ['170']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '171', 'type': 'expression_statement', 'children': ['172']}; {'id': '172', 'type': 'assignment', 'children': ['173', '178']}; {'id': '173', 'type': 'subscript', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': '__is_predicted_cur_iter'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'data_idx'}; {'id': '178', 'type': 'True', 'children': []}; {'id': '179', 'type': 'return_statement', 'children': ['180']}; {'id': '180', 'type': 'subscript', 'children': ['181', '184']}; {'id': '181', 'type': 'attribute', 'children': ['182', '183']}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': '__inner_predict_buffer'}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'data_idx'}
Predict for training and validation dataset.
def view_required_params_per_trt(token, dstore): csm_info = dstore['csm_info'] tbl = [] for grp_id, trt in sorted(csm_info.grp_by("trt").items()): gsims = csm_info.gsim_lt.get_gsims(trt) maker = ContextMaker(trt, gsims) distances = sorted(maker.REQUIRES_DISTANCES) siteparams = sorted(maker.REQUIRES_SITES_PARAMETERS) ruptparams = sorted(maker.REQUIRES_RUPTURE_PARAMETERS) tbl.append((grp_id, ' '.join(map(repr, map(repr, gsims))), distances, siteparams, ruptparams)) return rst_table( tbl, header='grp_id gsims distances siteparams ruptparams'.split(), fmt=scientificformat)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'view_required_params_per_trt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'token'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'dstore'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '17', '106']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'csm_info'}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'dstore'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'csm_info'"}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'tbl'}; {'id': '16', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '17', 'type': 'for_statement', 'children': ['18', '21', '34']}; {'id': '18', 'type': 'pattern_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'grp_id'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'trt'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '33']}; {'id': '25', 'type': 'attribute', 'children': ['26', '32']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'csm_info'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'grp_by'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"trt"'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'block', 'children': ['35', '46', '54', '63', '72', '81']}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'gsims'}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'csm_info'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'gsim_lt'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'get_gsims'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'trt'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'maker'}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'ContextMaker'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'trt'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'gsims'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'maker'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'REQUIRES_DISTANCES'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'siteparams'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'maker'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'REQUIRES_SITES_PARAMETERS'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'ruptparams'}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'maker'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'REQUIRES_RUPTURE_PARAMETERS'}; {'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': 'tbl'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'id': '87', 'type': 'tuple', 'children': ['88', '89', '103', '104', '105']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'grp_id'}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '98', 'type': 'call', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '100', 'type': 'argument_list', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'repr'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'gsims'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'distances'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'siteparams'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'ruptparams'}; {'id': '106', 'type': 'return_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'rst_table'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '111', '118']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'tbl'}; {'id': '111', 'type': 'keyword_argument', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'header'}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'string', 'children': [], 'value': "'grp_id gsims distances siteparams ruptparams'"}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '117', 'type': 'argument_list', 'children': []}; {'id': '118', 'type': 'keyword_argument', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'scientificformat'}
Display the parameters needed by each tectonic region type
def _run(name, cmd, exec_driver=None, output=None, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, use_vt=False, keep_env=None): if exec_driver is None: exec_driver = _get_exec_driver() ret = __salt__['container_resource.run']( name, cmd, container_type=__virtualname__, exec_driver=exec_driver, output=output, stdin=stdin, python_shell=python_shell, output_loglevel=output_loglevel, ignore_retcode=ignore_retcode, use_vt=use_vt, keep_env=keep_env) if output in (None, 'all'): return ret else: return ret[output]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '30']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_run'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9', '12', '15', '18', '21', '24', '27']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'exec_driver'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'default_parameter', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'default_parameter', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'python_shell'}; {'id': '17', 'type': 'True', 'children': []}; {'id': '18', 'type': 'default_parameter', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'output_loglevel'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'debug'"}; {'id': '21', 'type': 'default_parameter', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ignore_retcode'}; {'id': '23', 'type': 'False', 'children': []}; {'id': '24', 'type': 'default_parameter', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'use_vt'}; {'id': '26', 'type': 'False', 'children': []}; {'id': '27', 'type': 'default_parameter', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'keep_env'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31', '42', '79']}; {'id': '31', 'type': 'if_statement', 'children': ['32', '35']}; {'id': '32', 'type': 'comparison_operator', 'children': ['33', '34'], 'value': 'is'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'exec_driver'}; {'id': '34', 'type': 'None', 'children': []}; {'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': 'exec_driver'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_get_exec_driver'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': '__salt__'}; {'id': '48', 'type': 'string', 'children': [], 'value': "'container_resource.run'"}; {'id': '49', 'type': 'argument_list', 'children': ['50', '51', '52', '55', '58', '61', '64', '67', '70', '73', '76']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'container_type'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': '__virtualname__'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'exec_driver'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'exec_driver'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '61', 'type': 'keyword_argument', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'stdin'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'python_shell'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'python_shell'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'output_loglevel'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'output_loglevel'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'ignore_retcode'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'ignore_retcode'}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'use_vt'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'use_vt'}; {'id': '76', 'type': 'keyword_argument', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'keep_env'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'keep_env'}; {'id': '79', 'type': 'if_statement', 'children': ['80', '85', '88']}; {'id': '80', 'type': 'comparison_operator', 'children': ['81', '82'], 'value': 'in'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '82', 'type': 'tuple', 'children': ['83', '84']}; {'id': '83', 'type': 'None', 'children': []}; {'id': '84', 'type': 'string', 'children': [], 'value': "'all'"}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'return_statement', 'children': ['87']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '88', 'type': 'else_clause', 'children': ['89']}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'output'}
Common logic for docker.run functions
def str2float(text): try: return float(re.sub(r"\(.+\)*", "", text)) except TypeError: if isinstance(text, list) and len(text) == 1: return float(re.sub(r"\(.+\)*", "", text[0])) except ValueError as ex: if text.strip() == ".": return 0 raise ex
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'str2float'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '20', '51']}; {'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': 'float'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'string', 'children': [], 'value': 'r"\\(.+\\)*"'}; {'id': '18', 'type': 'string', 'children': [], 'value': '""'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '20', 'type': 'except_clause', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '36']}; {'id': '24', 'type': 'boolean_operator', 'children': ['25', '30'], 'value': 'and'}; {'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': 'text'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '35'], 'value': '=='}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 're'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '48']}; {'id': '46', 'type': 'string', 'children': [], 'value': 'r"\\(.+\\)*"'}; {'id': '47', 'type': 'string', 'children': [], 'value': '""'}; {'id': '48', 'type': 'subscript', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '50', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '51', 'type': 'except_clause', 'children': ['52', '56']}; {'id': '52', 'type': 'as_pattern', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '54', 'type': 'as_pattern_target', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ex'}; {'id': '56', 'type': 'block', 'children': ['57', '68']}; {'id': '57', 'type': 'if_statement', 'children': ['58', '65']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '64'], 'value': '=='}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '68', 'type': 'raise_statement', 'children': ['69']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ex'}
Remove uncertainty brackets from strings and return the float.
def _convert_label(label): style = qt_font_to_style(label.get("font"), label.get("color")) return { "text": html.escape(label["text"]), "rotation": 0, "style": style, "x": int(label["x"]), "y": int(label["y"]) }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_convert_label'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '5', 'type': 'block', 'children': ['6', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'qt_font_to_style'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '18']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"font"'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'string', 'children': [], 'value': '"color"'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'dictionary', 'children': ['26', '36', '39', '42', '50']}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'escape'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '35', 'type': 'string', 'children': [], 'value': '"text"'}; {'id': '36', 'type': 'pair', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"rotation"'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '39', 'type': 'pair', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': '"style"'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '42', 'type': 'pair', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"x"'}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'subscript', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '49', 'type': 'string', 'children': [], 'value': '"x"'}; {'id': '50', 'type': 'pair', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': '"y"'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '57', 'type': 'string', 'children': [], 'value': '"y"'}
Convert a label from 1.X to the new format
def _renameClasses(classes, prefix): renameMap = {} for classID, glyphList in classes.items(): if len(glyphList) == 0: groupName = "%s_empty_lu.%d_st.%d_cl.%d" % (prefix, classID[0], classID[1], classID[2]) elif len(glyphList) == 1: groupName = list(glyphList)[0] else: glyphList = list(sorted(glyphList)) groupName = prefix + glyphList[0] renameMap[classID] = groupName return renameMap
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_renameClasses'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'classes'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '88']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'renameMap'}; {'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': 'classID'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'glyphList'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'classes'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '82']}; {'id': '21', 'type': 'if_statement', 'children': ['22', '28', '45', '62']}; {'id': '22', 'type': 'comparison_operator', 'children': ['23', '27'], 'value': '=='}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'glyphList'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'groupName'}; {'id': '32', 'type': 'binary_operator', 'children': ['33', '34'], 'value': '%'}; {'id': '33', 'type': 'string', 'children': [], 'value': '"%s_empty_lu.%d_st.%d_cl.%d"'}; {'id': '34', 'type': 'tuple', 'children': ['35', '36', '39', '42']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'classID'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'classID'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'classID'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '45', 'type': 'elif_clause', 'children': ['46', '52']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '51'], 'value': '=='}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'glyphList'}; {'id': '51', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'groupName'}; {'id': '56', 'type': 'subscript', 'children': ['57', '61']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'glyphList'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'else_clause', 'children': ['63']}; {'id': '63', 'type': 'block', 'children': ['64', '74']}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'glyphList'}; {'id': '67', 'type': 'call', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'glyphList'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'groupName'}; {'id': '77', 'type': 'binary_operator', 'children': ['78', '79'], 'value': '+'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'glyphList'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '87']}; {'id': '84', 'type': 'subscript', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'renameMap'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'classID'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'groupName'}; {'id': '88', 'type': 'return_statement', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'renameMap'}
Replace class IDs with nice strings.
def graceful_ctrlc(func): @wraps(func) def wrapper(*args, **kwargs): try: return func(*args, **kwargs) except KeyboardInterrupt: exit(1) return wrapper
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'graceful_ctrlc'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '5', 'type': 'block', 'children': ['6', '38']}; {'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': 'wrapper'}; {'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']}; {'id': '20', 'type': 'try_statement', 'children': ['21', '30']}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '28']}; {'id': '26', 'type': 'list_splat', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '28', 'type': 'dictionary_splat', 'children': ['29']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '30', 'type': 'except_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'KeyboardInterrupt'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'wrapper'}
Makes the decorated function exit with code 1 on CTRL+C.
def from_fqdn(cls, fqdn): result = cls.list({'fqdn': fqdn}) if len(result) > 0: return result[0]['id']
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'from_fqdn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fqdn'}; {'id': '6', 'type': 'block', 'children': ['7', '19']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'dictionary', 'children': ['16']}; {'id': '16', 'type': 'pair', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'fqdn'"}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'fqdn'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '26']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '25'], 'value': '>'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'subscript', 'children': ['29', '32']}; {'id': '29', 'type': 'subscript', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'id'"}
Retrieve domain id associated to a FQDN.
def async_get_measurements(self, uid, fields='*'): return (yield from self._get('/pods/{}/measurements'.format(uid), fields=fields))[0]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'async_get_measurements'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '8', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'return_statement', 'children': ['11']}; {'id': '11', 'type': 'subscript', 'children': ['12', '28']}; {'id': '12', 'type': '()', 'children': ['13']}; {'id': '13', 'type': 'yield', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_get'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '25']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'/pods/{}/measurements'"}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'uid'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}
Get measurements of a device.
def _read_mz(self, mz_offset, mz_len, mz_enc_len): self.ibd.seek(mz_offset) data = self.ibd.read(mz_enc_len) self.ibd.seek(0, 2) data = self.mz_compression.decompress(data) return tuple(np.fromstring(data, dtype=self.mz_dtype))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_read_mz'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'mz_offset'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'mz_len'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'mz_enc_len'}; {'id': '8', 'type': 'block', 'children': ['9', '18', '29', '39', '50']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'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': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ibd'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'mz_offset'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ibd'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'mz_enc_len'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'call', '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': 'ibd'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '42', 'type': 'call', 'children': ['43', '48']}; {'id': '43', 'type': 'attribute', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'mz_compression'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'decompress'}; {'id': '48', 'type': 'argument_list', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '50', 'type': 'return_statement', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'fromstring'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'mz_dtype'}
reads a mz array from the currently open ibd file
def list_ebs(region, filter_by_kwargs): conn = boto.ec2.connect_to_region(region) instances = conn.get_all_volumes() return lookup(instances, filter_by=filter_by_kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_ebs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filter_by_kwargs'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '26']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'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': 'boto'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ec2'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'connect_to_region'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'get_all_volumes'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'lookup'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'filter_by'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'filter_by_kwargs'}
List running ebs volumes.
def _align_from_fastq(fastq1, fastq2, aligner, align_ref, sam_ref, names, align_dir, data): config = data["config"] align_fn = TOOLS[aligner].align_fn out = align_fn(fastq1, fastq2, align_ref, names, align_dir, data) if isinstance(out, dict): assert out.get("work_bam"), (dd.get_sample_name(data), out.get("work_bam")) return out else: work_bam = bam.sam_to_bam(out, config) data["work_bam"] = bam.sort(work_bam, config) return data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_align_from_fastq'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fastq1'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fastq2'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'aligner'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'align_ref'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sam_ref'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'align_dir'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '12', 'type': 'block', 'children': ['13', '19', '27', '39']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"config"'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'align_fn'}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'TOOLS'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'aligner'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'align_fn'}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'align_fn'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34', '35', '36', '37', '38']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'fastq1'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'fastq2'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'align_ref'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'align_dir'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '39', 'type': 'if_statement', 'children': ['40', '45', '68']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '45', 'type': 'block', 'children': ['46', '66']}; {'id': '46', 'type': 'assert_statement', 'children': ['47', '53']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"work_bam"'}; {'id': '53', 'type': 'tuple', 'children': ['54', '60']}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'dd'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get_sample_name'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'string', 'children': [], 'value': '"work_bam"'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '68', 'type': 'else_clause', 'children': ['69']}; {'id': '69', 'type': 'block', 'children': ['70', '80', '92']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'work_bam'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'bam'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'sam_to_bam'}; {'id': '77', 'type': 'argument_list', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'config'}; {'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': 'data'}; {'id': '84', 'type': 'string', 'children': [], 'value': '"work_bam"'}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'bam'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'work_bam'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'data'}
Align from fastq inputs, producing sorted BAM output.
def register_ddk_task(self, *args, **kwargs): kwargs["task_class"] = DdkTask return self.register_task(*args, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'register_ddk_task'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '9', 'type': 'block', 'children': ['10', '16']}; {'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': 'kwargs'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"task_class"'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'DdkTask'}; {'id': '16', 'type': 'return_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': 'register_task'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '24']}; {'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'}
Register a ddk task.
def save_user_and_user_email(self, user, user_email): if self.UserEmailClass: self.db_adapter.save_object(user_email) self.db_adapter.save_object(user)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_user_and_user_email'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'user_email'}; {'id': '7', 'type': 'block', 'children': ['8', '22']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'UserEmailClass'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', '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': 'db_adapter'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'save_object'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'user_email'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '29']}; {'id': '24', 'type': 'attribute', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'db_adapter'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'save_object'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'user'}
Save the User and UserEmail object.
def handle_rule_versions(self, filename, rule_type, rule): if 'versions' in rule: versions = rule.pop('versions') for version_key_suffix in versions: version = versions[version_key_suffix] version['key_suffix'] = version_key_suffix tmp_rule = dict(rule, **version) self.rules[filename].append(Rule(filename, rule_type, tmp_rule)) else: self.rules[filename].append(Rule(filename, rule_type, rule))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle_rule_versions'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'rule_type'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13', '64']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'in'}; {'id': '11', 'type': 'string', 'children': [], 'value': "'versions'"}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '13', 'type': 'block', 'children': ['14', '23']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'versions'}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '21', 'type': 'argument_list', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'versions'"}; {'id': '23', 'type': 'for_statement', 'children': ['24', '25', '26']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'version_key_suffix'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'versions'}; {'id': '26', 'type': 'block', 'children': ['27', '33', '39', '48']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'versions'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'version_key_suffix'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'key_suffix'"}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'version_key_suffix'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'tmp_rule'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'rule'}; {'id': '46', 'type': 'dictionary_splat', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '57']}; {'id': '50', 'type': 'attribute', 'children': ['51', '56']}; {'id': '51', 'type': 'subscript', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'rules'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'call', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'Rule'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62', '63']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'rule_type'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'tmp_rule'}; {'id': '64', 'type': 'else_clause', 'children': ['65']}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '75']}; {'id': '68', 'type': 'attribute', 'children': ['69', '74']}; {'id': '69', 'type': 'subscript', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'rules'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'Rule'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '80', '81']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'rule_type'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'rule'}
For each version of a rule found in the ruleset, append a new Rule object
def wrap(value): if isinstance(value, Document) or isinstance(value, DocumentList): return value elif isinstance(value, dict): return Document(value) elif isinstance(value, list): return DocumentList(value) else: return value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'wrap'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '18', '21', '33', '45']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '13'], 'value': 'or'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '10', 'type': 'argument_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Document'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'DocumentList'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '21', 'type': 'elif_clause', 'children': ['22', '27']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'Document'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '33', 'type': 'elif_clause', 'children': ['34', '39']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'list'}; {'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': 'DocumentList'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '45', 'type': 'else_clause', 'children': ['46']}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'value'}
Wraps the given value in a Document or DocumentList as applicable.
def parse_TKIP_hdr(pkt): assert pkt.FCfield.protected tkip_layer = pkt[Dot11TKIP] payload = tkip_layer.data if not tkip_layer.ext_iv: raise ValueError("Extended IV must be set for TKIP") TSC0 = tkip_layer.TSC0 TSC1 = tkip_layer.TSC1 WEPseed = tkip_layer.WEPSeed TSC2 = tkip_layer.TSC2 TSC3 = tkip_layer.TSC3 TSC4 = tkip_layer.TSC4 TSC5 = tkip_layer.TSC5 assert (TSC1 | 0x20) & 0x7f == WEPseed TA = [orb(e) for e in mac2str(pkt.addr2)] TSC = [TSC0, TSC1, TSC2, TSC3, TSC4, TSC5] return TSC, TA, payload
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_TKIP_hdr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'pkt'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '24', '35', '41', '47', '53', '59', '65', '71', '77', '86', '102', '112']}; {'id': '6', 'type': 'assert_statement', 'children': ['7']}; {'id': '7', 'type': 'attribute', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'pkt'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'FCfield'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'protected'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '15', 'type': 'subscript', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'pkt'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Dot11TKIP'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '29']}; {'id': '25', 'type': 'not_operator', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ext_iv'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'raise_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"Extended IV must be set for TKIP"'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'TSC0'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'TSC0'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'TSC1'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'TSC1'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'WEPseed'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'WEPSeed'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'TSC2'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'TSC2'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'TSC3'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'TSC3'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'TSC4'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'TSC4'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'TSC5'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'tkip_layer'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'TSC5'}; {'id': '77', 'type': 'assert_statement', 'children': ['78']}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '85'], 'value': '=='}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '84'], 'value': '&'}; {'id': '80', 'type': '()', 'children': ['81']}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '83'], 'value': '|'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'TSC1'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '0x20'}; {'id': '84', 'type': 'integer', 'children': [], 'value': '0x7f'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'WEPseed'}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'TA'}; {'id': '89', 'type': 'list_comprehension', 'children': ['90', '94']}; {'id': '90', 'type': 'call', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'orb'}; {'id': '92', 'type': 'argument_list', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '94', 'type': 'for_in_clause', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'mac2str'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'pkt'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'addr2'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'TSC'}; {'id': '105', 'type': 'list', 'children': ['106', '107', '108', '109', '110', '111'], 'value': '[TSC0, TSC1, TSC2, TSC3, TSC4, TSC5]'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'TSC0'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'TSC1'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'TSC2'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'TSC3'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'TSC4'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'TSC5'}; {'id': '112', 'type': 'return_statement', 'children': ['113']}; {'id': '113', 'type': 'expression_list', 'children': ['114', '115', '116']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'TSC'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'TA'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'payload'}
Extract TSCs, TA and encoded-data from a packet @pkt
def guess_input_handler(seqs, add_seq_names=False): if isinstance(seqs, str): if '\n' in seqs: return '_input_as_multiline_string' else: return '_input_as_string' if isinstance(seqs, list) and len(seqs) and isinstance(seqs[0], tuple): return '_input_as_seq_id_seq_pairs' if add_seq_names: return '_input_as_seqs' return '_input_as_lines'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'guess_input_handler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'seqs'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'add_seq_names'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '27', '49', '54']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '15']}; {'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': 'seqs'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20', '23']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'in'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'seqs'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'_input_as_multiline_string'"}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'_input_as_string'"}; {'id': '27', 'type': 'if_statement', 'children': ['28', '46']}; {'id': '28', 'type': 'boolean_operator', 'children': ['29', '39'], 'value': 'and'}; {'id': '29', 'type': 'boolean_operator', 'children': ['30', '35'], 'value': 'and'}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'seqs'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'seqs'}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'seqs'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'_input_as_seq_id_seq_pairs'"}; {'id': '49', 'type': 'if_statement', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'add_seq_names'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'return_statement', 'children': ['53']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'_input_as_seqs'"}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'_input_as_lines'"}
Returns the name of the input handler for seqs.
def _select_default_algorithm(analysis): if not analysis or analysis == "Standard": return "Standard", {"aligner": "bwa", "platform": "illumina", "quality_format": "Standard", "recalibrate": False, "realign": False, "mark_duplicates": True, "variantcaller": False} elif "variant" in analysis: try: config, _ = template.name_to_config(analysis) except ValueError: config, _ = template.name_to_config("freebayes-variant") return "variant", config["details"][0]["algorithm"] else: return analysis, {}
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_select_default_algorithm'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'analysis'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13', '39', '81']}; {'id': '7', 'type': 'boolean_operator', 'children': ['8', '10'], 'value': 'or'}; {'id': '8', 'type': 'not_operator', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'analysis'}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': '=='}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'analysis'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"Standard"'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': ['15']}; {'id': '15', 'type': 'expression_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"Standard"'}; {'id': '17', 'type': 'dictionary', 'children': ['18', '21', '24', '27', '30', '33', '36']}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': '"aligner"'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"bwa"'}; {'id': '21', 'type': 'pair', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"platform"'}; {'id': '23', 'type': 'string', 'children': [], 'value': '"illumina"'}; {'id': '24', 'type': 'pair', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"quality_format"'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"Standard"'}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': '"recalibrate"'}; {'id': '29', 'type': 'False', 'children': []}; {'id': '30', 'type': 'pair', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"realign"'}; {'id': '32', 'type': 'False', 'children': []}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"mark_duplicates"'}; {'id': '35', 'type': 'True', 'children': []}; {'id': '36', 'type': 'pair', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"variantcaller"'}; {'id': '38', 'type': 'False', 'children': []}; {'id': '39', 'type': 'elif_clause', 'children': ['40', '43']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '42'], 'value': 'in'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"variant"'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'analysis'}; {'id': '43', 'type': 'block', 'children': ['44', '71']}; {'id': '44', 'type': 'try_statement', 'children': ['45', '57']}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '51']}; {'id': '48', 'type': 'pattern_list', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '51', 'type': 'call', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'name_to_config'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'analysis'}; {'id': '57', 'type': 'except_clause', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '65']}; {'id': '62', 'type': 'pattern_list', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'name_to_config'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'string', 'children': [], 'value': '"freebayes-variant"'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'expression_list', 'children': ['73', '74']}; {'id': '73', 'type': 'string', 'children': [], 'value': '"variant"'}; {'id': '74', 'type': 'subscript', 'children': ['75', '80']}; {'id': '75', 'type': 'subscript', 'children': ['76', '79']}; {'id': '76', 'type': 'subscript', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '78', 'type': 'string', 'children': [], 'value': '"details"'}; {'id': '79', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '80', 'type': 'string', 'children': [], 'value': '"algorithm"'}; {'id': '81', 'type': 'else_clause', 'children': ['82']}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'return_statement', 'children': ['84']}; {'id': '84', 'type': 'expression_list', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'analysis'}; {'id': '86', 'type': 'dictionary', 'children': []}
Provide default algorithm sections from templates or standard
def spatial_slice_zeros(x): return tf.cast(tf.reduce_all(tf.less_equal(x, 0.0), [0, 1, 2]), tf.float32)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'spatial_slice_zeros'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cast'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '28']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'reduce_all'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '24']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'less_equal'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '23', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '24', 'type': 'list', 'children': ['25', '26', '27'], 'value': '[0, 1, 2]'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'tf'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'float32'}
Experimental summary that shows how many planes are unused for a batch.
def _spawn(self): self.queue = Queue(maxsize=self.num_threads * 10) for i in range(self.num_threads): t = Thread(target=self._consume) t.daemon = True t.start()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_spawn'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Queue'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'keyword_argument', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'maxsize'}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '20'], 'value': '*'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'num_threads'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '10'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '29']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'num_threads'}; {'id': '29', 'type': 'block', 'children': ['30', '41', '47']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'Thread'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'keyword_argument', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'target'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_consume'}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'daemon'}; {'id': '46', 'type': 'True', 'children': []}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '52', 'type': 'argument_list', 'children': []}
Initialize the queue and the threads.
def del_node(self, char, node): del self._real.character[char].node[node] for cache in ( self._char_nodes_rulebooks_cache, self._node_stat_cache, self._node_successors_cache ): try: del cache[char][node] except KeyError: pass if char in self._char_nodes_cache and node in self._char_nodes_cache[char]: self._char_nodes_cache[char] = self._char_nodes_cache[char] - frozenset([node]) if char in self._portal_stat_cache: portal_stat_cache_char = self._portal_stat_cache[char] if node in portal_stat_cache_char: del portal_stat_cache_char[node] for charo in portal_stat_cache_char.values(): if node in charo: del charo[node] if char in self._char_portals_rulebooks_cache: portal_rulebook_cache_char = self._char_portals_rulebooks_cache[char] if node in portal_rulebook_cache_char: del portal_rulebook_cache_char[node] for porto in portal_rulebook_cache_char.values(): if node in porto: del porto[node]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'del_node'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '45', '78', '119']}; {'id': '8', 'type': 'delete_statement', 'children': ['9']}; {'id': '9', 'type': 'subscript', 'children': ['10', '19']}; {'id': '10', 'type': 'attribute', 'children': ['11', '18']}; {'id': '11', 'type': 'subscript', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_real'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'character'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '32']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '22', 'type': 'tuple', 'children': ['23', '26', '29']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_char_nodes_rulebooks_cache'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_node_stat_cache'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_node_successors_cache'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'try_statement', 'children': ['34', '41']}; {'id': '34', 'type': 'block', 'children': ['35']}; {'id': '35', 'type': 'delete_statement', 'children': ['36']}; {'id': '36', 'type': 'subscript', 'children': ['37', '40']}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '41', 'type': 'except_clause', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'pass_statement', 'children': []}; {'id': '45', 'type': 'if_statement', 'children': ['46', '59']}; {'id': '46', 'type': 'boolean_operator', 'children': ['47', '52'], 'value': 'and'}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'in'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': '_char_nodes_cache'}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '54'], 'value': 'in'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '54', 'type': 'subscript', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': '_char_nodes_cache'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '67']}; {'id': '62', 'type': 'subscript', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': '_char_nodes_cache'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '67', 'type': 'binary_operator', 'children': ['68', '73'], 'value': '-'}; {'id': '68', 'type': 'subscript', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_char_nodes_cache'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'frozenset'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'list', 'children': ['77'], 'value': '[node]'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '84']}; {'id': '79', 'type': 'comparison_operator', 'children': ['80', '81'], 'value': 'in'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': '_portal_stat_cache'}; {'id': '84', 'type': 'block', 'children': ['85', '93', '102']}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'portal_stat_cache_char'}; {'id': '88', 'type': 'subscript', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': '_portal_stat_cache'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '93', 'type': 'if_statement', 'children': ['94', '97']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'in'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'portal_stat_cache_char'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'delete_statement', 'children': ['99']}; {'id': '99', 'type': 'subscript', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'portal_stat_cache_char'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '102', 'type': 'for_statement', 'children': ['103', '104', '109']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'charo'}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'portal_stat_cache_char'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '108', 'type': 'argument_list', 'children': []}; {'id': '109', 'type': 'block', 'children': ['110']}; {'id': '110', 'type': 'if_statement', 'children': ['111', '114']}; {'id': '111', 'type': 'comparison_operator', 'children': ['112', '113'], 'value': 'in'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'charo'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'delete_statement', 'children': ['116']}; {'id': '116', 'type': 'subscript', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'charo'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '119', 'type': 'if_statement', 'children': ['120', '125']}; {'id': '120', 'type': 'comparison_operator', 'children': ['121', '122'], 'value': 'in'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': '_char_portals_rulebooks_cache'}; {'id': '125', 'type': 'block', 'children': ['126', '134', '143']}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'portal_rulebook_cache_char'}; {'id': '129', 'type': 'subscript', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': '_char_portals_rulebooks_cache'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '134', 'type': 'if_statement', 'children': ['135', '138']}; {'id': '135', 'type': 'comparison_operator', 'children': ['136', '137'], 'value': 'in'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'portal_rulebook_cache_char'}; {'id': '138', 'type': 'block', 'children': ['139']}; {'id': '139', 'type': 'delete_statement', 'children': ['140']}; {'id': '140', 'type': 'subscript', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'portal_rulebook_cache_char'}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '143', 'type': 'for_statement', 'children': ['144', '145', '150']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'porto'}; {'id': '145', 'type': 'call', 'children': ['146', '149']}; {'id': '146', 'type': 'attribute', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'portal_rulebook_cache_char'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '149', 'type': 'argument_list', 'children': []}; {'id': '150', 'type': 'block', 'children': ['151']}; {'id': '151', 'type': 'if_statement', 'children': ['152', '155']}; {'id': '152', 'type': 'comparison_operator', 'children': ['153', '154'], 'value': 'in'}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'porto'}; {'id': '155', 'type': 'block', 'children': ['156']}; {'id': '156', 'type': 'delete_statement', 'children': ['157']}; {'id': '157', 'type': 'subscript', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'porto'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'node'}
Remove a node from a character.
def adapt_sum(line, cfg, filter_obj): lines = filter_obj.filter_all(line) res_s = [sum(it) for it in lines] r = res_s.index(min(res_s)) return lines[r]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'adapt_sum'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filter_obj'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '28', '40']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'filter_obj'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'filter_all'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'res_s'}; {'id': '20', 'type': 'list_comprehension', 'children': ['21', '25']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '25', 'type': 'for_in_clause', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'it'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'res_s'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'res_s'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'lines'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'r'}
Determine best filter by sum of all row values
def pupatizeElements(self) : for i in range(len(self)) : self[i] = self[i].pupa()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pupatizeElements'}; {'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', '15']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '10', 'type': 'argument_list', 'children': ['11']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '21', 'type': 'call', 'children': ['22', '27']}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'pupa'}; {'id': '27', 'type': 'argument_list', 'children': []}
Transform all raba object into pupas
def clear_last_check(self): with db.session.begin_nested(): self.last_check = None self.last_check_at = datetime.utcnow() return self
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_last_check'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '33']}; {'id': '6', 'type': 'with_statement', 'children': ['7', '16']}; {'id': '7', 'type': 'with_clause', 'children': ['8']}; {'id': '8', 'type': 'with_item', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'begin_nested'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '23']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'last_check'}; {'id': '22', 'type': 'None', 'children': []}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'last_check_at'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'utcnow'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}
Clear the checksum of the file.
def extract(json_object, args, csv_writer): found = [[]] for attribute in args.attributes: item = attribute.getElement(json_object) if len(item) == 0: for row in found: row.append("NA") else: found1 = [] for value in item: if value is None: value = "NA" new = copy.deepcopy(found) for row in new: row.append(value) found1.extend(new) found = found1 for row in found: csv_writer.writerow(row) return len(found)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'json_object'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'csv_writer'}; {'id': '7', 'type': 'block', 'children': ['8', '13', '97', '108']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '11', 'type': 'list', 'children': ['12'], 'value': '[[]]'}; {'id': '12', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '18']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'attributes'}; {'id': '18', 'type': 'block', 'children': ['19', '28']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'attribute'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getElement'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'json_object'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '35', '47']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '34'], 'value': '=='}; {'id': '30', 'type': 'call', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '34', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'for_statement', 'children': ['37', '38', '39']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'string', 'children': [], 'value': '"NA"'}; {'id': '47', 'type': 'else_clause', 'children': ['48']}; {'id': '48', 'type': 'block', 'children': ['49', '53', '93']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'found1'}; {'id': '52', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '56']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'item'}; {'id': '56', 'type': 'block', 'children': ['57', '66', '75', '86']}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'is'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '65', 'type': 'string', 'children': [], 'value': '"NA"'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '75', 'type': 'for_statement', 'children': ['76', '77', '78']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '78', 'type': 'block', 'children': ['79']}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'value'}; {'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': 'found1'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'new'}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'assignment', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'found1'}; {'id': '97', 'type': 'for_statement', 'children': ['98', '99', '100']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'found'}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'csv_writer'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'writerow'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'found'}
Extract and write found attributes.
def _CheckCollation(cursor): cur_collation_connection = _ReadVariable("collation_connection", cursor) if cur_collation_connection != COLLATION: logging.warning("Require MySQL collation_connection of %s, got %s.", COLLATION, cur_collation_connection) cur_collation_database = _ReadVariable("collation_database", cursor) if cur_collation_database != COLLATION: logging.warning( "Require MySQL collation_database of %s, got %s." " To create your database, use: %s", COLLATION, cur_collation_database, CREATE_DATABASE_QUERY)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_CheckCollation'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '28', '36']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'cur_collation_connection'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_ReadVariable'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'string', 'children': [], 'value': '"collation_connection"'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': '!='}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'cur_collation_connection'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'COLLATION'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26', '27']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"Require MySQL collation_connection of %s, got %s."'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'COLLATION'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cur_collation_connection'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'cur_collation_database'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_ReadVariable'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"collation_database"'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '40']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '!='}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'cur_collation_database'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'COLLATION'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'warning'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50', '51', '52']}; {'id': '47', 'type': 'concatenated_string', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"Require MySQL collation_database of %s, got %s."'}; {'id': '49', 'type': 'string', 'children': [], 'value': '" To create your database, use: %s"'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'COLLATION'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cur_collation_database'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'CREATE_DATABASE_QUERY'}
Checks MySQL collation and warns if misconfigured.
def _text_attr(self, attr): attr = text[attr] if attr == "reset": self.cursor_attributes = self.default_attributes elif attr == "underline-off": self.cursor_attributes = self._remove_text_attr("underline") elif attr == "blink-off": self.cursor_attributes = self._remove_text_attr("blink") elif attr == "reverse-off": self.cursor_attributes = self._remove_text_attr("reverse") else: self.cursor_attributes = self._add_text_attr(attr)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_text_attr'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '6', 'type': 'block', 'children': ['7', '13']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '10', 'type': 'subscript', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '13', 'type': 'if_statement', 'children': ['14', '17', '26', '42', '58', '74']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '16'], 'value': '=='}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"reset"'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'default_attributes'}; {'id': '26', 'type': 'elif_clause', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': '=='}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"underline-off"'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': '_remove_text_attr'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'string', 'children': [], 'value': '"underline"'}; {'id': '42', 'type': 'elif_clause', 'children': ['43', '46']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': '=='}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"blink-off"'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_remove_text_attr'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"blink"'}; {'id': '58', 'type': 'elif_clause', 'children': ['59', '62']}; {'id': '59', 'type': 'comparison_operator', 'children': ['60', '61'], 'value': '=='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'attr'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"reverse-off"'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': '_remove_text_attr'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': '"reverse"'}; {'id': '74', 'type': 'else_clause', 'children': ['75']}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'cursor_attributes'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': '_add_text_attr'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'attr'}
Given a text attribute, set the current cursor appropriately.
def _get(self, operation, field): self._check_exists() query = {Mark.FLD_OP: operation.name, Mark.FLD_MARK + "." + field: {"$exists": True}} return self._track.find_one(query)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '37']}; {'id': '8', 'type': 'expression_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': '_check_exists'}; {'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': 'query'}; {'id': '17', 'type': 'dictionary', 'children': ['18', '25']}; {'id': '18', 'type': 'pair', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'Mark'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'FLD_OP'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'operation'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'pair', 'children': ['26', '33']}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '32'], 'value': '+'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '31'], 'value': '+'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'Mark'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'FLD_MARK'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"."'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '33', 'type': 'dictionary', 'children': ['34']}; {'id': '34', 'type': 'pair', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': '"$exists"'}; {'id': '36', 'type': 'True', 'children': []}; {'id': '37', 'type': 'return_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_track'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'find_one'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'query'}
Get tracked position for a given operation and field.
def _send_method(self, method_sig, args=bytes(), content=None): if isinstance(args, AMQPWriter): args = args.getvalue() self.connection.method_writer.write_method(self.channel_id, method_sig, args, content)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_send_method'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'method_sig'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '30']}; {'id': '15', 'type': 'if_statement', 'children': ['16', '21']}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'AMQPWriter'}; {'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': 'args'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'getvalue'}; {'id': '29', 'type': 'argument_list', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '39']}; {'id': '32', 'type': 'attribute', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'method_writer'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'write_method'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '43', '44', '45']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'channel_id'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'method_sig'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'content'}
Send a method for our channel.
def cleanup(test_data, udfs, tmp_data, tmp_db): con = make_ibis_client(ENV) if udfs: con.hdfs.rmdir(os.path.join(ENV.test_data_dir, 'udf')) if test_data: con.drop_database(ENV.test_data_db, force=True) con.hdfs.rmdir(ENV.test_data_dir) if tmp_data: con.hdfs.rmdir(ENV.tmp_dir) if tmp_db: con.drop_database(ENV.tmp_db, force=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cleanup'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'test_data'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'udfs'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'tmp_data'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'tmp_db'}; {'id': '8', 'type': 'block', 'children': ['9', '16', '38', '64', '78']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'make_ibis_client'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ENV'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'udfs'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'hdfs'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'rmdir'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ENV'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'test_data_dir'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'udf'"}; {'id': '38', 'type': 'if_statement', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'test_data'}; {'id': '40', 'type': 'block', 'children': ['41', '53']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'drop_database'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'ENV'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'test_data_db'}; {'id': '50', 'type': 'keyword_argument', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '52', 'type': 'True', 'children': []}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'call', 'children': ['55', '60']}; {'id': '55', 'type': 'attribute', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'hdfs'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'rmdir'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ENV'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'test_data_dir'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'tmp_data'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'con'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'hdfs'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'rmdir'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ENV'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'tmp_dir'}; {'id': '78', 'type': 'if_statement', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'tmp_db'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'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': 'con'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'drop_database'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'ENV'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'tmp_db'}; {'id': '90', 'type': 'keyword_argument', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '92', 'type': 'True', 'children': []}
Cleanup Ibis test data and UDFs
def _is_somatic(rec): if _has_somatic_flag(rec): return True if _is_mutect2_somatic(rec): return True ss_flag = rec.INFO.get("SS") if ss_flag is not None: if str(ss_flag) == "2": return True status_flag = rec.INFO.get("STATUS") if status_flag is not None: if str(status_flag).lower() in ["somatic", "likelysomatic", "strongsomatic", "samplespecific"]: return True epr = rec.INFO.get("EPR", "").split(",") if epr and all([p == "pass" for p in epr]): return True return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_is_somatic'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '22', '33', '48', '59', '82', '99', '115']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '11']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_has_somatic_flag'}; {'id': '9', 'type': 'argument_list', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'True', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '19']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_is_mutect2_somatic'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'True', 'children': []}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ss_flag'}; {'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': 'rec'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'INFO'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': '"SS"'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '37']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '36'], 'value': 'is not'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'ss_flag'}; {'id': '36', 'type': 'None', 'children': []}; {'id': '37', 'type': 'block', 'children': ['38']}; {'id': '38', 'type': 'if_statement', 'children': ['39', '45']}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '44'], 'value': '=='}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ss_flag'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"2"'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'return_statement', 'children': ['47']}; {'id': '47', 'type': 'True', 'children': []}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'status_flag'}; {'id': '51', 'type': 'call', 'children': ['52', '57']}; {'id': '52', 'type': 'attribute', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'INFO'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'string', 'children': [], 'value': '"STATUS"'}; {'id': '59', 'type': 'if_statement', 'children': ['60', '63']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '62'], 'value': 'is not'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'status_flag'}; {'id': '62', 'type': 'None', 'children': []}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'if_statement', 'children': ['65', '79']}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '74'], 'value': 'in'}; {'id': '66', 'type': 'call', 'children': ['67', '73']}; {'id': '67', 'type': 'attribute', 'children': ['68', '72']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '70', 'type': 'argument_list', 'children': ['71']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'status_flag'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '73', 'type': 'argument_list', 'children': []}; {'id': '74', 'type': 'list', 'children': ['75', '76', '77', '78'], 'value': '["somatic", "likelysomatic", "strongsomatic", "samplespecific"]'}; {'id': '75', 'type': 'string', 'children': [], 'value': '"somatic"'}; {'id': '76', 'type': 'string', 'children': [], 'value': '"likelysomatic"'}; {'id': '77', 'type': 'string', 'children': [], 'value': '"strongsomatic"'}; {'id': '78', 'type': 'string', 'children': [], 'value': '"samplespecific"'}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'True', 'children': []}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'epr'}; {'id': '85', 'type': 'call', 'children': ['86', '97']}; {'id': '86', 'type': 'attribute', 'children': ['87', '96']}; {'id': '87', 'type': 'call', 'children': ['88', '93']}; {'id': '88', 'type': 'attribute', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'rec'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'INFO'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95']}; {'id': '94', 'type': 'string', 'children': [], 'value': '"EPR"'}; {'id': '95', 'type': 'string', 'children': [], 'value': '""'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '97', 'type': 'argument_list', 'children': ['98']}; {'id': '98', 'type': 'string', 'children': [], 'value': '","'}; {'id': '99', 'type': 'if_statement', 'children': ['100', '112']}; {'id': '100', 'type': 'boolean_operator', 'children': ['101', '102'], 'value': 'and'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'epr'}; {'id': '102', 'type': 'call', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'list_comprehension', 'children': ['106', '109']}; {'id': '106', 'type': 'comparison_operator', 'children': ['107', '108'], 'value': '=='}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '108', 'type': 'string', 'children': [], 'value': '"pass"'}; {'id': '109', 'type': 'for_in_clause', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'p'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'epr'}; {'id': '112', 'type': 'block', 'children': ['113']}; {'id': '113', 'type': 'return_statement', 'children': ['114']}; {'id': '114', 'type': 'True', 'children': []}; {'id': '115', 'type': 'return_statement', 'children': ['116']}; {'id': '116', 'type': 'False', 'children': []}
Handle somatic classifications from MuTect, MuTect2, VarDict and VarScan
def copyfile(self, target): shutil.copyfile(self.path, self._to_backend(target))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'copyfile'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'target'}; {'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': 'shutil'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'copyfile'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'path'}; {'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': '_to_backend'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'target'}
Copies this file to the given `target` location.
def serveUpcoming(self, request): myurl = self.get_url(request) today = timezone.localdate() monthlyUrl = myurl + self.reverse_subpage('serveMonth', args=[today.year, today.month]) weekNum = gregorian_to_week_date(today)[1] weeklyUrl = myurl + self.reverse_subpage('serveWeek', args=[today.year, weekNum]) listUrl = myurl + self.reverse_subpage('servePast') upcomingEvents = self._getUpcomingEvents(request) paginator = Paginator(upcomingEvents, self.EventsPerPage) try: eventsPage = paginator.page(request.GET.get('page')) except PageNotAnInteger: eventsPage = paginator.page(1) except EmptyPage: eventsPage = paginator.page(paginator.num_pages) return render(request, "joyous/calendar_list_upcoming.html", {'self': self, 'page': self, 'version': __version__, 'today': today, 'weeklyUrl': weeklyUrl, 'monthlyUrl': monthlyUrl, 'listUrl': listUrl, 'events': eventsPage})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'serveUpcoming'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '24', '44', '53', '71', '82', '91', '101', '145']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'myurl'}; {'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_url'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'timezone'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'localdate'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'monthlyUrl'}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '+'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'myurl'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'reverse_subpage'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'serveMonth'"}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '37', 'type': 'list', 'children': ['38', '41'], 'value': '[today.year, today.month]'}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'month'}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'assignment', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'weekNum'}; {'id': '47', 'type': 'subscript', 'children': ['48', '52']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'gregorian_to_week_date'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'weeklyUrl'}; {'id': '56', 'type': 'binary_operator', 'children': ['57', '58'], 'value': '+'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'myurl'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'reverse_subpage'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '64']}; {'id': '63', 'type': 'string', 'children': [], 'value': "'serveWeek'"}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '66', 'type': 'list', 'children': ['67', '70'], 'value': '[today.year, weekNum]'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'year'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'weekNum'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'listUrl'}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '76'], 'value': '+'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'myurl'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'reverse_subpage'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'string', 'children': [], 'value': "'servePast'"}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'upcomingEvents'}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_getUpcomingEvents'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'paginator'}; {'id': '94', 'type': 'call', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'Paginator'}; {'id': '96', 'type': 'argument_list', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'upcomingEvents'}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'EventsPerPage'}; {'id': '101', 'type': 'try_statement', 'children': ['102', '119', '131']}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'expression_statement', 'children': ['104']}; {'id': '104', 'type': 'assignment', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'eventsPage'}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'paginator'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'call', 'children': ['112', '117']}; {'id': '112', 'type': 'attribute', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'GET'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'string', 'children': [], 'value': "'page'"}; {'id': '119', 'type': 'except_clause', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'PageNotAnInteger'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'expression_statement', 'children': ['123']}; {'id': '123', 'type': 'assignment', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'eventsPage'}; {'id': '125', 'type': 'call', 'children': ['126', '129']}; {'id': '126', 'type': 'attribute', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'paginator'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '129', 'type': 'argument_list', 'children': ['130']}; {'id': '130', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '131', 'type': 'except_clause', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'EmptyPage'}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'eventsPage'}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'paginator'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'page'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'attribute', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'paginator'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'num_pages'}; {'id': '145', 'type': 'return_statement', 'children': ['146']}; {'id': '146', 'type': 'call', 'children': ['147', '148']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '148', 'type': 'argument_list', 'children': ['149', '150', '151']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '150', 'type': 'string', 'children': [], 'value': '"joyous/calendar_list_upcoming.html"'}; {'id': '151', 'type': 'dictionary', 'children': ['152', '155', '158', '161', '164', '167', '170', '173']}; {'id': '152', 'type': 'pair', 'children': ['153', '154']}; {'id': '153', 'type': 'string', 'children': [], 'value': "'self'"}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '155', 'type': 'pair', 'children': ['156', '157']}; {'id': '156', 'type': 'string', 'children': [], 'value': "'page'"}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '158', 'type': 'pair', 'children': ['159', '160']}; {'id': '159', 'type': 'string', 'children': [], 'value': "'version'"}; {'id': '160', 'type': 'identifier', 'children': [], 'value': '__version__'}; {'id': '161', 'type': 'pair', 'children': ['162', '163']}; {'id': '162', 'type': 'string', 'children': [], 'value': "'today'"}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'today'}; {'id': '164', 'type': 'pair', 'children': ['165', '166']}; {'id': '165', 'type': 'string', 'children': [], 'value': "'weeklyUrl'"}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'weeklyUrl'}; {'id': '167', 'type': 'pair', 'children': ['168', '169']}; {'id': '168', 'type': 'string', 'children': [], 'value': "'monthlyUrl'"}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'monthlyUrl'}; {'id': '170', 'type': 'pair', 'children': ['171', '172']}; {'id': '171', 'type': 'string', 'children': [], 'value': "'listUrl'"}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'listUrl'}; {'id': '173', 'type': 'pair', 'children': ['174', '175']}; {'id': '174', 'type': 'string', 'children': [], 'value': "'events'"}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'eventsPage'}
Upcoming events list view.
def transmit_agnocomplete_context(self): user = super(AgnocompleteContextQuerysetMixin, self) \ .transmit_agnocomplete_context() if user: self.queryset = self.agnocomplete.get_queryset() return user
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'transmit_agnocomplete_context'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '19', '34']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '9', 'type': 'call', 'children': ['10', '18']}; {'id': '10', 'type': 'attribute', 'children': ['11', '16', '17']}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'super'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'AgnocompleteContextQuerysetMixin'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'transmit_agnocomplete_context'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'queryset'}; {'id': '27', 'type': 'call', 'children': ['28', '33']}; {'id': '28', 'type': 'attribute', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'agnocomplete'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get_queryset'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'return_statement', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'user'}
We'll reset the current queryset only if the user is set.
def _add_timeout(self, request, future): io_loop = IOLoop.current() t = io_loop.call_later( request.ttl, self._request_timed_out, request.id, request.service, request.ttl, future, ) io_loop.add_future(future, lambda f: io_loop.remove_timeout(t))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_add_timeout'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'future'}; {'id': '7', 'type': 'block', 'children': ['8', '16', '40']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'io_loop'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'IOLoop'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'current'}; {'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': 't'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'io_loop'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'call_later'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '27', '30', '33', '36', '39']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ttl'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_request_timed_out'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'ttl'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'future'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'io_loop'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'add_future'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'future'}; {'id': '47', 'type': 'lambda', 'children': ['48', '50']}; {'id': '48', 'type': 'lambda_parameters', 'children': ['49']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'io_loop'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'remove_timeout'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 't'}
Adds a timeout for the given request to the given future.
def to_base_variable(self): return Variable(self.dims, self._data, self._attrs, encoding=self._encoding, fastpath=True)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_base_variable'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'return_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Variable'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '13', '16', '19', '24']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dims'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_data'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_attrs'}; {'id': '19', 'type': 'keyword_argument', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_encoding'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'fastpath'}; {'id': '26', 'type': 'True', 'children': []}
Return this variable as a base xarray.Variable
def verify(path): path = pathlib.Path(path) valid = False if path.suffix == ".npy": try: nf = np.load(str(path), mmap_mode="r", allow_pickle=False) except (OSError, ValueError, IsADirectoryError): pass else: if len(nf.shape) == 2: valid = True return valid
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'verify'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '19', '69']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'pathlib'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'Path'}; {'id': '13', 'type': 'argument_list', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'valid'}; {'id': '18', 'type': 'False', 'children': []}; {'id': '19', 'type': 'if_statement', 'children': ['20', '25']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '24'], 'value': '=='}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'suffix'}; {'id': '24', 'type': 'string', 'children': [], 'value': '".npy"'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'try_statement', 'children': ['27', '46', '53']}; {'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': 'nf'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '40', '43']}; {'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': 'path'}; {'id': '40', 'type': 'keyword_argument', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'mmap_mode'}; {'id': '42', 'type': 'string', 'children': [], 'value': '"r"'}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'allow_pickle'}; {'id': '45', 'type': 'False', 'children': []}; {'id': '46', 'type': 'except_clause', 'children': ['47', '51']}; {'id': '47', 'type': 'tuple', 'children': ['48', '49', '50']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'OSError'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'IsADirectoryError'}; {'id': '51', 'type': 'block', 'children': ['52']}; {'id': '52', 'type': 'pass_statement', 'children': []}; {'id': '53', 'type': 'else_clause', 'children': ['54']}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'if_statement', 'children': ['56', '64']}; {'id': '56', 'type': 'comparison_operator', 'children': ['57', '63'], 'value': '=='}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'nf'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '2'}; {'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': 'valid'}; {'id': '68', 'type': 'True', 'children': []}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'valid'}
Verify that `path` has a supported numpy file format
def start(st_reg_number): weights = [9, 8, 7, 6, 5, 4, 3, 2] digit_state_registration = st_reg_number[-1] if len(st_reg_number) != 9: return False sum_total = 0 for i in range(0, 8): sum_total = sum_total + weights[i] * int(st_reg_number[i]) if sum_total % 11 == 0: return digit_state_registration[-1] == '0' digit_check = 11 - sum_total % 11 return str(digit_check) == digit_state_registration
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'start'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'st_reg_number'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '25', '35', '39', '62', '76', '84']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'weights'}; {'id': '9', 'type': 'list', 'children': ['10', '11', '12', '13', '14', '15', '16', '17'], 'value': '[9, 8, 7, 6, 5, 4, 3, 2]'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '7'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '14', 'type': 'integer', 'children': [], 'value': '5'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '4'}; {'id': '16', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'digit_state_registration'}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'st_reg_number'}; {'id': '23', 'type': 'unary_operator', 'children': ['24'], 'value': '-'}; {'id': '24', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '25', 'type': 'if_statement', 'children': ['26', '32']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '31'], 'value': '!='}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'st_reg_number'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'False', 'children': []}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sum_total'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '39', 'type': 'for_statement', 'children': ['40', '41', '46']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '45']}; {'id': '44', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'sum_total'}; {'id': '50', 'type': 'binary_operator', 'children': ['51', '52'], 'value': '+'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sum_total'}; {'id': '52', 'type': 'binary_operator', 'children': ['53', '56'], 'value': '*'}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'weights'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'subscript', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'st_reg_number'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '62', 'type': 'if_statement', 'children': ['63', '68']}; {'id': '63', 'type': 'comparison_operator', 'children': ['64', '67'], 'value': '=='}; {'id': '64', 'type': 'binary_operator', 'children': ['65', '66'], 'value': '%'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sum_total'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '67', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '68', 'type': 'block', 'children': ['69']}; {'id': '69', 'type': 'return_statement', 'children': ['70']}; {'id': '70', 'type': 'comparison_operator', 'children': ['71', '75'], 'value': '=='}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'digit_state_registration'}; {'id': '73', 'type': 'unary_operator', 'children': ['74'], 'value': '-'}; {'id': '74', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '75', 'type': 'string', 'children': [], 'value': "'0'"}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'digit_check'}; {'id': '79', 'type': 'binary_operator', 'children': ['80', '81'], 'value': '-'}; {'id': '80', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '83'], 'value': '%'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'sum_total'}; {'id': '83', 'type': 'integer', 'children': [], 'value': '11'}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'comparison_operator', 'children': ['86', '90'], 'value': '=='}; {'id': '86', 'type': 'call', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'digit_check'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'digit_state_registration'}
Checks the number valiaty for the Paraiba state
def app_state(self, app): if not self.available or not self.screen_on: return STATE_OFF if self.current_app["package"] == app: return STATE_ON return STATE_OFF
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'app_state'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '31']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '17']}; {'id': '8', 'type': 'boolean_operator', 'children': ['9', '13'], 'value': 'or'}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'available'}; {'id': '13', 'type': 'not_operator', 'children': ['14']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'screen_on'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'STATE_OFF'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '28']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '27'], 'value': '=='}; {'id': '22', 'type': 'subscript', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'current_app'}; {'id': '26', 'type': 'string', 'children': [], 'value': '"package"'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'app'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'STATE_ON'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'STATE_OFF'}
Informs if application is running.
def load_user_catalog(): cat_dir = user_data_dir() if not os.path.isdir(cat_dir): return Catalog() else: return YAMLFilesCatalog(cat_dir)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_user_catalog'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'cat_dir'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'user_data_dir'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'if_statement', 'children': ['12', '21', '26']}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'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': 'os'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cat_dir'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'Catalog'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'YAMLFilesCatalog'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cat_dir'}
Return a catalog for the platform-specific user Intake directory
def acceptable(value, capitalize=False): name = regexes['punctuation'].sub("", regexes['joins'].sub("_", value)) name = regexes['repeated_underscore'].sub("_", name.strip('_')) if capitalize: name_parts = [] for word in name.split('_'): name_parts.append(word[0].upper()) if len(word) > 1: name_parts.append(word[1:]) name = ''.join(name_parts) return name
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'acceptable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'capitalize'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '29', '46', '103']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '12', 'type': 'call', 'children': ['13', '18']}; {'id': '13', 'type': 'attribute', 'children': ['14', '17']}; {'id': '14', 'type': 'subscript', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'regexes'}; {'id': '16', 'type': 'string', 'children': [], 'value': "'punctuation'"}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': '""'}; {'id': '20', 'type': 'call', 'children': ['21', '26']}; {'id': '21', 'type': 'attribute', 'children': ['22', '25']}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'regexes'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'joins'"}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"_"'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'regexes'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'repeated_underscore'"}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'sub'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"_"'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '46', 'type': 'if_statement', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'capitalize'}; {'id': '48', 'type': 'block', 'children': ['49', '53', '94']}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'name_parts'}; {'id': '52', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '53', 'type': 'for_statement', 'children': ['54', '55', '61']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'string', 'children': [], 'value': "'_'"}; {'id': '61', 'type': 'block', 'children': ['62', '75']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'name_parts'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '74']}; {'id': '69', 'type': 'attribute', 'children': ['70', '73']}; {'id': '70', 'type': 'subscript', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'if_statement', 'children': ['76', '82']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '81'], 'value': '>'}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '81', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'name_parts'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'word'}; {'id': '91', 'type': 'slice', 'children': ['92', '93']}; {'id': '92', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '93', 'type': 'colon', 'children': []}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'string', 'children': [], 'value': "''"}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '101', 'type': 'argument_list', 'children': ['102']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'name_parts'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'name'}
Convert a string into something that can be used as a valid python variable name
def round(self, digits=0): self._left = round(self._left, digits) self._bottom = round(self._bottom, digits) self._width = round(self._width, digits) self._height = round(self._height, digits)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'round'}; {'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': 'digits'}; {'id': '7', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '8', 'type': 'block', 'children': ['9', '21', '33', '45']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_left'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_left'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'digits'}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': '_bottom'}; {'id': '26', 'type': 'call', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '28', 'type': 'argument_list', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_bottom'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'digits'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_width'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_width'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'digits'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_height'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'round'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_height'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'digits'}
Round the dimensions of the given rectangle to the given number of digits.
def _build_session(username, password, trans_label=None): bigip = requests.session() bigip.auth = (username, password) bigip.verify = False bigip.headers.update({'Content-Type': 'application/json'}) if trans_label: trans_id = __salt__['grains.get']('bigip_f5_trans:{label}'.format(label=trans_label)) if trans_id: bigip.headers.update({'X-F5-REST-Coordination-Id': trans_id}) else: bigip.headers.update({'X-F5-REST-Coordination-Id': None}) return bigip
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_build_session'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'trans_label'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '18', '26', '32', '44', '92']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bigip'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'bigip'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'auth'}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'bigip'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'verify'}; {'id': '31', 'type': 'False', 'children': []}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bigip'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '39', 'type': 'argument_list', 'children': ['40']}; {'id': '40', 'type': 'dictionary', 'children': ['41']}; {'id': '41', 'type': 'pair', 'children': ['42', '43']}; {'id': '42', 'type': 'string', 'children': [], 'value': "'Content-Type'"}; {'id': '43', 'type': 'string', 'children': [], 'value': "'application/json'"}; {'id': '44', 'type': 'if_statement', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'trans_label'}; {'id': '46', 'type': 'block', 'children': ['47', '63']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'trans_id'}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'subscript', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': '__salt__'}; {'id': '53', 'type': 'string', 'children': [], 'value': "'grains.get'"}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'string', 'children': [], 'value': "'bigip_f5_trans:{label}'"}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'trans_label'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '65', '78']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'trans_id'}; {'id': '65', 'type': 'block', 'children': ['66']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '73']}; {'id': '68', 'type': 'attribute', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'bigip'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '73', 'type': 'argument_list', 'children': ['74']}; {'id': '74', 'type': 'dictionary', 'children': ['75']}; {'id': '75', 'type': 'pair', 'children': ['76', '77']}; {'id': '76', 'type': 'string', 'children': [], 'value': "'X-F5-REST-Coordination-Id'"}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'trans_id'}; {'id': '78', 'type': 'else_clause', 'children': ['79']}; {'id': '79', 'type': 'block', 'children': ['80']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'call', 'children': ['82', '87']}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'bigip'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'dictionary', 'children': ['89']}; {'id': '89', 'type': 'pair', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': "'X-F5-REST-Coordination-Id'"}; {'id': '91', 'type': 'None', 'children': []}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'bigip'}
Create a session to be used when connecting to iControl REST.
def T(self, ID, sign): lon = self.terms[sign][ID] ID = 'T_%s_%s' % (ID, sign) return self.G(ID, 0, lon)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'T'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'sign'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '26']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'lon'}; {'id': '11', 'type': 'subscript', 'children': ['12', '17']}; {'id': '12', 'type': 'subscript', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'terms'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'sign'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '%'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'T_%s_%s'"}; {'id': '23', 'type': 'tuple', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'sign'}; {'id': '26', 'type': 'return_statement', 'children': ['27']}; {'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': 'G'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ID'}; {'id': '33', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'lon'}
Returns the term of an object in a sign.
def to_json(self): res_dict = {} def gen_dep_edge(node, edge, dep_tgt, aliases): return { 'target': dep_tgt.address.spec, 'dependency_type': self._edge_type(node.concrete_target, edge, dep_tgt), 'products_used': len(edge.products_used), 'products_used_ratio': self._used_ratio(dep_tgt, edge), 'aliases': [alias.address.spec for alias in aliases], } for node in self._nodes.values(): res_dict[node.concrete_target.address.spec] = { 'cost': self._cost(node.concrete_target), 'cost_transitive': self._trans_cost(node.concrete_target), 'products_total': node.products_total, 'dependencies': [gen_dep_edge(node, edge, dep_tgt, node.dep_aliases.get(dep_tgt, {})) for dep_tgt, edge in node.dep_edges.items()], } yield str(json.dumps(res_dict, indent=2, sort_keys=True))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'to_json'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '67', '143']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'res_dict'}; {'id': '9', 'type': 'dictionary', 'children': []}; {'id': '10', 'type': 'function_definition', 'children': ['11', '12', '17']}; {'id': '11', 'type': 'function_name', 'children': [], 'value': 'gen_dep_edge'}; {'id': '12', 'type': 'parameters', 'children': ['13', '14', '15', '16']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'dep_tgt'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'aliases'}; {'id': '17', 'type': 'block', 'children': ['18']}; {'id': '18', 'type': 'return_statement', 'children': ['19']}; {'id': '19', 'type': 'dictionary', 'children': ['20', '27', '39', '47', '56']}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': "'target'"}; {'id': '22', 'type': 'attribute', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dep_tgt'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '27', 'type': 'pair', 'children': ['28', '29']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'dependency_type'"}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': '_edge_type'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37', '38']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'concrete_target'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'dep_tgt'}; {'id': '39', 'type': 'pair', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'products_used'"}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'products_used'}; {'id': '47', 'type': 'pair', 'children': ['48', '49']}; {'id': '48', 'type': 'string', 'children': [], 'value': "'products_used_ratio'"}; {'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': '_used_ratio'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'dep_tgt'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '56', 'type': 'pair', 'children': ['57', '58']}; {'id': '57', 'type': 'string', 'children': [], 'value': "'aliases'"}; {'id': '58', 'type': 'list_comprehension', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '64', 'type': 'for_in_clause', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'alias'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'aliases'}; {'id': '67', 'type': 'for_statement', 'children': ['68', '69', '76']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '69', 'type': 'call', 'children': ['70', '75']}; {'id': '70', 'type': 'attribute', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': '_nodes'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'block', 'children': ['77']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '88']}; {'id': '79', 'type': 'subscript', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'res_dict'}; {'id': '81', 'type': 'attribute', 'children': ['82', '87']}; {'id': '82', 'type': 'attribute', 'children': ['83', '86']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'concrete_target'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'spec'}; {'id': '88', 'type': 'dictionary', 'children': ['89', '99', '109', '114']}; {'id': '89', 'type': 'pair', 'children': ['90', '91']}; {'id': '90', 'type': 'string', 'children': [], 'value': "'cost'"}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_cost'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'concrete_target'}; {'id': '99', 'type': 'pair', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'cost_transitive'"}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_trans_cost'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'attribute', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'concrete_target'}; {'id': '109', 'type': 'pair', 'children': ['110', '111']}; {'id': '110', 'type': 'string', 'children': [], 'value': "'products_total'"}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'products_total'}; {'id': '114', 'type': 'pair', 'children': ['115', '116']}; {'id': '115', 'type': 'string', 'children': [], 'value': "'dependencies'"}; {'id': '116', 'type': 'list_comprehension', 'children': ['117', '132']}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'gen_dep_edge'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '121', '122', '123']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'dep_tgt'}; {'id': '123', 'type': 'call', 'children': ['124', '129']}; {'id': '124', 'type': 'attribute', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'dep_aliases'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '129', 'type': 'argument_list', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'dep_tgt'}; {'id': '131', 'type': 'dictionary', 'children': []}; {'id': '132', 'type': 'for_in_clause', 'children': ['133', '136']}; {'id': '133', 'type': 'pattern_list', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'dep_tgt'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'edge'}; {'id': '136', 'type': 'call', 'children': ['137', '142']}; {'id': '137', 'type': 'attribute', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'dep_edges'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '142', 'type': 'argument_list', 'children': []}; {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'yield', 'children': ['145']}; {'id': '145', 'type': 'call', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '147', 'type': 'argument_list', 'children': ['148']}; {'id': '148', 'type': 'call', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '152', 'type': 'argument_list', 'children': ['153', '154', '157']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'res_dict'}; {'id': '154', 'type': 'keyword_argument', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'indent'}; {'id': '156', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '157', 'type': 'keyword_argument', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'sort_keys'}; {'id': '159', 'type': 'True', 'children': []}
Outputs the entire graph.
def upgrade(cfg): db_node = cfg["db"] old_db_elems = ["host", "name", "port", "pass", "user", "dialect"] has_old_db_elems = [x in db_node for x in old_db_elems] if any(has_old_db_elems): print("Old database configuration found. " "Converting to new connect_string. " "This will *not* be stored in the configuration automatically.") cfg["db"]["connect_string"] = \ "{dialect}://{user}:{password}@{host}:{port}/{name}".format( dialect=cfg["db"]["dialect"]["value"], user=cfg["db"]["user"]["value"], password=cfg["db"]["pass"]["value"], host=cfg["db"]["host"]["value"], port=cfg["db"]["port"]["value"], name=cfg["db"]["name"]["value"])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'upgrade'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '22', '32']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'db_node'}; {'id': '9', 'type': 'subscript', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '11', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'old_db_elems'}; {'id': '15', 'type': 'list', 'children': ['16', '17', '18', '19', '20', '21'], 'value': '["host", "name", "port", "pass", "user", "dialect"]'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"host"'}; {'id': '17', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"port"'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"pass"'}; {'id': '20', 'type': 'string', 'children': [], 'value': '"user"'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"dialect"'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'has_old_db_elems'}; {'id': '25', 'type': 'list_comprehension', 'children': ['26', '29']}; {'id': '26', 'type': 'comparison_operator', 'children': ['27', '28'], 'value': 'in'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'db_node'}; {'id': '29', 'type': 'for_in_clause', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'old_db_elems'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '37']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'any'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'has_old_db_elems'}; {'id': '37', 'type': 'block', 'children': ['38', '46']}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'concatenated_string', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"Old database configuration found. "'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"Converting to new connect_string. "'}; {'id': '45', 'type': 'string', 'children': [], 'value': '"This will *not* be stored in the configuration automatically."'}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '53']}; {'id': '48', 'type': 'subscript', 'children': ['49', '52']}; {'id': '49', 'type': 'subscript', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '51', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '52', 'type': 'string', 'children': [], 'value': '"connect_string"'}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': '"{dialect}://{user}:{password}@{host}:{port}/{name}"'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '67', '76', '85', '94', '103']}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'dialect'}; {'id': '60', 'type': 'subscript', 'children': ['61', '66']}; {'id': '61', 'type': 'subscript', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '65', 'type': 'string', 'children': [], 'value': '"dialect"'}; {'id': '66', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '67', 'type': 'keyword_argument', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '69', 'type': 'subscript', 'children': ['70', '75']}; {'id': '70', 'type': 'subscript', 'children': ['71', '74']}; {'id': '71', 'type': 'subscript', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '73', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '74', 'type': 'string', 'children': [], 'value': '"user"'}; {'id': '75', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '76', 'type': 'keyword_argument', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '78', 'type': 'subscript', 'children': ['79', '84']}; {'id': '79', 'type': 'subscript', 'children': ['80', '83']}; {'id': '80', 'type': 'subscript', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '83', 'type': 'string', 'children': [], 'value': '"pass"'}; {'id': '84', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '85', 'type': 'keyword_argument', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '87', 'type': 'subscript', 'children': ['88', '93']}; {'id': '88', 'type': 'subscript', 'children': ['89', '92']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '91', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '92', 'type': 'string', 'children': [], 'value': '"host"'}; {'id': '93', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '94', 'type': 'keyword_argument', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '96', 'type': 'subscript', 'children': ['97', '102']}; {'id': '97', 'type': 'subscript', 'children': ['98', '101']}; {'id': '98', 'type': 'subscript', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '100', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '101', 'type': 'string', 'children': [], 'value': '"port"'}; {'id': '102', 'type': 'string', 'children': [], 'value': '"value"'}; {'id': '103', 'type': 'keyword_argument', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '105', 'type': 'subscript', 'children': ['106', '111']}; {'id': '106', 'type': 'subscript', 'children': ['107', '110']}; {'id': '107', 'type': 'subscript', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '109', 'type': 'string', 'children': [], 'value': '"db"'}; {'id': '110', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '111', 'type': 'string', 'children': [], 'value': '"value"'}
Provide forward migration for configuration files.
def envs(self): load = {'cmd': '_file_envs'} return salt.utils.data.decode(self.channel.send(load)) if six.PY2 \ else self.channel.send(load)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'envs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '9', 'type': 'dictionary', 'children': ['10']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'cmd'"}; {'id': '12', 'type': 'string', 'children': [], 'value': "'_file_envs'"}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'conditional_expression', 'children': ['15', '32', '35', '36'], 'value': 'if'}; {'id': '15', 'type': 'call', 'children': ['16', '23']}; {'id': '16', 'type': 'attribute', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'call', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'channel'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'load'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'PY2'}; {'id': '35', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'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': 'channel'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'send'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'load'}
Return a list of available environments
def check_stf_agent(adbprefix=None, kill=False): if adbprefix is None: adbprefix = ['adb'] command = adbprefix + ['shell', 'ps'] out = subprocess.check_output(command).strip() out = out.splitlines() if len(out) > 1: first, out = out[0], out[1:] idx = first.split().index('PID') pid = None for line in out: if 'stf.agent' in line: pid = line.split()[idx] print 'stf.agent is running, pid is', pid break if pid is not None: if kill: print 'killing', pid command = adbprefix + ['shell', 'kill', '-9', pid] subprocess.call(command) return False return True return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_stf_agent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'adbprefix'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kill'}; {'id': '9', 'type': 'False', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11', '21', '29', '42', '50', '144']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'is'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'adbprefix'}; {'id': '14', 'type': 'None', 'children': []}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'adbprefix'}; {'id': '19', 'type': 'list', 'children': ['20'], 'value': "['adb']"}; {'id': '20', 'type': 'string', 'children': [], 'value': "'adb'"}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '24', 'type': 'binary_operator', 'children': ['25', '26'], 'value': '+'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'adbprefix'}; {'id': '26', 'type': 'list', 'children': ['27', '28'], 'value': "['shell', 'ps']"}; {'id': '27', 'type': 'string', 'children': [], 'value': "'shell'"}; {'id': '28', 'type': 'string', 'children': [], 'value': "'ps'"}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '32', 'type': 'call', 'children': ['33', '41']}; {'id': '33', 'type': 'attribute', 'children': ['34', '40']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'check_output'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'strip'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'splitlines'}; {'id': '49', 'type': 'argument_list', 'children': []}; {'id': '50', 'type': 'if_statement', 'children': ['51', '57']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '56'], 'value': '>'}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '57', 'type': 'block', 'children': ['58', '72', '85', '89', '112']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'pattern_list', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '63', 'type': 'expression_list', 'children': ['64', '67']}; {'id': '64', 'type': 'subscript', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '66', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '69', 'type': 'slice', 'children': ['70', '71']}; {'id': '70', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '71', 'type': 'colon', 'children': []}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '75', 'type': 'call', 'children': ['76', '83']}; {'id': '76', 'type': 'attribute', 'children': ['77', '82']}; {'id': '77', 'type': 'call', 'children': ['78', '81']}; {'id': '78', 'type': 'attribute', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'first'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '81', 'type': 'argument_list', 'children': []}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'string', 'children': [], 'value': "'PID'"}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '88', 'type': 'None', 'children': []}; {'id': '89', 'type': 'for_statement', 'children': ['90', '91', '92']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'out'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'if_statement', 'children': ['94', '97']}; {'id': '94', 'type': 'comparison_operator', 'children': ['95', '96'], 'value': 'in'}; {'id': '95', 'type': 'string', 'children': [], 'value': "'stf.agent'"}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '97', 'type': 'block', 'children': ['98', '108', '111']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '101', 'type': 'subscript', 'children': ['102', '107']}; {'id': '102', 'type': 'call', 'children': ['103', '106']}; {'id': '103', 'type': 'attribute', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '106', 'type': 'argument_list', 'children': []}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'idx'}; {'id': '108', 'type': 'print_statement', 'children': ['109', '110']}; {'id': '109', 'type': 'string', 'children': [], 'value': "'stf.agent is running, pid is'"}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '111', 'type': 'break_statement', 'children': []}; {'id': '112', 'type': 'if_statement', 'children': ['113', '116']}; {'id': '113', 'type': 'comparison_operator', 'children': ['114', '115'], 'value': 'is not'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '115', 'type': 'None', 'children': []}; {'id': '116', 'type': 'block', 'children': ['117', '142']}; {'id': '117', 'type': 'if_statement', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'kill'}; {'id': '119', 'type': 'block', 'children': ['120', '123', '133', '140']}; {'id': '120', 'type': 'print_statement', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': "'killing'"}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '126', 'type': 'binary_operator', 'children': ['127', '128'], 'value': '+'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'adbprefix'}; {'id': '128', 'type': 'list', 'children': ['129', '130', '131', '132'], 'value': "['shell', 'kill', '-9', pid]"}; {'id': '129', 'type': 'string', 'children': [], 'value': "'shell'"}; {'id': '130', 'type': 'string', 'children': [], 'value': "'kill'"}; {'id': '131', 'type': 'string', 'children': [], 'value': "'-9'"}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'pid'}; {'id': '133', 'type': 'expression_statement', 'children': ['134']}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'subprocess'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'call'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'command'}; {'id': '140', 'type': 'return_statement', 'children': ['141']}; {'id': '141', 'type': 'False', 'children': []}; {'id': '142', 'type': 'return_statement', 'children': ['143']}; {'id': '143', 'type': 'True', 'children': []}; {'id': '144', 'type': 'return_statement', 'children': ['145']}; {'id': '145', 'type': 'False', 'children': []}
return True if agent is alive.
def write_bool(self, flag): if flag: self.write(b"\x01") else: self.write(b"\x00")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'write_bool'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '9', '17']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'flag'}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'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': 'write'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'string', 'children': [], 'value': 'b"\\x01"'}; {'id': '17', 'type': 'else_clause', 'children': ['18']}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', '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': 'write'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': 'b"\\x00"'}
Writes a boolean to the underlying output file as a 1-byte value.
def _push(self): push_cmds = self.vcs.push_commands() if not push_cmds: return if utils.ask("OK to push commits to the server?"): for push_cmd in push_cmds: output = utils.system(push_cmd) logger.info(output)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_push'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '21']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'push_cmds'}; {'id': '9', 'type': 'call', 'children': ['10', '15']}; {'id': '10', 'type': 'attribute', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'vcs'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'push_commands'}; {'id': '15', 'type': 'argument_list', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '19']}; {'id': '17', 'type': 'not_operator', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'push_cmds'}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'return_statement', 'children': []}; {'id': '21', 'type': 'if_statement', 'children': ['22', '28']}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ask'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'string', 'children': [], 'value': '"OK to push commits to the server?"'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'for_statement', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'push_cmd'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'push_cmds'}; {'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': 'output'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'system'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'push_cmd'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'output'}
Offer to push changes, if needed.
def focusWindow(self, hwnd): Debug.log(3, "Focusing window: " + str(hwnd)) SW_RESTORE = 9 if ctypes.windll.user32.IsIconic(hwnd): ctypes.windll.user32.ShowWindow(hwnd, SW_RESTORE) ctypes.windll.user32.SetForegroundWindow(hwnd)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'focusWindow'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'hwnd'}; {'id': '6', 'type': 'block', 'children': ['7', '20', '24', '48']}; {'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': 'Debug'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '16'], 'value': '+'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"Focusing window: "'}; {'id': '16', 'type': 'call', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'hwnd'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'SW_RESTORE'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '9'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '35']}; {'id': '25', 'type': 'call', 'children': ['26', '33']}; {'id': '26', 'type': 'attribute', 'children': ['27', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'windll'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'user32'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'IsIconic'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'hwnd'}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'call', 'children': ['38', '45']}; {'id': '38', 'type': 'attribute', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'windll'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'user32'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'ShowWindow'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'hwnd'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'SW_RESTORE'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '57']}; {'id': '50', 'type': 'attribute', 'children': ['51', '56']}; {'id': '51', 'type': 'attribute', 'children': ['52', '55']}; {'id': '52', 'type': 'attribute', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'windll'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'user32'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'SetForegroundWindow'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'hwnd'}
Brings specified window to the front
def calc_buffered_bounds( format, bounds, meters_per_pixel_dim, layer_name, geometry_type, buffer_cfg): if not buffer_cfg: return bounds format_buffer_cfg = buffer_cfg.get(format.extension) if format_buffer_cfg is None: return bounds geometry_type = normalize_geometry_type(geometry_type) per_layer_cfg = format_buffer_cfg.get('layer', {}).get(layer_name) if per_layer_cfg is not None: layer_geom_pixels = per_layer_cfg.get(geometry_type) if layer_geom_pixels is not None: assert isinstance(layer_geom_pixels, Number) result = bounds_buffer( bounds, meters_per_pixel_dim * layer_geom_pixels) return result by_geometry_pixels = format_buffer_cfg.get('geometry', {}).get( geometry_type) if by_geometry_pixels is not None: assert isinstance(by_geometry_pixels, Number) result = bounds_buffer( bounds, meters_per_pixel_dim * by_geometry_pixels) return result return bounds
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'calc_buffered_bounds'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'meters_per_pixel_dim'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'layer_name'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'geometry_type'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'buffer_cfg'}; {'id': '10', 'type': 'block', 'children': ['11', '17', '28', '35', '42', '57', '94', '109', '132']}; {'id': '11', 'type': 'if_statement', 'children': ['12', '14']}; {'id': '12', 'type': 'not_operator', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'buffer_cfg'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'format_buffer_cfg'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'buffer_cfg'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'extension'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '32']}; {'id': '29', 'type': 'comparison_operator', 'children': ['30', '31'], 'value': 'is'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'format_buffer_cfg'}; {'id': '31', 'type': 'None', 'children': []}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'geometry_type'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'normalize_geometry_type'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'geometry_type'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'per_layer_cfg'}; {'id': '45', 'type': 'call', 'children': ['46', '55']}; {'id': '46', 'type': 'attribute', 'children': ['47', '54']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'format_buffer_cfg'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'layer'"}; {'id': '53', 'type': 'dictionary', 'children': []}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'layer_name'}; {'id': '57', 'type': 'if_statement', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'is not'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'per_layer_cfg'}; {'id': '60', 'type': 'None', 'children': []}; {'id': '61', 'type': 'block', 'children': ['62', '71']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'layer_geom_pixels'}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'per_layer_cfg'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'geometry_type'}; {'id': '71', 'type': 'if_statement', 'children': ['72', '75']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '74'], 'value': 'is not'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'layer_geom_pixels'}; {'id': '74', 'type': 'None', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76', '82', '92']}; {'id': '76', 'type': 'assert_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '79', 'type': 'argument_list', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'layer_geom_pixels'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'Number'}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'assignment', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'bounds_buffer'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '89', 'type': 'binary_operator', 'children': ['90', '91'], 'value': '*'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'meters_per_pixel_dim'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'layer_geom_pixels'}; {'id': '92', 'type': 'return_statement', 'children': ['93']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'by_geometry_pixels'}; {'id': '97', 'type': 'call', 'children': ['98', '107']}; {'id': '98', 'type': 'attribute', 'children': ['99', '106']}; {'id': '99', 'type': 'call', 'children': ['100', '103']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'format_buffer_cfg'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '103', 'type': 'argument_list', 'children': ['104', '105']}; {'id': '104', 'type': 'string', 'children': [], 'value': "'geometry'"}; {'id': '105', 'type': 'dictionary', 'children': []}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '107', 'type': 'argument_list', 'children': ['108']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'geometry_type'}; {'id': '109', 'type': 'if_statement', 'children': ['110', '113']}; {'id': '110', 'type': 'comparison_operator', 'children': ['111', '112'], 'value': 'is not'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'by_geometry_pixels'}; {'id': '112', 'type': 'None', 'children': []}; {'id': '113', 'type': 'block', 'children': ['114', '120', '130']}; {'id': '114', 'type': 'assert_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '117', 'type': 'argument_list', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'by_geometry_pixels'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'Number'}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '123', 'type': 'call', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'bounds_buffer'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'bounds'}; {'id': '127', 'type': 'binary_operator', 'children': ['128', '129'], 'value': '*'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'meters_per_pixel_dim'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'by_geometry_pixels'}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '132', 'type': 'return_statement', 'children': ['133']}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'bounds'}
Calculate the buffered bounds per format per layer based on config.
def _from_dict(cls, _dict): args = {} if 'age' in _dict: args['age'] = FaceAge._from_dict(_dict.get('age')) if 'gender' in _dict: args['gender'] = FaceGender._from_dict(_dict.get('gender')) if 'face_location' in _dict: args['face_location'] = FaceLocation._from_dict( _dict.get('face_location')) return cls(**args)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_from_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '32', '53', '74']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'if_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'comparison_operator', 'children': ['13', '14'], 'value': 'in'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'age'"}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '20', 'type': 'string', 'children': [], 'value': "'age'"}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'FaceAge'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_from_dict'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'age'"}; {'id': '32', 'type': 'if_statement', 'children': ['33', '36']}; {'id': '33', 'type': 'comparison_operator', 'children': ['34', '35'], 'value': 'in'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'gender'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '42']}; {'id': '39', 'type': 'subscript', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'gender'"}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'FaceGender'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_from_dict'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': "'gender'"}; {'id': '53', 'type': 'if_statement', 'children': ['54', '57']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': 'in'}; {'id': '55', 'type': 'string', 'children': [], 'value': "'face_location'"}; {'id': '56', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '63']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '62', 'type': 'string', 'children': [], 'value': "'face_location'"}; {'id': '63', 'type': 'call', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'FaceLocation'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_from_dict'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '72']}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': "'face_location'"}; {'id': '74', 'type': 'return_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'dictionary_splat', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'args'}
Initialize a Face object from a json dictionary.
def down(self, point): self._vdown = arcball_map_to_sphere(point, self._center, self._radius) self._qdown = self._qpre = self._qnow if self._constrain and self._axes is not None: self._axis = arcball_nearest_axis(self._vdown, self._axes) self._vdown = arcball_constrain_to_axis(self._vdown, self._axis) else: self._axis = None
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'down'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'point'}; {'id': '6', 'type': 'block', 'children': ['7', '22', '34']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_vdown'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'arcball_map_to_sphere'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '19']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'point'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_center'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_radius'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': '_qdown'}; {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_qpre'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': '_qnow'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '44', '73']}; {'id': '35', 'type': 'boolean_operator', 'children': ['36', '39'], 'value': 'and'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_constrain'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '43'], 'value': 'is not'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': '_axes'}; {'id': '43', 'type': 'None', 'children': []}; {'id': '44', 'type': 'block', 'children': ['45', '59']}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_axis'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'arcball_nearest_axis'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_vdown'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_axes'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '_vdown'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'arcball_constrain_to_axis'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': '_vdown'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_axis'}; {'id': '73', 'type': 'else_clause', 'children': ['74']}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'expression_statement', 'children': ['76']}; {'id': '76', 'type': 'assignment', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '_axis'}; {'id': '80', 'type': 'None', 'children': []}
Set initial cursor window coordinates and pick constrain-axis.
def handle(self, *args, **options): self._connection = Auth()._get_connection() if len(args) == 0: containers = self._connection.list_containers() if not containers: print("No containers were found for this account.") elif len(args) == 1: containers = self._connection.list_container_object_names(args[0]) if not containers: print("No matching container found.") else: raise CommandError("Pass one and only one [container_name] as an argument") for container in containers: print(container)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'handle'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'list_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '9', 'type': 'block', 'children': ['10', '22', '86']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'Auth'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_get_connection'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'id': '22', 'type': 'if_statement', 'children': ['23', '29', '49', '79']}; {'id': '23', 'type': 'comparison_operator', 'children': ['24', '28'], 'value': '=='}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '28', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '29', 'type': 'block', 'children': ['30', '40']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'containers'}; {'id': '33', 'type': 'call', 'children': ['34', '39']}; {'id': '34', 'type': 'attribute', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'list_containers'}; {'id': '39', 'type': 'argument_list', 'children': []}; {'id': '40', 'type': 'if_statement', 'children': ['41', '43']}; {'id': '41', 'type': 'not_operator', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'containers'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'string', 'children': [], 'value': '"No containers were found for this account."'}; {'id': '49', 'type': 'elif_clause', 'children': ['50', '56']}; {'id': '50', 'type': 'comparison_operator', 'children': ['51', '55'], 'value': '=='}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '53', 'type': 'argument_list', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '55', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '56', 'type': 'block', 'children': ['57', '70']}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'containers'}; {'id': '60', 'type': 'call', 'children': ['61', '66']}; {'id': '61', 'type': 'attribute', 'children': ['62', '65']}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': '_connection'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'list_container_object_names'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'subscript', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '73']}; {'id': '71', 'type': 'not_operator', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'containers'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'string', 'children': [], 'value': '"No matching container found."'}; {'id': '79', 'type': 'else_clause', 'children': ['80']}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'raise_statement', 'children': ['82']}; {'id': '82', 'type': 'call', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'CommandError'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'string', 'children': [], 'value': '"Pass one and only one [container_name] as an argument"'}; {'id': '86', 'type': 'for_statement', 'children': ['87', '88', '89']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'container'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'containers'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'container'}
Lists all the items in a container to stdout.
def solve(self, solver_klass=None): t0 = time() om = self._construct_opf_model(self.case) if om is None: return {"converged": False, "output": {"message": "No Ref Bus."}} if solver_klass is not None: result = solver_klass(om, opt=self.opt).solve() elif self.dc: result = DCOPFSolver(om, opt=self.opt).solve() else: result = PIPSSolver(om, opt=self.opt).solve() result["elapsed"] = time() - t0 if self.opt.has_key("verbose"): if self.opt["verbose"]: logger.info("OPF completed in %.3fs." % result["elapsed"]) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'solve'}; {'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': 'solver_klass'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '15', '26', '42', '102', '112', '140']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 't0'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '14', 'type': 'argument_list', 'children': []}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'om'}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_construct_opf_model'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'case'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'om'}; {'id': '29', 'type': 'None', 'children': []}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'dictionary', 'children': ['33', '36']}; {'id': '33', 'type': 'pair', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"converged"'}; {'id': '35', 'type': 'False', 'children': []}; {'id': '36', 'type': 'pair', 'children': ['37', '38']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"output"'}; {'id': '38', 'type': 'dictionary', 'children': ['39']}; {'id': '39', 'type': 'pair', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': '"message"'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"No Ref Bus."'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '46', '63', '84']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': 'is not'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'solver_klass'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '50', 'type': 'call', 'children': ['51', '62']}; {'id': '51', 'type': 'attribute', 'children': ['52', '61']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'solver_klass'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'om'}; {'id': '56', 'type': 'keyword_argument', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'solve'}; {'id': '62', 'type': 'argument_list', 'children': []}; {'id': '63', 'type': 'elif_clause', 'children': ['64', '67']}; {'id': '64', 'type': 'attribute', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'dc'}; {'id': '67', 'type': 'block', 'children': ['68']}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'assignment', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '71', 'type': 'call', 'children': ['72', '83']}; {'id': '72', 'type': 'attribute', 'children': ['73', '82']}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'DCOPFSolver'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'om'}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'solve'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'else_clause', 'children': ['85']}; {'id': '85', 'type': 'block', 'children': ['86']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '89', 'type': 'call', 'children': ['90', '101']}; {'id': '90', 'type': 'attribute', 'children': ['91', '100']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'PIPSSolver'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'om'}; {'id': '95', 'type': 'keyword_argument', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'solve'}; {'id': '101', 'type': 'argument_list', 'children': []}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '107']}; {'id': '104', 'type': 'subscript', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '106', 'type': 'string', 'children': [], 'value': '"elapsed"'}; {'id': '107', 'type': 'binary_operator', 'children': ['108', '111'], 'value': '-'}; {'id': '108', 'type': 'call', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '110', 'type': 'argument_list', 'children': []}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 't0'}; {'id': '112', 'type': 'if_statement', 'children': ['113', '121']}; {'id': '113', 'type': 'call', 'children': ['114', '119']}; {'id': '114', 'type': 'attribute', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'has_key'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'string', 'children': [], 'value': '"verbose"'}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'if_statement', 'children': ['123', '128']}; {'id': '123', 'type': 'subscript', 'children': ['124', '127']}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'opt'}; {'id': '127', 'type': 'string', 'children': [], 'value': '"verbose"'}; {'id': '128', 'type': 'block', 'children': ['129']}; {'id': '129', 'type': 'expression_statement', 'children': ['130']}; {'id': '130', 'type': 'call', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'binary_operator', 'children': ['136', '137'], 'value': '%'}; {'id': '136', 'type': 'string', 'children': [], 'value': '"OPF completed in %.3fs."'}; {'id': '137', 'type': 'subscript', 'children': ['138', '139']}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '139', 'type': 'string', 'children': [], 'value': '"elapsed"'}; {'id': '140', 'type': 'return_statement', 'children': ['141']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'result'}
Solves an optimal power flow and returns a results dictionary.
def _pop_index(self, index, has_default): try: if index is NOT_SET: index = len(self._list) - 1 key, value = self._list.pop() else: key, value = self._list.pop(index) if index < 0: index += len(self._list) + 1 except IndexError: if has_default: return None, None, None else: raise index2, value2 = self._dict.pop(key) assert index == index2 assert value is value2 return key, index, value
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_pop_index'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'has_default'}; {'id': '7', 'type': 'block', 'children': ['8', '83', '96', '100', '104']}; {'id': '8', 'type': 'try_statement', 'children': ['9', '69']}; {'id': '9', 'type': 'block', 'children': ['10']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '14', '38']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '13'], 'value': 'is'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'NOT_SET'}; {'id': '14', 'type': 'block', 'children': ['15', '26']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '25'], 'value': '-'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'len'}; {'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': '_list'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '31']}; {'id': '28', 'type': 'pattern_list', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'value'}; {'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': '_list'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '37', 'type': 'argument_list', 'children': []}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40', '53']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'pattern_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '45', 'type': 'call', 'children': ['46', '51']}; {'id': '46', 'type': 'attribute', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': '_list'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '57']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '56'], 'value': '<'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '56', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'augmented_assignment', 'children': ['60', '61'], 'value': '+='}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '68'], 'value': '+'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_list'}; {'id': '68', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '69', 'type': 'except_clause', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'IndexError'}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'if_statement', 'children': ['73', '74', '80']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'has_default'}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'expression_list', 'children': ['77', '78', '79']}; {'id': '77', 'type': 'None', 'children': []}; {'id': '78', 'type': 'None', 'children': []}; {'id': '79', 'type': 'None', 'children': []}; {'id': '80', 'type': 'else_clause', 'children': ['81']}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'raise_statement', 'children': []}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '88']}; {'id': '85', 'type': 'pattern_list', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'index2'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'value2'}; {'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': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': '_dict'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '96', 'type': 'assert_statement', 'children': ['97']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': '=='}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'index2'}; {'id': '100', 'type': 'assert_statement', 'children': ['101']}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '103'], 'value': 'is'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'value2'}; {'id': '104', 'type': 'return_statement', 'children': ['105']}; {'id': '105', 'type': 'expression_list', 'children': ['106', '107', '108']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'value'}
Remove an element by index, or last element.
def html(self, label, *msg): lbl = "[" + label + "] " txt = lbl + " " + " ".join(list(msg)) if self.notebook is True: html = HTML(txt) display(lbl + html) else: print(lbl + txt)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'html'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '8', 'type': 'block', 'children': ['9', '17', '33']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'lbl'}; {'id': '12', 'type': 'binary_operator', 'children': ['13', '16'], 'value': '+'}; {'id': '13', 'type': 'binary_operator', 'children': ['14', '15'], 'value': '+'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"["'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"] "'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'txt'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '24'], 'value': '+'}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '+'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'lbl'}; {'id': '23', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '28', 'type': 'argument_list', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'msg'}; {'id': '33', 'type': 'if_statement', 'children': ['34', '39', '54']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '38'], 'value': 'is'}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '38', 'type': 'True', 'children': []}; {'id': '39', 'type': 'block', 'children': ['40', '47']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'HTML'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'txt'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'display'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'binary_operator', 'children': ['52', '53'], 'value': '+'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'lbl'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'html'}; {'id': '54', 'type': 'else_clause', 'children': ['55']}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'binary_operator', 'children': ['61', '62'], 'value': '+'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'lbl'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'txt'}
Prints html in notebook
def variant(self, case_id, variant_id): case_obj = self.case(case_id) plugin, case_id = self.select_plugin(case_obj) variant = plugin.variant(case_id, variant_id) return variant
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'variant'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'case_id'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'variant_id'}; {'id': '7', 'type': 'block', 'children': ['8', '17', '28', '38']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'case_obj'}; {'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': 'case'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'case_id'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '22']}; {'id': '19', 'type': 'pattern_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'case_id'}; {'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': 'select_plugin'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'case_obj'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'variant'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'plugin'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'variant'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'case_id'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'variant_id'}; {'id': '38', 'type': 'return_statement', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'variant'}
Fetch a single variant from variant source.
def on_episode_end(self, episode, logs): duration = timeit.default_timer() - self.starts[episode] metrics = self.metrics[episode] if np.isnan(metrics).all(): mean_metrics = np.array([np.nan for _ in self.metrics_names]) else: mean_metrics = np.nanmean(metrics, axis=0) assert len(mean_metrics) == len(self.metrics_names) data = list(zip(self.metrics_names, mean_metrics)) data += list(logs.items()) data += [('episode', episode), ('duration', duration)] for key, value in data: if key not in self.data: self.data[key] = [] self.data[key].append(value) if self.interval is not None and episode % self.interval == 0: self.save_data() del self.metrics[episode] del self.starts[episode]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_episode_end'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'episode'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'logs'}; {'id': '7', 'type': 'block', 'children': ['8', '22', '30', '73', '85', '98', '109', '119', '151', '172', '178']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'duration'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '17'], 'value': '-'}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'timeit'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'default_timer'}; {'id': '16', 'type': 'argument_list', 'children': []}; {'id': '17', 'type': 'subscript', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'episode'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'episode'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '41', '59']}; {'id': '31', 'type': 'call', 'children': ['32', '40']}; {'id': '32', 'type': 'attribute', 'children': ['33', '39']}; {'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': 'isnan'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'mean_metrics'}; {'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': 'array'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'list_comprehension', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'nan'}; {'id': '54', 'type': 'for_in_clause', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'metrics_names'}; {'id': '59', 'type': 'else_clause', 'children': ['60']}; {'id': '60', 'type': 'block', 'children': ['61']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'mean_metrics'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'nanmean'}; {'id': '68', 'type': 'argument_list', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'axis'}; {'id': '72', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '73', 'type': 'assert_statement', 'children': ['74']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '79'], 'value': '=='}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'mean_metrics'}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'metrics_names'}; {'id': '85', 'type': 'expression_statement', 'children': ['86']}; {'id': '86', 'type': 'assignment', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '88', 'type': 'call', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'metrics_names'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'mean_metrics'}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'augmented_assignment', 'children': ['100', '101'], 'value': '+='}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'list'}; {'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': 'logs'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '108', 'type': 'argument_list', 'children': []}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'augmented_assignment', 'children': ['111', '112'], 'value': '+='}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '112', 'type': 'list', 'children': ['113', '116'], 'value': "[('episode', episode), ('duration', duration)]"}; {'id': '113', 'type': 'tuple', 'children': ['114', '115']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'episode'"}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'episode'}; {'id': '116', 'type': 'tuple', 'children': ['117', '118']}; {'id': '117', 'type': 'string', 'children': [], 'value': "'duration'"}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'duration'}; {'id': '119', 'type': 'for_statement', 'children': ['120', '123', '124']}; {'id': '120', 'type': 'pattern_list', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '124', 'type': 'block', 'children': ['125', '140']}; {'id': '125', 'type': 'if_statement', 'children': ['126', '131']}; {'id': '126', 'type': 'comparison_operator', 'children': ['127', '128'], 'value': 'not in'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '128', 'type': 'attribute', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '139']}; {'id': '134', 'type': 'subscript', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '139', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '140', 'type': 'expression_statement', 'children': ['141']}; {'id': '141', 'type': 'call', 'children': ['142', '149']}; {'id': '142', 'type': 'attribute', 'children': ['143', '148']}; {'id': '143', 'type': 'subscript', 'children': ['144', '147']}; {'id': '144', 'type': 'attribute', 'children': ['145', '146']}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '151', 'type': 'if_statement', 'children': ['152', '165']}; {'id': '152', 'type': 'boolean_operator', 'children': ['153', '158'], 'value': 'and'}; {'id': '153', 'type': 'comparison_operator', 'children': ['154', '157'], 'value': 'is not'}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '157', 'type': 'None', 'children': []}; {'id': '158', 'type': 'comparison_operator', 'children': ['159', '164'], 'value': '=='}; {'id': '159', 'type': 'binary_operator', 'children': ['160', '161'], 'value': '%'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'episode'}; {'id': '161', 'type': 'attribute', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'interval'}; {'id': '164', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '165', 'type': 'block', 'children': ['166']}; {'id': '166', 'type': 'expression_statement', 'children': ['167']}; {'id': '167', 'type': 'call', 'children': ['168', '171']}; {'id': '168', 'type': 'attribute', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'save_data'}; {'id': '171', 'type': 'argument_list', 'children': []}; {'id': '172', 'type': 'delete_statement', 'children': ['173']}; {'id': '173', 'type': 'subscript', 'children': ['174', '177']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'metrics'}; {'id': '177', 'type': 'identifier', 'children': [], 'value': 'episode'}; {'id': '178', 'type': 'delete_statement', 'children': ['179']}; {'id': '179', 'type': 'subscript', 'children': ['180', '183']}; {'id': '180', 'type': 'attribute', 'children': ['181', '182']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'starts'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'episode'}
Compute and print metrics at the end of each episode
def get(self, entry): if self.apiVersion == 1: path = self.secretsmount + '/' + entry else: path = self.secretsmount + '/data/' + entry proj = yield self._http.get('/v1/{0}'.format(path)) code = yield proj.code if code != 200: raise KeyError("The key %s does not exist in Vault provider: request" " return code:%d." % (entry, code)) json = yield proj.json() if self.apiVersion == 1: ret = json.get('data', {}).get('value') else: ret = json.get('data', {}).get('data', {}).get('value') return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '6', 'type': 'block', 'children': ['7', '36', '53', '60', '76', '85', '130']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '13', '24']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '12'], 'value': '=='}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'apiVersion'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '23'], 'value': '+'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '+'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'secretsmount'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '24', 'type': 'else_clause', 'children': ['25']}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '35'], 'value': '+'}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '34'], 'value': '+'}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'secretsmount'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'/data/'"}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'proj'}; {'id': '39', 'type': 'yield', 'children': ['40']}; {'id': '40', 'type': 'call', 'children': ['41', '46']}; {'id': '41', 'type': 'attribute', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_http'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'/v1/{0}'"}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '56', 'type': 'yield', 'children': ['57']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'proj'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '60', 'type': 'if_statement', 'children': ['61', '64']}; {'id': '61', 'type': 'comparison_operator', 'children': ['62', '63'], 'value': '!='}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'raise_statement', 'children': ['66']}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'binary_operator', 'children': ['70', '73'], 'value': '%'}; {'id': '70', 'type': 'concatenated_string', 'children': ['71', '72']}; {'id': '71', 'type': 'string', 'children': [], 'value': '"The key %s does not exist in Vault provider: request"'}; {'id': '72', 'type': 'string', 'children': [], 'value': '" return code:%d."'}; {'id': '73', 'type': 'tuple', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '79', 'type': 'yield', 'children': ['80']}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'proj'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '84', 'type': 'argument_list', 'children': []}; {'id': '85', 'type': 'if_statement', 'children': ['86', '91', '107']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '90'], 'value': '=='}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'apiVersion'}; {'id': '90', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '91', 'type': 'block', 'children': ['92']}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '95', 'type': 'call', 'children': ['96', '105']}; {'id': '96', 'type': 'attribute', 'children': ['97', '104']}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '103', 'type': 'dictionary', 'children': []}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '107', 'type': 'else_clause', 'children': ['108']}; {'id': '108', 'type': 'block', 'children': ['109']}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'ret'}; {'id': '112', 'type': 'call', 'children': ['113', '128']}; {'id': '113', 'type': 'attribute', 'children': ['114', '127']}; {'id': '114', 'type': 'call', 'children': ['115', '124']}; {'id': '115', 'type': 'attribute', 'children': ['116', '123']}; {'id': '116', 'type': 'call', 'children': ['117', '120']}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '120', 'type': 'argument_list', 'children': ['121', '122']}; {'id': '121', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '122', 'type': 'dictionary', 'children': []}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '124', 'type': 'argument_list', 'children': ['125', '126']}; {'id': '125', 'type': 'string', 'children': [], 'value': "'data'"}; {'id': '126', 'type': 'dictionary', 'children': []}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '130', 'type': 'return_statement', 'children': ['131']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'ret'}
get the value from vault secret backend
def open(cls, blob, username, password): return cls(blob, blob.encryption_key(username, password))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'open'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'blob'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'return_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '12', 'type': 'argument_list', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'blob'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'blob'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'encryption_key'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'username'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'password'}
Creates a vault from a blob object
def save(self): active_language = get_language() for (name, value) in self.cleaned_data.items(): if name not in registry: name, code = name.rsplit('_modeltranslation_', 1) else: code = None setting_obj, created = Setting.objects.get_or_create(name=name) if settings.USE_MODELTRANSLATION: if registry[name]["translatable"]: try: activate(code) except: pass finally: setting_obj.value = value activate(active_language) else: for code in OrderedDict(settings.LANGUAGES): setattr(setting_obj, build_localized_fieldname('value', code), value) else: setting_obj.value = value setting_obj.save()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'active_language'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'get_language'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'for_statement', 'children': ['13', '16', '23']}; {'id': '13', 'type': 'tuple_pattern', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '16', 'type': 'call', 'children': ['17', '22']}; {'id': '17', 'type': 'attribute', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cleaned_data'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'block', 'children': ['24', '47', '62', '127']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28', '41']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'not in'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '34']}; {'id': '31', 'type': 'pattern_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'code'}; {'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': 'rsplit'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': "'_modeltranslation_'"}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'else_clause', 'children': ['42']}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '46', 'type': 'None', 'children': []}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '52']}; {'id': '49', 'type': 'pattern_list', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'setting_obj'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'created'}; {'id': '52', 'type': 'call', 'children': ['53', '58']}; {'id': '53', 'type': 'attribute', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'Setting'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get_or_create'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '62', 'type': 'if_statement', 'children': ['63', '66', '119']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'USE_MODELTRANSLATION'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'if_statement', 'children': ['68', '73', '97']}; {'id': '68', 'type': 'subscript', 'children': ['69', '72']}; {'id': '69', 'type': 'subscript', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'registry'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '72', 'type': 'string', 'children': [], 'value': '"translatable"'}; {'id': '73', 'type': 'block', 'children': ['74']}; {'id': '74', 'type': 'try_statement', 'children': ['75', '81', '84']}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'call', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'activate'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '81', 'type': 'except_clause', 'children': ['82']}; {'id': '82', 'type': 'block', 'children': ['83']}; {'id': '83', 'type': 'pass_statement', 'children': []}; {'id': '84', 'type': 'finally_clause', 'children': ['85']}; {'id': '85', 'type': 'block', 'children': ['86', '92']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'setting_obj'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'call', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'activate'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'active_language'}; {'id': '97', 'type': 'else_clause', 'children': ['98']}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'for_statement', 'children': ['100', '101', '107']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '103', 'type': 'argument_list', 'children': ['104']}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'settings'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'LANGUAGES'}; {'id': '107', 'type': 'block', 'children': ['108']}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'setattr'}; {'id': '111', 'type': 'argument_list', 'children': ['112', '113', '118']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'setting_obj'}; {'id': '113', 'type': 'call', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'build_localized_fieldname'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '117']}; {'id': '116', 'type': 'string', 'children': [], 'value': "'value'"}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '119', 'type': 'else_clause', 'children': ['120']}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'assignment', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'setting_obj'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '127', 'type': 'expression_statement', 'children': ['128']}; {'id': '128', 'type': 'call', 'children': ['129', '132']}; {'id': '129', 'type': 'attribute', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'setting_obj'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '132', 'type': 'argument_list', 'children': []}
Save each of the settings to the DB.
def next_frame_pixel_noise(): hparams = next_frame_basic_deterministic() hparams.add_hparam("video_modality_input_noise", 0.05) hparams.bottom["inputs"] = modalities.video_pixel_noise_bottom hparams.top["inputs"] = modalities.video_top return hparams
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'next_frame_pixel_noise'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '11', '19', '29', '39']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'assignment', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '8', 'type': 'call', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'next_frame_basic_deterministic'}; {'id': '10', 'type': 'argument_list', 'children': []}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'add_hparam'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"video_modality_input_noise"'}; {'id': '18', 'type': 'float', 'children': [], 'value': '0.05'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '26']}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'bottom'}; {'id': '25', 'type': 'string', 'children': [], 'value': '"inputs"'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'modalities'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'video_pixel_noise_bottom'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '36']}; {'id': '31', 'type': 'subscript', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'hparams'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'top'}; {'id': '35', 'type': 'string', 'children': [], 'value': '"inputs"'}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'modalities'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'video_top'}; {'id': '39', 'type': 'return_statement', 'children': ['40']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'hparams'}
Basic 2-frame conv model with pixel noise.
async def on_raw_authenticate(self, message): if self._sasl_timer: self._sasl_timer.cancel() self._sasl_timer = None response = ' '.join(message.params) if response != EMPTY_MESSAGE: self._sasl_challenge += base64.b64decode(response) if len(response) % RESPONSE_LIMIT > 0: await self._sasl_respond() else: self._sasl_timer = self.eventloop.call_later(self.SASL_TIMEOUT, self._sasl_abort(timeout=True))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'on_raw_authenticate'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '6', 'type': 'block', 'children': ['7', '26', '37', '53']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '11']}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_sasl_timer'}; {'id': '11', 'type': 'block', 'children': ['12', '20']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'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': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_sasl_timer'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cancel'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_sasl_timer'}; {'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': 'response'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '37', 'type': 'if_statement', 'children': ['38', '41']}; {'id': '38', 'type': 'comparison_operator', 'children': ['39', '40'], 'value': '!='}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'EMPTY_MESSAGE'}; {'id': '41', 'type': 'block', 'children': ['42']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'augmented_assignment', 'children': ['44', '47'], 'value': '+='}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_sasl_challenge'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'base64'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'b64decode'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '53', 'type': 'if_statement', 'children': ['54', '62', '70']}; {'id': '54', 'type': 'comparison_operator', 'children': ['55', '61'], 'value': '>'}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '60'], 'value': '%'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'RESPONSE_LIMIT'}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'block', 'children': ['63']}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'await', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_sasl_respond'}; {'id': '69', 'type': 'argument_list', 'children': []}; {'id': '70', 'type': 'else_clause', 'children': ['71']}; {'id': '71', 'type': 'block', 'children': ['72']}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': '_sasl_timer'}; {'id': '77', 'type': 'call', 'children': ['78', '83']}; {'id': '78', 'type': 'attribute', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'eventloop'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'call_later'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'SASL_TIMEOUT'}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': '_sasl_abort'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'keyword_argument', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'timeout'}; {'id': '94', 'type': 'True', 'children': []}
Received part of the authentication challenge.
def get(self, request, *args, **kwargs): self.object = self.get_object() can_delete = True protected_objects = [] collector_message = None collector = Collector(using="default") try: collector.collect([self.object]) except ProtectedError as e: collector_message = ( "Cannot delete %s because it has relations " "that depends on it." % self.object ) protected_objects = e.protected_objects can_delete = False if can_delete and self.redirect: messages.success(request, self.get_success_message(self.object)) return self.delete(request, *args, **kwargs) context = self.get_context_data( object=self.object, can_delete=can_delete, collector_message=collector_message, protected_objects=protected_objects, ) return self.render_to_response(context)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'request'}; {'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', '21', '25', '29', '33', '42', '81', '114', '136']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'object'}; {'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': 'get_object'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'can_delete'}; {'id': '24', 'type': 'True', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'protected_objects'}; {'id': '28', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'collector_message'}; {'id': '32', 'type': 'None', 'children': []}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'Collector'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '41', 'type': 'string', 'children': [], 'value': '"default"'}; {'id': '42', 'type': 'try_statement', 'children': ['43', '54']}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'expression_statement', 'children': ['45']}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'collector'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'collect'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'list', 'children': ['51'], 'value': '[self.object]'}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '54', 'type': 'except_clause', 'children': ['55', '59']}; {'id': '55', 'type': 'as_pattern', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'ProtectedError'}; {'id': '57', 'type': 'as_pattern_target', 'children': ['58']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '59', 'type': 'block', 'children': ['60', '71', '77']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'collector_message'}; {'id': '63', 'type': '()', 'children': ['64']}; {'id': '64', 'type': 'binary_operator', 'children': ['65', '68'], 'value': '%'}; {'id': '65', 'type': 'concatenated_string', 'children': ['66', '67']}; {'id': '66', 'type': 'string', 'children': [], 'value': '"Cannot delete %s because it has relations "'}; {'id': '67', 'type': 'string', 'children': [], 'value': '"that depends on it."'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'protected_objects'}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'protected_objects'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'can_delete'}; {'id': '80', 'type': 'False', 'children': []}; {'id': '81', 'type': 'if_statement', 'children': ['82', '87']}; {'id': '82', 'type': 'boolean_operator', 'children': ['83', '84'], 'value': 'and'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'can_delete'}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'redirect'}; {'id': '87', 'type': 'block', 'children': ['88', '103']}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'messages'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'success'}; {'id': '93', 'type': 'argument_list', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'get_success_message'}; {'id': '99', 'type': 'argument_list', 'children': ['100']}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '103', 'type': 'return_statement', 'children': ['104']}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '110', '112']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '110', 'type': 'list_splat', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '112', 'type': 'dictionary_splat', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'assignment', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'get_context_data'}; {'id': '121', 'type': 'argument_list', 'children': ['122', '127', '130', '133']}; {'id': '122', 'type': 'keyword_argument', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '124', 'type': 'attribute', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'object'}; {'id': '127', 'type': 'keyword_argument', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'can_delete'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'can_delete'}; {'id': '130', 'type': 'keyword_argument', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'collector_message'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'collector_message'}; {'id': '133', 'type': 'keyword_argument', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'protected_objects'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'protected_objects'}; {'id': '136', 'type': 'return_statement', 'children': ['137']}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'render_to_response'}; {'id': '141', 'type': 'argument_list', 'children': ['142']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'context'}
Catch protected relations and show to user.
def cor(y_true, y_pred): y_true, y_pred = _mask_nan(y_true, y_pred) return np.corrcoef(y_true, y_pred)[0, 1]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cor'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'y_true'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'y_pred'}; {'id': '6', 'type': 'block', 'children': ['7', '17']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '12']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'y_true'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'y_pred'}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': '_mask_nan'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'y_true'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'y_pred'}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'subscript', 'children': ['19', '26', '27']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'corrcoef'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'y_true'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'y_pred'}; {'id': '26', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '1'}
Compute Pearson correlation coefficient.
def clock_in(request): user = request.user active_entry = utils.get_active_entry(user, select_for_update=True) initial = dict([(k, v) for k, v in request.GET.items()]) data = request.POST or None form = ClockInForm(data, initial=initial, user=user, active=active_entry) if form.is_valid(): entry = form.save() message = 'You have clocked into {0} on {1}.'.format( entry.activity.name, entry.project) messages.info(request, message) return HttpResponseRedirect(reverse('dashboard')) return render(request, 'timepiece/entry/clock_in.html', { 'form': form, 'active': active_entry, })
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clock_in'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '24', '45', '53', '69', '116']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'active_entry'}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_active_entry'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'select_for_update'}; {'id': '23', 'type': 'True', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'initial'}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '29', 'type': 'argument_list', 'children': ['30']}; {'id': '30', 'type': 'list_comprehension', 'children': ['31', '34']}; {'id': '31', 'type': 'tuple', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '34', 'type': 'for_in_clause', 'children': ['35', '38']}; {'id': '35', 'type': 'pattern_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '38', 'type': 'call', 'children': ['39', '44']}; {'id': '39', 'type': 'attribute', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'GET'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '48', 'type': 'boolean_operator', 'children': ['49', '52'], 'value': 'or'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'POST'}; {'id': '52', 'type': 'None', 'children': []}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '56', 'type': 'call', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'ClockInForm'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60', '63', '66']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'initial'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'initial'}; {'id': '63', 'type': 'keyword_argument', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'active'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'active_entry'}; {'id': '69', 'type': 'if_statement', 'children': ['70', '75']}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'is_valid'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'block', 'children': ['76', '84', '100', '108']}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '83', 'type': 'argument_list', 'children': []}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '87', 'type': 'call', 'children': ['88', '91']}; {'id': '88', 'type': 'attribute', 'children': ['89', '90']}; {'id': '89', 'type': 'string', 'children': [], 'value': "'You have clocked into {0} on {1}.'"}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '97']}; {'id': '92', 'type': 'attribute', 'children': ['93', '96']}; {'id': '93', 'type': 'attribute', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'activity'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'entry'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'project'}; {'id': '100', 'type': 'expression_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'messages'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '108', 'type': 'return_statement', 'children': ['109']}; {'id': '109', 'type': 'call', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'HttpResponseRedirect'}; {'id': '111', 'type': 'argument_list', 'children': ['112']}; {'id': '112', 'type': 'call', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'reverse'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'string', 'children': [], 'value': "'dashboard'"}; {'id': '116', 'type': 'return_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '119', 'type': 'argument_list', 'children': ['120', '121', '122']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '121', 'type': 'string', 'children': [], 'value': "'timepiece/entry/clock_in.html'"}; {'id': '122', 'type': 'dictionary', 'children': ['123', '126']}; {'id': '123', 'type': 'pair', 'children': ['124', '125']}; {'id': '124', 'type': 'string', 'children': [], 'value': "'form'"}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '126', 'type': 'pair', 'children': ['127', '128']}; {'id': '127', 'type': 'string', 'children': [], 'value': "'active'"}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'active_entry'}
For clocking the user into a project.