code
stringlengths
51
2.34k
sequence
stringlengths
1.16k
13.1k
docstring
stringlengths
11
171
def remote_exception(exc, tb): if type(exc) in exceptions: typ = exceptions[type(exc)] return typ(exc, tb) else: try: typ = type(exc.__class__.__name__, (RemoteException, type(exc)), {'exception_type': type(exc)}) exceptions[type(exc)] = typ return typ(exc, tb) except TypeError: return exc
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remote_exception'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tb'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14', '30']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': 'in'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '14', 'type': 'block', 'children': ['15', '24']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '18', 'type': 'subscript', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '27', 'type': 'argument_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'tb'}; {'id': '30', 'type': 'else_clause', 'children': ['31']}; {'id': '31', 'type': 'block', 'children': ['32']}; {'id': '32', 'type': 'try_statement', 'children': ['33', '73']}; {'id': '33', 'type': 'block', 'children': ['34', '58', '67']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '37', 'type': 'call', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '45', '51']}; {'id': '40', 'type': 'attribute', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '45', 'type': 'tuple', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'RemoteException'}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '51', 'type': 'dictionary', 'children': ['52']}; {'id': '52', 'type': 'pair', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'exception_type'"}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '66']}; {'id': '60', 'type': 'subscript', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'exceptions'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '67', 'type': 'return_statement', 'children': ['68']}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'typ'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'exc'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'tb'}; {'id': '73', 'type': 'except_clause', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '75', 'type': 'block', 'children': ['76']}; {'id': '76', 'type': 'return_statement', 'children': ['77']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'exc'}
Metaclass that wraps exception type in RemoteException
def _repo_url_to_path(self, repo): repo = repo.replace('http://', '') repo = repo.replace('https://', '') repo = repo.replace('/', '_') return os.sep.join([self._data_directory, repo])
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_repo_url_to_path'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '27', '37']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'http://'"}; {'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': 'repo'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '24', 'type': 'argument_list', 'children': ['25', '26']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'https://'"}; {'id': '26', 'type': 'string', 'children': [], 'value': "''"}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'repo'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '36']}; {'id': '35', 'type': 'string', 'children': [], 'value': "'/'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'_'"}; {'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': 'os'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'sep'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'list', 'children': ['46', '49'], 'value': '[self._data_directory, repo]'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': '_data_directory'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'repo'}
Convert a `repo` url to a file path for local storage.
def refresh(self, fields=None, **kwargs): cond = self.c[self._primary_field]==self._key query = self.filter(cond, **kwargs) if not fields: fields = list(self.table.c) v = query.values_one(*fields) if not v: raise NotFound('Instance <{0}:{1}> can not be found'.format(self.tablename, self._key)) d = self._data_prepare(v.items()) self.update(**d) self.set_saved()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'refresh'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '25', '36', '51', '61', '80', '93', '101']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'cond'}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '22'], 'value': '=='}; {'id': '15', 'type': 'subscript', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_primary_field'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_key'}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '32', 'type': 'argument_list', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'cond'}; {'id': '34', 'type': 'dictionary_splat', 'children': ['35']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '36', 'type': 'if_statement', 'children': ['37', '39']}; {'id': '37', 'type': 'not_operator', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'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': 'table'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'c'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'values_one'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'list_splat', 'children': ['60']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '61', 'type': 'if_statement', 'children': ['62', '64']}; {'id': '62', 'type': 'not_operator', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'v'}; {'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': 'NotFound'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '73']}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'string', 'children': [], 'value': "'Instance <{0}:{1}> can not be found'"}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'tablename'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': '_key'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_data_prepare'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'call', 'children': ['89', '92']}; {'id': '89', 'type': 'attribute', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '92', 'type': 'argument_list', 'children': []}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'call', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '98', 'type': 'argument_list', 'children': ['99']}; {'id': '99', 'type': 'dictionary_splat', 'children': ['100']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'd'}; {'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': 'self'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'set_saved'}; {'id': '106', 'type': 'argument_list', 'children': []}
Re get the instance of current id
def update_fw_local_result_str(self, os_result=None, dcnm_result=None, dev_result=None): fw_dict = self.get_fw_dict() if os_result is not None: fw_dict['os_status'] = os_result if dcnm_result is not None: fw_dict['dcnm_status'] = dcnm_result if dev_result is not None: fw_dict['dev_status'] = dev_result self.update_fw_dict(fw_dict)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'update_fw_local_result_str'}; {'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': 'os_result'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'dcnm_result'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dev_result'}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'block', 'children': ['15', '23', '34', '45', '56']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'id': '16', 'type': 'assignment', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'fw_dict'}; {'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': 'get_fw_dict'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'if_statement', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'is not'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'os_result'}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '33']}; {'id': '30', 'type': 'subscript', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'fw_dict'}; {'id': '32', 'type': 'string', 'children': [], 'value': "'os_status'"}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'os_result'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': 'is not'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'dcnm_result'}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '44']}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'fw_dict'}; {'id': '43', 'type': 'string', 'children': [], 'value': "'dcnm_status'"}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dcnm_result'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': 'is not'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'dev_result'}; {'id': '48', 'type': 'None', 'children': []}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '55']}; {'id': '52', 'type': 'subscript', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'fw_dict'}; {'id': '54', 'type': 'string', 'children': [], 'value': "'dev_status'"}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'dev_result'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'update_fw_dict'}; {'id': '61', 'type': 'argument_list', 'children': ['62']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'fw_dict'}
Update the FW result in the dict.
def _parity_interaction(q0: ops.Qid, q1: ops.Qid, rads: float, atol: float, gate: Optional[ops.Gate] = None): if abs(rads) < atol: return h = rads * -2 / np.pi if gate is not None: g = cast(ops.Gate, gate) yield g.on(q0), g.on(q1) if _is_trivial_angle(rads, atol): yield ops.CZ.on(q0, q1) else: yield ops.CZ(q0, q1) ** (-2 * h) yield ops.Z(q0)**h yield ops.Z(q1)**h if gate is not None: g = protocols.inverse(gate) yield g.on(q0), g.on(q1)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '35']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parity_interaction'}; {'id': '3', 'type': 'parameters', 'children': ['4', '10', '16', '20', '24']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'q0'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'Qid'}; {'id': '10', 'type': 'typed_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'q1'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'Qid'}; {'id': '16', 'type': 'typed_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'rads'}; {'id': '18', 'type': 'type', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '20', 'type': 'typed_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'atol'}; {'id': '22', 'type': 'type', 'children': ['23']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '24', 'type': 'typed_default_parameter', 'children': ['25', '26', '34']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '26', 'type': 'type', 'children': ['27']}; {'id': '27', 'type': 'generic_type', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'Optional'}; {'id': '29', 'type': 'type_parameter', 'children': ['30']}; {'id': '30', 'type': 'type', 'children': ['31']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'Gate'}; {'id': '34', 'type': 'None', 'children': []}; {'id': '35', 'type': 'block', 'children': ['36', '45', '56', '86', '121', '131', '141']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '43']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '42'], 'value': '<'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'abs'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'rads'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'atol'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'return_statement', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '53'], 'value': '/'}; {'id': '49', 'type': 'binary_operator', 'children': ['50', '51'], 'value': '*'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'rads'}; {'id': '51', 'type': 'unary_operator', 'children': ['52'], 'value': '-'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'pi'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '60']}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '59'], 'value': 'is not'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '59', 'type': 'None', 'children': []}; {'id': '60', 'type': 'block', 'children': ['61', '71']}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'cast'}; {'id': '66', 'type': 'argument_list', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'Gate'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'yield', 'children': ['73']}; {'id': '73', 'type': 'expression_list', 'children': ['74', '80']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'q0'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'q1'}; {'id': '86', 'type': 'if_statement', 'children': ['87', '92', '104']}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_is_trivial_angle'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'rads'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'atol'}; {'id': '92', 'type': 'block', 'children': ['93']}; {'id': '93', 'type': 'expression_statement', 'children': ['94']}; {'id': '94', 'type': 'yield', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '101']}; {'id': '96', 'type': 'attribute', 'children': ['97', '100']}; {'id': '97', 'type': 'attribute', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'CZ'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'q0'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'q1'}; {'id': '104', 'type': 'else_clause', 'children': ['105']}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'yield', 'children': ['108']}; {'id': '108', 'type': 'binary_operator', 'children': ['109', '116'], 'value': '**'}; {'id': '109', 'type': 'call', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'CZ'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'q0'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'q1'}; {'id': '116', 'type': '()', 'children': ['117']}; {'id': '117', 'type': 'binary_operator', 'children': ['118', '120'], 'value': '*'}; {'id': '118', 'type': 'unary_operator', 'children': ['119'], 'value': '-'}; {'id': '119', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'yield', 'children': ['123']}; {'id': '123', 'type': 'binary_operator', 'children': ['124', '130'], 'value': '**'}; {'id': '124', 'type': 'call', 'children': ['125', '128']}; {'id': '125', 'type': 'attribute', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'Z'}; {'id': '128', 'type': 'argument_list', 'children': ['129']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'q0'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'yield', 'children': ['133']}; {'id': '133', 'type': 'binary_operator', 'children': ['134', '140'], 'value': '**'}; {'id': '134', 'type': 'call', 'children': ['135', '138']}; {'id': '135', 'type': 'attribute', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'ops'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'Z'}; {'id': '138', 'type': 'argument_list', 'children': ['139']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'q1'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'h'}; {'id': '141', 'type': 'if_statement', 'children': ['142', '145']}; {'id': '142', 'type': 'comparison_operator', 'children': ['143', '144'], 'value': 'is not'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '144', 'type': 'None', 'children': []}; {'id': '145', 'type': 'block', 'children': ['146', '155']}; {'id': '146', 'type': 'expression_statement', 'children': ['147']}; {'id': '147', 'type': 'assignment', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '149', 'type': 'call', 'children': ['150', '153']}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'protocols'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'inverse'}; {'id': '153', 'type': 'argument_list', 'children': ['154']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'gate'}; {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'yield', 'children': ['157']}; {'id': '157', 'type': 'expression_list', 'children': ['158', '164']}; {'id': '158', 'type': 'call', 'children': ['159', '162']}; {'id': '159', 'type': 'attribute', 'children': ['160', '161']}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'q0'}; {'id': '164', 'type': 'call', 'children': ['165', '168']}; {'id': '165', 'type': 'attribute', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'g'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'on'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'q1'}
Yields a ZZ interaction framed by the given operation.
def ghz_state(qubits: Union[int, Qubits]) -> State: N, qubits = qubits_count_tuple(qubits) ket = np.zeros(shape=[2] * N) ket[(0, ) * N] = 1 / sqrt(2) ket[(1, ) * N] = 1 / sqrt(2) return State(ket, qubits)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '14', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ghz_state'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'typed_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'qubits'}; {'id': '6', 'type': 'type', 'children': ['7']}; {'id': '7', 'type': 'generic_type', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'Union'}; {'id': '9', 'type': 'type_parameter', 'children': ['10', '12']}; {'id': '10', 'type': 'type', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '12', 'type': 'type', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'Qubits'}; {'id': '14', 'type': 'type', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'State'}; {'id': '16', 'type': 'block', 'children': ['17', '26', '40', '54', '68']}; {'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': 'N'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'qubits'}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'qubits_count_tuple'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'qubits'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'ket'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'zeros'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '36', 'type': 'binary_operator', 'children': ['37', '39'], 'value': '*'}; {'id': '37', 'type': 'list', 'children': ['38'], 'value': '[2]'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '48']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'ket'}; {'id': '44', 'type': 'binary_operator', 'children': ['45', '47'], 'value': '*'}; {'id': '45', 'type': 'tuple', 'children': ['46']}; {'id': '46', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '48', 'type': 'binary_operator', 'children': ['49', '50'], 'value': '/'}; {'id': '49', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '62']}; {'id': '56', 'type': 'subscript', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'ket'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '61'], 'value': '*'}; {'id': '59', 'type': 'tuple', 'children': ['60']}; {'id': '60', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'N'}; {'id': '62', 'type': 'binary_operator', 'children': ['63', '64'], 'value': '/'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '64', 'type': 'call', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '66', 'type': 'argument_list', 'children': ['67']}; {'id': '67', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '68', 'type': 'return_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'State'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'ket'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'qubits'}
Return a GHZ state on N qubits
def complete_shells(line, text, predicate=lambda i: True): res = [i.display_name + ' ' for i in dispatchers.all_instances() if i.display_name.startswith(text) and predicate(i) and ' ' + i.display_name + ' ' not in line] return res
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'complete_shells'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'predicate'}; {'id': '8', 'type': 'lambda', 'children': ['9', '11']}; {'id': '9', 'type': 'lambda_parameters', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '11', 'type': 'True', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '53']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '16', 'type': 'list_comprehension', 'children': ['17', '22', '29']}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '21'], 'value': '+'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'display_name'}; {'id': '21', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '24', 'type': 'call', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dispatchers'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'all_instances'}; {'id': '28', 'type': 'argument_list', 'children': []}; {'id': '29', 'type': 'if_clause', 'children': ['30']}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '44'], 'value': 'and'}; {'id': '31', 'type': 'boolean_operator', 'children': ['32', '40'], 'value': 'and'}; {'id': '32', 'type': 'call', 'children': ['33', '38']}; {'id': '33', 'type': 'attribute', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'display_name'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'startswith'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'predicate'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '44', 'type': 'comparison_operator', 'children': ['45', '52'], 'value': 'not in'}; {'id': '45', 'type': 'binary_operator', 'children': ['46', '51'], 'value': '+'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '+'}; {'id': '47', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'display_name'}; {'id': '51', 'type': 'string', 'children': [], 'value': "' '"}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '53', 'type': 'return_statement', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'res'}
Return the shell names to include in the completion
def getErrorComponent(result, tag): return math.sqrt(sum( (error*2)**2 for (var, error) in result.error_components().items() if var.tag == tag ))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getErrorComponent'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'math'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sqrt'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '15', 'type': 'generator_expression', 'children': ['16', '22', '35']}; {'id': '16', 'type': 'binary_operator', 'children': ['17', '21'], 'value': '**'}; {'id': '17', 'type': '()', 'children': ['18']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '20'], 'value': '*'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '20', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '22', 'type': 'for_in_clause', 'children': ['23', '26']}; {'id': '23', 'type': 'tuple_pattern', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '26', 'type': 'call', 'children': ['27', '34']}; {'id': '27', 'type': 'attribute', 'children': ['28', '33']}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'error_components'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '34', 'type': 'argument_list', 'children': []}; {'id': '35', 'type': 'if_clause', 'children': ['36']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '40'], 'value': '=='}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'var'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'tag'}
get total error contribution for component with specific tag
def cat_hist(val, shade, ax, **kwargs_shade): bins = get_bins(val) binned_d, _ = np.histogram(val, bins=bins, normed=True) bin_edges = np.linspace(np.min(val), np.max(val), len(bins)) centers = 0.5 * (bin_edges + np.roll(bin_edges, 1))[:-1] heights = np.diff(bin_edges) lefts = -0.5 * binned_d ax.barh(centers, binned_d, height=heights, left=lefts, alpha=shade, **kwargs_shade)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'cat_hist'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'shade'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'ax'}; {'id': '7', 'type': 'dictionary_splat_pattern', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'kwargs_shade'}; {'id': '9', 'type': 'block', 'children': ['10', '17', '34', '58', '78', '87', '94']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_bins'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'val'}; {'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': 'binned_d'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'histogram'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28', '31']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '28', 'type': 'keyword_argument', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'normed'}; {'id': '33', 'type': 'True', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bin_edges'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'linspace'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '48', '54']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '54', 'type': 'call', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'bins'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'centers'}; {'id': '61', 'type': 'binary_operator', 'children': ['62', '63'], 'value': '*'}; {'id': '62', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '63', 'type': 'subscript', 'children': ['64', '74']}; {'id': '64', 'type': '()', 'children': ['65']}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '67'], 'value': '+'}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'bin_edges'}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'roll'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'bin_edges'}; {'id': '73', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '74', 'type': 'slice', 'children': ['75', '76']}; {'id': '75', 'type': 'colon', 'children': []}; {'id': '76', 'type': 'unary_operator', 'children': ['77'], 'value': '-'}; {'id': '77', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'heights'}; {'id': '81', 'type': 'call', 'children': ['82', '85']}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'diff'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'bin_edges'}; {'id': '87', 'type': 'expression_statement', 'children': ['88']}; {'id': '88', 'type': 'assignment', 'children': ['89', '90']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'lefts'}; {'id': '90', 'type': 'binary_operator', 'children': ['91', '93'], 'value': '*'}; {'id': '91', 'type': 'unary_operator', 'children': ['92'], 'value': '-'}; {'id': '92', 'type': 'float', 'children': [], 'value': '0.5'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'binned_d'}; {'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': 'ax'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'barh'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101', '102', '105', '108', '111']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'centers'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'binned_d'}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'heights'}; {'id': '105', 'type': 'keyword_argument', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'left'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'lefts'}; {'id': '108', 'type': 'keyword_argument', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'alpha'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'shade'}; {'id': '111', 'type': 'dictionary_splat', 'children': ['112']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'kwargs_shade'}
Auxiliary function to plot discrete-violinplots.
async def stop(self): if self.__started: self.__transport._unregister_rtp_receiver(self) self.__stop_decoder() self.__rtcp_task.cancel() await self.__rtcp_exited.wait()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stop'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '10']}; {'id': '7', 'type': 'attribute', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '__started'}; {'id': '10', 'type': 'block', 'children': ['11', '20', '26', '34']}; {'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': '__transport'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_unregister_rtp_receiver'}; {'id': '18', 'type': 'argument_list', 'children': ['19']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '__stop_decoder'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', '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': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '__rtcp_task'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'cancel'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'await', 'children': ['36']}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'attribute', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '__rtcp_exited'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'wait'}; {'id': '42', 'type': 'argument_list', 'children': []}
Irreversibly stop the receiver.
def parents(self): parents = [] if self.parent is None: return [] category = self while category.parent is not None: parents.append(category.parent) category = category.parent return parents[::-1]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parents'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '19', '23', '45']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '9', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '10', 'type': 'if_statement', 'children': ['11', '16']}; {'id': '11', 'type': 'comparison_operator', 'children': ['12', '15'], 'value': 'is'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17']}; {'id': '17', 'type': 'return_statement', 'children': ['18']}; {'id': '18', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'while_statement', 'children': ['24', '29']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '28'], 'value': 'is not'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'block', 'children': ['30', '39']}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '45', 'type': 'return_statement', 'children': ['46']}; {'id': '46', 'type': 'subscript', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'parents'}; {'id': '48', 'type': 'slice', 'children': ['49', '50', '51']}; {'id': '49', 'type': 'colon', 'children': []}; {'id': '50', 'type': 'colon', 'children': []}; {'id': '51', 'type': 'unary_operator', 'children': ['52'], 'value': '-'}; {'id': '52', 'type': 'integer', 'children': [], 'value': '1'}
Returns a list of all the current category's parents.
def CA(self): try: return self._CA except AttributeError: pass self._CA = [self.C, self.A] return self._CA
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'CA'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '16', '28']}; {'id': '6', 'type': 'try_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': '_CA'}; {'id': '12', 'type': 'except_clause', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'pass_statement', 'children': []}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_CA'}; {'id': '21', 'type': 'list', 'children': ['22', '25'], 'value': '[self.C, self.A]'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'C'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'A'}; {'id': '28', 'type': 'return_statement', 'children': ['29']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': '_CA'}
Vertices C and A, list.
def evaluate_result(self, m): fixed_fields = list(m.groups()) for n in self._fixed_fields: if n in self._type_conversions: fixed_fields[n] = self._type_conversions[n](fixed_fields[n], m) fixed_fields = tuple(fixed_fields[n] for n in self._fixed_fields) groupdict = m.groupdict() named_fields = {} name_map = {} for k in self._named_fields: korig = self._group_to_name_map[k] name_map[korig] = k if k in self._type_conversions: value = self._type_conversions[k](groupdict[k], m) else: value = groupdict[k] named_fields[korig] = value spans = dict((n, m.span(name_map[n])) for n in named_fields) spans.update((i, m.span(n + 1)) for i, n in enumerate(self._fixed_fields)) return Result(fixed_fields, self._expand_named_fields(named_fields), spans)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'evaluate_result'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '47', '61', '69', '73', '77', '132', '151', '177']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'fixed_fields'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'groups'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'for_statement', 'children': ['19', '20', '23']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_fixed_fields'}; {'id': '23', 'type': 'block', 'children': ['24']}; {'id': '24', 'type': 'if_statement', 'children': ['25', '30']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': 'in'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_type_conversions'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '36']}; {'id': '33', 'type': 'subscript', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'fixed_fields'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '36', 'type': 'call', 'children': ['37', '42']}; {'id': '37', 'type': 'subscript', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': '_type_conversions'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '46']}; {'id': '43', 'type': 'subscript', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'fixed_fields'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'fixed_fields'}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'tuple'}; {'id': '52', 'type': 'generator_expression', 'children': ['53', '56']}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'fixed_fields'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '56', 'type': 'for_in_clause', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_fixed_fields'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '64', 'type': 'call', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '68', 'type': 'argument_list', 'children': []}; {'id': '69', 'type': 'expression_statement', 'children': ['70']}; {'id': '70', 'type': 'assignment', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'named_fields'}; {'id': '72', 'type': 'dictionary', 'children': []}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'name_map'}; {'id': '76', 'type': 'dictionary', 'children': []}; {'id': '77', 'type': 'for_statement', 'children': ['78', '79', '82']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': '_named_fields'}; {'id': '82', 'type': 'block', 'children': ['83', '91', '97', '126']}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'korig'}; {'id': '86', 'type': 'subscript', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': '_group_to_name_map'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '91', 'type': 'expression_statement', 'children': ['92']}; {'id': '92', 'type': 'assignment', 'children': ['93', '96']}; {'id': '93', 'type': 'subscript', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'name_map'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'korig'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '97', 'type': 'if_statement', 'children': ['98', '103', '118']}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': 'in'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '100', 'type': 'attribute', 'children': ['101', '102']}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '102', 'type': 'identifier', 'children': [], 'value': '_type_conversions'}; {'id': '103', 'type': 'block', 'children': ['104']}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '107', 'type': 'call', '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': '_type_conversions'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '113', 'type': 'argument_list', 'children': ['114', '117']}; {'id': '114', 'type': 'subscript', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '118', 'type': 'else_clause', 'children': ['119']}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '123']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '123', 'type': 'subscript', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'groupdict'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '126', 'type': 'expression_statement', 'children': ['127']}; {'id': '127', 'type': 'assignment', 'children': ['128', '131']}; {'id': '128', 'type': 'subscript', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'named_fields'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'korig'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '132', 'type': 'expression_statement', 'children': ['133']}; {'id': '133', 'type': 'assignment', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'spans'}; {'id': '135', 'type': 'call', 'children': ['136', '137']}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '137', 'type': 'generator_expression', 'children': ['138', '148']}; {'id': '138', 'type': 'tuple', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '140', 'type': 'call', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'span'}; {'id': '144', 'type': 'argument_list', 'children': ['145']}; {'id': '145', 'type': 'subscript', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'name_map'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '148', 'type': 'for_in_clause', 'children': ['149', '150']}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'named_fields'}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'call', 'children': ['153', '156']}; {'id': '153', 'type': 'attribute', 'children': ['154', '155']}; {'id': '154', 'type': 'identifier', 'children': [], 'value': 'spans'}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '156', 'type': 'generator_expression', 'children': ['157', '167']}; {'id': '157', 'type': 'tuple', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '159', 'type': 'call', 'children': ['160', '163']}; {'id': '160', 'type': 'attribute', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'm'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'span'}; {'id': '163', 'type': 'argument_list', 'children': ['164']}; {'id': '164', 'type': 'binary_operator', 'children': ['165', '166'], 'value': '+'}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '166', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '167', 'type': 'for_in_clause', 'children': ['168', '171']}; {'id': '168', 'type': 'pattern_list', 'children': ['169', '170']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '171', 'type': 'call', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '173', 'type': 'argument_list', 'children': ['174']}; {'id': '174', 'type': 'attribute', 'children': ['175', '176']}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '176', 'type': 'identifier', 'children': [], 'value': '_fixed_fields'}; {'id': '177', 'type': 'return_statement', 'children': ['178']}; {'id': '178', 'type': 'call', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'Result'}; {'id': '180', 'type': 'argument_list', 'children': ['181', '182', '188']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'fixed_fields'}; {'id': '182', 'type': 'call', 'children': ['183', '186']}; {'id': '183', 'type': 'attribute', 'children': ['184', '185']}; {'id': '184', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '185', 'type': 'identifier', 'children': [], 'value': '_expand_named_fields'}; {'id': '186', 'type': 'argument_list', 'children': ['187']}; {'id': '187', 'type': 'identifier', 'children': [], 'value': 'named_fields'}; {'id': '188', 'type': 'identifier', 'children': [], 'value': 'spans'}
Generate a Result instance for the given regex match object
def get(self, *args, **kwargs): assert not args assert list(kwargs.keys()) == ['pk'] pk = kwargs['pk'] model_name = self.model.__name__ object_spec = (model_name, pk, None) instances = self.cache.get_instances((object_spec,)) try: model_data = instances[(model_name, pk)][0] except KeyError: raise self.model.DoesNotExist( "No match for %r with args %r, kwargs %r" % (self.model, args, kwargs)) else: return CachedModel(self.model, model_data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'get'}; {'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', '13', '25', '31', '39', '46', '58']}; {'id': '10', 'type': 'assert_statement', 'children': ['11']}; {'id': '11', 'type': 'not_operator', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '13', 'type': 'assert_statement', 'children': ['14']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '23'], 'value': '=='}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'call', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'list', 'children': ['24'], 'value': "['pk']"}; {'id': '24', 'type': 'string', 'children': [], 'value': "'pk'"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'pk'"}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'model_name'}; {'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': 'model'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'object_spec'}; {'id': '42', 'type': 'tuple', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'model_name'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '45', 'type': 'None', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'assignment', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '49', 'type': 'call', 'children': ['50', '55']}; {'id': '50', 'type': 'attribute', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'cache'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'get_instances'}; {'id': '55', 'type': 'argument_list', 'children': ['56']}; {'id': '56', 'type': 'tuple', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'object_spec'}; {'id': '58', 'type': 'try_statement', 'children': ['59', '70', '89']}; {'id': '59', 'type': 'block', 'children': ['60']}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'model_data'}; {'id': '63', 'type': 'subscript', 'children': ['64', '69']}; {'id': '64', 'type': 'subscript', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'instances'}; {'id': '66', 'type': 'tuple', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'model_name'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '69', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '70', 'type': 'except_clause', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'KeyError'}; {'id': '72', 'type': 'block', 'children': ['73']}; {'id': '73', 'type': 'raise_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '80']}; {'id': '75', 'type': 'attribute', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'DoesNotExist'}; {'id': '80', 'type': 'argument_list', 'children': ['81']}; {'id': '81', 'type': 'binary_operator', 'children': ['82', '83'], 'value': '%'}; {'id': '82', 'type': 'string', 'children': [], 'value': '"No match for %r with args %r, kwargs %r"'}; {'id': '83', 'type': 'tuple', 'children': ['84', '87', '88']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '89', 'type': 'else_clause', 'children': ['90']}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'CachedModel'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '98']}; {'id': '95', 'type': 'attribute', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'model_data'}
Return the single item from the filtered queryset.
def inspect_node(self, index): if index >= len(self.graph.nodes): raise RPCErrorCode(6) return create_binary_descriptor(str(self.graph.nodes[index]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inspect_node'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '6', 'type': 'block', 'children': ['7', '24']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '18']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '>='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'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': 'graph'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'raise_statement', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'RPCErrorCode'}; {'id': '22', 'type': 'argument_list', 'children': ['23']}; {'id': '23', 'type': 'integer', 'children': [], 'value': '6'}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'create_binary_descriptor'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'subscript', 'children': ['32', '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': 'graph'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'index'}
Inspect the graph node at the given index.
def sort_func(self, key): if key == self._KEYS.VALUE: return 'aaa' if key == self._KEYS.SOURCE: return 'zzz' return key
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'sort_func'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'block', 'children': ['7', '18', '29']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '10'], 'value': '=='}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'key'}; {'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': '_KEYS'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'VALUE'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'return_statement', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'aaa'"}; {'id': '18', 'type': 'if_statement', 'children': ['19', '26']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': '=='}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'key'}; {'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': '_KEYS'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'SOURCE'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'return_statement', 'children': ['28']}; {'id': '28', 'type': 'string', 'children': [], 'value': "'zzz'"}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'key'}
Sorting logic for `Quantity` objects.
def reset (self): self.number = 0 self.errors = 0 self.errors_printed = 0 self.warnings = 0 self.warnings_printed = 0 self.internal_errors = 0 self.link_types = ContentTypes.copy() self.max_url_length = 0 self.min_url_length = 0 self.avg_url_length = 0.0 self.avg_number = 0 self.downloaded_bytes = None
{'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', '12', '18', '24', '30', '36', '42', '52', '58', '64', '70', '76']}; {'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': 'number'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'errors'}; {'id': '17', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'errors_printed'}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'warnings'}; {'id': '29', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'warnings_printed'}; {'id': '35', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'internal_errors'}; {'id': '41', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'link_types'}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'ContentTypes'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '51', 'type': 'argument_list', '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': 'max_url_length'}; {'id': '57', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'min_url_length'}; {'id': '63', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'avg_url_length'}; {'id': '69', 'type': 'float', 'children': [], 'value': '0.0'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'avg_number'}; {'id': '75', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'downloaded_bytes'}; {'id': '81', 'type': 'None', 'children': []}
Reset all log statistics to default values.
def list_classification_predictors(self): preds = [self.create(x) for x in self._predictors.keys()] return [x.name for x in preds if x.ptype == "classification"]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list_classification_predictors'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '25']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'preds'}; {'id': '9', 'type': 'list_comprehension', 'children': ['10', '16']}; {'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': 'create'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '16', 'type': 'for_in_clause', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_predictors'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'list_comprehension', 'children': ['27', '30', '33']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '30', 'type': 'for_in_clause', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'preds'}; {'id': '33', 'type': 'if_clause', 'children': ['34']}; {'id': '34', 'type': 'comparison_operator', 'children': ['35', '38'], 'value': '=='}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'x'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'ptype'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"classification"'}
List available classification predictors.
def queue_jobs(main_task_path, params_list, queue=None, batch_size=1000): if len(params_list) == 0: return [] if queue is None: task_def = context.get_current_config().get("tasks", {}).get(main_task_path) or {} queue = task_def.get("queue", "default") from .queue import Queue queue_obj = Queue(queue) if queue_obj.is_raw: raise Exception("Can't queue regular jobs on a raw queue") all_ids = [] for params_group in group_iter(params_list, n=batch_size): context.metric("jobs.status.queued", len(params_group)) job_ids = Job.insert([{ "path": main_task_path, "params": params, "queue": queue, "datequeued": datetime.datetime.utcnow(), "status": "queued" } for params in params_group], w=1, return_jobs=False) all_ids += job_ids queue_obj.notify(len(all_ids)) set_queues_size({queue: len(all_ids)}) return all_ids
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'queue_jobs'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'main_task_path'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'params_list'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '11', 'type': 'integer', 'children': [], 'value': '1000'}; {'id': '12', 'type': 'block', 'children': ['13', '23', '59', '66', '73', '83', '87', '152', '162', '173']}; {'id': '13', 'type': 'if_statement', 'children': ['14', '20']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '19'], 'value': '=='}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'params_list'}; {'id': '19', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '23', 'type': 'if_statement', 'children': ['24', '27']}; {'id': '24', 'type': 'comparison_operator', 'children': ['25', '26'], 'value': 'is'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '26', 'type': 'None', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28', '49']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'task_def'}; {'id': '31', 'type': 'boolean_operator', 'children': ['32', '48'], 'value': 'or'}; {'id': '32', 'type': 'call', 'children': ['33', '46']}; {'id': '33', 'type': 'attribute', 'children': ['34', '45']}; {'id': '34', 'type': 'call', 'children': ['35', '42']}; {'id': '35', 'type': 'attribute', 'children': ['36', '41']}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get_current_config'}; {'id': '40', 'type': 'argument_list', 'children': []}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'string', 'children': [], 'value': '"tasks"'}; {'id': '44', 'type': 'dictionary', 'children': []}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '46', 'type': 'argument_list', 'children': ['47']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'main_task_path'}; {'id': '48', 'type': 'dictionary', 'children': []}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'task_def'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '58']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"queue"'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"default"'}; {'id': '59', 'type': 'import_from_statement', 'children': ['60', '64']}; {'id': '60', 'type': 'relative_import', 'children': ['61', '62']}; {'id': '61', 'type': 'import_prefix', 'children': []}; {'id': '62', 'type': 'dotted_name', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '64', 'type': 'dotted_name', 'children': ['65']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'Queue'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'queue_obj'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'Queue'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '73', 'type': 'if_statement', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'queue_obj'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'is_raw'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'raise_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '81', 'type': 'argument_list', 'children': ['82']}; {'id': '82', 'type': 'string', 'children': [], 'value': '"Can\'t queue regular jobs on a raw queue"'}; {'id': '83', 'type': 'expression_statement', 'children': ['84']}; {'id': '84', 'type': 'assignment', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'all_ids'}; {'id': '86', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '87', 'type': 'for_statement', 'children': ['88', '89', '96']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'params_group'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'group_iter'}; {'id': '91', 'type': 'argument_list', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'params_list'}; {'id': '93', 'type': 'keyword_argument', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'batch_size'}; {'id': '96', 'type': 'block', 'children': ['97', '108', '148']}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'call', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '102', 'type': 'argument_list', 'children': ['103', '104']}; {'id': '103', 'type': 'string', 'children': [], 'value': '"jobs.status.queued"'}; {'id': '104', 'type': 'call', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '106', 'type': 'argument_list', 'children': ['107']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'params_group'}; {'id': '108', 'type': 'expression_statement', 'children': ['109']}; {'id': '109', 'type': 'assignment', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'job_ids'}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'Job'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'insert'}; {'id': '115', 'type': 'argument_list', 'children': ['116', '142', '145']}; {'id': '116', 'type': 'list_comprehension', 'children': ['117', '139']}; {'id': '117', 'type': 'dictionary', 'children': ['118', '121', '124', '127', '136']}; {'id': '118', 'type': 'pair', 'children': ['119', '120']}; {'id': '119', 'type': 'string', 'children': [], 'value': '"path"'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'main_task_path'}; {'id': '121', 'type': 'pair', 'children': ['122', '123']}; {'id': '122', 'type': 'string', 'children': [], 'value': '"params"'}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '124', 'type': 'pair', 'children': ['125', '126']}; {'id': '125', 'type': 'string', 'children': [], 'value': '"queue"'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '127', 'type': 'pair', 'children': ['128', '129']}; {'id': '128', 'type': 'string', 'children': [], 'value': '"datequeued"'}; {'id': '129', 'type': 'call', 'children': ['130', '135']}; {'id': '130', 'type': 'attribute', 'children': ['131', '134']}; {'id': '131', 'type': 'attribute', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'datetime'}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'utcnow'}; {'id': '135', 'type': 'argument_list', 'children': []}; {'id': '136', 'type': 'pair', 'children': ['137', '138']}; {'id': '137', 'type': 'string', 'children': [], 'value': '"status"'}; {'id': '138', 'type': 'string', 'children': [], 'value': '"queued"'}; {'id': '139', 'type': 'for_in_clause', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'params_group'}; {'id': '142', 'type': 'keyword_argument', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'w'}; {'id': '144', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'return_jobs'}; {'id': '147', 'type': 'False', 'children': []}; {'id': '148', 'type': 'expression_statement', 'children': ['149']}; {'id': '149', 'type': 'augmented_assignment', 'children': ['150', '151'], 'value': '+='}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'all_ids'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'job_ids'}; {'id': '152', 'type': 'expression_statement', 'children': ['153']}; {'id': '153', 'type': 'call', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'identifier', 'children': [], 'value': 'queue_obj'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'notify'}; {'id': '157', 'type': 'argument_list', 'children': ['158']}; {'id': '158', 'type': 'call', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'all_ids'}; {'id': '162', 'type': 'expression_statement', 'children': ['163']}; {'id': '163', 'type': 'call', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'set_queues_size'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'dictionary', 'children': ['167']}; {'id': '167', 'type': 'pair', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'queue'}; {'id': '169', 'type': 'call', 'children': ['170', '171']}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '171', 'type': 'argument_list', 'children': ['172']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'all_ids'}; {'id': '173', 'type': 'return_statement', 'children': ['174']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'all_ids'}
Queue multiple jobs on a regular queue
def video(video_type, video_mime, doc=None): @on_valid(video_mime) def video_handler(data, **kwargs): if hasattr(data, 'read'): return data elif hasattr(data, 'save'): output = stream() data.save(output, format=video_type.upper()) output.seek(0) return output elif hasattr(data, 'render'): return data.render() elif os.path.isfile(data): return open(data, 'rb') video_handler.__doc__ = doc or "{0} formatted video".format(video_type) return video_handler
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'video'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'video_type'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'video_mime'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '97', '110']}; {'id': '10', 'type': 'decorated_definition', 'children': ['11', '16']}; {'id': '11', 'type': 'decorator', 'children': ['12']}; {'id': '12', 'type': 'call', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'on_valid'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'video_mime'}; {'id': '16', 'type': 'function_definition', 'children': ['17', '18', '22']}; {'id': '17', 'type': 'function_name', 'children': [], 'value': 'video_handler'}; {'id': '18', 'type': 'parameters', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '20', 'type': 'dictionary_splat_pattern', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'if_statement', 'children': ['24', '29', '32', '68', '81']}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'read'"}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '32', 'type': 'elif_clause', 'children': ['33', '38']}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '37', 'type': 'string', 'children': [], 'value': "'save'"}; {'id': '38', 'type': 'block', 'children': ['39', '45', '59', '66']}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '42', 'type': 'call', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'stream'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'video_type'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '58', 'type': 'argument_list', 'children': []}; {'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': 'output'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'seek'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '66', 'type': 'return_statement', 'children': ['67']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '68', 'type': 'elif_clause', 'children': ['69', '74']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '73', 'type': 'string', 'children': [], 'value': "'render'"}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '80', 'type': 'argument_list', 'children': []}; {'id': '81', 'type': 'elif_clause', 'children': ['82', '90']}; {'id': '82', 'type': 'call', 'children': ['83', '88']}; {'id': '83', 'type': 'attribute', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'isfile'}; {'id': '88', 'type': 'argument_list', 'children': ['89']}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '90', 'type': 'block', 'children': ['91']}; {'id': '91', 'type': 'return_statement', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '94', 'type': 'argument_list', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'rb'"}; {'id': '97', 'type': 'expression_statement', 'children': ['98']}; {'id': '98', 'type': 'assignment', 'children': ['99', '102']}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'video_handler'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': '__doc__'}; {'id': '102', 'type': 'boolean_operator', 'children': ['103', '104'], 'value': 'or'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'doc'}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'string', 'children': [], 'value': '"{0} formatted video"'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '108', 'type': 'argument_list', 'children': ['109']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'video_type'}; {'id': '110', 'type': 'return_statement', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'video_handler'}
Dynamically creates a video type handler for the specified video type
def add_hs_service(self, info, address): if self.protocol and self.protocol != PROTOCOL_DMAP: return name = info.properties[b'Name'].decode('utf-8') hsgid = info.properties[b'hG'].decode('utf-8') self._handle_service( address, name, conf.DmapService(hsgid, port=info.port))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_hs_service'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '33', '46']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '18']}; {'id': '9', 'type': 'boolean_operator', 'children': ['10', '13'], 'value': 'and'}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '13', 'type': 'comparison_operator', 'children': ['14', '17'], 'value': '!='}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'PROTOCOL_DMAP'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'return_statement', 'children': []}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '23', 'type': 'call', 'children': ['24', '31']}; {'id': '24', 'type': 'attribute', 'children': ['25', '30']}; {'id': '25', 'type': 'subscript', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '29', 'type': 'string', 'children': [], 'value': "b'Name'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'hsgid'}; {'id': '36', 'type': 'call', 'children': ['37', '44']}; {'id': '37', 'type': 'attribute', 'children': ['38', '43']}; {'id': '38', 'type': 'subscript', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'properties'}; {'id': '42', 'type': 'string', 'children': [], 'value': "b'hG'"}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '44', 'type': 'argument_list', 'children': ['45']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'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': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': '_handle_service'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53', '54']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '54', 'type': 'call', 'children': ['55', '58']}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'conf'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'DmapService'}; {'id': '58', 'type': 'argument_list', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'hsgid'}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'port'}
Add a new device to discovered list.
def bind(self, form): field = self.field(default=self.default, **self.field_kwargs) form._fields[self.name] = field.bind(form, self.name, prefix=form._prefix)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'bind'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '6', 'type': 'block', 'children': ['7', '24']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'field'}; {'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': 'field'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '20']}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '20', 'type': 'dictionary_splat', 'children': ['21']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'field_kwargs'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '33']}; {'id': '26', 'type': 'subscript', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_fields'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'bind'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39', '42']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '42', 'type': 'keyword_argument', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'prefix'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'form'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': '_prefix'}
Bind to filters form.
def normalization_factor(self): return 1.0 / (self.num_atoms - self.composition.get('H', 0) - self.composition.get('O', 0))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalization_factor'}; {'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': 'binary_operator', 'children': ['8', '9'], 'value': '/'}; {'id': '8', 'type': 'float', 'children': [], 'value': '1.0'}; {'id': '9', 'type': '()', 'children': ['10']}; {'id': '10', 'type': 'binary_operator', 'children': ['11', '24'], 'value': '-'}; {'id': '11', 'type': 'binary_operator', 'children': ['12', '15'], 'value': '-'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'num_atoms'}; {'id': '15', 'type': 'call', 'children': ['16', '21']}; {'id': '16', 'type': 'attribute', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'composition'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': "'H'"}; {'id': '23', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'composition'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'string', 'children': [], 'value': "'O'"}; {'id': '32', 'type': 'integer', 'children': [], 'value': '0'}
Sum of number of atoms minus the number of H and O in composition
def _get_request_param(self, request): params = {} try: params = request.POST.copy() if not params: params = json.loads(request.body) except Exception: pass for key in params: if key in self.mask_fields: params[key] = '*' * 8 files = request.FILES.values() if list(files): filenames = ', '.join( [up_file.name for up_file in files]) params['file_name'] = filenames try: return json.dumps(params, ensure_ascii=False) except Exception: return 'Unserializable Object'
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_request_param'}; {'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', '11', '42', '61', '71', '98']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '10', 'type': 'dictionary', 'children': []}; {'id': '11', 'type': 'try_statement', 'children': ['12', '38']}; {'id': '12', 'type': 'block', 'children': ['13', '23']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'params'}; {'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': 'request'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'POST'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'if_statement', 'children': ['24', '26']}; {'id': '24', 'type': 'not_operator', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '38', 'type': 'except_clause', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '40', 'type': 'block', 'children': ['41']}; {'id': '41', 'type': 'pass_statement', 'children': []}; {'id': '42', 'type': 'for_statement', 'children': ['43', '44', '45']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '45', 'type': 'block', 'children': ['46']}; {'id': '46', 'type': 'if_statement', 'children': ['47', '52']}; {'id': '47', 'type': 'comparison_operator', 'children': ['48', '49'], 'value': 'in'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'mask_fields'}; {'id': '52', 'type': 'block', 'children': ['53']}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '58']}; {'id': '55', 'type': 'subscript', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '60'], 'value': '*'}; {'id': '59', 'type': 'string', 'children': [], 'value': "'*'"}; {'id': '60', 'type': 'integer', 'children': [], 'value': '8'}; {'id': '61', 'type': 'expression_statement', 'children': ['62']}; {'id': '62', 'type': 'assignment', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '64', 'type': 'call', 'children': ['65', '70']}; {'id': '65', 'type': 'attribute', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'FILES'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '70', 'type': 'argument_list', 'children': []}; {'id': '71', 'type': 'if_statement', 'children': ['72', '76']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '76', 'type': 'block', 'children': ['77', '92']}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '80', 'type': 'call', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'string', 'children': [], 'value': "', '"}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'list_comprehension', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'up_file'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '89', 'type': 'for_in_clause', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'up_file'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'files'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '97']}; {'id': '94', 'type': 'subscript', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '96', 'type': 'string', 'children': [], 'value': "'file_name'"}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'filenames'}; {'id': '98', 'type': 'try_statement', 'children': ['99', '110']}; {'id': '99', 'type': 'block', 'children': ['100']}; {'id': '100', 'type': 'return_statement', 'children': ['101']}; {'id': '101', 'type': 'call', 'children': ['102', '105']}; {'id': '102', 'type': 'attribute', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '105', 'type': 'argument_list', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '107', 'type': 'keyword_argument', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'ensure_ascii'}; {'id': '109', 'type': 'False', 'children': []}; {'id': '110', 'type': 'except_clause', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '112', 'type': 'block', 'children': ['113']}; {'id': '113', 'type': 'return_statement', 'children': ['114']}; {'id': '114', 'type': 'string', 'children': [], 'value': "'Unserializable Object'"}
Change POST data to JSON string and mask data.
def create_mailbox(self, actor, loop): client = MailboxClient(actor.monitor.address, actor, loop) loop.call_soon_threadsafe(self.hand_shake, actor) return client
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_mailbox'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '7', 'type': 'block', 'children': ['8', '21', '31']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '11', 'type': 'call', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'MailboxClient'}; {'id': '13', 'type': 'argument_list', 'children': ['14', '19', '20']}; {'id': '14', 'type': 'attribute', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'monitor'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'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': 'loop'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'call_soon_threadsafe'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'hand_shake'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'actor'}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'client'}
Create the mailbox for ``actor``.
def _set_roi_mask(self, roi_mask): if isinstance(roi_mask, np.ndarray): self._verify_shape_compatibility(roi_mask, 'ROI set') self.roi_mask = roi_mask self.roi_list = np.unique(roi_mask.flatten()) np.setdiff1d(self.roi_list, cfg.background_value) else: self.roi_mask = np.ones(self.carpet.shape[:-1]) self.roi_list = [1, ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_set_roi_mask'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'roi_mask'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '15', '57']}; {'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': 'roi_mask'}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'ndarray'}; {'id': '15', 'type': 'block', 'children': ['16', '24', '30', '45']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': '_verify_shape_compatibility'}; {'id': '21', 'type': 'argument_list', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'roi_mask'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'ROI set'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'roi_mask'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'roi_mask'}; {'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': 'self'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'roi_list'}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'unique'}; {'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': 'roi_mask'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'flatten'}; {'id': '44', 'type': 'argument_list', 'children': []}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'setdiff1d'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'roi_list'}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'cfg'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'background_value'}; {'id': '57', 'type': 'else_clause', 'children': ['58']}; {'id': '58', 'type': 'block', 'children': ['59', '79']}; {'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': 'roi_mask'}; {'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': 'ones'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'subscript', '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': 'carpet'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '75', 'type': 'slice', 'children': ['76', '77']}; {'id': '76', 'type': 'colon', 'children': []}; {'id': '77', 'type': 'unary_operator', 'children': ['78'], 'value': '-'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'assignment', 'children': ['81', '84']}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'roi_list'}; {'id': '84', 'type': 'list', 'children': ['85'], 'value': '[1, ]'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '1'}
Sets a new ROI mask.
def create_rflink_connection(port=None, host=None, baud=57600, protocol=RflinkProtocol, packet_callback=None, event_callback=None, disconnect_callback=None, ignore=None, loop=None): protocol = partial( protocol, loop=loop if loop else asyncio.get_event_loop(), packet_callback=packet_callback, event_callback=event_callback, disconnect_callback=disconnect_callback, ignore=ignore if ignore else [], ) if host: conn = loop.create_connection(protocol, host, port) else: baud = baud conn = create_serial_connection(loop, protocol, port, baud) return conn
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '31']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'create_rflink_connection'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22', '25', '28']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'baud'}; {'id': '12', 'type': 'integer', 'children': [], 'value': '57600'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'RflinkProtocol'}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'packet_callback'}; {'id': '18', 'type': 'None', 'children': []}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'event_callback'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'default_parameter', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'disconnect_callback'}; {'id': '24', 'type': 'None', 'children': []}; {'id': '25', 'type': 'default_parameter', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ignore'}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'default_parameter', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '30', 'type': 'None', 'children': []}; {'id': '31', 'type': 'block', 'children': ['32', '64', '94']}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39', '49', '52', '55', '58']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '39', 'type': 'keyword_argument', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '41', 'type': 'conditional_expression', 'children': ['42', '43', '44'], 'value': 'if'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'asyncio'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'get_event_loop'}; {'id': '48', 'type': 'argument_list', 'children': []}; {'id': '49', 'type': 'keyword_argument', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'packet_callback'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'packet_callback'}; {'id': '52', 'type': 'keyword_argument', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'event_callback'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'event_callback'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'disconnect_callback'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'disconnect_callback'}; {'id': '58', 'type': 'keyword_argument', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ignore'}; {'id': '60', 'type': 'conditional_expression', 'children': ['61', '62', '63'], 'value': 'if'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'ignore'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ignore'}; {'id': '63', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '64', 'type': 'if_statement', 'children': ['65', '66', '78']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '70', 'type': 'call', 'children': ['71', '74']}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'create_connection'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76', '77']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '78', 'type': 'else_clause', 'children': ['79']}; {'id': '79', 'type': 'block', 'children': ['80', '84']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'baud'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'baud'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'assignment', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '87', 'type': 'call', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'create_serial_connection'}; {'id': '89', 'type': 'argument_list', 'children': ['90', '91', '92', '93']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'loop'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'protocol'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'baud'}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'conn'}
Create Rflink manager class, returns transport coroutine.
def imprints(self, key, value): return { 'place': value.get('a'), 'publisher': value.get('b'), 'date': normalize_date_aggressively(value.get('c')), }
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'imprints'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'dictionary', 'children': ['10', '18', '26']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': "'place'"}; {'id': '12', 'type': 'call', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'string', 'children': [], 'value': "'a'"}; {'id': '18', 'type': 'pair', 'children': ['19', '20']}; {'id': '19', 'type': 'string', 'children': [], 'value': "'publisher'"}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': "'b'"}; {'id': '26', 'type': 'pair', 'children': ['27', '28']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'date'"}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'normalize_date_aggressively'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'c'"}
Populate the ``imprints`` key.
def unregister(self): machine_id = generate_machine_id() try: logger.debug("Unregistering %s", machine_id) url = self.api_url + "/v1/systems/" + machine_id net_logger.info("DELETE %s", url) self.session.delete(url) logger.info( "Successfully unregistered from the Red Hat Insights Service") return True except requests.ConnectionError as e: logger.debug(e) logger.error("Could not unregister this system") return False
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'unregister'}; {'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': 'machine_id'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'generate_machine_id'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'try_statement', 'children': ['13', '58']}; {'id': '13', 'type': 'block', 'children': ['14', '22', '32', '40', '49', '56']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': '"Unregistering %s"'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'machine_id'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '25', 'type': 'binary_operator', 'children': ['26', '31'], 'value': '+'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '30'], 'value': '+'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'api_url'}; {'id': '30', 'type': 'string', 'children': [], 'value': '"/v1/systems/"'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'machine_id'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'net_logger'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'string', 'children': [], 'value': '"DELETE %s"'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'delete'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': '"Successfully unregistered from the Red Hat Insights Service"'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'True', 'children': []}; {'id': '58', 'type': 'except_clause', 'children': ['59', '65']}; {'id': '59', 'type': 'as_pattern', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'ConnectionError'}; {'id': '63', 'type': 'as_pattern_target', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '65', 'type': 'block', 'children': ['66', '73', '80']}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'logger'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'error'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"Could not unregister this system"'}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'False', 'children': []}
Unregister this system from the insights service
def _currentLineExtraSelections(self): if self._currentLineColor is None: return [] def makeSelection(cursor): selection = QTextEdit.ExtraSelection() selection.format.setBackground(self._currentLineColor) selection.format.setProperty(QTextFormat.FullWidthSelection, True) cursor.clearSelection() selection.cursor = cursor return selection rectangularSelectionCursors = self._rectangularSelection.cursors() if rectangularSelectionCursors: return [makeSelection(cursor) \ for cursor in rectangularSelectionCursors] else: return [makeSelection(self.textCursor())]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_currentLineExtraSelections'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '15', '65', '75']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '12']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': '_currentLineColor'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '15', 'type': 'function_definition', 'children': ['16', '17', '19']}; {'id': '16', 'type': 'function_name', 'children': [], 'value': 'makeSelection'}; {'id': '17', 'type': 'parameters', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '19', 'type': 'block', 'children': ['20', '28', '39', '51', '57', '63']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '23', 'type': 'call', 'children': ['24', '27']}; {'id': '24', 'type': 'attribute', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'QTextEdit'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ExtraSelection'}; {'id': '27', 'type': 'argument_list', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'call', 'children': ['30', '35']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'setBackground'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_currentLineColor'}; {'id': '39', 'type': 'expression_statement', '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': 'selection'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'setProperty'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'QTextFormat'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'FullWidthSelection'}; {'id': '50', 'type': 'True', 'children': []}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'clearSelection'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'expression_statement', 'children': ['58']}; {'id': '58', 'type': 'assignment', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'selection'}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'rectangularSelectionCursors'}; {'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': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_rectangularSelection'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'cursors'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'if_statement', 'children': ['76', '77', '88']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'rectangularSelectionCursors'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'return_statement', 'children': ['79']}; {'id': '79', 'type': 'list_comprehension', 'children': ['80', '84', '85']}; {'id': '80', 'type': 'call', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'makeSelection'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '84', 'type': 'line_continuation', 'children': [], 'value': '\\'}; {'id': '85', 'type': 'for_in_clause', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'cursor'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'rectangularSelectionCursors'}; {'id': '88', 'type': 'else_clause', 'children': ['89']}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'return_statement', 'children': ['91']}; {'id': '91', 'type': 'list', 'children': ['92'], 'value': '[makeSelection(self.textCursor())]'}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'makeSelection'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'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': 'textCursor'}; {'id': '99', 'type': 'argument_list', 'children': []}
QTextEdit.ExtraSelection, which highlightes current line
def txn(self, overwrite=False, lock=True): if lock: self._lock.acquire() try: new_state, existing_generation = self.state_and_generation new_state = copy.deepcopy(new_state) yield new_state if overwrite: existing_generation = None self.set_state(new_state, existing_generation=existing_generation) finally: if lock: self._lock.release()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'txn'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'overwrite'}; {'id': '7', 'type': 'False', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'id': '10', 'type': 'True', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '23']}; {'id': '12', 'type': 'if_statement', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'expression_statement', 'children': ['16']}; {'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': '_lock'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'acquire'}; {'id': '22', 'type': 'argument_list', 'children': []}; {'id': '23', 'type': 'try_statement', 'children': ['24', '62']}; {'id': '24', 'type': 'block', 'children': ['25', '33', '42', '45', '52']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '30']}; {'id': '27', 'type': 'pattern_list', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'new_state'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'existing_generation'}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'state_and_generation'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'new_state'}; {'id': '36', 'type': 'call', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'new_state'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'yield', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'new_state'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'overwrite'}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'existing_generation'}; {'id': '51', 'type': 'None', 'children': []}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'set_state'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'new_state'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'existing_generation'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'existing_generation'}; {'id': '62', 'type': 'finally_clause', 'children': ['63']}; {'id': '63', 'type': 'block', 'children': ['64']}; {'id': '64', 'type': 'if_statement', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'lock'}; {'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': 'self'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': '_lock'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '74', 'type': 'argument_list', 'children': []}
Context manager for a state modification transaction.
def clear_and_configure(config=None, bind_in_runtime=True): with _INJECTOR_LOCK: clear() return configure(config, bind_in_runtime=bind_in_runtime)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'clear_and_configure'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'bind_in_runtime'}; {'id': '9', 'type': 'True', 'children': []}; {'id': '10', 'type': 'block', 'children': ['11']}; {'id': '11', 'type': 'with_statement', 'children': ['12', '15']}; {'id': '12', 'type': 'with_clause', 'children': ['13']}; {'id': '13', 'type': 'with_item', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': '_INJECTOR_LOCK'}; {'id': '15', 'type': 'block', 'children': ['16', '20']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'clear'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'return_statement', 'children': ['21']}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'configure'}; {'id': '23', 'type': 'argument_list', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'bind_in_runtime'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'bind_in_runtime'}
Clear an existing injector and create another one with a callable config.
def rollback(using=None): if using is None: for using in tldap.backend.connections: connection = tldap.backend.connections[using] connection.rollback() return connection = tldap.backend.connections[using] connection.rollback()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'rollback'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8', '38', '48']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12']}; {'id': '9', 'type': 'comparison_operator', 'children': ['10', '11'], 'value': 'is'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '37']}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '20']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '15', 'type': 'attribute', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tldap'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'connections'}; {'id': '20', 'type': 'block', 'children': ['21', '31']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '24', 'type': 'subscript', 'children': ['25', '30']}; {'id': '25', 'type': 'attribute', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'tldap'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'connections'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'rollback'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'return_statement', 'children': []}; {'id': '38', 'type': 'expression_statement', 'children': ['39']}; {'id': '39', 'type': 'assignment', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '41', 'type': 'subscript', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'tldap'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'connections'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'using'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'connection'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'rollback'}; {'id': '53', 'type': 'argument_list', 'children': []}
This function does the rollback itself and resets the dirty flag.
def service(self): service_class = getattr(self, 'service_class') service = service_class(self.http_request) return service
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'service'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '23']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'service_class'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'string', 'children': [], 'value': "'service_class'"}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'service'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'service_class'}; {'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': 'http_request'}; {'id': '23', 'type': 'return_statement', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'service'}
Instantiate service class with django http_request
def save_admin_log(build, **kwargs): message = kwargs.pop('message', None) release = kwargs.pop('release', None) run = kwargs.pop('run', None) if not len(kwargs) == 1: raise TypeError('Must specify a LOG_TYPE argument') log_enum = kwargs.keys()[0] log_type = getattr(models.AdminLog, log_enum.upper(), None) if not log_type: raise TypeError('Bad log_type argument: %s' % log_enum) if current_user.is_anonymous(): user_id = None else: user_id = current_user.get_id() log = models.AdminLog( build_id=build.id, log_type=log_type, message=message, user_id=user_id) if release: log.release_id = release.id if run: log.run_id = run.id log.release_id = run.release_id db.session.add(log)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'save_admin_log'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'build'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '28', '38', '52', '62', '77', '88', '109', '131', '142', '161']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': "'message'"}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '27']}; {'id': '26', 'type': 'string', 'children': [], 'value': "'release'"}; {'id': '27', 'type': 'None', 'children': []}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37']}; {'id': '36', 'type': 'string', 'children': [], 'value': "'run'"}; {'id': '37', 'type': 'None', 'children': []}; {'id': '38', 'type': 'if_statement', 'children': ['39', '46']}; {'id': '39', 'type': 'not_operator', 'children': ['40']}; {'id': '40', 'type': 'comparison_operator', 'children': ['41', '45'], 'value': '=='}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '45', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '46', 'type': 'block', 'children': ['47']}; {'id': '47', 'type': 'raise_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'TypeError'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'Must specify a LOG_TYPE argument'"}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'log_enum'}; {'id': '55', 'type': 'subscript', 'children': ['56', '61']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'keys'}; {'id': '60', 'type': 'argument_list', 'children': []}; {'id': '61', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'log_type'}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '67', 'type': 'argument_list', 'children': ['68', '71', '76']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'AdminLog'}; {'id': '71', 'type': 'call', 'children': ['72', '75']}; {'id': '72', 'type': 'attribute', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'log_enum'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '75', 'type': 'argument_list', 'children': []}; {'id': '76', 'type': 'None', 'children': []}; {'id': '77', 'type': 'if_statement', 'children': ['78', '80']}; {'id': '78', 'type': 'not_operator', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'log_type'}; {'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': 'TypeError'}; {'id': '84', 'type': 'argument_list', 'children': ['85']}; {'id': '85', 'type': 'binary_operator', 'children': ['86', '87'], 'value': '%'}; {'id': '86', 'type': 'string', 'children': [], 'value': "'Bad log_type argument: %s'"}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'log_enum'}; {'id': '88', 'type': 'if_statement', 'children': ['89', '94', '99']}; {'id': '89', 'type': 'call', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'current_user'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'is_anonymous'}; {'id': '93', 'type': 'argument_list', 'children': []}; {'id': '94', 'type': 'block', 'children': ['95']}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '98', 'type': 'None', 'children': []}; {'id': '99', 'type': 'else_clause', 'children': ['100']}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '104', 'type': 'call', 'children': ['105', '108']}; {'id': '105', 'type': 'attribute', 'children': ['106', '107']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'current_user'}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'get_id'}; {'id': '108', 'type': 'argument_list', 'children': []}; {'id': '109', 'type': 'expression_statement', 'children': ['110']}; {'id': '110', 'type': 'assignment', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '112', 'type': 'call', 'children': ['113', '116']}; {'id': '113', 'type': 'attribute', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'models'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'AdminLog'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '122', '125', '128']}; {'id': '117', 'type': 'keyword_argument', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'build_id'}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'build'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '122', 'type': 'keyword_argument', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'log_type'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'log_type'}; {'id': '125', 'type': 'keyword_argument', 'children': ['126', '127']}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '128', 'type': 'keyword_argument', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'user_id'}; {'id': '131', 'type': 'if_statement', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'release_id'}; {'id': '139', 'type': 'attribute', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'release'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '142', 'type': 'if_statement', 'children': ['143', '144']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '144', 'type': 'block', 'children': ['145', '153']}; {'id': '145', 'type': 'expression_statement', 'children': ['146']}; {'id': '146', 'type': 'assignment', 'children': ['147', '150']}; {'id': '147', 'type': 'attribute', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '149', 'type': 'identifier', 'children': [], 'value': 'run_id'}; {'id': '150', 'type': 'attribute', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'release_id'}; {'id': '158', 'type': 'attribute', 'children': ['159', '160']}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'run'}; {'id': '160', 'type': 'identifier', 'children': [], 'value': 'release_id'}; {'id': '161', 'type': 'expression_statement', 'children': ['162']}; {'id': '162', 'type': 'call', 'children': ['163', '168']}; {'id': '163', 'type': 'attribute', 'children': ['164', '167']}; {'id': '164', 'type': 'attribute', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': 'db'}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '168', 'type': 'argument_list', 'children': ['169']}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'log'}
Saves an action to the admin log.
def import_sqlite(db_file, older_than=None, **kwargs): conn = _open_sqlite(db_file) cur = conn.cursor() select = "SELECT * FROM testcases WHERE exported != 'yes'" if older_than: cur.execute(" ".join((select, "AND sqltime < ?")), (older_than,)) else: cur.execute(select) columns = [description[0] for description in cur.description] rows = cur.fetchall() results = [] for row in rows: record = OrderedDict(list(zip(columns, row))) results.append(record) testrun = _get_testrun_from_sqlite(conn) conn.close() return xunit_exporter.ImportedData(results=results, testrun=testrun)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'import_sqlite'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'db_file'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'older_than'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '18', '26', '30', '58', '70', '78', '82', '107', '114', '120']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_open_sqlite'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'db_file'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'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': 'cursor'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '29', 'type': 'string', 'children': [], 'value': '"SELECT * FROM testcases WHERE exported != \'yes\'"'}; {'id': '30', 'type': 'if_statement', 'children': ['31', '32', '49']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'older_than'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '38', 'type': 'argument_list', 'children': ['39', '47']}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'string', 'children': [], 'value': '" "'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'tuple', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '46', 'type': 'string', 'children': [], 'value': '"AND sqltime < ?"'}; {'id': '47', 'type': 'tuple', 'children': ['48']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'older_than'}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'execute'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'assignment', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '61', 'type': 'list_comprehension', 'children': ['62', '65']}; {'id': '62', 'type': 'subscript', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '64', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '65', 'type': 'for_in_clause', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'description'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '73', 'type': 'call', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'cur'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'fetchall'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '81', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '82', 'type': 'for_statement', 'children': ['83', '84', '85']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '85', 'type': 'block', 'children': ['86', '100']}; {'id': '86', 'type': 'expression_statement', 'children': ['87']}; {'id': '87', 'type': 'assignment', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '89', 'type': 'call', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'OrderedDict'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'call', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'row'}; {'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': 'results'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '105', 'type': 'argument_list', 'children': ['106']}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'record'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'testrun'}; {'id': '110', 'type': 'call', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': '_get_testrun_from_sqlite'}; {'id': '112', 'type': 'argument_list', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '114', 'type': 'expression_statement', 'children': ['115']}; {'id': '115', 'type': 'call', 'children': ['116', '119']}; {'id': '116', 'type': 'attribute', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'conn'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '119', 'type': 'argument_list', 'children': []}; {'id': '120', 'type': 'return_statement', 'children': ['121']}; {'id': '121', 'type': 'call', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'xunit_exporter'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'ImportedData'}; {'id': '125', 'type': 'argument_list', 'children': ['126', '129']}; {'id': '126', 'type': 'keyword_argument', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '129', 'type': 'keyword_argument', 'children': ['130', '131']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'testrun'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'testrun'}
Reads the content of the database file and returns imported data.
def add_override(self, addr, key, value): address = Address(str(addr)).id _LOGGER.debug('New override for %s %s is %s', address, key, value) device_override = self._overrides.get(address, {}) device_override[key] = value self._overrides[address] = device_override
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_override'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'addr'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '8', 'type': 'block', 'children': ['9', '21', '31', '43', '49']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '12', 'type': 'attribute', 'children': ['13', '20']}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'Address'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'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': 'addr'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'id'}; {'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': '_LOGGER'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'debug'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28', '29', '30']}; {'id': '27', 'type': 'string', 'children': [], 'value': "'New override for %s %s is %s'"}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'device_override'}; {'id': '34', 'type': 'call', 'children': ['35', '40']}; {'id': '35', 'type': 'attribute', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': '_overrides'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '40', 'type': 'argument_list', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '42', 'type': 'dictionary', 'children': []}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '48']}; {'id': '45', 'type': 'subscript', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'device_override'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '49', 'type': 'expression_statement', 'children': ['50']}; {'id': '50', 'type': 'assignment', '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': '_overrides'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'address'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'device_override'}
Register an attribute override for a device.
def _get_user_allowed_fields(self): model_name = self.Meta.model.__name__.lower() app_label = self.Meta.model._meta.app_label full_model_name = '%s.%s' % (app_label, model_name) permissions = self.cached_allowed_fields.get(full_model_name) if not permissions: permissions = FieldPermission.objects.filter( user_field_permissions__user=self.user, content_type__model=model_name, content_type__app_label=app_label ) self.cached_allowed_fields[full_model_name] = permissions return permissions
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_get_user_allowed_fields'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '20', '32', '40', '51', '84']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'model_name'}; {'id': '9', 'type': 'call', 'children': ['10', '19']}; {'id': '10', 'type': 'attribute', 'children': ['11', '18']}; {'id': '11', 'type': 'attribute', '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': 'Meta'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'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': 'app_label'}; {'id': '23', 'type': 'attribute', 'children': ['24', '31']}; {'id': '24', 'type': 'attribute', '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': 'Meta'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'model'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_meta'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'app_label'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'full_model_name'}; {'id': '35', 'type': 'binary_operator', 'children': ['36', '37'], 'value': '%'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'%s.%s'"}; {'id': '37', 'type': 'tuple', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'app_label'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'model_name'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'permissions'}; {'id': '43', 'type': 'call', 'children': ['44', '49']}; {'id': '44', 'type': 'attribute', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'cached_allowed_fields'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'full_model_name'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '54']}; {'id': '52', 'type': 'not_operator', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'permissions'}; {'id': '54', 'type': 'block', 'children': ['55', '76']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'permissions'}; {'id': '58', 'type': 'call', 'children': ['59', '64']}; {'id': '59', 'type': 'attribute', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'FieldPermission'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'objects'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'filter'}; {'id': '64', 'type': 'argument_list', 'children': ['65', '70', '73']}; {'id': '65', 'type': 'keyword_argument', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'user_field_permissions__user'}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '70', 'type': 'keyword_argument', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'content_type__model'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'model_name'}; {'id': '73', 'type': 'keyword_argument', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'content_type__app_label'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'app_label'}; {'id': '76', 'type': 'expression_statement', 'children': ['77']}; {'id': '77', 'type': 'assignment', 'children': ['78', '83']}; {'id': '78', 'type': 'subscript', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'cached_allowed_fields'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'full_model_name'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'permissions'}; {'id': '84', 'type': 'return_statement', 'children': ['85']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'permissions'}
Retrieve all allowed field names ofr authenticated user.
def ext_pillar(minion_id, pillar, key=None, only=()): url = __opts__['cobbler.url'] user = __opts__['cobbler.user'] password = __opts__['cobbler.password'] log.info("Querying cobbler at %r for information for %r", url, minion_id) try: server = salt.ext.six.moves.xmlrpc_client.Server(url, allow_none=True) if user: server.login(user, password) result = server.get_blended_data(None, minion_id) except Exception: log.exception( 'Could not connect to cobbler.' ) return {} if only: result = dict((k, result[k]) for k in only if k in result) if key: result = {key: result} return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '12']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'ext_pillar'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '9']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'minion_id'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pillar'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'default_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'only'}; {'id': '11', 'type': 'tuple', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '19', '25', '31', '40', '95', '116', '126']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '18', 'type': 'string', 'children': [], 'value': "'cobbler.url'"}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'cobbler.user'"}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '28', 'type': 'subscript', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '__opts__'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'cobbler.password'"}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38', '39']}; {'id': '37', 'type': 'string', 'children': [], 'value': '"Querying cobbler at %r for information for %r"'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'minion_id'}; {'id': '40', 'type': 'try_statement', 'children': ['41', '83']}; {'id': '41', 'type': 'block', 'children': ['42', '62', '73']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '45', 'type': 'call', 'children': ['46', '57']}; {'id': '46', 'type': 'attribute', 'children': ['47', '56']}; {'id': '47', 'type': 'attribute', 'children': ['48', '55']}; {'id': '48', 'type': 'attribute', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'salt'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'six'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'moves'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'xmlrpc_client'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'Server'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '59', 'type': 'keyword_argument', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'allow_none'}; {'id': '61', 'type': 'True', 'children': []}; {'id': '62', 'type': 'if_statement', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'user'}; {'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': 'server'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'login'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'user'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'password'}; {'id': '73', 'type': 'expression_statement', 'children': ['74']}; {'id': '74', 'type': 'assignment', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '76', 'type': 'call', 'children': ['77', '80']}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'server'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'get_blended_data'}; {'id': '80', 'type': 'argument_list', 'children': ['81', '82']}; {'id': '81', 'type': 'None', 'children': []}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'minion_id'}; {'id': '83', 'type': 'except_clause', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'Exception'}; {'id': '85', 'type': 'block', 'children': ['86', '93']}; {'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': 'log'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'exception'}; {'id': '91', 'type': 'argument_list', 'children': ['92']}; {'id': '92', 'type': 'string', 'children': [], 'value': "'Could not connect to cobbler.'"}; {'id': '93', 'type': 'return_statement', 'children': ['94']}; {'id': '94', 'type': 'dictionary', 'children': []}; {'id': '95', 'type': 'if_statement', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'only'}; {'id': '97', 'type': 'block', 'children': ['98']}; {'id': '98', 'type': 'expression_statement', 'children': ['99']}; {'id': '99', 'type': 'assignment', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '101', 'type': 'call', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '103', 'type': 'generator_expression', 'children': ['104', '109', '112']}; {'id': '104', 'type': 'tuple', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '106', 'type': 'subscript', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '109', 'type': 'for_in_clause', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'only'}; {'id': '112', 'type': 'if_clause', 'children': ['113']}; {'id': '113', 'type': 'comparison_operator', 'children': ['114', '115'], 'value': 'in'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'k'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '116', 'type': 'if_statement', 'children': ['117', '118']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '118', 'type': 'block', 'children': ['119']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '122', 'type': 'dictionary', 'children': ['123']}; {'id': '123', 'type': 'pair', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '126', 'type': 'return_statement', 'children': ['127']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'result'}
Read pillar data from Cobbler via its API.
def remove_style(self): for n in self.root.xpath('.//w:rStyle[@w:val="%s"]' % self.style, namespaces=self.namespaces): n.getparent().remove(n)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_style'}; {'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', '25']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'n'}; {'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': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'root'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'xpath'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '20']}; {'id': '15', 'type': 'binary_operator', 'children': ['16', '17'], 'value': '%'}; {'id': '16', 'type': 'string', 'children': [], 'value': '\'.//w:rStyle[@w:val="%s"]\''}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'style'}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'call', 'children': ['28', '35']}; {'id': '28', 'type': 'attribute', 'children': ['29', '34']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'getparent'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'n'}
Remove all XSL run rStyle elements
def as_dict(self): d = {"@module": self.__class__.__module__, "@class": self.__class__.__name__} d["structure"] = self.structure d["energy"] = self.energy d["miller_index"] = self.miller_index d["label"] = self.label d["coverage"] = self.coverage d["adsorbates"] = self.adsorbates d["clean_entry"] = self.clean_entry return d
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'as_dict'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '24', '32', '40', '48', '56', '64', '72', '80']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '9', 'type': 'dictionary', 'children': ['10', '17']}; {'id': '10', 'type': 'pair', 'children': ['11', '12']}; {'id': '11', 'type': 'string', 'children': [], 'value': '"@module"'}; {'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': '__class__'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '__module__'}; {'id': '17', 'type': 'pair', 'children': ['18', '19']}; {'id': '18', 'type': 'string', 'children': [], 'value': '"@class"'}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '29']}; {'id': '26', 'type': 'subscript', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '28', 'type': 'string', 'children': [], 'value': '"structure"'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'structure'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '37']}; {'id': '34', 'type': 'subscript', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '36', 'type': 'string', 'children': [], 'value': '"energy"'}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'energy'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '44', 'type': 'string', 'children': [], 'value': '"miller_index"'}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'miller_index'}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'assignment', 'children': ['50', '53']}; {'id': '50', 'type': 'subscript', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '52', 'type': 'string', 'children': [], 'value': '"label"'}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'label'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'assignment', 'children': ['58', '61']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"coverage"'}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'coverage'}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'assignment', 'children': ['66', '69']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '68', 'type': 'string', 'children': [], 'value': '"adsorbates"'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'adsorbates'}; {'id': '72', 'type': 'expression_statement', 'children': ['73']}; {'id': '73', 'type': 'assignment', 'children': ['74', '77']}; {'id': '74', 'type': 'subscript', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'd'}; {'id': '76', 'type': 'string', 'children': [], 'value': '"clean_entry"'}; {'id': '77', 'type': 'attribute', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'clean_entry'}; {'id': '80', 'type': 'return_statement', 'children': ['81']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'd'}
Returns dict which contains Slab Entry data.
def getHighestVersion(name, region=None, table="credential-store", **kwargs): session = get_session(**kwargs) dynamodb = session.resource('dynamodb', region_name=region) secrets = dynamodb.Table(table) response = secrets.query(Limit=1, ScanIndexForward=False, ConsistentRead=True, KeyConditionExpression=boto3.dynamodb.conditions.Key( "name").eq(name), ProjectionExpression="version") if response["Count"] == 0: return 0 return response["Items"][0]["version"]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '13']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'getHighestVersion'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '10', 'type': 'string', 'children': [], 'value': '"credential-store"'}; {'id': '11', 'type': 'dictionary_splat_pattern', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '13', 'type': 'block', 'children': ['14', '22', '34', '43', '80', '89']}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'get_session'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'dictionary_splat', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'id': '23', 'type': 'assignment', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'dynamodb'}; {'id': '25', 'type': 'call', 'children': ['26', '29']}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'session'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'resource'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'string', 'children': [], 'value': "'dynamodb'"}; {'id': '31', 'type': 'keyword_argument', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'region_name'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'region'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'secrets'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'dynamodb'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'Table'}; {'id': '41', 'type': 'argument_list', 'children': ['42']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'table'}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'assignment', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'secrets'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '54', '57', '60', '77']}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'Limit'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'ScanIndexForward'}; {'id': '56', 'type': 'False', 'children': []}; {'id': '57', 'type': 'keyword_argument', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'ConsistentRead'}; {'id': '59', 'type': 'True', 'children': []}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'KeyConditionExpression'}; {'id': '62', 'type': 'call', 'children': ['63', '75']}; {'id': '63', 'type': 'attribute', 'children': ['64', '74']}; {'id': '64', 'type': 'call', 'children': ['65', '72']}; {'id': '65', 'type': 'attribute', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'boto3'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'dynamodb'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'conditions'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'Key'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'string', 'children': [], 'value': '"name"'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'eq'}; {'id': '75', 'type': 'argument_list', 'children': ['76']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '77', 'type': 'keyword_argument', 'children': ['78', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'ProjectionExpression'}; {'id': '79', 'type': 'string', 'children': [], 'value': '"version"'}; {'id': '80', 'type': 'if_statement', 'children': ['81', '86']}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '85'], 'value': '=='}; {'id': '82', 'type': 'subscript', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '84', 'type': 'string', 'children': [], 'value': '"Count"'}; {'id': '85', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '86', 'type': 'block', 'children': ['87']}; {'id': '87', 'type': 'return_statement', 'children': ['88']}; {'id': '88', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '89', 'type': 'return_statement', 'children': ['90']}; {'id': '90', 'type': 'subscript', 'children': ['91', '96']}; {'id': '91', 'type': 'subscript', 'children': ['92', '95']}; {'id': '92', 'type': 'subscript', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '94', 'type': 'string', 'children': [], 'value': '"Items"'}; {'id': '95', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '96', 'type': 'string', 'children': [], 'value': '"version"'}
Return the highest version of `name` in the table
def convert_row(self, row, schema, fallbacks): for index, field in enumerate(schema.fields): value = row[index] if index in fallbacks: value = _uncast_value(value, field=field) else: value = field.cast_value(value) row[index] = value return row
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'convert_row'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'fallbacks'}; {'id': '8', 'type': 'block', 'children': ['9', '58']}; {'id': '9', 'type': 'for_statement', 'children': ['10', '13', '19']}; {'id': '10', 'type': 'pattern_list', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '15', 'type': 'argument_list', 'children': ['16']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'schema'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '19', 'type': 'block', 'children': ['20', '26', '52']}; {'id': '20', 'type': 'expression_statement', 'children': ['21']}; {'id': '21', 'type': 'assignment', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '23', 'type': 'subscript', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30', '41']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'in'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'fallbacks'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_uncast_value'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '38', 'type': 'keyword_argument', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'field'}; {'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': 'value'}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'field'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'cast_value'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '57']}; {'id': '54', 'type': 'subscript', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'row'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'row'}
Convert row to BigQuery
def _create_algo_bin(self, ro_rw_zi): sect_ro, sect_rw, sect_zi = ro_rw_zi algo_size = sect_ro.length + sect_rw.length + sect_zi.length algo_data = bytearray(algo_size) for section in (sect_ro, sect_rw): start = section.start size = section.length data = section.data assert len(data) == size algo_data[start:start + size] = data return algo_data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_create_algo_bin'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'ro_rw_zi'}; {'id': '6', 'type': 'block', 'children': ['7', '14', '28', '35', '77']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '13']}; {'id': '9', 'type': 'pattern_list', 'children': ['10', '11', '12']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'sect_ro'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'sect_rw'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'sect_zi'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'ro_rw_zi'}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'assignment', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'algo_size'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '25'], 'value': '+'}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '+'}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'sect_ro'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sect_rw'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'sect_zi'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'assignment', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'algo_data'}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'bytearray'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'algo_size'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '37', '40']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '37', 'type': 'tuple', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'sect_ro'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'sect_rw'}; {'id': '40', 'type': 'block', 'children': ['41', '47', '53', '59', '66']}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '59', 'type': 'assert_statement', 'children': ['60']}; {'id': '60', 'type': 'comparison_operator', 'children': ['61', '65'], 'value': '=='}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '63', 'type': 'argument_list', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '66', 'type': 'expression_statement', 'children': ['67']}; {'id': '67', 'type': 'assignment', 'children': ['68', '76']}; {'id': '68', 'type': 'subscript', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'algo_data'}; {'id': '70', 'type': 'slice', 'children': ['71', '72', '73']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '72', 'type': 'colon', 'children': []}; {'id': '73', 'type': 'binary_operator', 'children': ['74', '75'], 'value': '+'}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '77', 'type': 'return_statement', 'children': ['78']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'algo_data'}
Create a binary blob of the flash algo which can execute from ram
def with_options(self, component): options = component.get_required_config() component_name = _get_component_name(component) return BoundConfig(self._get_base_config(), component_name, options)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'with_options'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '22']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'get_required_config'}; {'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': 'component_name'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': '_get_component_name'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'component'}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'BoundConfig'}; {'id': '25', 'type': 'argument_list', 'children': ['26', '31', '32']}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_get_base_config'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'component_name'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'options'}
Apply options component options to this configuration.
def _generate_random_word(self, length): return ''.join(random.choice(string.ascii_lowercase) for _ in range(length))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_generate_random_word'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'length'}; {'id': '6', 'type': 'block', 'children': ['7']}; {'id': '7', 'type': 'return_statement', 'children': ['8']}; {'id': '8', 'type': 'call', 'children': ['9', '12']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'string', 'children': [], 'value': "''"}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '12', 'type': 'generator_expression', 'children': ['13', '21']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'random'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'choice'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'string'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ascii_lowercase'}; {'id': '21', 'type': 'for_in_clause', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '23', 'type': 'call', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'range'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'length'}
Generates a random word
def encrypt(self, orig_pkt, assoclen=None): hdr = copy.deepcopy(orig_pkt) del hdr[MACsec].payload del hdr[MACsec].type pktlen = len(orig_pkt) if self.send_sci: hdrlen = NOSCI_LEN + SCI_LEN else: hdrlen = NOSCI_LEN if assoclen is None or not self.do_encrypt: if self.do_encrypt: assoclen = hdrlen else: assoclen = pktlen iv = self.make_iv(orig_pkt) assoc, pt, _ = MACsecSA.split_pkt(orig_pkt, assoclen) encryptor = Cipher( algorithms.AES(self.key), modes.GCM(iv), backend=default_backend() ).encryptor() encryptor.authenticate_additional_data(assoc) ct = encryptor.update(pt) + encryptor.finalize() hdr[MACsec].payload = Raw(assoc[hdrlen:assoclen] + ct + encryptor.tag) return hdr
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'encrypt'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'orig_pkt'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'assoclen'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '19', '25', '31', '38', '55', '80', '89', '102', '131', '138', '153', '175']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'deepcopy'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'orig_pkt'}; {'id': '19', 'type': 'delete_statement', 'children': ['20']}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'subscript', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'MACsec'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '25', 'type': 'delete_statement', 'children': ['26']}; {'id': '26', 'type': 'attribute', 'children': ['27', '30']}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'MACsec'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'pktlen'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'orig_pkt'}; {'id': '38', 'type': 'if_statement', 'children': ['39', '42', '49']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'send_sci'}; {'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': 'hdrlen'}; {'id': '46', 'type': 'binary_operator', 'children': ['47', '48'], 'value': '+'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'NOSCI_LEN'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'SCI_LEN'}; {'id': '49', 'type': 'else_clause', 'children': ['50']}; {'id': '50', 'type': 'block', 'children': ['51']}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'hdrlen'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'NOSCI_LEN'}; {'id': '55', 'type': 'if_statement', 'children': ['56', '64']}; {'id': '56', 'type': 'boolean_operator', 'children': ['57', '60'], 'value': 'or'}; {'id': '57', 'type': 'comparison_operator', 'children': ['58', '59'], 'value': 'is'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'assoclen'}; {'id': '59', 'type': 'None', 'children': []}; {'id': '60', 'type': 'not_operator', 'children': ['61']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'do_encrypt'}; {'id': '64', 'type': 'block', 'children': ['65']}; {'id': '65', 'type': 'if_statement', 'children': ['66', '69', '74']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'do_encrypt'}; {'id': '69', 'type': 'block', 'children': ['70']}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'assoclen'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'hdrlen'}; {'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', '79']}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'assoclen'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'pktlen'}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'make_iv'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'orig_pkt'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '95']}; {'id': '91', 'type': 'pattern_list', 'children': ['92', '93', '94']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'assoc'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'pt'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '95', 'type': 'call', 'children': ['96', '99']}; {'id': '96', 'type': 'attribute', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'MACsecSA'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'split_pkt'}; {'id': '99', 'type': 'argument_list', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'orig_pkt'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'assoclen'}; {'id': '102', 'type': 'expression_statement', 'children': ['103']}; {'id': '103', 'type': 'assignment', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '105', 'type': 'call', 'children': ['106', '130']}; {'id': '106', 'type': 'attribute', 'children': ['107', '129']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'Cipher'}; {'id': '109', 'type': 'argument_list', 'children': ['110', '118', '124']}; {'id': '110', 'type': 'call', 'children': ['111', '114']}; {'id': '111', 'type': 'attribute', 'children': ['112', '113']}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'algorithms'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'AES'}; {'id': '114', 'type': 'argument_list', 'children': ['115']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '118', 'type': 'call', 'children': ['119', '122']}; {'id': '119', 'type': 'attribute', 'children': ['120', '121']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'modes'}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'GCM'}; {'id': '122', 'type': 'argument_list', 'children': ['123']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'iv'}; {'id': '124', 'type': 'keyword_argument', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'backend'}; {'id': '126', 'type': 'call', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'default_backend'}; {'id': '128', 'type': 'argument_list', 'children': []}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '130', 'type': 'argument_list', 'children': []}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'call', 'children': ['133', '136']}; {'id': '133', 'type': 'attribute', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'authenticate_additional_data'}; {'id': '136', 'type': 'argument_list', 'children': ['137']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'assoc'}; {'id': '138', 'type': 'expression_statement', 'children': ['139']}; {'id': '139', 'type': 'assignment', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '141', 'type': 'binary_operator', 'children': ['142', '148'], 'value': '+'}; {'id': '142', 'type': 'call', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '146', 'type': 'argument_list', 'children': ['147']}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'pt'}; {'id': '148', 'type': 'call', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'finalize'}; {'id': '152', 'type': 'argument_list', 'children': []}; {'id': '153', 'type': 'expression_statement', 'children': ['154']}; {'id': '154', 'type': 'assignment', 'children': ['155', '160']}; {'id': '155', 'type': 'attribute', 'children': ['156', '159']}; {'id': '156', 'type': 'subscript', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'hdr'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'MACsec'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'payload'}; {'id': '160', 'type': 'call', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'Raw'}; {'id': '162', 'type': 'argument_list', 'children': ['163']}; {'id': '163', 'type': 'binary_operator', 'children': ['164', '172'], 'value': '+'}; {'id': '164', 'type': 'binary_operator', 'children': ['165', '171'], 'value': '+'}; {'id': '165', 'type': 'subscript', 'children': ['166', '167']}; {'id': '166', 'type': 'identifier', 'children': [], 'value': 'assoc'}; {'id': '167', 'type': 'slice', 'children': ['168', '169', '170']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'hdrlen'}; {'id': '169', 'type': 'colon', 'children': []}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'assoclen'}; {'id': '171', 'type': 'identifier', 'children': [], 'value': 'ct'}; {'id': '172', 'type': 'attribute', 'children': ['173', '174']}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'encryptor'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '175', 'type': 'return_statement', 'children': ['176']}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'hdr'}
encrypt a MACsec frame for this Secure Association
def _store_lasterr(self): from sys import exc_info from traceback import format_exception e = exc_info() self.lasterr = '\n'.join(format_exception(e[0], e[1], e[2]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_store_lasterr'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '16', '22']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'exc_info'}; {'id': '11', 'type': 'import_from_statement', 'children': ['12', '14']}; {'id': '12', 'type': 'dotted_name', 'children': ['13']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'traceback'}; {'id': '14', 'type': 'dotted_name', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'format_exception'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '19', 'type': 'call', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'exc_info'}; {'id': '21', 'type': 'argument_list', 'children': []}; {'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': 'lasterr'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'string', 'children': [], 'value': "'\\n'"}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'format_exception'}; {'id': '34', 'type': 'argument_list', 'children': ['35', '38', '41']}; {'id': '35', 'type': 'subscript', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '37', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '40', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '41', 'type': 'subscript', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '2'}
Stores the information about the last unhandled exception.
def dict_jsonify(param): if not isinstance(param, dict): param = dict(param) return jsonify(param)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'dict_jsonify'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '5', 'type': 'block', 'children': ['6', '21']}; {'id': '6', 'type': 'if_statement', 'children': ['7', '13']}; {'id': '7', 'type': 'not_operator', 'children': ['8']}; {'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': 'param'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'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': 'param'}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'param'}; {'id': '21', 'type': 'return_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'jsonify'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'param'}
Convert the parameter into a dictionary before calling jsonify, if it's not already one
def print_summary(self, strm): nerr = 0 nerr += LintHelper._print_summary_map(strm, self.cpp_header_map, 'cpp-header') nerr += LintHelper._print_summary_map(strm, self.cpp_src_map, 'cpp-soruce') nerr += LintHelper._print_summary_map(strm, self.python_map, 'python') if nerr == 0: strm.write('All passed!\n') else: strm.write('%d files failed lint\n' % nerr) return nerr
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_summary'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'strm'}; {'id': '6', 'type': 'block', 'children': ['7', '11', '24', '37', '50', '73']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'nerr'}; {'id': '10', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'augmented_assignment', 'children': ['13', '14'], 'value': '+='}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'nerr'}; {'id': '14', 'type': 'call', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'LintHelper'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_print_summary_map'}; {'id': '18', 'type': 'argument_list', 'children': ['19', '20', '23']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'strm'}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'cpp_header_map'}; {'id': '23', 'type': 'string', 'children': [], 'value': "'cpp-header'"}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'augmented_assignment', 'children': ['26', '27'], 'value': '+='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'nerr'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'LintHelper'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': '_print_summary_map'}; {'id': '31', 'type': 'argument_list', 'children': ['32', '33', '36']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'strm'}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'cpp_src_map'}; {'id': '36', 'type': 'string', 'children': [], 'value': "'cpp-soruce'"}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'augmented_assignment', 'children': ['39', '40'], 'value': '+='}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'nerr'}; {'id': '40', 'type': 'call', 'children': ['41', '44']}; {'id': '41', 'type': 'attribute', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'LintHelper'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': '_print_summary_map'}; {'id': '44', 'type': 'argument_list', 'children': ['45', '46', '49']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'strm'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'python_map'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'python'"}; {'id': '50', 'type': 'if_statement', 'children': ['51', '54', '62']}; {'id': '51', 'type': 'comparison_operator', 'children': ['52', '53'], 'value': '=='}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'nerr'}; {'id': '53', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'strm'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'All passed!\\n'"}; {'id': '62', 'type': 'else_clause', 'children': ['63']}; {'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': 'strm'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'binary_operator', 'children': ['71', '72'], 'value': '%'}; {'id': '71', 'type': 'string', 'children': [], 'value': "'%d files failed lint\\n'"}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'nerr'}; {'id': '73', 'type': 'return_statement', 'children': ['74']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'nerr'}
Print summary of lint.
def template_runner(client, parser, args): if args.builtin_list: aomi.template.builtin_list() elif args.builtin_info: aomi.template.builtin_info(args.builtin_info) elif args.template and args.destination and args.vault_paths: aomi.render.template(client, args.template, args.destination, args.vault_paths, args) else: parser.print_usage() sys.exit(2) sys.exit(0)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'template_runner'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '7', 'type': 'block', 'children': ['8', '84']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '12', '21', '37', '69']}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'builtin_list'}; {'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': 'aomi'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'builtin_list'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'id': '21', 'type': 'elif_clause', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'builtin_info'}; {'id': '25', 'type': 'block', 'children': ['26']}; {'id': '26', 'type': 'expression_statement', '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': 'aomi'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'builtin_info'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'builtin_info'}; {'id': '37', 'type': 'elif_clause', 'children': ['38', '49']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '46'], 'value': 'and'}; {'id': '39', 'type': 'boolean_operator', 'children': ['40', '43'], 'value': 'and'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'vault_paths'}; {'id': '49', 'type': 'block', 'children': ['50']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'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': 'aomi'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'render'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '57', 'type': 'argument_list', 'children': ['58', '59', '62', '65', '68']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'template'}; {'id': '62', 'type': 'attribute', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'destination'}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'vault_paths'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71', '77']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'parser'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'print_usage'}; {'id': '76', 'type': 'argument_list', 'children': []}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '84', 'type': 'expression_statement', 'children': ['85']}; {'id': '85', 'type': 'call', 'children': ['86', '89']}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '89', 'type': 'argument_list', 'children': ['90']}; {'id': '90', 'type': 'integer', 'children': [], 'value': '0'}
Executes template related operations
def _raw_pack(key_handle, flags, data): return struct.pack('<IBB', key_handle, flags, len(data)) + data
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_raw_pack'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'key_handle'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'return_statement', 'children': ['9']}; {'id': '9', 'type': 'binary_operator', 'children': ['10', '22'], 'value': '+'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'struct'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'pack'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16', '17', '18']}; {'id': '15', 'type': 'string', 'children': [], 'value': "'<IBB'"}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'key_handle'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'flags'}; {'id': '18', 'type': 'call', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '20', 'type': 'argument_list', 'children': ['21']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'data'}
Common code for packing payload to YHSM_HMAC_SHA1_GENERATE command.
def query_gfy(self, gfyname): self.check_token() r = requests.get(QUERY_ENDPOINT + gfyname, headers=self.headers) response = r.json() if r.status_code != 200 and not ERROR_KEY in response: raise GfycatClientError('Bad response from Gfycat', r.status_code) elif ERROR_KEY in response: raise GfycatClientError(response[ERROR_KEY], r.status_code) return response
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'query_gfy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'gfyname'}; {'id': '6', 'type': 'block', 'children': ['7', '13', '29', '37', '72']}; {'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': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'check_token'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '16', 'type': 'call', 'children': ['17', '20']}; {'id': '17', 'type': 'attribute', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'requests'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '20', 'type': 'argument_list', 'children': ['21', '24']}; {'id': '21', 'type': 'binary_operator', 'children': ['22', '23'], 'value': '+'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'QUERY_ENDPOINT'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'gfyname'}; {'id': '24', 'type': 'keyword_argument', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '26', 'type': 'attribute', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'headers'}; {'id': '29', 'type': 'expression_statement', 'children': ['30']}; {'id': '30', 'type': 'assignment', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'if_statement', 'children': ['38', '48', '57']}; {'id': '38', 'type': 'boolean_operator', 'children': ['39', '44'], 'value': 'and'}; {'id': '39', 'type': 'comparison_operator', 'children': ['40', '43'], 'value': '!='}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '43', 'type': 'integer', 'children': [], 'value': '200'}; {'id': '44', 'type': 'not_operator', 'children': ['45']}; {'id': '45', 'type': 'comparison_operator', 'children': ['46', '47'], 'value': 'in'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'ERROR_KEY'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '48', 'type': 'block', 'children': ['49']}; {'id': '49', 'type': 'raise_statement', 'children': ['50']}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'GfycatClientError'}; {'id': '52', 'type': 'argument_list', 'children': ['53', '54']}; {'id': '53', 'type': 'string', 'children': [], 'value': "'Bad response from Gfycat'"}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '57', 'type': 'elif_clause', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'in'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'ERROR_KEY'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'raise_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'GfycatClientError'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '69']}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'response'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'ERROR_KEY'}; {'id': '69', 'type': 'attribute', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'r'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'status_code'}; {'id': '72', 'type': 'return_statement', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'response'}
Query a gfy name for URLs and more information.
def catalog_split_yaml(self, **kwargs): kwargs_copy = self.base_dict.copy() kwargs_copy.update(**kwargs) self._replace_none(kwargs_copy) localpath = NameFactory.catalog_split_yaml_format.format(**kwargs_copy) if kwargs.get('fullpath', False): return self.fullpath(localpath=localpath) return localpath
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'catalog_split_yaml'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '26', '33', '45', '63']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '11', 'type': 'call', 'children': ['12', '17']}; {'id': '12', 'type': 'attribute', 'children': ['13', '16']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'base_dict'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'dictionary_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'expression_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': '_replace_none'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'localpath'}; {'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': 'NameFactory'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'catalog_split_yaml_format'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '42', 'type': 'argument_list', 'children': ['43']}; {'id': '43', 'type': 'dictionary_splat', 'children': ['44']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'kwargs_copy'}; {'id': '45', 'type': 'if_statement', 'children': ['46', '53']}; {'id': '46', 'type': 'call', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'fullpath'"}; {'id': '52', 'type': 'False', 'children': []}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'return_statement', 'children': ['55']}; {'id': '55', 'type': 'call', 'children': ['56', '59']}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'fullpath'}; {'id': '59', 'type': 'argument_list', 'children': ['60']}; {'id': '60', 'type': 'keyword_argument', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'localpath'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'localpath'}; {'id': '63', 'type': 'return_statement', 'children': ['64']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'localpath'}
return the name of a catalog split yaml file
def map(self, func, *columns): if not columns: return map(func, self.rows) else: values = (self.values(column) for column in columns) result = [map(func, v) for v in values] if len(columns) == 1: return result[0] else: return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'map'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '6', 'type': 'list_splat_pattern', 'children': ['7']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '12', '21']}; {'id': '10', 'type': 'not_operator', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'return_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'rows'}; {'id': '21', 'type': 'else_clause', 'children': ['22']}; {'id': '22', 'type': 'block', 'children': ['23', '36', '48']}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '26', 'type': 'generator_expression', 'children': ['27', '33']}; {'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': 'values'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '33', 'type': 'for_in_clause', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'column'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '36', 'type': 'expression_statement', 'children': ['37']}; {'id': '37', 'type': 'assignment', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '39', 'type': 'list_comprehension', 'children': ['40', '45']}; {'id': '40', 'type': 'call', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'map'}; {'id': '42', 'type': 'argument_list', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'func'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '45', 'type': 'for_in_clause', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'v'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'values'}; {'id': '48', 'type': 'if_statement', 'children': ['49', '55', '60']}; {'id': '49', 'type': 'comparison_operator', 'children': ['50', '54'], 'value': '=='}; {'id': '50', 'type': 'call', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'columns'}; {'id': '54', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'subscript', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '59', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '60', 'type': 'else_clause', 'children': ['61']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'return_statement', 'children': ['63']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'result'}
Map a function to rows, or to given columns
def reset_generation(self): with self._lock: self._generation = Generation.NO_GENERATION self.rejoin_needed = True self.state = MemberState.UNJOINED
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'reset_generation'}; {'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', '21', '27']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '18']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': '_generation'}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'Generation'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'NO_GENERATION'}; {'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': 'rejoin_needed'}; {'id': '26', 'type': 'True', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'state'}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'MemberState'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'UNJOINED'}
Reset the generation and memberId because we have fallen out of the group.
def extract_haml(fileobj, keywords, comment_tags, options): import haml from mako import lexer, parsetree from mako.ext.babelplugin import extract_nodes encoding = options.get('input_encoding', options.get('encoding', None)) template_node = lexer.Lexer(haml.preprocessor(fileobj.read()), input_encoding=encoding).parse() for extracted in extract_nodes(template_node.get_children(), keywords, comment_tags, options): yield extracted
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'extract_haml'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'fileobj'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'keywords'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'comment_tags'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '8', 'type': 'block', 'children': ['9', '12', '19', '26', '42', '67']}; {'id': '9', 'type': 'import_statement', 'children': ['10']}; {'id': '10', 'type': 'dotted_name', 'children': ['11']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'haml'}; {'id': '12', 'type': 'import_from_statement', 'children': ['13', '15', '17']}; {'id': '13', 'type': 'dotted_name', 'children': ['14']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'mako'}; {'id': '15', 'type': 'dotted_name', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'lexer'}; {'id': '17', 'type': 'dotted_name', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parsetree'}; {'id': '19', 'type': 'import_from_statement', 'children': ['20', '24']}; {'id': '20', 'type': 'dotted_name', 'children': ['21', '22', '23']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'mako'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'babelplugin'}; {'id': '24', 'type': 'dotted_name', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'extract_nodes'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '35']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'input_encoding'"}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '39', 'type': 'argument_list', 'children': ['40', '41']}; {'id': '40', 'type': 'string', 'children': [], 'value': "'encoding'"}; {'id': '41', 'type': 'None', 'children': []}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'template_node'}; {'id': '45', 'type': 'call', 'children': ['46', '66']}; {'id': '46', 'type': 'attribute', 'children': ['47', '65']}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'lexer'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'Lexer'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '62']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'haml'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'preprocessor'}; {'id': '56', 'type': 'argument_list', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'fileobj'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '61', 'type': 'argument_list', 'children': []}; {'id': '62', 'type': 'keyword_argument', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'input_encoding'}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'for_statement', 'children': ['68', '69', '80']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'extracted'}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'extract_nodes'}; {'id': '71', 'type': 'argument_list', 'children': ['72', '77', '78', '79']}; {'id': '72', 'type': 'call', 'children': ['73', '76']}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'template_node'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'get_children'}; {'id': '76', 'type': 'argument_list', 'children': []}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'keywords'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'comment_tags'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'options'}; {'id': '80', 'type': 'block', 'children': ['81']}; {'id': '81', 'type': 'expression_statement', 'children': ['82']}; {'id': '82', 'type': 'yield', 'children': ['83']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'extracted'}
babel translation token extract function for haml files
def run(configobj=None): acscte(configobj['input'], exec_path=configobj['exec_path'], time_stamps=configobj['time_stamps'], verbose=configobj['verbose'], quiet=configobj['quiet'], single_core=configobj['single_core'] )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'configobj'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'block', 'children': ['8']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'acscte'}; {'id': '11', 'type': 'argument_list', 'children': ['12', '15', '20', '25', '30', '35']}; {'id': '12', 'type': 'subscript', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'configobj'}; {'id': '14', 'type': 'string', 'children': [], 'value': "'input'"}; {'id': '15', 'type': 'keyword_argument', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'exec_path'}; {'id': '17', 'type': 'subscript', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'configobj'}; {'id': '19', 'type': 'string', 'children': [], 'value': "'exec_path'"}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'time_stamps'}; {'id': '22', 'type': 'subscript', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'configobj'}; {'id': '24', 'type': 'string', 'children': [], 'value': "'time_stamps'"}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'verbose'}; {'id': '27', 'type': 'subscript', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'configobj'}; {'id': '29', 'type': 'string', 'children': [], 'value': "'verbose'"}; {'id': '30', 'type': 'keyword_argument', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'quiet'}; {'id': '32', 'type': 'subscript', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'configobj'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'quiet'"}; {'id': '35', 'type': 'keyword_argument', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'single_core'}; {'id': '37', 'type': 'subscript', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'configobj'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'single_core'"}
TEAL interface for the `acscte` function.
def merge(cls, source_blocks): if len(source_blocks) == 1: return source_blocks[0] source_blocks.sort(key=operator.attrgetter('start_line_number')) main_block = source_blocks[0] boot_lines = main_block.boot_lines source_lines = [source_line for source_block in source_blocks for source_line in source_block.source_lines] return cls(boot_lines, source_lines, directive=main_block.directive, language=main_block.language, roles=main_block.roles)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'merge'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'source_blocks'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '33', '39', '45', '58']}; {'id': '7', 'type': 'if_statement', 'children': ['8', '14']}; {'id': '8', 'type': 'comparison_operator', 'children': ['9', '13'], 'value': '=='}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'source_blocks'}; {'id': '13', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '14', 'type': 'block', 'children': ['15']}; {'id': '15', 'type': 'return_statement', 'children': ['16']}; {'id': '16', 'type': 'subscript', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'source_blocks'}; {'id': '18', 'type': 'integer', 'children': [], 'value': '0'}; {'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': 'source_blocks'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'sort'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'keyword_argument', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '27', 'type': 'call', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'operator'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'attrgetter'}; {'id': '31', 'type': 'argument_list', 'children': ['32']}; {'id': '32', 'type': 'string', 'children': [], 'value': "'start_line_number'"}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'assignment', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'main_block'}; {'id': '36', 'type': 'subscript', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'source_blocks'}; {'id': '38', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'boot_lines'}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'main_block'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'boot_lines'}; {'id': '45', 'type': 'expression_statement', 'children': ['46']}; {'id': '46', 'type': 'assignment', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'source_lines'}; {'id': '48', 'type': 'list_comprehension', 'children': ['49', '50', '53']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'source_line'}; {'id': '50', 'type': 'for_in_clause', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'source_block'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'source_blocks'}; {'id': '53', 'type': 'for_in_clause', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'source_line'}; {'id': '55', 'type': 'attribute', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'source_block'}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'source_lines'}; {'id': '58', 'type': 'return_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63', '64', '69', '74']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'boot_lines'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'source_lines'}; {'id': '64', 'type': 'keyword_argument', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'directive'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'main_block'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'directive'}; {'id': '69', 'type': 'keyword_argument', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '71', 'type': 'attribute', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'main_block'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'language'}; {'id': '74', 'type': 'keyword_argument', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'roles'}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'main_block'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'roles'}
Merge multiple SourceBlocks together
def _overlapping_channels(self, wavelengths): sizes = self.meta["channel_sizes"] min_a, max_a = wavelengths.min(), wavelengths.max() matched_channel_names = [] for i, (name, size) in enumerate(zip(self.channel_names, sizes)): si = sum(sizes[:i]) min_b, max_b = self.wavelengths[[si, si + size - 1]] if max_a > min_b and min_a < max_b: matched_channel_names.append(name) return matched_channel_names
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_overlapping_channels'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'wavelengths'}; {'id': '6', 'type': 'block', 'children': ['7', '15', '31', '35', '95']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'sizes'}; {'id': '10', 'type': 'subscript', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'meta'}; {'id': '14', 'type': 'string', 'children': [], 'value': '"channel_sizes"'}; {'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': 'min_a'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'max_a'}; {'id': '20', 'type': 'expression_list', 'children': ['21', '26']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'wavelengths'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'min'}; {'id': '25', 'type': 'argument_list', 'children': []}; {'id': '26', 'type': 'call', 'children': ['27', '30']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'wavelengths'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'max'}; {'id': '30', 'type': 'argument_list', 'children': []}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'matched_channel_names'}; {'id': '34', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '35', 'type': 'for_statement', 'children': ['36', '41', '51']}; {'id': '36', 'type': 'pattern_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '38', 'type': 'tuple_pattern', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '41', 'type': 'call', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '43', 'type': 'argument_list', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '46', 'type': 'argument_list', 'children': ['47', '50']}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'channel_names'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'sizes'}; {'id': '51', 'type': 'block', 'children': ['52', '63', '79']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'si'}; {'id': '55', 'type': 'call', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'sum'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'subscript', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'sizes'}; {'id': '60', 'type': 'slice', 'children': ['61', '62']}; {'id': '61', 'type': 'colon', 'children': []}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '68']}; {'id': '65', 'type': 'pattern_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'min_b'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'max_b'}; {'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': 'wavelengths'}; {'id': '72', 'type': 'list', 'children': ['73', '74'], 'value': '[si, si + size - 1]'}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'si'}; {'id': '74', 'type': 'binary_operator', 'children': ['75', '78'], 'value': '-'}; {'id': '75', 'type': 'binary_operator', 'children': ['76', '77'], 'value': '+'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'si'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'size'}; {'id': '78', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '79', 'type': 'if_statement', 'children': ['80', '87']}; {'id': '80', 'type': 'boolean_operator', 'children': ['81', '84'], 'value': 'and'}; {'id': '81', 'type': 'comparison_operator', 'children': ['82', '83'], 'value': '>'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'max_a'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'min_b'}; {'id': '84', 'type': 'comparison_operator', 'children': ['85', '86'], 'value': '<'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'min_a'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'max_b'}; {'id': '87', 'type': 'block', 'children': ['88']}; {'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': 'matched_channel_names'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'matched_channel_names'}
Return the channels that match the given wavelength array.
def _load_environment_vars(self): self._config[kinds.ENV_VAR].update( self._normalized_keys(":env:", self._get_environ_vars()) )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_load_environment_vars'}; {'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': 'call', 'children': ['8', '17']}; {'id': '8', 'type': 'attribute', 'children': ['9', '16']}; {'id': '9', 'type': 'subscript', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': '_config'}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kinds'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ENV_VAR'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'update'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'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': '_normalized_keys'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24']}; {'id': '23', 'type': 'string', 'children': [], 'value': '":env:"'}; {'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': '_get_environ_vars'}; {'id': '28', 'type': 'argument_list', 'children': []}
Loads configuration from environment variables
def htmlDocDump(self, f): ret = libxml2mod.htmlDocDump(f, self._o) return ret
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'htmlDocDump'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'f'}; {'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': 'ret'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'libxml2mod'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'htmlDocDump'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_o'}; {'id': '19', 'type': 'return_statement', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'ret'}
Dump an HTML document to an open FILE.
def load_from_args(args): if not args.reads: return None if args.read_source_name: read_source_names = util.expand( args.read_source_name, 'read_source_name', 'read source', len(args.reads)) else: read_source_names = util.drop_prefix(args.reads) filters = [] for (name, info) in READ_FILTERS.items(): value = getattr(args, name) if value is not None: filters.append(functools.partial(info[-1], value)) return [ load_bam(filename, name, filters) for (filename, name) in zip(args.reads, read_source_names) ]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'load_from_args'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '51', '55', '94']}; {'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': 'args'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'reads'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': ['13']}; {'id': '13', 'type': 'None', 'children': []}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18', '38']}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'read_source_name'}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'read_source_names'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'expand'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '30', '31', '32']}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'read_source_name'}; {'id': '30', 'type': 'string', 'children': [], 'value': "'read_source_name'"}; {'id': '31', 'type': 'string', 'children': [], 'value': "'read source'"}; {'id': '32', 'type': 'call', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'reads'}; {'id': '38', 'type': 'else_clause', 'children': ['39']}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'read_source_names'}; {'id': '43', 'type': 'call', 'children': ['44', '47']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'util'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'drop_prefix'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'reads'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'filters'}; {'id': '54', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '55', 'type': 'for_statement', 'children': ['56', '59', '64']}; {'id': '56', 'type': 'tuple_pattern', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'READ_FILTERS'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'block', 'children': ['65', '73']}; {'id': '65', 'type': 'expression_statement', 'children': ['66']}; {'id': '66', 'type': 'assignment', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '70', 'type': 'argument_list', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '73', 'type': 'if_statement', 'children': ['74', '77']}; {'id': '74', 'type': 'comparison_operator', 'children': ['75', '76'], 'value': 'is not'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '76', 'type': 'None', 'children': []}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'filters'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '83', 'type': 'argument_list', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '88']}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'functools'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'partial'}; {'id': '88', 'type': 'argument_list', 'children': ['89', '93']}; {'id': '89', 'type': 'subscript', 'children': ['90', '91']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '91', 'type': 'unary_operator', 'children': ['92'], 'value': '-'}; {'id': '92', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'list_comprehension', 'children': ['96', '102']}; {'id': '96', 'type': 'call', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'load_bam'}; {'id': '98', 'type': 'argument_list', 'children': ['99', '100', '101']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'filters'}; {'id': '102', 'type': 'for_in_clause', 'children': ['103', '106']}; {'id': '103', 'type': 'tuple_pattern', 'children': ['104', '105']}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '106', 'type': 'call', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '108', 'type': 'argument_list', 'children': ['109', '112']}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'reads'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'read_source_names'}
Given parsed commandline arguments, returns a list of ReadSource objects
def add_filehandler(level, fmt, filename, mode, backup_count, limit, when): kwargs = {} if filename is None: filename = getattr(sys.modules['__main__'], '__file__', 'log.py') filename = os.path.basename(filename.replace('.py', '.log')) filename = os.path.join('/tmp', filename) if not os.path.exists(os.path.dirname(filename)): os.mkdir(os.path.dirname(filename)) kwargs['filename'] = filename if backup_count == 0: cls = logging.FileHandler kwargs['mode'] = mode elif when is None: cls = logging.handlers.RotatingFileHandler kwargs['maxBytes'] = limit kwargs['backupCount'] = backup_count kwargs['mode'] = mode else: cls = logging.handlers.TimedRotatingFileHandler kwargs['when'] = when kwargs['interval'] = limit kwargs['backupCount'] = backup_count return add_handler(cls, level, fmt, False, **kwargs)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_filehandler'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8', '9', '10']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'backup_count'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'when'}; {'id': '11', 'type': 'block', 'children': ['12', '16', '63', '95', '101', '177']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '15', 'type': 'dictionary', 'children': []}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20']}; {'id': '17', 'type': 'comparison_operator', 'children': ['18', '19'], 'value': 'is'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '19', 'type': 'None', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21', '34', '51']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'assignment', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'getattr'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '32', '33']}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'sys'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'modules'}; {'id': '31', 'type': 'string', 'children': [], 'value': "'__main__'"}; {'id': '32', 'type': 'string', 'children': [], 'value': "'__file__'"}; {'id': '33', 'type': 'string', 'children': [], 'value': "'log.py'"}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'os'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'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': 'filename'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'replace'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50']}; {'id': '49', 'type': 'string', 'children': [], 'value': "'.py'"}; {'id': '50', 'type': 'string', 'children': [], 'value': "'.log'"}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'assignment', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'os'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '60', 'type': 'argument_list', 'children': ['61', '62']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'/tmp'"}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '63', 'type': 'if_statement', 'children': ['64', '80']}; {'id': '64', 'type': 'not_operator', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '71']}; {'id': '66', 'type': 'attribute', 'children': ['67', '70']}; {'id': '67', 'type': 'attribute', 'children': ['68', '69']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '78']}; {'id': '73', 'type': 'attribute', 'children': ['74', '77']}; {'id': '74', 'type': 'attribute', 'children': ['75', '76']}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '78', 'type': 'argument_list', 'children': ['79']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'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': 'os'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'mkdir'}; {'id': '86', 'type': 'argument_list', 'children': ['87']}; {'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': 'os'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '93', 'type': 'argument_list', 'children': ['94']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '95', 'type': 'expression_statement', 'children': ['96']}; {'id': '96', 'type': 'assignment', 'children': ['97', '100']}; {'id': '97', 'type': 'subscript', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '99', 'type': 'string', 'children': [], 'value': "'filename'"}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'filename'}; {'id': '101', 'type': 'if_statement', 'children': ['102', '105', '118', '149']}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': '=='}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'backup_count'}; {'id': '104', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '105', 'type': 'block', 'children': ['106', '112']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'assignment', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '109', 'type': 'attribute', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'FileHandler'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'assignment', 'children': ['114', '117']}; {'id': '114', 'type': 'subscript', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '116', 'type': 'string', 'children': [], 'value': "'mode'"}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '118', 'type': 'elif_clause', 'children': ['119', '122']}; {'id': '119', 'type': 'comparison_operator', 'children': ['120', '121'], 'value': 'is'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'when'}; {'id': '121', 'type': 'None', 'children': []}; {'id': '122', 'type': 'block', 'children': ['123', '131', '137', '143']}; {'id': '123', 'type': 'expression_statement', 'children': ['124']}; {'id': '124', 'type': 'assignment', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '126', 'type': 'attribute', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'handlers'}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'RotatingFileHandler'}; {'id': '131', 'type': 'expression_statement', 'children': ['132']}; {'id': '132', 'type': 'assignment', 'children': ['133', '136']}; {'id': '133', 'type': 'subscript', 'children': ['134', '135']}; {'id': '134', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '135', 'type': 'string', 'children': [], 'value': "'maxBytes'"}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '137', 'type': 'expression_statement', 'children': ['138']}; {'id': '138', 'type': 'assignment', 'children': ['139', '142']}; {'id': '139', 'type': 'subscript', 'children': ['140', '141']}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '141', 'type': 'string', 'children': [], 'value': "'backupCount'"}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'backup_count'}; {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'assignment', 'children': ['145', '148']}; {'id': '145', 'type': 'subscript', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '147', 'type': 'string', 'children': [], 'value': "'mode'"}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'mode'}; {'id': '149', 'type': 'else_clause', 'children': ['150']}; {'id': '150', 'type': 'block', 'children': ['151', '159', '165', '171']}; {'id': '151', 'type': 'expression_statement', 'children': ['152']}; {'id': '152', 'type': 'assignment', 'children': ['153', '154']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '154', 'type': 'attribute', 'children': ['155', '158']}; {'id': '155', 'type': 'attribute', 'children': ['156', '157']}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'logging'}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'handlers'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'TimedRotatingFileHandler'}; {'id': '159', 'type': 'expression_statement', 'children': ['160']}; {'id': '160', 'type': 'assignment', 'children': ['161', '164']}; {'id': '161', 'type': 'subscript', 'children': ['162', '163']}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '163', 'type': 'string', 'children': [], 'value': "'when'"}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'when'}; {'id': '165', 'type': 'expression_statement', 'children': ['166']}; {'id': '166', 'type': 'assignment', 'children': ['167', '170']}; {'id': '167', 'type': 'subscript', 'children': ['168', '169']}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '169', 'type': 'string', 'children': [], 'value': "'interval'"}; {'id': '170', 'type': 'identifier', 'children': [], 'value': 'limit'}; {'id': '171', 'type': 'expression_statement', 'children': ['172']}; {'id': '172', 'type': 'assignment', 'children': ['173', '176']}; {'id': '173', 'type': 'subscript', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '175', 'type': 'string', 'children': [], 'value': "'backupCount'"}; {'id': '176', 'type': 'identifier', 'children': [], 'value': 'backup_count'}; {'id': '177', 'type': 'return_statement', 'children': ['178']}; {'id': '178', 'type': 'call', 'children': ['179', '180']}; {'id': '179', 'type': 'identifier', 'children': [], 'value': 'add_handler'}; {'id': '180', 'type': 'argument_list', 'children': ['181', '182', '183', '184', '185']}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'cls'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'level'}; {'id': '183', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '184', 'type': 'False', 'children': []}; {'id': '185', 'type': 'dictionary_splat', 'children': ['186']}; {'id': '186', 'type': 'identifier', 'children': [], 'value': 'kwargs'}
Add a file handler to the global logger.
def _win32_strerror(err): buf = ctypes.c_char_p() FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_IGNORE_INSERTS, None, err, 0, buf, 0, None, ) try: return buf.value finally: LocalFree(buf)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_win32_strerror'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '5', 'type': 'block', 'children': ['6', '14', '29']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '9', 'type': 'call', 'children': ['10', '13']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'ctypes'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'c_char_p'}; {'id': '13', 'type': 'argument_list', 'children': []}; {'id': '14', 'type': 'expression_statement', 'children': ['15']}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'FormatMessage'}; {'id': '17', 'type': 'argument_list', 'children': ['18', '23', '24', '25', '26', '27', '28']}; {'id': '18', 'type': 'binary_operator', 'children': ['19', '22'], 'value': '|'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '|'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'FORMAT_MESSAGE_FROM_SYSTEM'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'FORMAT_MESSAGE_ALLOCATE_BUFFER'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'FORMAT_MESSAGE_IGNORE_INSERTS'}; {'id': '23', 'type': 'None', 'children': []}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '25', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '27', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '28', 'type': 'None', 'children': []}; {'id': '29', 'type': 'try_statement', 'children': ['30', '35']}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'return_statement', 'children': ['32']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'buf'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '35', 'type': 'finally_clause', 'children': ['36']}; {'id': '36', 'type': 'block', 'children': ['37']}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'LocalFree'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'buf'}
expand a win32 error code into a human readable message
def find_overlapping_slots(all_slots): overlaps = set([]) for slot in all_slots: start = slot.get_start_time() end = slot.end_time for other_slot in all_slots: if other_slot.pk == slot.pk: continue if other_slot.get_day() != slot.get_day(): continue other_start = other_slot.get_start_time() other_end = other_slot.end_time if start <= other_start and other_start < end: overlaps.add(slot) overlaps.add(other_slot) elif start < other_end and other_end <= end: overlaps.add(slot) overlaps.add(other_slot) return overlaps
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'find_overlapping_slots'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'all_slots'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '119']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'overlaps'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '13', 'type': 'for_statement', 'children': ['14', '15', '16']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'all_slots'}; {'id': '16', 'type': 'block', 'children': ['17', '25', '31']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'get_start_time'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '31', 'type': 'for_statement', 'children': ['32', '33', '34']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'other_slot'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'all_slots'}; {'id': '34', 'type': 'block', 'children': ['35', '45', '59', '67', '73']}; {'id': '35', 'type': 'if_statement', 'children': ['36', '43']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '40'], 'value': '=='}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'other_slot'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '43', 'type': 'block', 'children': ['44']}; {'id': '44', 'type': 'continue_statement', 'children': []}; {'id': '45', 'type': 'if_statement', 'children': ['46', '57']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '52'], 'value': '!='}; {'id': '47', 'type': 'call', 'children': ['48', '51']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'other_slot'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'get_day'}; {'id': '51', 'type': 'argument_list', 'children': []}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'get_day'}; {'id': '56', 'type': 'argument_list', 'children': []}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'continue_statement', 'children': []}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'assignment', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'other_start'}; {'id': '62', 'type': 'call', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'other_slot'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'get_start_time'}; {'id': '66', 'type': 'argument_list', 'children': []}; {'id': '67', 'type': 'expression_statement', 'children': ['68']}; {'id': '68', 'type': 'assignment', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'other_end'}; {'id': '70', 'type': 'attribute', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'other_slot'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'end_time'}; {'id': '73', 'type': 'if_statement', 'children': ['74', '81', '96']}; {'id': '74', 'type': 'boolean_operator', 'children': ['75', '78'], 'value': 'and'}; {'id': '75', 'type': 'comparison_operator', 'children': ['76', '77'], 'value': '<='}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'other_start'}; {'id': '78', 'type': 'comparison_operator', 'children': ['79', '80'], 'value': '<'}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'other_start'}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '81', 'type': 'block', 'children': ['82', '89']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '87']}; {'id': '84', 'type': 'attribute', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'overlaps'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'call', 'children': ['91', '94']}; {'id': '91', 'type': 'attribute', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'overlaps'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '94', 'type': 'argument_list', 'children': ['95']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'other_slot'}; {'id': '96', 'type': 'elif_clause', 'children': ['97', '104']}; {'id': '97', 'type': 'boolean_operator', 'children': ['98', '101'], 'value': 'and'}; {'id': '98', 'type': 'comparison_operator', 'children': ['99', '100'], 'value': '<'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'other_end'}; {'id': '101', 'type': 'comparison_operator', 'children': ['102', '103'], 'value': '<='}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'other_end'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'end'}; {'id': '104', 'type': 'block', 'children': ['105', '112']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'call', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'overlaps'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '110', 'type': 'argument_list', 'children': ['111']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'slot'}; {'id': '112', 'type': 'expression_statement', 'children': ['113']}; {'id': '113', 'type': 'call', 'children': ['114', '117']}; {'id': '114', 'type': 'attribute', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'overlaps'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'add'}; {'id': '117', 'type': 'argument_list', 'children': ['118']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'other_slot'}; {'id': '119', 'type': 'return_statement', 'children': ['120']}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'overlaps'}
Find any slots that overlap
def pickle_save(thing,fname=None): if fname is None: fname=os.path.expanduser("~")+"/%d.pkl"%time.time() assert type(fname) is str and os.path.isdir(os.path.dirname(fname)) pickle.dump(thing, open(fname,"wb"),pickle.HIGHEST_PROTOCOL) print("saved",fname)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'pickle_save'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'thing'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '33', '56', '71']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '12'], 'value': 'is'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'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': 'fname'}; {'id': '17', 'type': 'binary_operator', 'children': ['18', '26'], 'value': '+'}; {'id': '18', 'type': 'call', 'children': ['19', '24']}; {'id': '19', 'type': 'attribute', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'expanduser'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'string', 'children': [], 'value': '"~"'}; {'id': '26', 'type': 'binary_operator', 'children': ['27', '28'], 'value': '%'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"/%d.pkl"'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'time'}; {'id': '32', 'type': 'argument_list', 'children': []}; {'id': '33', 'type': 'assert_statement', 'children': ['34']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '41'], 'value': 'and'}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '40'], 'value': 'is'}; {'id': '36', 'type': 'call', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'type'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '41', 'type': 'call', 'children': ['42', '47']}; {'id': '42', 'type': 'attribute', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'isdir'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '54']}; {'id': '49', 'type': 'attribute', 'children': ['50', '53']}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'dirname'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'dump'}; {'id': '61', 'type': 'argument_list', 'children': ['62', '63', '68']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'thing'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'open'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'fname'}; {'id': '67', 'type': 'string', 'children': [], 'value': '"wb"'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'pickle'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'HIGHEST_PROTOCOL'}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '74', 'type': 'argument_list', 'children': ['75', '76']}; {'id': '75', 'type': 'string', 'children': [], 'value': '"saved"'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'fname'}
save something to a pickle file
def end_output (self, **kwargs): self.write_edges() self.end_graph() if self.has_part("outro"): self.write_outro() self.close_fileoutput()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'end_output'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'dictionary_splat_pattern', 'children': ['6']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '7', 'type': 'block', 'children': ['8', '14', '20', '34']}; {'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': 'write_edges'}; {'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': 'end_graph'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'if_statement', 'children': ['21', '27']}; {'id': '21', 'type': 'call', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'has_part'}; {'id': '25', 'type': 'argument_list', 'children': ['26']}; {'id': '26', 'type': 'string', 'children': [], 'value': '"outro"'}; {'id': '27', 'type': 'block', 'children': ['28']}; {'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': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'write_outro'}; {'id': '33', 'type': 'argument_list', 'children': []}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '39']}; {'id': '36', 'type': 'attribute', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'close_fileoutput'}; {'id': '39', 'type': 'argument_list', 'children': []}
Write edges and end of checking info as gml comment.
def get(self, name, default=_MISSING): name = self._convert_name(name) if name not in self._fields: if default is _MISSING: default = self._default_value(name) return default if name in _UNICODEFIELDS: value = self._fields[name] return value elif name in _LISTFIELDS: value = self._fields[name] if value is None: return [] res = [] for val in value: if name not in _LISTTUPLEFIELDS: res.append(val) else: res.append((val[0], val[1])) return res elif name in _ELEMENTSFIELD: value = self._fields[name] if isinstance(value, string_types): return value.split(',') return self._fields[name]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'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': 'name'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '8', 'type': 'identifier', 'children': [], 'value': '_MISSING'}; {'id': '9', 'type': 'block', 'children': ['10', '19', '42', '141']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': '_convert_name'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '19', 'type': 'if_statement', 'children': ['20', '25']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '22'], 'value': 'not in'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': '_fields'}; {'id': '25', 'type': 'block', 'children': ['26', '40']}; {'id': '26', 'type': 'if_statement', 'children': ['27', '30']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': 'is'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_MISSING'}; {'id': '30', 'type': 'block', 'children': ['31']}; {'id': '31', 'type': 'expression_statement', 'children': ['32']}; {'id': '32', 'type': 'assignment', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '34', 'type': 'call', 'children': ['35', '38']}; {'id': '35', 'type': 'attribute', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': '_default_value'}; {'id': '38', 'type': 'argument_list', 'children': ['39']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'default'}; {'id': '42', 'type': 'if_statement', 'children': ['43', '46', '57', '114']}; {'id': '43', 'type': 'comparison_operator', 'children': ['44', '45'], 'value': 'in'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': '_UNICODEFIELDS'}; {'id': '46', 'type': 'block', 'children': ['47', '55']}; {'id': '47', 'type': 'expression_statement', 'children': ['48']}; {'id': '48', 'type': 'assignment', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '50', 'type': 'subscript', 'children': ['51', '54']}; {'id': '51', 'type': 'attribute', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': '_fields'}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '55', 'type': 'return_statement', 'children': ['56']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '57', 'type': 'elif_clause', 'children': ['58', '61']}; {'id': '58', 'type': 'comparison_operator', 'children': ['59', '60'], 'value': 'in'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '_LISTFIELDS'}; {'id': '61', 'type': 'block', 'children': ['62', '70', '77', '81', '112']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'assignment', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '65', 'type': 'subscript', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_fields'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '70', 'type': 'if_statement', 'children': ['71', '74']}; {'id': '71', 'type': 'comparison_operator', 'children': ['72', '73'], 'value': 'is'}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '73', 'type': 'None', 'children': []}; {'id': '74', 'type': 'block', 'children': ['75']}; {'id': '75', 'type': 'return_statement', 'children': ['76']}; {'id': '76', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '77', 'type': 'expression_statement', 'children': ['78']}; {'id': '78', 'type': 'assignment', 'children': ['79', '80']}; {'id': '79', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '80', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '81', 'type': 'for_statement', 'children': ['82', '83', '84']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '84', 'type': 'block', 'children': ['85']}; {'id': '85', 'type': 'if_statement', 'children': ['86', '89', '97']}; {'id': '86', 'type': 'comparison_operator', 'children': ['87', '88'], 'value': 'not in'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': '_LISTTUPLEFIELDS'}; {'id': '89', 'type': 'block', 'children': ['90']}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'call', 'children': ['92', '95']}; {'id': '92', 'type': 'attribute', 'children': ['93', '94']}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '95', 'type': 'argument_list', 'children': ['96']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '97', 'type': 'else_clause', 'children': ['98']}; {'id': '98', 'type': 'block', 'children': ['99']}; {'id': '99', 'type': 'expression_statement', 'children': ['100']}; {'id': '100', 'type': 'call', 'children': ['101', '104']}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '104', 'type': 'argument_list', 'children': ['105']}; {'id': '105', 'type': 'tuple', 'children': ['106', '109']}; {'id': '106', 'type': 'subscript', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '108', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '109', 'type': 'subscript', 'children': ['110', '111']}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'val'}; {'id': '111', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '112', 'type': 'return_statement', 'children': ['113']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'res'}; {'id': '114', 'type': 'elif_clause', 'children': ['115', '118']}; {'id': '115', 'type': 'comparison_operator', 'children': ['116', '117'], 'value': 'in'}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': '_ELEMENTSFIELD'}; {'id': '118', 'type': 'block', 'children': ['119', '127']}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '122', 'type': 'subscript', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': '_fields'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '127', 'type': 'if_statement', 'children': ['128', '133']}; {'id': '128', 'type': 'call', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '130', 'type': 'argument_list', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'string_types'}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'return_statement', 'children': ['135']}; {'id': '135', 'type': 'call', 'children': ['136', '139']}; {'id': '136', 'type': 'attribute', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'split'}; {'id': '139', 'type': 'argument_list', 'children': ['140']}; {'id': '140', 'type': 'string', 'children': [], 'value': "','"}; {'id': '141', 'type': 'return_statement', 'children': ['142']}; {'id': '142', 'type': 'subscript', 'children': ['143', '146']}; {'id': '143', 'type': 'attribute', 'children': ['144', '145']}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '145', 'type': 'identifier', 'children': [], 'value': '_fields'}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'name'}
Get a metadata field.
def repr(self, *args, **kwargs): if not self.is_numpy: text = "'" + self.str(*args, **kwargs) + "'" else: text = "{} numpy array, {} uncertainties".format(self.shape, len(self.uncertainties)) return "<{} at {}, {}>".format(self.__class__.__name__, hex(id(self)), text)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'repr'}; {'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', '51']}; {'id': '10', 'type': 'if_statement', 'children': ['11', '15', '32']}; {'id': '11', 'type': 'not_operator', 'children': ['12']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'is_numpy'}; {'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': 'text'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '31'], 'value': '+'}; {'id': '20', 'type': 'binary_operator', 'children': ['21', '22'], 'value': '+'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"\'"'}; {'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': 'str'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '29']}; {'id': '27', 'type': 'list_splat', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '29', 'type': 'dictionary_splat', 'children': ['30']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '31', 'type': 'string', 'children': [], 'value': '"\'"'}; {'id': '32', 'type': 'else_clause', 'children': ['33']}; {'id': '33', 'type': 'block', 'children': ['34']}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'assignment', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'string', 'children': [], 'value': '"{} numpy array, {} uncertainties"'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '45']}; {'id': '42', 'type': 'attribute', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'shape'}; {'id': '45', 'type': 'call', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '47', 'type': 'argument_list', 'children': ['48']}; {'id': '48', 'type': 'attribute', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'uncertainties'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '56']}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'string', 'children': [], 'value': '"<{} at {}, {}>"'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '56', 'type': 'argument_list', 'children': ['57', '62', '69']}; {'id': '57', 'type': 'attribute', 'children': ['58', '61']}; {'id': '58', 'type': 'attribute', 'children': ['59', '60']}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '60', 'type': 'identifier', 'children': [], 'value': '__class__'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': '__name__'}; {'id': '62', 'type': 'call', 'children': ['63', '64']}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'hex'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '67', 'type': 'argument_list', 'children': ['68']}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'text'}
Returns the unique string representation of the number.
def run(): _parser_options() set_verbose(args["verbose"]) if _check_global_settings(): _load_db() else: exit(-1) _setup_server() if args["rollback"]: _server_rollback() okay("The server rollback appears to have been successful.") exit(0) _server_enable() _list_repos() _handle_install() _do_cron()
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'run'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '9', '16', '33', '37', '56', '60', '64', '68']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'call', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': '_parser_options'}; {'id': '8', 'type': 'argument_list', 'children': []}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'set_verbose'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'subscript', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"verbose"'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '20', '25']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': '_check_global_settings'}; {'id': '19', 'type': 'argument_list', 'children': []}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': '_load_db'}; {'id': '24', 'type': 'argument_list', 'children': []}; {'id': '25', 'type': 'else_clause', 'children': ['26']}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'unary_operator', 'children': ['32'], 'value': '-'}; {'id': '32', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '33', 'type': 'expression_statement', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': '_setup_server'}; {'id': '36', 'type': 'argument_list', 'children': []}; {'id': '37', 'type': 'if_statement', 'children': ['38', '41']}; {'id': '38', 'type': 'subscript', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '40', 'type': 'string', 'children': [], 'value': '"rollback"'}; {'id': '41', 'type': 'block', 'children': ['42', '46', '51']}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_server_rollback'}; {'id': '45', 'type': 'argument_list', 'children': []}; {'id': '46', 'type': 'expression_statement', 'children': ['47']}; {'id': '47', 'type': 'call', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'okay'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'string', 'children': [], 'value': '"The server rollback appears to have been successful."'}; {'id': '51', 'type': 'expression_statement', 'children': ['52']}; {'id': '52', 'type': 'call', 'children': ['53', '54']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'exit'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '56', 'type': 'expression_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_server_enable'}; {'id': '59', 'type': 'argument_list', 'children': []}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'call', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': '_list_repos'}; {'id': '63', 'type': 'argument_list', 'children': []}; {'id': '64', 'type': 'expression_statement', 'children': ['65']}; {'id': '65', 'type': 'call', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': '_handle_install'}; {'id': '67', 'type': 'argument_list', 'children': []}; {'id': '68', 'type': 'expression_statement', 'children': ['69']}; {'id': '69', 'type': 'call', 'children': ['70', '71']}; {'id': '70', 'type': 'identifier', 'children': [], 'value': '_do_cron'}; {'id': '71', 'type': 'argument_list', 'children': []}
Main script entry to handle the arguments given to the script.
def list(): "List EC2 name and public and private ip address" for node in env.nodes: print "%s (%s, %s)" % (node.tags["Name"], node.ip_address, node.private_ip_address)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '4']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'list'}; {'id': '3', 'type': 'parameters', 'children': []}; {'id': '4', 'type': 'block', 'children': ['5', '7']}; {'id': '5', 'type': 'expression_statement', 'children': ['6']}; {'id': '6', 'type': 'string', 'children': [], 'value': '"List EC2 name and public and private ip address"'}; {'id': '7', 'type': 'for_statement', 'children': ['8', '9', '12']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'env'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'nodes'}; {'id': '12', 'type': 'block', 'children': ['13']}; {'id': '13', 'type': 'print_statement', 'children': ['14']}; {'id': '14', 'type': 'binary_operator', 'children': ['15', '16'], 'value': '%'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"%s (%s, %s)"'}; {'id': '16', 'type': 'tuple', 'children': ['17', '22', '25']}; {'id': '17', 'type': 'subscript', 'children': ['18', '21']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'tags'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"Name"'}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'ip_address'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'node'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'private_ip_address'}
List EC2 name and public and private ip address
def resize_lazy(image, width=None, height=None, crop=False, force=False, namespace="resized", storage=default_storage, as_url=False): width, height, crop = _normalize_params(image, width, height, crop) name = _get_resized_name(image, width, height, crop, namespace) try: storage = image.storage except AttributeError: pass if force or not storage.exists(name): resized_image = None try: resized_image = resize(image, width, height, crop) name = storage.save(name, resized_image) finally: if resized_image is not None: resized_image.close() if as_url: return storage.url(name) return name
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '26']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'resize_lazy'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8', '11', '14', '17', '20', '23']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'default_parameter', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'crop'}; {'id': '13', 'type': 'False', 'children': []}; {'id': '14', 'type': 'default_parameter', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '16', 'type': 'False', 'children': []}; {'id': '17', 'type': 'default_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '19', 'type': 'string', 'children': [], 'value': '"resized"'}; {'id': '20', 'type': 'default_parameter', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'default_storage'}; {'id': '23', 'type': 'default_parameter', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'as_url'}; {'id': '25', 'type': 'False', 'children': []}; {'id': '26', 'type': 'block', 'children': ['27', '40', '51', '63', '113', '123']}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '33']}; {'id': '29', 'type': 'pattern_list', 'children': ['30', '31', '32']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'crop'}; {'id': '33', 'type': 'call', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': '_normalize_params'}; {'id': '35', 'type': 'argument_list', 'children': ['36', '37', '38', '39']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'crop'}; {'id': '40', 'type': 'expression_statement', 'children': ['41']}; {'id': '41', 'type': 'assignment', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '43', 'type': 'call', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': '_get_resized_name'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '48', '49', '50']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'crop'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'namespace'}; {'id': '51', 'type': 'try_statement', 'children': ['52', '59']}; {'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': 'storage'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '59', 'type': 'except_clause', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'AttributeError'}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'pass_statement', 'children': []}; {'id': '63', 'type': 'if_statement', 'children': ['64', '73']}; {'id': '64', 'type': 'boolean_operator', 'children': ['65', '66'], 'value': 'or'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'force'}; {'id': '66', 'type': 'not_operator', 'children': ['67']}; {'id': '67', 'type': 'call', 'children': ['68', '71']}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'exists'}; {'id': '71', 'type': 'argument_list', 'children': ['72']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '73', 'type': 'block', 'children': ['74', '78']}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'assignment', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'resized_image'}; {'id': '77', 'type': 'None', 'children': []}; {'id': '78', 'type': 'try_statement', 'children': ['79', '100']}; {'id': '79', 'type': 'block', 'children': ['80', '90']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'resized_image'}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'resize'}; {'id': '85', 'type': 'argument_list', 'children': ['86', '87', '88', '89']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'image'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'width'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'height'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'crop'}; {'id': '90', 'type': 'expression_statement', 'children': ['91']}; {'id': '91', 'type': 'assignment', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '93', 'type': 'call', 'children': ['94', '97']}; {'id': '94', 'type': 'attribute', 'children': ['95', '96']}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'save'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '99']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'resized_image'}; {'id': '100', 'type': 'finally_clause', 'children': ['101']}; {'id': '101', 'type': 'block', 'children': ['102']}; {'id': '102', 'type': 'if_statement', 'children': ['103', '106']}; {'id': '103', 'type': 'comparison_operator', 'children': ['104', '105'], 'value': 'is not'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': 'resized_image'}; {'id': '105', 'type': 'None', 'children': []}; {'id': '106', 'type': 'block', 'children': ['107']}; {'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': 'resized_image'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'close'}; {'id': '112', 'type': 'argument_list', 'children': []}; {'id': '113', 'type': 'if_statement', 'children': ['114', '115']}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'as_url'}; {'id': '115', 'type': 'block', 'children': ['116']}; {'id': '116', 'type': 'return_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '121']}; {'id': '118', 'type': 'attribute', 'children': ['119', '120']}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'storage'}; {'id': '120', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '121', 'type': 'argument_list', 'children': ['122']}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '123', 'type': 'return_statement', 'children': ['124']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'name'}
Returns the name of the resized file. Returns the url if as_url is True
def read_name(self, start: int, line: int, col: int, prev: Token) -> Token: body = self.source.body body_length = len(body) position = start + 1 while position < body_length: char = body[position] if not ( char == "_" or "0" <= char <= "9" or "A" <= char <= "Z" or "a" <= char <= "z" ): break position += 1 return Token( TokenKind.NAME, start, position, line, col, prev, body[start:position] )
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '21', '23']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'read_name'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '9', '13', '17']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'typed_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '7', 'type': 'type', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '9', 'type': 'typed_parameter', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '11', 'type': 'type', 'children': ['12']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '13', 'type': 'typed_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '15', 'type': 'type', 'children': ['16']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '17', 'type': 'typed_parameter', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '19', 'type': 'type', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'Token'}; {'id': '21', 'type': 'type', 'children': ['22']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'Token'}; {'id': '23', 'type': 'block', 'children': ['24', '32', '39', '45', '83']}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '27', 'type': 'attribute', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'source'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'body_length'}; {'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': 'body'}; {'id': '39', 'type': 'expression_statement', 'children': ['40']}; {'id': '40', 'type': 'assignment', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '+'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '44', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '45', 'type': 'while_statement', 'children': ['46', '49']}; {'id': '46', 'type': 'comparison_operator', 'children': ['47', '48'], 'value': '<'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'body_length'}; {'id': '49', 'type': 'block', 'children': ['50', '56', '79']}; {'id': '50', 'type': 'expression_statement', 'children': ['51']}; {'id': '51', 'type': 'assignment', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '53', 'type': 'subscript', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '56', 'type': 'if_statement', 'children': ['57', '77']}; {'id': '57', 'type': 'not_operator', 'children': ['58']}; {'id': '58', 'type': '()', 'children': ['59']}; {'id': '59', 'type': 'boolean_operator', 'children': ['60', '73'], 'value': 'or'}; {'id': '60', 'type': 'boolean_operator', 'children': ['61', '69'], 'value': 'or'}; {'id': '61', 'type': 'boolean_operator', 'children': ['62', '65'], 'value': 'or'}; {'id': '62', 'type': 'comparison_operator', 'children': ['63', '64'], 'value': '=='}; {'id': '63', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '64', 'type': 'string', 'children': [], 'value': '"_"'}; {'id': '65', 'type': 'comparison_operator', 'children': ['66', '67', '68'], 'value': '<='}; {'id': '66', 'type': 'string', 'children': [], 'value': '"0"'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '68', 'type': 'string', 'children': [], 'value': '"9"'}; {'id': '69', 'type': 'comparison_operator', 'children': ['70', '71', '72'], 'value': '<='}; {'id': '70', 'type': 'string', 'children': [], 'value': '"A"'}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '72', 'type': 'string', 'children': [], 'value': '"Z"'}; {'id': '73', 'type': 'comparison_operator', 'children': ['74', '75', '76'], 'value': '<='}; {'id': '74', 'type': 'string', 'children': [], 'value': '"a"'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '76', 'type': 'string', 'children': [], 'value': '"z"'}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'break_statement', 'children': []}; {'id': '79', 'type': 'expression_statement', 'children': ['80']}; {'id': '80', 'type': 'augmented_assignment', 'children': ['81', '82'], 'value': '+='}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '82', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '83', 'type': 'return_statement', 'children': ['84']}; {'id': '84', 'type': 'call', 'children': ['85', '86']}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'Token'}; {'id': '86', 'type': 'argument_list', 'children': ['87', '90', '91', '92', '93', '94', '95']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'TokenKind'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'NAME'}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'position'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'col'}; {'id': '94', 'type': 'identifier', 'children': [], 'value': 'prev'}; {'id': '95', 'type': 'subscript', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'body'}; {'id': '97', 'type': 'slice', 'children': ['98', '99', '100']}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'start'}; {'id': '99', 'type': 'colon', 'children': []}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'position'}
Read an alphanumeric + underscore name from the source.
def _etree_py26_write(f, tree): f.write("<?xml version='1.0' encoding='utf-8'?>\n".encode('utf-8')) if etree.VERSION[:3] == '1.2': def fixtag(tag, namespaces): if tag == XML_NS + 'lang': return 'xml:lang', "" if '}' in tag: j = tag.index('}') + 1 tag = tag[j:] xmlns = '' if tag == 'feed': xmlns = ('xmlns', str('http://www.w3.org/2005/Atom')) namespaces['http://www.w3.org/2005/Atom'] = 'xmlns' return tag, xmlns else: fixtag = etree.fixtag old_fixtag = etree.fixtag etree.fixtag = fixtag try: tree.write(f, encoding=str('utf-8')) finally: etree.fixtag = old_fixtag
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_etree_py26_write'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '6', 'type': 'block', 'children': ['7', '19', '107', '113', '119']}; {'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': 'f'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"<?xml version=\'1.0\' encoding=\'utf-8\'?>\\n"'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'encode'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '19', 'type': 'if_statement', 'children': ['20', '29', '99']}; {'id': '20', 'type': 'comparison_operator', 'children': ['21', '28'], 'value': '=='}; {'id': '21', 'type': 'subscript', 'children': ['22', '25']}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'VERSION'}; {'id': '25', 'type': 'slice', 'children': ['26', '27']}; {'id': '26', 'type': 'colon', 'children': []}; {'id': '27', 'type': 'integer', 'children': [], 'value': '3'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'1.2'"}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'function_definition', 'children': ['31', '32', '35']}; {'id': '31', 'type': 'function_name', 'children': [], 'value': 'fixtag'}; {'id': '32', 'type': 'parameters', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '35', 'type': 'block', 'children': ['36', '47', '75', '95']}; {'id': '36', 'type': 'if_statement', 'children': ['37', '42']}; {'id': '37', 'type': 'comparison_operator', 'children': ['38', '39'], 'value': '=='}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '39', 'type': 'binary_operator', 'children': ['40', '41'], 'value': '+'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'XML_NS'}; {'id': '41', 'type': 'string', 'children': [], 'value': "'lang'"}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'return_statement', 'children': ['44']}; {'id': '44', 'type': 'expression_list', 'children': ['45', '46']}; {'id': '45', 'type': 'string', 'children': [], 'value': "'xml:lang'"}; {'id': '46', 'type': 'string', 'children': [], 'value': '""'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '51']}; {'id': '48', 'type': 'comparison_operator', 'children': ['49', '50'], 'value': 'in'}; {'id': '49', 'type': 'string', 'children': [], 'value': "'}'"}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '51', 'type': 'block', 'children': ['52', '63', '71']}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'assignment', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '55', 'type': 'binary_operator', 'children': ['56', '62'], 'value': '+'}; {'id': '56', 'type': 'call', 'children': ['57', '60']}; {'id': '57', 'type': 'attribute', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '59', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '60', 'type': 'argument_list', 'children': ['61']}; {'id': '61', 'type': 'string', 'children': [], 'value': "'}'"}; {'id': '62', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '63', 'type': 'expression_statement', 'children': ['64']}; {'id': '64', 'type': 'assignment', 'children': ['65', '66']}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '66', 'type': 'subscript', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '68', 'type': 'slice', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'j'}; {'id': '70', 'type': 'colon', 'children': []}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'xmlns'}; {'id': '74', 'type': 'string', 'children': [], 'value': "''"}; {'id': '75', 'type': 'if_statement', 'children': ['76', '79']}; {'id': '76', 'type': 'comparison_operator', 'children': ['77', '78'], 'value': '=='}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '78', 'type': 'string', 'children': [], 'value': "'feed'"}; {'id': '79', 'type': 'block', 'children': ['80', '89']}; {'id': '80', 'type': 'expression_statement', 'children': ['81']}; {'id': '81', 'type': 'assignment', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'xmlns'}; {'id': '83', 'type': 'tuple', 'children': ['84', '85']}; {'id': '84', 'type': 'string', 'children': [], 'value': "'xmlns'"}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'string', 'children': [], 'value': "'http://www.w3.org/2005/Atom'"}; {'id': '89', 'type': 'expression_statement', 'children': ['90']}; {'id': '90', 'type': 'assignment', 'children': ['91', '94']}; {'id': '91', 'type': 'subscript', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'namespaces'}; {'id': '93', 'type': 'string', 'children': [], 'value': "'http://www.w3.org/2005/Atom'"}; {'id': '94', 'type': 'string', 'children': [], 'value': "'xmlns'"}; {'id': '95', 'type': 'return_statement', 'children': ['96']}; {'id': '96', 'type': 'expression_list', 'children': ['97', '98']}; {'id': '97', 'type': 'identifier', 'children': [], 'value': 'tag'}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'xmlns'}; {'id': '99', 'type': 'else_clause', 'children': ['100']}; {'id': '100', 'type': 'block', 'children': ['101']}; {'id': '101', 'type': 'expression_statement', 'children': ['102']}; {'id': '102', 'type': 'assignment', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'fixtag'}; {'id': '104', 'type': 'attribute', 'children': ['105', '106']}; {'id': '105', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '106', 'type': 'identifier', 'children': [], 'value': 'fixtag'}; {'id': '107', 'type': 'expression_statement', 'children': ['108']}; {'id': '108', 'type': 'assignment', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'old_fixtag'}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'fixtag'}; {'id': '113', 'type': 'expression_statement', 'children': ['114']}; {'id': '114', 'type': 'assignment', 'children': ['115', '118']}; {'id': '115', 'type': 'attribute', 'children': ['116', '117']}; {'id': '116', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'fixtag'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'fixtag'}; {'id': '119', 'type': 'try_statement', 'children': ['120', '134']}; {'id': '120', 'type': 'block', 'children': ['121']}; {'id': '121', 'type': 'expression_statement', 'children': ['122']}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'tree'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}; {'id': '127', 'type': 'identifier', 'children': [], 'value': 'f'}; {'id': '128', 'type': 'keyword_argument', 'children': ['129', '130']}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'encoding'}; {'id': '130', 'type': 'call', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '132', 'type': 'argument_list', 'children': ['133']}; {'id': '133', 'type': 'string', 'children': [], 'value': "'utf-8'"}; {'id': '134', 'type': 'finally_clause', 'children': ['135']}; {'id': '135', 'type': 'block', 'children': ['136']}; {'id': '136', 'type': 'expression_statement', 'children': ['137']}; {'id': '137', 'type': 'assignment', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'etree'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'fixtag'}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'old_fixtag'}
Compatibility workaround for ElementTree shipped with py2.6
def broadcast_tx(self, tx): url = self.base_url("txs/push") data = {"tx": tx.as_hex()} result = json.loads(urlopen(url, data=json.dumps(data)).read().decode("utf8")) return result
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'broadcast_tx'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'tx'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '27', '56']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'url'}; {'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': 'base_url'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"txs/push"'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '19', 'type': 'dictionary', 'children': ['20']}; {'id': '20', 'type': 'pair', 'children': ['21', '22']}; {'id': '21', 'type': 'string', 'children': [], 'value': '"tx"'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'tx'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'as_hex'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'expression_statement', 'children': ['28']}; {'id': '28', 'type': 'assignment', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'result'}; {'id': '30', 'type': 'call', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'loads'}; {'id': '34', 'type': 'argument_list', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '54']}; {'id': '36', 'type': 'attribute', 'children': ['37', '53']}; {'id': '37', 'type': 'call', 'children': ['38', '52']}; {'id': '38', 'type': 'attribute', 'children': ['39', '51']}; {'id': '39', 'type': 'call', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'urlopen'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '43', 'type': 'keyword_argument', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '45', 'type': 'call', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'json'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'dumps'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'read'}; {'id': '52', 'type': 'argument_list', 'children': []}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'decode'}; {'id': '54', 'type': 'argument_list', 'children': ['55']}; {'id': '55', 'type': 'string', 'children': [], 'value': '"utf8"'}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'result'}
broadcast a transaction to the network
def __init_object(self): if self.init_function is not None: new_obj = self.init_function() self.__enqueue(new_obj) else: raise TypeError("The Pool must have a non None function to fill the pool.")
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '__init_object'}; {'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', '28']}; {'id': '7', 'type': 'comparison_operator', 'children': ['8', '11'], 'value': 'is not'}; {'id': '8', 'type': 'attribute', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'init_function'}; {'id': '11', 'type': 'None', 'children': []}; {'id': '12', 'type': 'block', 'children': ['13', '21']}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'assignment', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'new_obj'}; {'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': 'init_function'}; {'id': '20', 'type': 'argument_list', 'children': []}; {'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': '__enqueue'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'new_obj'}; {'id': '28', 'type': 'else_clause', 'children': ['29']}; {'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': 'TypeError'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"The Pool must have a non None function to fill the pool."'}
Create a new object for the pool.
def print_poem(self): for index, verse in enumerate(self.verses): for line in verse: print(line) if index != len(self.verses) - 1: print('')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'print_poem'}; {'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', '10', '16']}; {'id': '7', 'type': 'pattern_list', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'verse'}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'enumerate'}; {'id': '12', 'type': 'argument_list', 'children': ['13']}; {'id': '13', 'type': 'attribute', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'verses'}; {'id': '16', 'type': 'block', 'children': ['17', '26']}; {'id': '17', 'type': 'for_statement', 'children': ['18', '19', '20']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'verse'}; {'id': '20', 'type': 'block', 'children': ['21']}; {'id': '21', 'type': 'expression_statement', 'children': ['22']}; {'id': '22', 'type': 'call', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'print'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'line'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '37']}; {'id': '27', 'type': 'comparison_operator', 'children': ['28', '29'], 'value': '!='}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'index'}; {'id': '29', 'type': 'binary_operator', 'children': ['30', '36'], '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': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'verses'}; {'id': '36', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '37', 'type': 'block', 'children': ['38']}; {'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': 'string', 'children': [], 'value': "''"}
Print all the verses.
def save(self): client = self._new_api_client() params = {'id': self.id} if hasattr(self, 'id') else {} action = 'patch' if hasattr(self, 'id') else 'post' saved_model = client.make_request(self, action, url_params=params, post_data=self._to_json) self.__init__(**saved_model._to_dict)
{'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', '14', '30', '41', '59']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'client'}; {'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': '_new_api_client'}; {'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': 'params'}; {'id': '17', 'type': 'conditional_expression', 'children': ['18', '24', '29'], 'value': 'if'}; {'id': '18', 'type': 'dictionary', 'children': ['19']}; {'id': '19', 'type': 'pair', 'children': ['20', '21']}; {'id': '20', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '24', 'type': 'call', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '26', 'type': 'argument_list', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '29', 'type': 'dictionary', 'children': []}; {'id': '30', 'type': 'expression_statement', 'children': ['31']}; {'id': '31', 'type': 'assignment', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '33', 'type': 'conditional_expression', 'children': ['34', '35', '40'], 'value': 'if'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'patch'"}; {'id': '35', 'type': 'call', 'children': ['36', '37']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'hasattr'}; {'id': '37', 'type': 'argument_list', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'string', 'children': [], 'value': "'id'"}; {'id': '40', 'type': 'string', 'children': [], 'value': "'post'"}; {'id': '41', 'type': 'expression_statement', 'children': ['42']}; {'id': '42', 'type': 'assignment', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'saved_model'}; {'id': '44', 'type': 'call', 'children': ['45', '48']}; {'id': '45', 'type': 'attribute', 'children': ['46', '47']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'make_request'}; {'id': '48', 'type': 'argument_list', 'children': ['49', '50', '51', '54']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'action'}; {'id': '51', 'type': 'keyword_argument', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'url_params'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '54', 'type': 'keyword_argument', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'post_data'}; {'id': '56', 'type': 'attribute', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': '_to_json'}; {'id': '59', 'type': 'expression_statement', 'children': ['60']}; {'id': '60', 'type': 'call', 'children': ['61', '64']}; {'id': '61', 'type': 'attribute', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '63', 'type': 'identifier', 'children': [], 'value': '__init__'}; {'id': '64', 'type': 'argument_list', 'children': ['65']}; {'id': '65', 'type': 'dictionary_splat', 'children': ['66']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'saved_model'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': '_to_dict'}
Save an instance of a Union object
def _parent_tile(tiles): parent = None for t in tiles: if parent is None: parent = t else: parent = common_parent(parent, t) return parent
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_parent_tile'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tiles'}; {'id': '5', 'type': 'block', 'children': ['6', '10', '33']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'for_statement', 'children': ['11', '12', '13']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'tiles'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'if_statement', 'children': ['15', '18', '23']}; {'id': '15', 'type': 'comparison_operator', 'children': ['16', '17'], 'value': 'is'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '17', 'type': 'None', 'children': []}; {'id': '18', 'type': 'block', 'children': ['19']}; {'id': '19', 'type': 'expression_statement', 'children': ['20']}; {'id': '20', 'type': 'assignment', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '23', 'type': 'else_clause', 'children': ['24']}; {'id': '24', 'type': 'block', 'children': ['25']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'common_parent'}; {'id': '30', 'type': 'argument_list', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'parent'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 't'}; {'id': '33', 'type': 'return_statement', 'children': ['34']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'parent'}
Find the common parent tile for a sequence of tiles.
def show(self, annotations=True): if self.is_closed: self.plot_discrete(show=True, annotations=annotations) else: self.plot_entities(show=True, annotations=annotations)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'show'}; {'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': 'annotations'}; {'id': '7', 'type': 'True', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9']}; {'id': '9', 'type': 'if_statement', 'children': ['10', '13', '26']}; {'id': '10', 'type': 'attribute', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'is_closed'}; {'id': '13', 'type': 'block', 'children': ['14']}; {'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': 'plot_discrete'}; {'id': '19', 'type': 'argument_list', 'children': ['20', '23']}; {'id': '20', 'type': 'keyword_argument', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'show'}; {'id': '22', 'type': 'True', 'children': []}; {'id': '23', 'type': 'keyword_argument', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'annotations'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'annotations'}; {'id': '26', 'type': 'else_clause', 'children': ['27']}; {'id': '27', 'type': 'block', 'children': ['28']}; {'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': 'self'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'plot_entities'}; {'id': '33', 'type': 'argument_list', 'children': ['34', '37']}; {'id': '34', 'type': 'keyword_argument', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'show'}; {'id': '36', 'type': 'True', 'children': []}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'annotations'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'annotations'}
Plot the current Path2D object using matplotlib.
def normalize_residuals(self, points): residuals = self.evaluate_residual(points) solutions = self.evaluate_solution(points) return [resid / soln for resid, soln in zip(residuals, solutions)]
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'normalize_residuals'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'points'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '25']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'residuals'}; {'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': 'evaluate_residual'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'points'}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'assignment', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'solutions'}; {'id': '19', 'type': 'call', 'children': ['20', '23']}; {'id': '20', 'type': 'attribute', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'evaluate_solution'}; {'id': '23', 'type': 'argument_list', 'children': ['24']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'points'}; {'id': '25', 'type': 'return_statement', 'children': ['26']}; {'id': '26', 'type': 'list_comprehension', 'children': ['27', '30']}; {'id': '27', 'type': 'binary_operator', 'children': ['28', '29'], 'value': '/'}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'resid'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'soln'}; {'id': '30', 'type': 'for_in_clause', 'children': ['31', '34']}; {'id': '31', 'type': 'pattern_list', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'resid'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'soln'}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'zip'}; {'id': '36', 'type': 'argument_list', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'residuals'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'solutions'}
Normalize residuals by the level of the variable.
def parse_extras(extras_str): from pkg_resources import Requirement extras = Requirement.parse("fakepkg{0}".format(extras_to_string(extras_str))).extras return sorted(dedup([extra.lower() for extra in extras]))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'parse_extras'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'extras_str'}; {'id': '5', 'type': 'block', 'children': ['6', '11', '30']}; {'id': '6', 'type': 'import_from_statement', 'children': ['7', '9']}; {'id': '7', 'type': 'dotted_name', 'children': ['8']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'pkg_resources'}; {'id': '9', 'type': 'dotted_name', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'Requirement'}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'extras'}; {'id': '14', 'type': 'attribute', 'children': ['15', '29']}; {'id': '15', 'type': 'call', 'children': ['16', '19']}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'Requirement'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'parse'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'call', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'string', 'children': [], 'value': '"fakepkg{0}"'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '24', 'type': 'argument_list', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'extras_to_string'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'extras_str'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'extras'}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'sorted'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'call', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'dedup'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'list_comprehension', 'children': ['38', '43']}; {'id': '38', 'type': 'call', 'children': ['39', '42']}; {'id': '39', 'type': 'attribute', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '42', 'type': 'argument_list', 'children': []}; {'id': '43', 'type': 'for_in_clause', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'extra'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'extras'}
Turn a string of extras into a parsed extras list
def check_password_readable(self, section, fields): if not fields: return if len(self.read_ok) != 1: return fn = self.read_ok[0] if fileutil.is_accessable_by_others(fn): log.warn(LOG_CHECK, "The configuration file %s contains password information (in section [%s] and options %s) and the file is readable by others. Please make the file only readable by you.", fn, section, fields) if os.name == 'posix': log.warn(LOG_CHECK, _("For example execute 'chmod go-rw %s'.") % fn) elif os.name == 'nt': log.warn(LOG_CHECK, _("See http://support.microsoft.com/kb/308419 for more info on setting file permissions."))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_password_readable'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '7', 'type': 'block', 'children': ['8', '13', '24', '32']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '11']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '11', 'type': 'block', 'children': ['12']}; {'id': '12', 'type': 'return_statement', 'children': []}; {'id': '13', 'type': 'if_statement', 'children': ['14', '22']}; {'id': '14', 'type': 'comparison_operator', 'children': ['15', '21'], 'value': '!='}; {'id': '15', 'type': 'call', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'len'}; {'id': '17', 'type': 'argument_list', 'children': ['18']}; {'id': '18', 'type': 'attribute', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'read_ok'}; {'id': '21', 'type': 'integer', 'children': [], 'value': '1'}; {'id': '22', 'type': 'block', 'children': ['23']}; {'id': '23', 'type': 'return_statement', 'children': []}; {'id': '24', 'type': 'expression_statement', 'children': ['25']}; {'id': '25', 'type': 'assignment', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '27', 'type': 'subscript', 'children': ['28', '31']}; {'id': '28', 'type': 'attribute', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'read_ok'}; {'id': '31', 'type': 'integer', 'children': [], 'value': '0'}; {'id': '32', 'type': 'if_statement', 'children': ['33', '39']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'fileutil'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'is_accessable_by_others'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '39', 'type': 'block', 'children': ['40', '51']}; {'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': 'log'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47', '48', '49', '50']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'LOG_CHECK'}; {'id': '47', 'type': 'string', 'children': [], 'value': '"The configuration file %s contains password information (in section [%s] and options %s) and the file is readable by others. Please make the file only readable by you."'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'section'}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'fields'}; {'id': '51', 'type': 'if_statement', 'children': ['52', '57', '71']}; {'id': '52', 'type': 'comparison_operator', 'children': ['53', '56'], 'value': '=='}; {'id': '53', 'type': 'attribute', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '56', 'type': 'string', 'children': [], 'value': "'posix'"}; {'id': '57', 'type': 'block', 'children': ['58']}; {'id': '58', 'type': 'expression_statement', 'children': ['59']}; {'id': '59', 'type': 'call', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '63', 'type': 'argument_list', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'LOG_CHECK'}; {'id': '65', 'type': 'binary_operator', 'children': ['66', '70'], 'value': '%'}; {'id': '66', 'type': 'call', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '68', 'type': 'argument_list', 'children': ['69']}; {'id': '69', 'type': 'string', 'children': [], 'value': '"For example execute \'chmod go-rw %s\'."'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'fn'}; {'id': '71', 'type': 'elif_clause', 'children': ['72', '77']}; {'id': '72', 'type': 'comparison_operator', 'children': ['73', '76'], 'value': '=='}; {'id': '73', 'type': 'attribute', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '76', 'type': 'string', 'children': [], 'value': "'nt'"}; {'id': '77', 'type': 'block', 'children': ['78']}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'call', 'children': ['80', '83']}; {'id': '80', 'type': 'attribute', 'children': ['81', '82']}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '83', 'type': 'argument_list', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'LOG_CHECK'}; {'id': '85', 'type': 'call', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': '_'}; {'id': '87', 'type': 'argument_list', 'children': ['88']}; {'id': '88', 'type': 'string', 'children': [], 'value': '"See http://support.microsoft.com/kb/308419 for more info on setting file permissions."'}
Check if there is a readable configuration file and print a warning.
def stops(self): serves = set() for trip in self.trips(): for stop_time in trip.stop_times(): serves |= stop_time.stops() return serves
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'stops'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '36']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'serves'}; {'id': '9', 'type': 'call', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'set'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'for_statement', 'children': ['13', '14', '19']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'trip'}; {'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': 'trips'}; {'id': '18', 'type': 'argument_list', 'children': []}; {'id': '19', 'type': 'block', 'children': ['20']}; {'id': '20', 'type': 'for_statement', 'children': ['21', '22', '27']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'stop_time'}; {'id': '22', 'type': 'call', 'children': ['23', '26']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'trip'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'stop_times'}; {'id': '26', 'type': 'argument_list', 'children': []}; {'id': '27', 'type': 'block', 'children': ['28']}; {'id': '28', 'type': 'expression_statement', 'children': ['29']}; {'id': '29', 'type': 'augmented_assignment', 'children': ['30', '31'], 'value': '|='}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'serves'}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'stop_time'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'stops'}; {'id': '35', 'type': 'argument_list', 'children': []}; {'id': '36', 'type': 'return_statement', 'children': ['37']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'serves'}
Return stops served by this route.
def metric_details(request, pk, format=None): metric = get_object_or_404(Metric, pk=pk) if request.method == 'GET': try: results = metric.select(q=request.query_params.get('q', metric.query)) except InfluxDBClientError as e: return Response({'detail': e.content}, status=e.code) return Response(list(results.get_points(metric.name))) else: if not request.data: return Response({'detail': 'expected values in POST data or JSON payload'}, status=400) data = request.data.copy() if request.content_type != 'application/json': for key, value in data.items(): try: data[key] = float(value) if '.' in value else int(value) except ValueError: pass metric.write(data) return Response({'detail': 'ok'})
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '9']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'metric_details'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '6', 'type': 'default_parameter', 'children': ['7', '8']}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '8', 'type': 'None', 'children': []}; {'id': '9', 'type': 'block', 'children': ['10', '20']}; {'id': '10', 'type': 'expression_statement', 'children': ['11']}; {'id': '11', 'type': 'assignment', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '13', 'type': 'call', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get_object_or_404'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'Metric'}; {'id': '17', 'type': 'keyword_argument', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'pk'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '26', '86']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '25'], 'value': '=='}; {'id': '22', 'type': 'attribute', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'method'}; {'id': '25', 'type': 'string', 'children': [], 'value': "'GET'"}; {'id': '26', 'type': 'block', 'children': ['27', '71']}; {'id': '27', 'type': 'try_statement', 'children': ['28', '50']}; {'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': 'results'}; {'id': '32', 'type': 'call', 'children': ['33', '36']}; {'id': '33', 'type': 'attribute', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'select'}; {'id': '36', 'type': 'argument_list', 'children': ['37']}; {'id': '37', 'type': 'keyword_argument', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'q'}; {'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': 'request'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'query_params'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '45', 'type': 'argument_list', 'children': ['46', '47']}; {'id': '46', 'type': 'string', 'children': [], 'value': "'q'"}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'query'}; {'id': '50', 'type': 'except_clause', 'children': ['51', '55']}; {'id': '51', 'type': 'as_pattern', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'InfluxDBClientError'}; {'id': '53', 'type': 'as_pattern_target', 'children': ['54']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '55', 'type': 'block', 'children': ['56']}; {'id': '56', 'type': 'return_statement', 'children': ['57']}; {'id': '57', 'type': 'call', 'children': ['58', '59']}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '59', 'type': 'argument_list', 'children': ['60', '66']}; {'id': '60', 'type': 'dictionary', 'children': ['61']}; {'id': '61', 'type': 'pair', 'children': ['62', '63']}; {'id': '62', 'type': 'string', 'children': [], 'value': "'detail'"}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'content'}; {'id': '66', 'type': 'keyword_argument', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '68', 'type': 'attribute', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'e'}; {'id': '70', 'type': 'identifier', 'children': [], 'value': 'code'}; {'id': '71', 'type': 'return_statement', 'children': ['72']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '74', 'type': 'argument_list', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '77', 'type': 'argument_list', 'children': ['78']}; {'id': '78', 'type': 'call', 'children': ['79', '82']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'results'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'get_points'}; {'id': '82', 'type': 'argument_list', 'children': ['83']}; {'id': '83', 'type': 'attribute', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '86', 'type': 'else_clause', 'children': ['87']}; {'id': '87', 'type': 'block', 'children': ['88', '105', '115', '155', '162']}; {'id': '88', 'type': 'if_statement', 'children': ['89', '93']}; {'id': '89', 'type': 'not_operator', 'children': ['90']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '93', 'type': 'block', 'children': ['94']}; {'id': '94', 'type': 'return_statement', 'children': ['95']}; {'id': '95', 'type': 'call', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '97', 'type': 'argument_list', 'children': ['98', '102']}; {'id': '98', 'type': 'dictionary', 'children': ['99']}; {'id': '99', 'type': 'pair', 'children': ['100', '101']}; {'id': '100', 'type': 'string', 'children': [], 'value': "'detail'"}; {'id': '101', 'type': 'string', 'children': [], 'value': "'expected values in POST data or JSON payload'"}; {'id': '102', 'type': 'keyword_argument', 'children': ['103', '104']}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'status'}; {'id': '104', 'type': 'integer', 'children': [], 'value': '400'}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '108', 'type': 'call', 'children': ['109', '114']}; {'id': '109', 'type': 'attribute', 'children': ['110', '113']}; {'id': '110', 'type': 'attribute', 'children': ['111', '112']}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'copy'}; {'id': '114', 'type': 'argument_list', 'children': []}; {'id': '115', 'type': 'if_statement', 'children': ['116', '121']}; {'id': '116', 'type': 'comparison_operator', 'children': ['117', '120'], 'value': '!='}; {'id': '117', 'type': 'attribute', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'request'}; {'id': '119', 'type': 'identifier', 'children': [], 'value': 'content_type'}; {'id': '120', 'type': 'string', 'children': [], 'value': "'application/json'"}; {'id': '121', 'type': 'block', 'children': ['122']}; {'id': '122', 'type': 'for_statement', 'children': ['123', '126', '131']}; {'id': '123', 'type': 'pattern_list', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '130', 'type': 'argument_list', 'children': []}; {'id': '131', 'type': 'block', 'children': ['132']}; {'id': '132', 'type': 'try_statement', 'children': ['133', '151']}; {'id': '133', 'type': 'block', 'children': ['134']}; {'id': '134', 'type': 'expression_statement', 'children': ['135']}; {'id': '135', 'type': 'assignment', 'children': ['136', '139']}; {'id': '136', 'type': 'subscript', 'children': ['137', '138']}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '139', 'type': 'conditional_expression', 'children': ['140', '144', '147'], 'value': 'if'}; {'id': '140', 'type': 'call', 'children': ['141', '142']}; {'id': '141', 'type': 'identifier', 'children': [], 'value': 'float'}; {'id': '142', 'type': 'argument_list', 'children': ['143']}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '144', 'type': 'comparison_operator', 'children': ['145', '146'], 'value': 'in'}; {'id': '145', 'type': 'string', 'children': [], 'value': "'.'"}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '147', 'type': 'call', 'children': ['148', '149']}; {'id': '148', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '149', 'type': 'argument_list', 'children': ['150']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'value'}; {'id': '151', 'type': 'except_clause', 'children': ['152', '153']}; {'id': '152', 'type': 'identifier', 'children': [], 'value': 'ValueError'}; {'id': '153', 'type': 'block', 'children': ['154']}; {'id': '154', 'type': 'pass_statement', 'children': []}; {'id': '155', 'type': 'expression_statement', 'children': ['156']}; {'id': '156', 'type': 'call', 'children': ['157', '160']}; {'id': '157', 'type': 'attribute', 'children': ['158', '159']}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'metric'}; {'id': '159', 'type': 'identifier', 'children': [], 'value': 'write'}; {'id': '160', 'type': 'argument_list', 'children': ['161']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '162', 'type': 'return_statement', 'children': ['163']}; {'id': '163', 'type': 'call', 'children': ['164', '165']}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'Response'}; {'id': '165', 'type': 'argument_list', 'children': ['166']}; {'id': '166', 'type': 'dictionary', 'children': ['167']}; {'id': '167', 'type': 'pair', 'children': ['168', '169']}; {'id': '168', 'type': 'string', 'children': [], 'value': "'detail'"}; {'id': '169', 'type': 'string', 'children': [], 'value': "'ok'"}
Get or write metric values
def generate_non_rabs(self): logging.info('Building non-Rab DB') run_cmd([self.pathfinder['cd-hit'], '-i', self.path['non_rab_db'], '-o', self.output['non_rab_db'], '-d', '100', '-c', str(config['param']['non_rab_db_identity_threshold']), '-g', '1', '-T', self.cpu]) os.remove(self.output['non_rab_db'] + '.clstr')
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'generate_non_rabs'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '13', '52']}; {'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': 'logging'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'info'}; {'id': '11', 'type': 'argument_list', 'children': ['12']}; {'id': '12', 'type': 'string', 'children': [], 'value': "'Building non-Rab DB'"}; {'id': '13', 'type': 'expression_statement', 'children': ['14']}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'run_cmd'}; {'id': '16', 'type': 'argument_list', 'children': ['17']}; {'id': '17', 'type': 'list', 'children': ['18', '23', '24', '29', '30', '35', '36', '37', '38', '46', '47', '48', '49'], 'value': "[self.pathfinder['cd-hit'], '-i', self.path['non_rab_db'], '-o', self.output['non_rab_db'],\n '-d', '100', '-c', str(config['param']['non_rab_db_identity_threshold']), '-g', '1', '-T', self.cpu]"}; {'id': '18', 'type': 'subscript', 'children': ['19', '22']}; {'id': '19', 'type': 'attribute', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'pathfinder'}; {'id': '22', 'type': 'string', 'children': [], 'value': "'cd-hit'"}; {'id': '23', 'type': 'string', 'children': [], 'value': "'-i'"}; {'id': '24', 'type': 'subscript', 'children': ['25', '28']}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '28', 'type': 'string', 'children': [], 'value': "'non_rab_db'"}; {'id': '29', 'type': 'string', 'children': [], 'value': "'-o'"}; {'id': '30', 'type': 'subscript', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '34', 'type': 'string', 'children': [], 'value': "'non_rab_db'"}; {'id': '35', 'type': 'string', 'children': [], 'value': "'-d'"}; {'id': '36', 'type': 'string', 'children': [], 'value': "'100'"}; {'id': '37', 'type': 'string', 'children': [], 'value': "'-c'"}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'str'}; {'id': '40', 'type': 'argument_list', 'children': ['41']}; {'id': '41', 'type': 'subscript', 'children': ['42', '45']}; {'id': '42', 'type': 'subscript', 'children': ['43', '44']}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'config'}; {'id': '44', 'type': 'string', 'children': [], 'value': "'param'"}; {'id': '45', 'type': 'string', 'children': [], 'value': "'non_rab_db_identity_threshold'"}; {'id': '46', 'type': 'string', 'children': [], 'value': "'-g'"}; {'id': '47', 'type': 'string', 'children': [], 'value': "'1'"}; {'id': '48', 'type': 'string', 'children': [], 'value': "'-T'"}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'cpu'}; {'id': '52', 'type': 'expression_statement', 'children': ['53']}; {'id': '53', 'type': 'call', 'children': ['54', '57']}; {'id': '54', 'type': 'attribute', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'remove'}; {'id': '57', 'type': 'argument_list', 'children': ['58']}; {'id': '58', 'type': 'binary_operator', 'children': ['59', '64'], 'value': '+'}; {'id': '59', 'type': 'subscript', 'children': ['60', '63']}; {'id': '60', 'type': 'attribute', 'children': ['61', '62']}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '63', 'type': 'string', 'children': [], 'value': "'non_rab_db'"}; {'id': '64', 'type': 'string', 'children': [], 'value': "'.clstr'"}
Shrink the non-Rab DB size by reducing sequence redundancy.
def remove_dependency(id=None, name=None, dependency_id=None, dependency_name=None): data = remove_dependency_raw(id, name, dependency_id, dependency_name) if data: return utils.format_json_list(data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '16']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'remove_dependency'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '6', 'type': 'None', 'children': []}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '9', 'type': 'None', 'children': []}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'dependency_id'}; {'id': '12', 'type': 'None', 'children': []}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dependency_name'}; {'id': '15', 'type': 'None', 'children': []}; {'id': '16', 'type': 'block', 'children': ['17', '27']}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '20', 'type': 'call', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'remove_dependency_raw'}; {'id': '22', 'type': 'argument_list', 'children': ['23', '24', '25', '26']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'id'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dependency_id'}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'dependency_name'}; {'id': '27', 'type': 'if_statement', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '29', 'type': 'block', 'children': ['30']}; {'id': '30', 'type': 'return_statement', 'children': ['31']}; {'id': '31', 'type': 'call', 'children': ['32', '35']}; {'id': '32', 'type': 'attribute', 'children': ['33', '34']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'utils'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'format_json_list'}; {'id': '35', 'type': 'argument_list', 'children': ['36']}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'data'}
Remove a BuildConfiguration from the dependency list of another BuildConfiguration
def connect(self, host=None, port=None): host = self.host if host is None else host port = self.port if port is None else port self.socket.connect(host, port)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '11']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'connect'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'default_parameter', 'children': ['6', '7']}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'default_parameter', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '10', 'type': 'None', 'children': []}; {'id': '11', 'type': 'block', 'children': ['12', '23', '34']}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '15', 'type': 'conditional_expression', 'children': ['16', '19', '22'], 'value': 'if'}; {'id': '16', 'type': 'attribute', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '21'], 'value': 'is'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '21', 'type': 'None', 'children': []}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '23', 'type': 'expression_statement', 'children': ['24']}; {'id': '24', 'type': 'assignment', 'children': ['25', '26']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '26', 'type': 'conditional_expression', 'children': ['27', '30', '33'], 'value': 'if'}; {'id': '27', 'type': 'attribute', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '30', 'type': 'comparison_operator', 'children': ['31', '32'], 'value': 'is'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '32', 'type': 'None', 'children': []}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '34', 'type': 'expression_statement', 'children': ['35']}; {'id': '35', 'type': 'call', 'children': ['36', '41']}; {'id': '36', 'type': 'attribute', 'children': ['37', '40']}; {'id': '37', 'type': 'attribute', 'children': ['38', '39']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'socket'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'connect'}; {'id': '41', 'type': 'argument_list', 'children': ['42', '43']}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'host'}; {'id': '43', 'type': 'identifier', 'children': [], 'value': 'port'}
Connects to given host address and port.
def inflate_dtype(arr, names): arr = np.asanyarray(arr) if has_structured_dt(arr): return arr.dtype s_dt = arr.dtype dt = [(n, s_dt) for n in names] dt = np.dtype(dt) return dt
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inflate_dtype'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '6', 'type': 'block', 'children': ['7', '16', '26', '32', '42', '51']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'np'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'asanyarray'}; {'id': '14', 'type': 'argument_list', 'children': ['15']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '16', 'type': 'if_statement', 'children': ['17', '21']}; {'id': '17', 'type': 'call', 'children': ['18', '19']}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'has_structured_dt'}; {'id': '19', 'type': 'argument_list', 'children': ['20']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '21', 'type': 'block', 'children': ['22']}; {'id': '22', 'type': 'return_statement', 'children': ['23']}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 's_dt'}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'arr'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'dtype'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'assignment', 'children': ['34', '35']}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '35', 'type': 'list_comprehension', 'children': ['36', '39']}; {'id': '36', 'type': 'tuple', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 's_dt'}; {'id': '39', 'type': 'for_in_clause', 'children': ['40', '41']}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'n'}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'names'}; {'id': '42', 'type': 'expression_statement', 'children': ['43']}; {'id': '43', 'type': 'assignment', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'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': 'dtype'}; {'id': '49', 'type': 'argument_list', 'children': ['50']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'dt'}; {'id': '51', 'type': 'return_statement', 'children': ['52']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dt'}
Create structured dtype from a 2d ndarray with unstructured dtype.
def add_action_view(self, name, url, actions, **kwargs): view = ActionsView(name, url=url, self_var=self, **kwargs) if isinstance(actions, dict): for group, actions in actions.iteritems(): view.actions.extend(load_actions(actions, group=group or None)) else: view.actions.extend(load_actions(actions)) self.add_view(view) return view
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '10']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'add_action_view'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6', '7', '8']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '7', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '8', 'type': 'dictionary_splat_pattern', 'children': ['9']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '10', 'type': 'block', 'children': ['11', '26', '74', '81']}; {'id': '11', 'type': 'expression_statement', 'children': ['12']}; {'id': '12', 'type': 'assignment', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '14', 'type': 'call', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'ActionsView'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '21', '24']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'name'}; {'id': '18', 'type': 'keyword_argument', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'url'}; {'id': '21', 'type': 'keyword_argument', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self_var'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '24', 'type': 'dictionary_splat', 'children': ['25']}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'kwargs'}; {'id': '26', 'type': 'if_statement', 'children': ['27', '32', '60']}; {'id': '27', 'type': 'call', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '29', 'type': 'argument_list', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '32', 'type': 'block', 'children': ['33']}; {'id': '33', 'type': 'for_statement', 'children': ['34', '37', '42']}; {'id': '34', 'type': 'pattern_list', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '37', 'type': 'call', 'children': ['38', '41']}; {'id': '38', 'type': 'attribute', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'iteritems'}; {'id': '41', 'type': 'argument_list', 'children': []}; {'id': '42', 'type': 'block', 'children': ['43']}; {'id': '43', 'type': 'expression_statement', 'children': ['44']}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '50', 'type': 'argument_list', 'children': ['51']}; {'id': '51', 'type': 'call', 'children': ['52', '53']}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'load_actions'}; {'id': '53', 'type': 'argument_list', 'children': ['54', '55']}; {'id': '54', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '55', 'type': 'keyword_argument', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '57', 'type': 'boolean_operator', 'children': ['58', '59'], 'value': 'or'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'group'}; {'id': '59', 'type': 'None', 'children': []}; {'id': '60', 'type': 'else_clause', 'children': ['61']}; {'id': '61', 'type': 'block', 'children': ['62']}; {'id': '62', 'type': 'expression_statement', 'children': ['63']}; {'id': '63', 'type': 'call', 'children': ['64', '69']}; {'id': '64', 'type': 'attribute', 'children': ['65', '68']}; {'id': '65', 'type': 'attribute', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'extend'}; {'id': '69', 'type': 'argument_list', 'children': ['70']}; {'id': '70', 'type': 'call', 'children': ['71', '72']}; {'id': '71', 'type': 'identifier', 'children': [], 'value': 'load_actions'}; {'id': '72', 'type': 'argument_list', 'children': ['73']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'actions'}; {'id': '74', 'type': 'expression_statement', 'children': ['75']}; {'id': '75', 'type': 'call', 'children': ['76', '79']}; {'id': '76', 'type': 'attribute', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'add_view'}; {'id': '79', 'type': 'argument_list', 'children': ['80']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'view'}; {'id': '81', 'type': 'return_statement', 'children': ['82']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'view'}
Creates an ActionsView instance and registers it.
def _recursive_upsert(context, params, data): children = params.get("children", {}) nested_calls = [] for child_params in children: key = child_params.get("key") child_data_list = ensure_list(data.pop(key)) if isinstance(child_data_list, dict): child_data_list = [child_data_list] if not (isinstance(child_data_list, list) and all(isinstance(i, dict) for i in child_data_list)): context.log.warn( "Expecting a dict or a lost of dicts as children for key", key ) continue if child_data_list: table_suffix = child_params.get("table_suffix", key) child_params["table"] = params.get("table") + "_" + table_suffix inherit = child_params.get("inherit", {}) for child_data in child_data_list: for dest, src in inherit.items(): child_data[dest] = data.get(src) nested_calls.append((child_params, child_data)) _upsert(context, params, data) for child_params, child_data in nested_calls: _recursive_upsert(context, child_params, child_data)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_recursive_upsert'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '7', 'type': 'block', 'children': ['8', '18', '22', '163', '170']}; {'id': '8', 'type': 'expression_statement', 'children': ['9']}; {'id': '9', 'type': 'assignment', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '11', 'type': 'call', 'children': ['12', '15']}; {'id': '12', 'type': 'attribute', 'children': ['13', '14']}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '15', 'type': 'argument_list', 'children': ['16', '17']}; {'id': '16', 'type': 'string', 'children': [], 'value': '"children"'}; {'id': '17', 'type': 'dictionary', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'nested_calls'}; {'id': '21', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '22', 'type': 'for_statement', 'children': ['23', '24', '25']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'children'}; {'id': '25', 'type': 'block', 'children': ['26', '35', '47', '59', '91']}; {'id': '26', 'type': 'expression_statement', 'children': ['27']}; {'id': '27', 'type': 'assignment', 'children': ['28', '29']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': '"key"'}; {'id': '35', 'type': 'expression_statement', 'children': ['36']}; {'id': '36', 'type': 'assignment', 'children': ['37', '38']}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '38', 'type': 'call', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'ensure_list'}; {'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': 'data'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'pop'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '47', 'type': 'if_statement', 'children': ['48', '53']}; {'id': '48', 'type': 'call', 'children': ['49', '50']}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '53', 'type': 'block', 'children': ['54']}; {'id': '54', 'type': 'expression_statement', 'children': ['55']}; {'id': '55', 'type': 'assignment', 'children': ['56', '57']}; {'id': '56', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '57', 'type': 'list', 'children': ['58'], 'value': '[child_data_list]'}; {'id': '58', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '59', 'type': 'if_statement', 'children': ['60', '79']}; {'id': '60', 'type': 'not_operator', 'children': ['61']}; {'id': '61', 'type': '()', 'children': ['62']}; {'id': '62', 'type': 'boolean_operator', 'children': ['63', '68'], 'value': 'and'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '67']}; {'id': '66', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'list'}; {'id': '68', 'type': 'call', 'children': ['69', '70']}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'all'}; {'id': '70', 'type': 'generator_expression', 'children': ['71', '76']}; {'id': '71', 'type': 'call', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'isinstance'}; {'id': '73', 'type': 'argument_list', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 'dict'}; {'id': '76', 'type': 'for_in_clause', 'children': ['77', '78']}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'i'}; {'id': '78', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '79', 'type': 'block', 'children': ['80', '90']}; {'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': 'context'}; {'id': '85', 'type': 'identifier', 'children': [], 'value': 'log'}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'warn'}; {'id': '87', 'type': 'argument_list', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': '"Expecting a dict or a lost of dicts as children for key"'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '90', 'type': 'continue_statement', 'children': []}; {'id': '91', 'type': 'if_statement', 'children': ['92', '93']}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '93', 'type': 'block', 'children': ['94', '104', '119', '129']}; {'id': '94', 'type': 'expression_statement', 'children': ['95']}; {'id': '95', 'type': 'assignment', 'children': ['96', '97']}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'table_suffix'}; {'id': '97', 'type': 'call', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '101', 'type': 'argument_list', 'children': ['102', '103']}; {'id': '102', 'type': 'string', 'children': [], 'value': '"table_suffix"'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'key'}; {'id': '104', 'type': 'expression_statement', 'children': ['105']}; {'id': '105', 'type': 'assignment', 'children': ['106', '109']}; {'id': '106', 'type': 'subscript', 'children': ['107', '108']}; {'id': '107', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '108', 'type': 'string', 'children': [], 'value': '"table"'}; {'id': '109', 'type': 'binary_operator', 'children': ['110', '118'], 'value': '+'}; {'id': '110', 'type': 'binary_operator', 'children': ['111', '117'], 'value': '+'}; {'id': '111', 'type': 'call', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '115', 'type': 'argument_list', 'children': ['116']}; {'id': '116', 'type': 'string', 'children': [], 'value': '"table"'}; {'id': '117', 'type': 'string', 'children': [], 'value': '"_"'}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'table_suffix'}; {'id': '119', 'type': 'expression_statement', 'children': ['120']}; {'id': '120', 'type': 'assignment', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'inherit'}; {'id': '122', 'type': 'call', 'children': ['123', '126']}; {'id': '123', 'type': 'attribute', 'children': ['124', '125']}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '126', 'type': 'argument_list', 'children': ['127', '128']}; {'id': '127', 'type': 'string', 'children': [], 'value': '"inherit"'}; {'id': '128', 'type': 'dictionary', 'children': []}; {'id': '129', 'type': 'for_statement', 'children': ['130', '131', '132']}; {'id': '130', 'type': 'identifier', 'children': [], 'value': 'child_data'}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'child_data_list'}; {'id': '132', 'type': 'block', 'children': ['133', '154']}; {'id': '133', 'type': 'for_statement', 'children': ['134', '137', '142']}; {'id': '134', 'type': 'pattern_list', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '137', 'type': 'call', 'children': ['138', '141']}; {'id': '138', 'type': 'attribute', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'inherit'}; {'id': '140', 'type': 'identifier', 'children': [], 'value': 'items'}; {'id': '141', 'type': 'argument_list', 'children': []}; {'id': '142', 'type': 'block', 'children': ['143']}; {'id': '143', 'type': 'expression_statement', 'children': ['144']}; {'id': '144', 'type': 'assignment', 'children': ['145', '148']}; {'id': '145', 'type': 'subscript', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'child_data'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'dest'}; {'id': '148', 'type': 'call', 'children': ['149', '152']}; {'id': '149', 'type': 'attribute', 'children': ['150', '151']}; {'id': '150', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}; {'id': '153', 'type': 'identifier', 'children': [], 'value': 'src'}; {'id': '154', 'type': 'expression_statement', 'children': ['155']}; {'id': '155', 'type': 'call', 'children': ['156', '159']}; {'id': '156', 'type': 'attribute', 'children': ['157', '158']}; {'id': '157', 'type': 'identifier', 'children': [], 'value': 'nested_calls'}; {'id': '158', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '159', 'type': 'argument_list', 'children': ['160']}; {'id': '160', 'type': 'tuple', 'children': ['161', '162']}; {'id': '161', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '162', 'type': 'identifier', 'children': [], 'value': 'child_data'}; {'id': '163', 'type': 'expression_statement', 'children': ['164']}; {'id': '164', 'type': 'call', 'children': ['165', '166']}; {'id': '165', 'type': 'identifier', 'children': [], 'value': '_upsert'}; {'id': '166', 'type': 'argument_list', 'children': ['167', '168', '169']}; {'id': '167', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'params'}; {'id': '169', 'type': 'identifier', 'children': [], 'value': 'data'}; {'id': '170', 'type': 'for_statement', 'children': ['171', '174', '175']}; {'id': '171', 'type': 'pattern_list', 'children': ['172', '173']}; {'id': '172', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '173', 'type': 'identifier', 'children': [], 'value': 'child_data'}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'nested_calls'}; {'id': '175', 'type': 'block', 'children': ['176']}; {'id': '176', 'type': 'expression_statement', 'children': ['177']}; {'id': '177', 'type': 'call', 'children': ['178', '179']}; {'id': '178', 'type': 'identifier', 'children': [], 'value': '_recursive_upsert'}; {'id': '179', 'type': 'argument_list', 'children': ['180', '181', '182']}; {'id': '180', 'type': 'identifier', 'children': [], 'value': 'context'}; {'id': '181', 'type': 'identifier', 'children': [], 'value': 'child_params'}; {'id': '182', 'type': 'identifier', 'children': [], 'value': 'child_data'}
Insert or update nested dicts recursively into db tables
def inspect(self): policy = self.policy config_id = self.config_id if self.config_id.config_type == ItemType.VOLUME: if self.container_map.use_attached_parent_name: container_name = policy.aname(config_id.map_name, config_id.instance_name, config_id.config_name) else: container_name = policy.aname(config_id.map_name, config_id.instance_name) else: container_name = policy.cname(config_id.map_name, config_id.config_name, config_id.instance_name) self.container_name = container_name if container_name in policy.container_names[self.client_name]: self.detail = self.client.inspect_container(container_name) else: self.detail = NOT_FOUND
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'inspect'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '88', '94']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'assignment', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '9', 'type': 'attribute', 'children': ['10', '11']}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'assignment', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '15', 'type': 'attribute', 'children': ['16', '17']}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '18', 'type': 'if_statement', 'children': ['19', '28', '69']}; {'id': '19', 'type': 'comparison_operator', 'children': ['20', '25'], 'value': '=='}; {'id': '20', 'type': 'attribute', 'children': ['21', '24']}; {'id': '21', 'type': 'attribute', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'config_type'}; {'id': '25', 'type': 'attribute', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'ItemType'}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'VOLUME'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'if_statement', 'children': ['30', '35', '53']}; {'id': '30', 'type': 'attribute', 'children': ['31', '34']}; {'id': '31', 'type': 'attribute', 'children': ['32', '33']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'container_map'}; {'id': '34', 'type': 'identifier', 'children': [], 'value': 'use_attached_parent_name'}; {'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': 'container_name'}; {'id': '39', 'type': 'call', 'children': ['40', '43']}; {'id': '40', 'type': 'attribute', 'children': ['41', '42']}; {'id': '41', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '42', 'type': 'identifier', 'children': [], 'value': 'aname'}; {'id': '43', 'type': 'argument_list', 'children': ['44', '47', '50']}; {'id': '44', 'type': 'attribute', 'children': ['45', '46']}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'map_name'}; {'id': '47', 'type': 'attribute', 'children': ['48', '49']}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'instance_name'}; {'id': '50', 'type': 'attribute', 'children': ['51', '52']}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '52', 'type': 'identifier', 'children': [], 'value': 'config_name'}; {'id': '53', 'type': 'else_clause', 'children': ['54']}; {'id': '54', 'type': 'block', 'children': ['55']}; {'id': '55', 'type': 'expression_statement', 'children': ['56']}; {'id': '56', 'type': 'assignment', 'children': ['57', '58']}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'container_name'}; {'id': '58', 'type': 'call', 'children': ['59', '62']}; {'id': '59', 'type': 'attribute', 'children': ['60', '61']}; {'id': '60', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '61', 'type': 'identifier', 'children': [], 'value': 'aname'}; {'id': '62', 'type': 'argument_list', 'children': ['63', '66']}; {'id': '63', 'type': 'attribute', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'map_name'}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'instance_name'}; {'id': '69', 'type': 'else_clause', 'children': ['70']}; {'id': '70', 'type': 'block', 'children': ['71']}; {'id': '71', 'type': 'expression_statement', 'children': ['72']}; {'id': '72', 'type': 'assignment', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'container_name'}; {'id': '74', 'type': 'call', 'children': ['75', '78']}; {'id': '75', 'type': 'attribute', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'cname'}; {'id': '78', 'type': 'argument_list', 'children': ['79', '82', '85']}; {'id': '79', 'type': 'attribute', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '81', 'type': 'identifier', 'children': [], 'value': 'map_name'}; {'id': '82', 'type': 'attribute', 'children': ['83', '84']}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'config_name'}; {'id': '85', 'type': 'attribute', 'children': ['86', '87']}; {'id': '86', 'type': 'identifier', 'children': [], 'value': 'config_id'}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'instance_name'}; {'id': '88', 'type': 'expression_statement', 'children': ['89']}; {'id': '89', 'type': 'assignment', 'children': ['90', '93']}; {'id': '90', 'type': 'attribute', 'children': ['91', '92']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '92', 'type': 'identifier', 'children': [], 'value': 'container_name'}; {'id': '93', 'type': 'identifier', 'children': [], 'value': 'container_name'}; {'id': '94', 'type': 'if_statement', 'children': ['95', '104', '118']}; {'id': '95', 'type': 'comparison_operator', 'children': ['96', '97'], 'value': 'in'}; {'id': '96', 'type': 'identifier', 'children': [], 'value': 'container_name'}; {'id': '97', 'type': 'subscript', 'children': ['98', '101']}; {'id': '98', 'type': 'attribute', 'children': ['99', '100']}; {'id': '99', 'type': 'identifier', 'children': [], 'value': 'policy'}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'container_names'}; {'id': '101', 'type': 'attribute', 'children': ['102', '103']}; {'id': '102', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'client_name'}; {'id': '104', 'type': 'block', 'children': ['105']}; {'id': '105', 'type': 'expression_statement', 'children': ['106']}; {'id': '106', 'type': 'assignment', 'children': ['107', '110']}; {'id': '107', 'type': 'attribute', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'detail'}; {'id': '110', 'type': 'call', 'children': ['111', '116']}; {'id': '111', 'type': 'attribute', 'children': ['112', '115']}; {'id': '112', 'type': 'attribute', 'children': ['113', '114']}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '114', 'type': 'identifier', 'children': [], 'value': 'client'}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'inspect_container'}; {'id': '116', 'type': 'argument_list', 'children': ['117']}; {'id': '117', 'type': 'identifier', 'children': [], 'value': 'container_name'}; {'id': '118', 'type': 'else_clause', 'children': ['119']}; {'id': '119', 'type': 'block', 'children': ['120']}; {'id': '120', 'type': 'expression_statement', 'children': ['121']}; {'id': '121', 'type': 'assignment', 'children': ['122', '125']}; {'id': '122', 'type': 'attribute', 'children': ['123', '124']}; {'id': '123', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '124', 'type': 'identifier', 'children': [], 'value': 'detail'}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'NOT_FOUND'}
Fetches information about the container from the client.
def abort_io(self, iocb, err): if _debug: IOChainMixIn._debug("abort_io %r %r", iocb, err) if iocb is not self.ioChain: raise RuntimeError("broken chain") self.abort(err)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'abort_io'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'iocb'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '7', 'type': 'block', 'children': ['8', '20', '32']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': '_debug'}; {'id': '10', 'type': 'block', 'children': ['11']}; {'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': 'IOChainMixIn'}; {'id': '15', 'type': 'identifier', 'children': [], 'value': '_debug'}; {'id': '16', 'type': 'argument_list', 'children': ['17', '18', '19']}; {'id': '17', 'type': 'string', 'children': [], 'value': '"abort_io %r %r"'}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'iocb'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'err'}; {'id': '20', 'type': 'if_statement', 'children': ['21', '26']}; {'id': '21', 'type': 'comparison_operator', 'children': ['22', '23'], 'value': 'is not'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'iocb'}; {'id': '23', 'type': 'attribute', 'children': ['24', '25']}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'ioChain'}; {'id': '26', 'type': 'block', 'children': ['27']}; {'id': '27', 'type': 'raise_statement', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': 'RuntimeError'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'string', 'children': [], 'value': '"broken chain"'}; {'id': '32', 'type': 'expression_statement', 'children': ['33']}; {'id': '33', 'type': 'call', 'children': ['34', '37']}; {'id': '34', 'type': 'attribute', 'children': ['35', '36']}; {'id': '35', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'abort'}; {'id': '37', 'type': 'argument_list', 'children': ['38']}; {'id': '38', 'type': 'identifier', 'children': [], 'value': 'err'}
Forward the abort downstream.
def itemgetter_handle(tokens): internal_assert(len(tokens) == 2, "invalid implicit itemgetter args", tokens) op, args = tokens if op == "[": return "_coconut.operator.itemgetter(" + args + ")" elif op == "$[": return "_coconut.functools.partial(_coconut_igetitem, index=" + args + ")" else: raise CoconutInternalException("invalid implicit itemgetter type", op)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'itemgetter_handle'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '5', 'type': 'block', 'children': ['6', '18', '24']}; {'id': '6', 'type': 'expression_statement', 'children': ['7']}; {'id': '7', 'type': 'call', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'internal_assert'}; {'id': '9', 'type': 'argument_list', 'children': ['10', '16', '17']}; {'id': '10', 'type': 'comparison_operator', 'children': ['11', '15'], 'value': '=='}; {'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': 'tokens'}; {'id': '15', 'type': 'integer', 'children': [], 'value': '2'}; {'id': '16', 'type': 'string', 'children': [], 'value': '"invalid implicit itemgetter args"'}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '23']}; {'id': '20', 'type': 'pattern_list', 'children': ['21', '22']}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'tokens'}; {'id': '24', 'type': 'if_statement', 'children': ['25', '28', '35', '46']}; {'id': '25', 'type': 'comparison_operator', 'children': ['26', '27'], 'value': '=='}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"["'}; {'id': '28', 'type': 'block', 'children': ['29']}; {'id': '29', 'type': 'return_statement', 'children': ['30']}; {'id': '30', 'type': 'binary_operator', 'children': ['31', '34'], 'value': '+'}; {'id': '31', 'type': 'binary_operator', 'children': ['32', '33'], 'value': '+'}; {'id': '32', 'type': 'string', 'children': [], 'value': '"_coconut.operator.itemgetter("'}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '34', 'type': 'string', 'children': [], 'value': '")"'}; {'id': '35', 'type': 'elif_clause', 'children': ['36', '39']}; {'id': '36', 'type': 'comparison_operator', 'children': ['37', '38'], 'value': '=='}; {'id': '37', 'type': 'identifier', 'children': [], 'value': 'op'}; {'id': '38', 'type': 'string', 'children': [], 'value': '"$["'}; {'id': '39', 'type': 'block', 'children': ['40']}; {'id': '40', 'type': 'return_statement', 'children': ['41']}; {'id': '41', 'type': 'binary_operator', 'children': ['42', '45'], 'value': '+'}; {'id': '42', 'type': 'binary_operator', 'children': ['43', '44'], 'value': '+'}; {'id': '43', 'type': 'string', 'children': [], 'value': '"_coconut.functools.partial(_coconut_igetitem, index="'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'args'}; {'id': '45', 'type': 'string', 'children': [], 'value': '")"'}; {'id': '46', 'type': 'else_clause', 'children': ['47']}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'raise_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'CoconutInternalException'}; {'id': '51', 'type': 'argument_list', 'children': ['52', '53']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"invalid implicit itemgetter type"'}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'op'}
Process implicit itemgetter partials.
def _run_strip_accents(self, text): text = unicodedata.normalize("NFD", text) output = [] for char in text: cat = unicodedata.category(char) if cat == "Mn": continue output.append(char) return "".join(output)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '6']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_run_strip_accents'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '6', 'type': 'block', 'children': ['7', '17', '21', '47']}; {'id': '7', 'type': 'expression_statement', 'children': ['8']}; {'id': '8', 'type': 'assignment', 'children': ['9', '10']}; {'id': '9', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '10', 'type': 'call', 'children': ['11', '14']}; {'id': '11', 'type': 'attribute', 'children': ['12', '13']}; {'id': '12', 'type': 'identifier', 'children': [], 'value': 'unicodedata'}; {'id': '13', 'type': 'identifier', 'children': [], 'value': 'normalize'}; {'id': '14', 'type': 'argument_list', 'children': ['15', '16']}; {'id': '15', 'type': 'string', 'children': [], 'value': '"NFD"'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '17', 'type': 'expression_statement', 'children': ['18']}; {'id': '18', 'type': 'assignment', 'children': ['19', '20']}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'output'}; {'id': '20', 'type': 'list', 'children': [], 'value': '[]'}; {'id': '21', 'type': 'for_statement', 'children': ['22', '23', '24']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'text'}; {'id': '24', 'type': 'block', 'children': ['25', '34', '40']}; {'id': '25', 'type': 'expression_statement', 'children': ['26']}; {'id': '26', 'type': 'assignment', 'children': ['27', '28']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'cat'}; {'id': '28', 'type': 'call', 'children': ['29', '32']}; {'id': '29', 'type': 'attribute', 'children': ['30', '31']}; {'id': '30', 'type': 'identifier', 'children': [], 'value': 'unicodedata'}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'category'}; {'id': '32', 'type': 'argument_list', 'children': ['33']}; {'id': '33', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '34', 'type': 'if_statement', 'children': ['35', '38']}; {'id': '35', 'type': 'comparison_operator', 'children': ['36', '37'], 'value': '=='}; {'id': '36', 'type': 'identifier', 'children': [], 'value': 'cat'}; {'id': '37', 'type': 'string', 'children': [], 'value': '"Mn"'}; {'id': '38', 'type': 'block', 'children': ['39']}; {'id': '39', 'type': 'continue_statement', 'children': []}; {'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': 'output'}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'append'}; {'id': '45', 'type': 'argument_list', 'children': ['46']}; {'id': '46', 'type': 'identifier', 'children': [], 'value': 'char'}; {'id': '47', 'type': 'return_statement', 'children': ['48']}; {'id': '48', 'type': 'call', 'children': ['49', '52']}; {'id': '49', 'type': 'attribute', 'children': ['50', '51']}; {'id': '50', 'type': 'string', 'children': [], 'value': '""'}; {'id': '51', 'type': 'identifier', 'children': [], 'value': 'join'}; {'id': '52', 'type': 'argument_list', 'children': ['53']}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'output'}
Strips accents from a piece of text.
def away(self, message=None): cmd = 'AWAY' if message: cmd += ' :' + message self.send_line(cmd)
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '8']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'away'}; {'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': 'message'}; {'id': '7', 'type': 'None', 'children': []}; {'id': '8', 'type': 'block', 'children': ['9', '13', '22']}; {'id': '9', 'type': 'expression_statement', 'children': ['10']}; {'id': '10', 'type': 'assignment', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '12', 'type': 'string', 'children': [], 'value': "'AWAY'"}; {'id': '13', 'type': 'if_statement', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '15', 'type': 'block', 'children': ['16']}; {'id': '16', 'type': 'expression_statement', 'children': ['17']}; {'id': '17', 'type': 'augmented_assignment', 'children': ['18', '19'], 'value': '+='}; {'id': '18', 'type': 'identifier', 'children': [], 'value': 'cmd'}; {'id': '19', 'type': 'binary_operator', 'children': ['20', '21'], 'value': '+'}; {'id': '20', 'type': 'string', 'children': [], 'value': "' :'"}; {'id': '21', 'type': 'identifier', 'children': [], 'value': 'message'}; {'id': '22', 'type': 'expression_statement', 'children': ['23']}; {'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': 'send_line'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'identifier', 'children': [], 'value': 'cmd'}
mark ourself as away
def _repr_png_(self): app.process_events() QApplication.processEvents() img = read_pixels() return bytes(_make_png(img))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '5']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': '_repr_png_'}; {'id': '3', 'type': 'parameters', 'children': ['4']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'self'}; {'id': '5', 'type': 'block', 'children': ['6', '12', '18', '24']}; {'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': 'app'}; {'id': '10', 'type': 'identifier', 'children': [], 'value': 'process_events'}; {'id': '11', 'type': 'argument_list', 'children': []}; {'id': '12', 'type': 'expression_statement', 'children': ['13']}; {'id': '13', 'type': 'call', 'children': ['14', '17']}; {'id': '14', 'type': 'attribute', 'children': ['15', '16']}; {'id': '15', 'type': 'identifier', 'children': [], 'value': 'QApplication'}; {'id': '16', 'type': 'identifier', 'children': [], 'value': 'processEvents'}; {'id': '17', 'type': 'argument_list', 'children': []}; {'id': '18', 'type': 'expression_statement', 'children': ['19']}; {'id': '19', 'type': 'assignment', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'img'}; {'id': '21', 'type': 'call', 'children': ['22', '23']}; {'id': '22', 'type': 'identifier', 'children': [], 'value': 'read_pixels'}; {'id': '23', 'type': 'argument_list', 'children': []}; {'id': '24', 'type': 'return_statement', 'children': ['25']}; {'id': '25', 'type': 'call', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'bytes'}; {'id': '27', 'type': 'argument_list', 'children': ['28']}; {'id': '28', 'type': 'call', 'children': ['29', '30']}; {'id': '29', 'type': 'identifier', 'children': [], 'value': '_make_png'}; {'id': '30', 'type': 'argument_list', 'children': ['31']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'img'}
This is used by ipython to plot inline.
def check_file_version(notebook, source_path, outputs_path): if not insert_or_test_version_number(): return _, ext = os.path.splitext(source_path) if ext.endswith('.ipynb'): return version = notebook.metadata.get('jupytext', {}).get('text_representation', {}).get('format_version') format_name = format_name_for_ext(notebook.metadata, ext) fmt = get_format_implementation(ext, format_name) current = fmt.current_version_number if notebook.metadata and not version: version = current if version == fmt.current_version_number: return if (fmt.min_readable_version_number or current) <= version <= current: return raise JupytextFormatError("File {} is in format/version={}/{} (current version is {}). " "It would not be safe to override the source of {} with that file. " "Please remove one or the other file." .format(os.path.basename(source_path), format_name, version, current, os.path.basename(outputs_path)))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '7']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'check_file_version'}; {'id': '3', 'type': 'parameters', 'children': ['4', '5', '6']}; {'id': '4', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'source_path'}; {'id': '6', 'type': 'identifier', 'children': [], 'value': 'outputs_path'}; {'id': '7', 'type': 'block', 'children': ['8', '15', '28', '37', '60', '70', '78', '84', '96', '104', '116']}; {'id': '8', 'type': 'if_statement', 'children': ['9', '13']}; {'id': '9', 'type': 'not_operator', 'children': ['10']}; {'id': '10', 'type': 'call', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'insert_or_test_version_number'}; {'id': '12', 'type': 'argument_list', 'children': []}; {'id': '13', 'type': 'block', 'children': ['14']}; {'id': '14', 'type': 'return_statement', 'children': []}; {'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': '_'}; {'id': '19', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'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': 'os'}; {'id': '24', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '25', 'type': 'identifier', 'children': [], 'value': 'splitext'}; {'id': '26', 'type': 'argument_list', 'children': ['27']}; {'id': '27', 'type': 'identifier', 'children': [], 'value': 'source_path'}; {'id': '28', 'type': 'if_statement', 'children': ['29', '35']}; {'id': '29', 'type': 'call', 'children': ['30', '33']}; {'id': '30', 'type': 'attribute', 'children': ['31', '32']}; {'id': '31', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'endswith'}; {'id': '33', 'type': 'argument_list', 'children': ['34']}; {'id': '34', 'type': 'string', 'children': [], 'value': "'.ipynb'"}; {'id': '35', 'type': 'block', 'children': ['36']}; {'id': '36', 'type': 'return_statement', 'children': []}; {'id': '37', 'type': 'expression_statement', 'children': ['38']}; {'id': '38', 'type': 'assignment', 'children': ['39', '40']}; {'id': '39', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '40', 'type': 'call', 'children': ['41', '58']}; {'id': '41', 'type': 'attribute', 'children': ['42', '57']}; {'id': '42', 'type': 'call', 'children': ['43', '54']}; {'id': '43', 'type': 'attribute', 'children': ['44', '53']}; {'id': '44', 'type': 'call', 'children': ['45', '50']}; {'id': '45', 'type': 'attribute', 'children': ['46', '49']}; {'id': '46', 'type': 'attribute', 'children': ['47', '48']}; {'id': '47', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '48', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '49', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '50', 'type': 'argument_list', 'children': ['51', '52']}; {'id': '51', 'type': 'string', 'children': [], 'value': "'jupytext'"}; {'id': '52', 'type': 'dictionary', 'children': []}; {'id': '53', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '54', 'type': 'argument_list', 'children': ['55', '56']}; {'id': '55', 'type': 'string', 'children': [], 'value': "'text_representation'"}; {'id': '56', 'type': 'dictionary', 'children': []}; {'id': '57', 'type': 'identifier', 'children': [], 'value': 'get'}; {'id': '58', 'type': 'argument_list', 'children': ['59']}; {'id': '59', 'type': 'string', 'children': [], 'value': "'format_version'"}; {'id': '60', 'type': 'expression_statement', 'children': ['61']}; {'id': '61', 'type': 'assignment', 'children': ['62', '63']}; {'id': '62', 'type': 'identifier', 'children': [], 'value': 'format_name'}; {'id': '63', 'type': 'call', 'children': ['64', '65']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 'format_name_for_ext'}; {'id': '65', 'type': 'argument_list', 'children': ['66', '69']}; {'id': '66', 'type': 'attribute', 'children': ['67', '68']}; {'id': '67', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '68', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '69', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '70', 'type': 'expression_statement', 'children': ['71']}; {'id': '71', 'type': 'assignment', 'children': ['72', '73']}; {'id': '72', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '73', 'type': 'call', 'children': ['74', '75']}; {'id': '74', 'type': 'identifier', 'children': [], 'value': 'get_format_implementation'}; {'id': '75', 'type': 'argument_list', 'children': ['76', '77']}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'ext'}; {'id': '77', 'type': 'identifier', 'children': [], 'value': 'format_name'}; {'id': '78', 'type': 'expression_statement', 'children': ['79']}; {'id': '79', 'type': 'assignment', 'children': ['80', '81']}; {'id': '80', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '81', 'type': 'attribute', 'children': ['82', '83']}; {'id': '82', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '83', 'type': 'identifier', 'children': [], 'value': 'current_version_number'}; {'id': '84', 'type': 'if_statement', 'children': ['85', '91']}; {'id': '85', 'type': 'boolean_operator', 'children': ['86', '89'], 'value': 'and'}; {'id': '86', 'type': 'attribute', 'children': ['87', '88']}; {'id': '87', 'type': 'identifier', 'children': [], 'value': 'notebook'}; {'id': '88', 'type': 'identifier', 'children': [], 'value': 'metadata'}; {'id': '89', 'type': 'not_operator', 'children': ['90']}; {'id': '90', 'type': 'identifier', 'children': [], 'value': 'version'}; {'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': 'version'}; {'id': '95', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '96', 'type': 'if_statement', 'children': ['97', '102']}; {'id': '97', 'type': 'comparison_operator', 'children': ['98', '99'], 'value': '=='}; {'id': '98', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '99', 'type': 'attribute', 'children': ['100', '101']}; {'id': '100', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '101', 'type': 'identifier', 'children': [], 'value': 'current_version_number'}; {'id': '102', 'type': 'block', 'children': ['103']}; {'id': '103', 'type': 'return_statement', 'children': []}; {'id': '104', 'type': 'if_statement', 'children': ['105', '114']}; {'id': '105', 'type': 'comparison_operator', 'children': ['106', '112', '113'], 'value': '<='}; {'id': '106', 'type': '()', 'children': ['107']}; {'id': '107', 'type': 'boolean_operator', 'children': ['108', '111'], 'value': 'or'}; {'id': '108', 'type': 'attribute', 'children': ['109', '110']}; {'id': '109', 'type': 'identifier', 'children': [], 'value': 'fmt'}; {'id': '110', 'type': 'identifier', 'children': [], 'value': 'min_readable_version_number'}; {'id': '111', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '112', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '113', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '114', 'type': 'block', 'children': ['115']}; {'id': '115', 'type': 'return_statement', 'children': []}; {'id': '116', 'type': 'raise_statement', 'children': ['117']}; {'id': '117', 'type': 'call', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'JupytextFormatError'}; {'id': '119', 'type': 'argument_list', 'children': ['120']}; {'id': '120', 'type': 'call', 'children': ['121', '127']}; {'id': '121', 'type': 'attribute', 'children': ['122', '126']}; {'id': '122', 'type': 'concatenated_string', 'children': ['123', '124', '125']}; {'id': '123', 'type': 'string', 'children': [], 'value': '"File {} is in format/version={}/{} (current version is {}). "'}; {'id': '124', 'type': 'string', 'children': [], 'value': '"It would not be safe to override the source of {} with that file. "'}; {'id': '125', 'type': 'string', 'children': [], 'value': '"Please remove one or the other file."'}; {'id': '126', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '127', 'type': 'argument_list', 'children': ['128', '136', '137', '138', '139']}; {'id': '128', 'type': 'call', 'children': ['129', '134']}; {'id': '129', 'type': 'attribute', 'children': ['130', '133']}; {'id': '130', 'type': 'attribute', 'children': ['131', '132']}; {'id': '131', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '133', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '134', 'type': 'argument_list', 'children': ['135']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'source_path'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'format_name'}; {'id': '137', 'type': 'identifier', 'children': [], 'value': 'version'}; {'id': '138', 'type': 'identifier', 'children': [], 'value': 'current'}; {'id': '139', 'type': 'call', 'children': ['140', '145']}; {'id': '140', 'type': 'attribute', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'os'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'path'}; {'id': '144', 'type': 'identifier', 'children': [], 'value': 'basename'}; {'id': '145', 'type': 'argument_list', 'children': ['146']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'outputs_path'}
Raise if file version in source file would override outputs
def runserver(port=8080, debug_toolbar="yes", werkzeug="no", dummy_cache="no", short_cache="no", template_warnings="no", log_level="DEBUG", insecure="no"): if not port or (not isinstance(port, int) and not port.isdigit()): abort("You must specify a port.") yes_or_no = ("debug_toolbar", "werkzeug", "dummy_cache", "short_cache", "template_warnings", "insecure") for s in yes_or_no: if locals()[s].lower() not in ("yes", "no"): abort("Specify 'yes' or 'no' for {} option.".format(s)) _log_levels = ("DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL") if log_level not in _log_levels: abort("Invalid log level.") with shell_env(SHOW_DEBUG_TOOLBAR=debug_toolbar.upper(), DUMMY_CACHE=dummy_cache.upper(), SHORT_CACHE=short_cache.upper(), WARN_INVALID_TEMPLATE_VARS=template_warnings.upper(), LOG_LEVEL=log_level): local("./manage.py runserver{} 0.0.0.0:{}{}".format("_plus" if werkzeug.lower() == "yes" else "", port, " --insecure" if insecure.lower() == "yes" else ""))
{'id': '0', 'type': 'module', 'children': ['1']}; {'id': '1', 'type': 'function_definition', 'children': ['2', '3', '28']}; {'id': '2', 'type': 'function_name', 'children': [], 'value': 'runserver'}; {'id': '3', 'type': 'parameters', 'children': ['4', '7', '10', '13', '16', '19', '22', '25']}; {'id': '4', 'type': 'default_parameter', 'children': ['5', '6']}; {'id': '5', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '6', 'type': 'integer', 'children': [], 'value': '8080'}; {'id': '7', 'type': 'default_parameter', 'children': ['8', '9']}; {'id': '8', 'type': 'identifier', 'children': [], 'value': 'debug_toolbar'}; {'id': '9', 'type': 'string', 'children': [], 'value': '"yes"'}; {'id': '10', 'type': 'default_parameter', 'children': ['11', '12']}; {'id': '11', 'type': 'identifier', 'children': [], 'value': 'werkzeug'}; {'id': '12', 'type': 'string', 'children': [], 'value': '"no"'}; {'id': '13', 'type': 'default_parameter', 'children': ['14', '15']}; {'id': '14', 'type': 'identifier', 'children': [], 'value': 'dummy_cache'}; {'id': '15', 'type': 'string', 'children': [], 'value': '"no"'}; {'id': '16', 'type': 'default_parameter', 'children': ['17', '18']}; {'id': '17', 'type': 'identifier', 'children': [], 'value': 'short_cache'}; {'id': '18', 'type': 'string', 'children': [], 'value': '"no"'}; {'id': '19', 'type': 'default_parameter', 'children': ['20', '21']}; {'id': '20', 'type': 'identifier', 'children': [], 'value': 'template_warnings'}; {'id': '21', 'type': 'string', 'children': [], 'value': '"no"'}; {'id': '22', 'type': 'default_parameter', 'children': ['23', '24']}; {'id': '23', 'type': 'identifier', 'children': [], 'value': 'log_level'}; {'id': '24', 'type': 'string', 'children': [], 'value': '"DEBUG"'}; {'id': '25', 'type': 'default_parameter', 'children': ['26', '27']}; {'id': '26', 'type': 'identifier', 'children': [], 'value': 'insecure'}; {'id': '27', 'type': 'string', 'children': [], 'value': '"no"'}; {'id': '28', 'type': 'block', 'children': ['29', '53', '63', '92', '101', '111']}; {'id': '29', 'type': 'if_statement', 'children': ['30', '47']}; {'id': '30', 'type': 'boolean_operator', 'children': ['31', '33'], 'value': 'or'}; {'id': '31', 'type': 'not_operator', 'children': ['32']}; {'id': '32', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '33', 'type': '()', 'children': ['34']}; {'id': '34', 'type': 'boolean_operator', 'children': ['35', '41'], 'value': 'and'}; {'id': '35', 'type': 'not_operator', 'children': ['36']}; {'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': 'port'}; {'id': '40', 'type': 'identifier', 'children': [], 'value': 'int'}; {'id': '41', 'type': 'not_operator', 'children': ['42']}; {'id': '42', 'type': 'call', 'children': ['43', '46']}; {'id': '43', 'type': 'attribute', 'children': ['44', '45']}; {'id': '44', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '45', 'type': 'identifier', 'children': [], 'value': 'isdigit'}; {'id': '46', 'type': 'argument_list', 'children': []}; {'id': '47', 'type': 'block', 'children': ['48']}; {'id': '48', 'type': 'expression_statement', 'children': ['49']}; {'id': '49', 'type': 'call', 'children': ['50', '51']}; {'id': '50', 'type': 'identifier', 'children': [], 'value': 'abort'}; {'id': '51', 'type': 'argument_list', 'children': ['52']}; {'id': '52', 'type': 'string', 'children': [], 'value': '"You must specify a port."'}; {'id': '53', 'type': 'expression_statement', 'children': ['54']}; {'id': '54', 'type': 'assignment', 'children': ['55', '56']}; {'id': '55', 'type': 'identifier', 'children': [], 'value': 'yes_or_no'}; {'id': '56', 'type': 'tuple', 'children': ['57', '58', '59', '60', '61', '62']}; {'id': '57', 'type': 'string', 'children': [], 'value': '"debug_toolbar"'}; {'id': '58', 'type': 'string', 'children': [], 'value': '"werkzeug"'}; {'id': '59', 'type': 'string', 'children': [], 'value': '"dummy_cache"'}; {'id': '60', 'type': 'string', 'children': [], 'value': '"short_cache"'}; {'id': '61', 'type': 'string', 'children': [], 'value': '"template_warnings"'}; {'id': '62', 'type': 'string', 'children': [], 'value': '"insecure"'}; {'id': '63', 'type': 'for_statement', 'children': ['64', '65', '66']}; {'id': '64', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '65', 'type': 'identifier', 'children': [], 'value': 'yes_or_no'}; {'id': '66', 'type': 'block', 'children': ['67']}; {'id': '67', 'type': 'if_statement', 'children': ['68', '81']}; {'id': '68', 'type': 'comparison_operator', 'children': ['69', '78'], 'value': 'not in'}; {'id': '69', 'type': 'call', 'children': ['70', '77']}; {'id': '70', 'type': 'attribute', 'children': ['71', '76']}; {'id': '71', 'type': 'subscript', 'children': ['72', '75']}; {'id': '72', 'type': 'call', 'children': ['73', '74']}; {'id': '73', 'type': 'identifier', 'children': [], 'value': 'locals'}; {'id': '74', 'type': 'argument_list', 'children': []}; {'id': '75', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '76', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '77', 'type': 'argument_list', 'children': []}; {'id': '78', 'type': 'tuple', 'children': ['79', '80']}; {'id': '79', 'type': 'string', 'children': [], 'value': '"yes"'}; {'id': '80', 'type': 'string', 'children': [], 'value': '"no"'}; {'id': '81', 'type': 'block', 'children': ['82']}; {'id': '82', 'type': 'expression_statement', 'children': ['83']}; {'id': '83', 'type': 'call', 'children': ['84', '85']}; {'id': '84', 'type': 'identifier', 'children': [], 'value': 'abort'}; {'id': '85', 'type': 'argument_list', 'children': ['86']}; {'id': '86', 'type': 'call', 'children': ['87', '90']}; {'id': '87', 'type': 'attribute', 'children': ['88', '89']}; {'id': '88', 'type': 'string', 'children': [], 'value': '"Specify \'yes\' or \'no\' for {} option."'}; {'id': '89', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '90', 'type': 'argument_list', 'children': ['91']}; {'id': '91', 'type': 'identifier', 'children': [], 'value': 's'}; {'id': '92', 'type': 'expression_statement', 'children': ['93']}; {'id': '93', 'type': 'assignment', 'children': ['94', '95']}; {'id': '94', 'type': 'identifier', 'children': [], 'value': '_log_levels'}; {'id': '95', 'type': 'tuple', 'children': ['96', '97', '98', '99', '100']}; {'id': '96', 'type': 'string', 'children': [], 'value': '"DEBUG"'}; {'id': '97', 'type': 'string', 'children': [], 'value': '"INFO"'}; {'id': '98', 'type': 'string', 'children': [], 'value': '"WARNING"'}; {'id': '99', 'type': 'string', 'children': [], 'value': '"ERROR"'}; {'id': '100', 'type': 'string', 'children': [], 'value': '"CRITICAL"'}; {'id': '101', 'type': 'if_statement', 'children': ['102', '105']}; {'id': '102', 'type': 'comparison_operator', 'children': ['103', '104'], 'value': 'not in'}; {'id': '103', 'type': 'identifier', 'children': [], 'value': 'log_level'}; {'id': '104', 'type': 'identifier', 'children': [], 'value': '_log_levels'}; {'id': '105', 'type': 'block', 'children': ['106']}; {'id': '106', 'type': 'expression_statement', 'children': ['107']}; {'id': '107', 'type': 'call', 'children': ['108', '109']}; {'id': '108', 'type': 'identifier', 'children': [], 'value': 'abort'}; {'id': '109', 'type': 'argument_list', 'children': ['110']}; {'id': '110', 'type': 'string', 'children': [], 'value': '"Invalid log level."'}; {'id': '111', 'type': 'with_statement', 'children': ['112', '148']}; {'id': '112', 'type': 'with_clause', 'children': ['113']}; {'id': '113', 'type': 'with_item', 'children': ['114']}; {'id': '114', 'type': 'call', 'children': ['115', '116']}; {'id': '115', 'type': 'identifier', 'children': [], 'value': 'shell_env'}; {'id': '116', 'type': 'argument_list', 'children': ['117', '124', '131', '138', '145']}; {'id': '117', 'type': 'keyword_argument', 'children': ['118', '119']}; {'id': '118', 'type': 'identifier', 'children': [], 'value': 'SHOW_DEBUG_TOOLBAR'}; {'id': '119', 'type': 'call', 'children': ['120', '123']}; {'id': '120', 'type': 'attribute', 'children': ['121', '122']}; {'id': '121', 'type': 'identifier', 'children': [], 'value': 'debug_toolbar'}; {'id': '122', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '123', 'type': 'argument_list', 'children': []}; {'id': '124', 'type': 'keyword_argument', 'children': ['125', '126']}; {'id': '125', 'type': 'identifier', 'children': [], 'value': 'DUMMY_CACHE'}; {'id': '126', 'type': 'call', 'children': ['127', '130']}; {'id': '127', 'type': 'attribute', 'children': ['128', '129']}; {'id': '128', 'type': 'identifier', 'children': [], 'value': 'dummy_cache'}; {'id': '129', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '130', 'type': 'argument_list', 'children': []}; {'id': '131', 'type': 'keyword_argument', 'children': ['132', '133']}; {'id': '132', 'type': 'identifier', 'children': [], 'value': 'SHORT_CACHE'}; {'id': '133', 'type': 'call', 'children': ['134', '137']}; {'id': '134', 'type': 'attribute', 'children': ['135', '136']}; {'id': '135', 'type': 'identifier', 'children': [], 'value': 'short_cache'}; {'id': '136', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '137', 'type': 'argument_list', 'children': []}; {'id': '138', 'type': 'keyword_argument', 'children': ['139', '140']}; {'id': '139', 'type': 'identifier', 'children': [], 'value': 'WARN_INVALID_TEMPLATE_VARS'}; {'id': '140', 'type': 'call', 'children': ['141', '144']}; {'id': '141', 'type': 'attribute', 'children': ['142', '143']}; {'id': '142', 'type': 'identifier', 'children': [], 'value': 'template_warnings'}; {'id': '143', 'type': 'identifier', 'children': [], 'value': 'upper'}; {'id': '144', 'type': 'argument_list', 'children': []}; {'id': '145', 'type': 'keyword_argument', 'children': ['146', '147']}; {'id': '146', 'type': 'identifier', 'children': [], 'value': 'LOG_LEVEL'}; {'id': '147', 'type': 'identifier', 'children': [], 'value': 'log_level'}; {'id': '148', 'type': 'block', 'children': ['149']}; {'id': '149', 'type': 'expression_statement', 'children': ['150']}; {'id': '150', 'type': 'call', 'children': ['151', '152']}; {'id': '151', 'type': 'identifier', 'children': [], 'value': 'local'}; {'id': '152', 'type': 'argument_list', 'children': ['153']}; {'id': '153', 'type': 'call', 'children': ['154', '157']}; {'id': '154', 'type': 'attribute', 'children': ['155', '156']}; {'id': '155', 'type': 'string', 'children': [], 'value': '"./manage.py runserver{} 0.0.0.0:{}{}"'}; {'id': '156', 'type': 'identifier', 'children': [], 'value': 'format'}; {'id': '157', 'type': 'argument_list', 'children': ['158', '168', '169']}; {'id': '158', 'type': 'conditional_expression', 'children': ['159', '160', '167'], 'value': 'if'}; {'id': '159', 'type': 'string', 'children': [], 'value': '"_plus"'}; {'id': '160', 'type': 'comparison_operator', 'children': ['161', '166'], 'value': '=='}; {'id': '161', 'type': 'call', 'children': ['162', '165']}; {'id': '162', 'type': 'attribute', 'children': ['163', '164']}; {'id': '163', 'type': 'identifier', 'children': [], 'value': 'werkzeug'}; {'id': '164', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '165', 'type': 'argument_list', 'children': []}; {'id': '166', 'type': 'string', 'children': [], 'value': '"yes"'}; {'id': '167', 'type': 'string', 'children': [], 'value': '""'}; {'id': '168', 'type': 'identifier', 'children': [], 'value': 'port'}; {'id': '169', 'type': 'conditional_expression', 'children': ['170', '171', '178'], 'value': 'if'}; {'id': '170', 'type': 'string', 'children': [], 'value': '" --insecure"'}; {'id': '171', 'type': 'comparison_operator', 'children': ['172', '177'], 'value': '=='}; {'id': '172', 'type': 'call', 'children': ['173', '176']}; {'id': '173', 'type': 'attribute', 'children': ['174', '175']}; {'id': '174', 'type': 'identifier', 'children': [], 'value': 'insecure'}; {'id': '175', 'type': 'identifier', 'children': [], 'value': 'lower'}; {'id': '176', 'type': 'argument_list', 'children': []}; {'id': '177', 'type': 'string', 'children': [], 'value': '"yes"'}; {'id': '178', 'type': 'string', 'children': [], 'value': '""'}
Clear compiled python files and start the Django dev server.